/* ============================================================
   Artemis Calendar — App Styles
   Image grid, cards, filters, scorecard, modal/overlay.
   Depends on tokens.css + system.css.
   ============================================================ */

/* ---------- PAGE LAYOUT ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin: var(--s-5) 0 var(--s-4);
}

.page-header h1 {
  font-family: var(--serif);
  font-size: var(--fs-h2);
  font-weight: 500;
  margin: 0;
}

/* ---------- CONTROLS ---------- */
.controls {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.controls select,
.controls input {
  font-family: var(--mono);
  font-size: var(--fs-small);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--atlas-rule-soft);
  border-radius: var(--r-sm);
  background: var(--atlas-paper);
  color: var(--atlas-ink);
}

.controls label {
  font-family: var(--mono);
  font-size: var(--fs-meta);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--atlas-muted);
}

/* ---------- IMAGE GRID ---------- */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--s-3);
  margin: var(--s-4) 0;
}

/* ---------- IMAGE CARD ---------- */
.image-card {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--atlas-paper-2);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}

.image-card:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

.image-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

.image-card .card-info {
  padding: var(--s-2) var(--s-3);
}

.image-card .score-badge {
  position: absolute;
  top: var(--s-2);
  right: var(--s-2);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-family: var(--mono);
  font-size: var(--fs-meta);
  padding: 2px 6px;
  border-radius: var(--r-sm);
}

.image-card .cluster-pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: var(--fs-meta);
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--atlas-accent);
  color: #fff;
}

/* ---------- PAGINATION ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  margin: var(--s-5) 0;
  font-family: var(--mono);
  font-size: var(--fs-small);
}

.pagination button {
  font-family: var(--mono);
  font-size: var(--fs-small);
  padding: var(--s-2) var(--s-4);
  border: 1px solid var(--atlas-rule-soft);
  border-radius: var(--r-sm);
  background: var(--atlas-paper);
  color: var(--atlas-ink);
  cursor: pointer;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

.pagination button:hover:not(:disabled) {
  background: var(--atlas-paper-2);
}

/* ---------- MODAL / OVERLAY ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
}

.modal-content {
  background: var(--atlas-paper);
  border-radius: var(--r-lg);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--s-6);
  position: relative;
}

.modal-close {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--atlas-muted);
  line-height: 1;
}

.modal-close:hover {
  color: var(--atlas-ink);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
  margin-top: var(--s-4);
}

.detail-grid img {
  width: 100%;
  border-radius: var(--r-md);
}

/* ---------- SCORE TABLE ---------- */
.score-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: var(--fs-small);
}

.score-table th,
.score-table td {
  text-align: left;
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--atlas-rule-soft);
}

.score-table th {
  font-size: var(--fs-meta);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--atlas-muted);
}

.score-table .best {
  color: var(--atlas-good);
  font-weight: 600;
}

/* ---------- CANDIDATES ---------- */
.candidate-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--s-4);
  margin: var(--s-4) 0;
}

.candidate-card {
  border: 1px solid var(--atlas-rule-soft);
  border-radius: var(--r-md);
  padding: var(--s-4);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease);
}

.candidate-card:hover {
  border-color: var(--atlas-accent);
}

.candidate-card h3 {
  font-family: var(--mono);
  font-size: var(--fs-body);
  margin: 0 0 var(--s-2);
}

.candidate-card .metric {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: var(--fs-small);
  color: var(--atlas-ink-2);
}

/* ---------- MONTH GRID (candidate detail) ---------- */
.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--s-3);
  margin: var(--s-4) 0;
}

.month-card {
  border: 1px solid var(--atlas-rule-soft);
  border-radius: var(--r-md);
  overflow: hidden;
}

.month-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
}

.month-card .month-info {
  padding: var(--s-2) var(--s-3);
}

.month-card .month-label {
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--fs-small);
}

.month-card .month-score {
  font-family: var(--mono);
  font-size: var(--fs-meta);
  color: var(--atlas-muted);
}

/* ---------- CLUSTER CARDS ---------- */
.cluster-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--s-4);
  margin: var(--s-4) 0;
}

.cluster-card {
  border: 1px solid var(--atlas-rule-soft);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease);
}

.cluster-card:hover {
  border-color: var(--atlas-accent);
}

.cluster-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
}

.cluster-card .cluster-info {
  padding: var(--s-2) var(--s-3);
}

.cluster-card .cluster-label {
  font-family: var(--mono);
  font-weight: 600;
  font-size: var(--fs-small);
}

.cluster-card .cluster-meta {
  font-family: var(--mono);
  font-size: var(--fs-meta);
  color: var(--atlas-muted);
}

/* ---------- STATS ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s-4);
  margin: var(--s-4) 0;
}

.stat-card {
  border: 1px solid var(--atlas-rule-soft);
  border-radius: var(--r-md);
  padding: var(--s-4);
}

.stat-card h3 {
  font-family: var(--mono);
  font-size: var(--fs-small);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--atlas-muted);
  margin: 0 0 var(--s-3);
}

.stat-value {
  font-family: var(--mono);
  font-size: var(--fs-h2);
  font-weight: 600;
}

.stat-detail {
  font-family: var(--mono);
  font-size: var(--fs-small);
  color: var(--atlas-ink-2);
  margin-top: var(--s-2);
}

/* ---------- SELECTION BUILDER ---------- */
.selection-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--s-5);
  margin: var(--s-4) 0;
}

.calendar-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--s-3);
}

.slot {
  border: 2px dashed var(--atlas-rule-soft);
  border-radius: var(--r-md);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease);
}

.slot.filled {
  border-style: solid;
}

.slot:hover {
  border-color: var(--atlas-accent);
}

.slot img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: var(--r-sm);
}

.slot .slot-label {
  font-family: var(--mono);
  font-size: var(--fs-meta);
  color: var(--atlas-muted);
  padding: var(--s-1) 0;
}

.selection-sidebar {
  border: 1px solid var(--atlas-rule-soft);
  border-radius: var(--r-md);
  padding: var(--s-4);
}

.selection-sidebar h3 {
  font-family: var(--mono);
  font-size: var(--fs-small);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--atlas-muted);
  margin: 0 0 var(--s-3);
}

.btn {
  font-family: var(--mono);
  font-size: var(--fs-small);
  padding: var(--s-2) var(--s-4);
  border: 1px solid var(--atlas-rule-soft);
  border-radius: var(--r-sm);
  background: var(--atlas-paper);
  color: var(--atlas-ink);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}

.btn:hover {
  background: var(--atlas-paper-2);
}

.btn-primary {
  background: var(--atlas-accent);
  color: #fff;
  border-color: var(--atlas-accent);
}

.btn-primary:hover {
  opacity: 0.9;
}

/* ---------- LOADING ---------- */
.loading {
  text-align: center;
  padding: var(--s-7);
  font-family: var(--mono);
  font-size: var(--fs-small);
  color: var(--atlas-muted);
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .selection-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .image-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- FILTER BUTTONS ---------- */
.filter-btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--atlas-muted);
  background: transparent;
  border: 1px solid var(--atlas-rule-soft);
  border-radius: var(--r-pill);
  padding: 4px 12px;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.filter-btn:hover {
  border-color: var(--atlas-ink);
  color: var(--atlas-ink);
}
.filter-btn.active {
  background: var(--atlas-ink);
  color: var(--atlas-paper);
  border-color: var(--atlas-ink);
}

/* ---------- LESSON CARDS ---------- */
.card:hover {
  background: var(--atlas-paper-2);
  border-color: color-mix(in oklab, var(--atlas-ink) 20%, transparent);
}

/* ---------- LESSON DETAIL ---------- */
.lesson-detail { max-width: var(--reading-max); }
.lesson-body h1 {
  font-family: var(--serif);
  font-size: var(--fs-h1);
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: var(--lh-snug);
  margin: 0 0 var(--s-6);
}
.lesson-body h2 {
  font-family: var(--serif);
  font-size: var(--fs-h2);
  font-weight: 400;
  margin: var(--s-7) 0 var(--s-4);
}
.lesson-body h3 {
  font-family: var(--serif);
  font-size: var(--fs-h3);
  font-weight: 500;
  margin: var(--s-6) 0 var(--s-3);
}
.lesson-body p {
  line-height: var(--lh-body);
  margin: 0 0 var(--s-4);
}
.lesson-body ul, .lesson-body ol {
  margin: 0 0 var(--s-4);
  padding-left: var(--s-6);
  line-height: var(--lh-body);
}
.lesson-body li { margin-bottom: var(--s-2); }
.lesson-body code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--atlas-paper-2);
  padding: 1px 5px;
  border-radius: var(--r-sm);
}
.lesson-body pre {
  background: var(--atlas-paper-2);
  border: 1px solid var(--atlas-rule-soft);
  border-radius: var(--r-md);
  padding: var(--s-4);
  overflow-x: auto;
  margin: 0 0 var(--s-5);
  line-height: 1.5;
}
.lesson-body pre code {
  background: none;
  padding: 0;
}
.lesson-body blockquote {
  border-left: 3px solid var(--atlas-accent-2);
  margin: 0 0 var(--s-4);
  padding: var(--s-3) var(--s-5);
  color: var(--atlas-ink-2);
}
.lesson-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 var(--s-5);
  font-size: var(--fs-small);
}
.lesson-body th, .lesson-body td {
  border: 1px solid var(--atlas-rule-soft);
  padding: var(--s-2) var(--s-3);
  text-align: left;
}
.lesson-body th {
  background: var(--atlas-paper-2);
  font-weight: 600;
}

/* ============================================================
   HOME / LANDING PAGE
   ============================================================ */

.home { margin: calc(-1 * var(--s-5)) calc(-1 * var(--s-5)); }
@media (min-width: 769px) { .home { margin: calc(-1 * var(--s-7)) calc(-1 * var(--s-7)); } }

/* --- Hero --- */
.home-hero {
  position: relative;
  min-height: 70vh;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background: #0a0c10;
}
.hero-mosaic {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 2px;
  opacity: 0.55;
}
.mosaic-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.mosaic-fade {
  position: absolute;
  inset: 0;
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  background: linear-gradient(
    to bottom,
    rgba(10,12,16,0) 0%,
    rgba(10,12,16,0.3) 40%,
    rgba(10,12,16,0.85) 75%,
    rgba(10,12,16,1) 100%
  );
}
.hero-content {
  position: relative;
  z-index: 1;
  padding: var(--s-7) var(--s-7) var(--s-8);
  max-width: var(--content-max);
  color: #F2EEE3;
}
.hero-eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-meta);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--atlas-accent-2);
  margin-bottom: var(--s-4);
}
.hero-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(36px, 5vw, 72px);
  line-height: var(--lh-tight);
  letter-spacing: -.03em;
  margin: 0 0 var(--s-5);
}
.hero-title em {
  font-style: italic;
  font-weight: 300;
  color: var(--atlas-accent-2);
}
.hero-lede {
  font-family: var(--serif);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.55;
  color: #B8B5AC;
  max-width: 54ch;
  margin-bottom: var(--s-6);
}
.hero-actions {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
}
.hero-btn {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 12px 28px;
  border-radius: var(--r-pill);
  transition: all var(--t-base) var(--ease);
  cursor: pointer;
  border: 1px solid;
}
.hero-btn.primary {
  background: #F2EEE3;
  color: #0a0c10;
  border-color: #F2EEE3;
}
.hero-btn.primary:hover {
  background: var(--atlas-accent-2);
  border-color: var(--atlas-accent-2);
}
.hero-btn.secondary {
  background: transparent;
  color: #F2EEE3;
  border-color: rgba(242,238,227,.3);
}
.hero-btn.secondary:hover {
  border-color: #F2EEE3;
}

/* --- Stats bar --- */
.home-stats {
  display: flex;
  justify-content: center;
  gap: var(--s-7);
  padding: var(--s-7) var(--s-5);
  background: var(--atlas-paper-2);
  border-bottom: 1px solid var(--atlas-rule-soft);
  flex-wrap: wrap;
}
.stat-item {
  text-align: center;
}
.stat-number {
  display: block;
  font-family: var(--sans);
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 600;
  color: var(--atlas-ink);
  letter-spacing: -.02em;
  line-height: 1;
}
.stat-label {
  font-family: var(--mono);
  font-size: var(--fs-meta);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--atlas-muted);
  margin-top: var(--s-2);
  display: block;
}

/* --- Pipeline --- */
.home-pipeline {
  padding: var(--s-8) var(--s-7);
  text-align: center;
}
.section-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--fs-h2);
  letter-spacing: -.01em;
  margin: 0 0 var(--s-3);
}
.section-desc {
  color: var(--atlas-ink-2);
  max-width: 48ch;
  margin: 0 auto var(--s-6);
  line-height: var(--lh-body);
}
.pipeline-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.pipe-step {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border: 1px solid var(--atlas-rule-soft);
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: var(--fs-small);
  letter-spacing: .04em;
}
.pipe-num {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--atlas-ink);
  color: var(--atlas-paper);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
}
.pipe-arrow {
  color: var(--atlas-muted);
  font-size: 18px;
}

/* --- Showcase grid --- */
.home-showcase {
  padding: var(--s-8) var(--s-7);
  text-align: center;
}
.showcase-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--s-3);
}
.showcase-card {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  aspect-ratio: 4/3;
  text-decoration: none;
  transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.showcase-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-2);
}
.showcase-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.showcase-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--s-2) var(--s-3);
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.showcase-score {
  font-family: var(--mono);
  font-size: 12px;
  color: #F2EEE3;
  font-weight: 600;
}
.showcase-cluster {
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(242,238,227,.6);
  letter-spacing: .08em;
}

/* --- Section cards --- */
.home-sections {
  padding: var(--s-8) var(--s-7);
  text-align: center;
}
.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--s-4);
  text-align: left;
}
.section-card {
  padding: var(--s-5);
  border: 1px solid var(--atlas-rule-soft);
  border-radius: var(--r-md);
  text-decoration: none;
  color: inherit;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-base) var(--ease);
}
.section-card:hover {
  background: var(--atlas-paper-2);
  border-color: color-mix(in oklab, var(--atlas-ink) 20%, transparent);
  transform: translateY(-2px);
}
.section-icon {
  font-size: 24px;
  display: block;
  margin-bottom: var(--s-3);
}
.section-card-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 var(--s-2);
}
.section-card-desc {
  font-size: var(--fs-small);
  color: var(--atlas-ink-2);
  line-height: var(--lh-body);
  margin: 0;
}

/* --- Methods --- */
.home-methods {
  padding: var(--s-8) var(--s-7);
  background: var(--atlas-paper-2);
  text-align: center;
}
.methods-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s-4);
  text-align: left;
}
.method-card {
  padding: var(--s-5);
  background: var(--atlas-paper);
  border-radius: var(--r-md);
  border: 1px solid var(--atlas-rule-soft);
}
.method-card h4 {
  font-family: var(--mono);
  font-size: var(--fs-small);
  letter-spacing: .06em;
  margin: 0 0 var(--s-2);
  color: var(--atlas-accent);
}
.method-card p {
  font-size: var(--fs-small);
  color: var(--atlas-ink-2);
  line-height: var(--lh-body);
  margin: 0;
}

/* --- Footer --- */
.home-footer {
  padding: var(--s-7);
  text-align: center;
  border-top: 1px solid var(--atlas-rule-soft);
  font-size: var(--fs-small);
  color: var(--atlas-muted);
}
.home-footer a {
  color: var(--atlas-accent);
  text-decoration: none;
}
.home-footer a:hover { text-decoration: underline; }

/* --- Responsive — home page --- */
@media (max-width: 768px) {
  .home { margin: calc(-1 * var(--s-3)) calc(-1 * var(--s-4)); }
  .home-hero { min-height: 60vh; }
  .hero-mosaic { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(5, 1fr); }
  .hero-content { padding: var(--s-5) var(--s-4) var(--s-6); }
  .showcase-grid { grid-template-columns: repeat(2, 1fr); }
  .home-stats { gap: var(--s-4); padding: var(--s-5) var(--s-4); }
  .stat-number { font-size: 24px; }
  .home-pipeline,
  .home-showcase,
  .home-sections,
  .home-methods,
  .home-footer { padding-left: var(--s-4); padding-right: var(--s-4); }
  .pipeline-steps { gap: var(--s-1); }
  .pipe-step { padding: var(--s-1) var(--s-3); font-size: 11px; }
  .pipe-arrow { display: none; }
  .section-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .home-hero { min-height: 50vh; }
  .hero-mosaic { grid-template-columns: repeat(3, 1fr); }
  .showcase-grid { grid-template-columns: repeat(2, 1fr); }
  .home-stats { gap: var(--s-3); }
  .stat-item { min-width: 80px; }
  .hero-actions { flex-direction: column; }
  .hero-btn { text-align: center; }
  .methods-grid { grid-template-columns: 1fr; }
}
