/* Atlas Landing Page — Atelier Paper & Nocturne Split-Stage System */

@font-face {
  font-family: "Allo";
  src: url("assets/fonts/AlloVariable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fffaf0;
  --alt: #f3ecde;
  --surface: #ffffff;
  --surface-soft: #f7f1e4;
  --ink: #0d1616;
  --ink2: #323c3c;
  --ink3: #596363;
  --teal: #1a3a3a;
  --teal-hover: #254d4d;
  --teal-ink: #fffaf0;
  --teal-soft: #c7d5d1;
  --accent: #ff4d8b;
  --accent-hover: #e03a76;
  --accent-ink: #ffffff;
  --gold: #d4a024;
  --emerald: #2f8f62;
  --ui-border: rgba(26, 58, 58, 0.14);
  --font: "Allo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pad-x: clamp(20px, 3.6vw, 52px);
}

:root[data-theme="dark"] {
  --bg: #141416;
  --alt: #1b1b20;
  --surface: #212127;
  --surface-soft: #292931;
  --ink: #f4f4f5;
  --ink2: #c8c8ce;
  --ink3: #95959e;
  --teal: #142a2a;
  --teal-hover: #1e3b3b;
  --teal-ink: #fffaf0;
  --teal-soft: #b6c8c3;
  --accent: #ff4d8b;
  --accent-hover: #ff699d;
  --accent-ink: #ffffff;
  --gold: #e8b94a;
  --emerald: #22c55e;
  --ui-border: rgba(255, 255, 255, 0.11);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.54;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  transition: background-color 220ms var(--ease), color 220ms var(--ease);
}

h1, h2, h3, p, figure {
  margin: 0;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.nums {
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  z-index: 99;
}

.skip-link:focus {
  left: var(--pad-x);
  top: 16px;
}

/* Masked Headline Reveal */
.line-mask {
  display: block;
  overflow: hidden;
  padding: 0.04em 0 0.22em;
  margin-bottom: -0.22em;
}

.line-inner {
  display: block;
  transform: translateY(108%);
  opacity: 0;
  animation: lineRise 520ms var(--ease) forwards;
}

.line-mask:nth-child(2) .line-inner {
  animation-delay: 60ms;
}

@keyframes lineRise {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.js-ready [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 520ms var(--ease), transform 520ms var(--ease);
  transition-delay: var(--delay, 0ms);
}

.js-ready [data-reveal].is-shown {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .line-inner,
  .js-ready [data-reveal] {
    animation: none;
    transition: none;
    transform: none;
    opacity: 1;
  }
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px var(--pad-x);
  background: var(--bg);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.top-links {
  display: flex;
  gap: 28px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink2);
}

.top-links a:hover {
  color: var(--ink);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 20px;
  border: 0;
  border-radius: 0;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms var(--ease), transform 120ms var(--ease), color 150ms var(--ease);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--alt);
  color: var(--ink);
}

.btn-secondary:hover {
  background: var(--teal);
  color: var(--teal-ink);
}

.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.97);
}

/* Split-Stage Architecture */
.split-chapter {
  display: grid;
  grid-template-columns: minmax(310px, 35%) 1fr;
  align-items: start;
  min-height: 82vh;
}

.split-chapter.alt {
  background: var(--alt);
}

.rail {
  position: sticky;
  top: 0;
  padding: clamp(32px, 4.4vw, 64px) var(--pad-x);
  display: flex;
  flex-direction: column;
  gap: 22px;
  align-items: flex-start;
}

.stage {
  padding: clamp(28px, 4vw, 56px) var(--pad-x) clamp(48px, 6vw, 84px) 0;
}

.hero-title {
  font-size: clamp(2.8rem, 4.8vw, 4.5rem);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.035em;
}

h2 {
  font-size: clamp(2rem, 3.3vw, 3rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.03em;
}

h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 5px;
}

.rail-lead {
  font-size: 17px;
  color: var(--ink2);
  max-width: 34ch;
}

.rail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.rail-points {
  display: grid;
  gap: 12px;
  width: 100%;
}

.rail-point {
  background: var(--alt);
  padding: 16px 18px;
}

.split-chapter.alt .rail-point {
  background: var(--bg);
}

.rail-point p {
  font-size: 15px;
  color: var(--ink2);
}

/* Interactive Chips */
.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 38px;
  padding: 8px 16px;
  border: 0;
  border-radius: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}

.split-chapter:not(.alt) .chip:not(.is-on) {
  background: var(--alt);
}

.chip.is-on {
  background: var(--teal);
  color: var(--teal-ink);
}

/* ============================================================
   LIVE ATLAS LIBRARY APP FRAGMENT (data-ui)
   ============================================================ */
.app-window {
  display: grid;
  grid-template-columns: 200px minmax(230px, 0.95fr) minmax(260px, 1.15fr);
  min-height: 580px;
  background: var(--surface);
  overflow: hidden;
}

.app-sidebar {
  background: var(--teal);
  color: var(--teal-ink);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 18px;
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  padding: 4px 8px;
}

.app-sidebar-brand img {
  border-radius: 5px;
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--teal-soft);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.app-nav-item:hover {
  background: rgba(255, 250, 240, 0.08);
  color: var(--teal-ink);
}

.app-nav-item.is-active {
  background: var(--teal-ink);
  color: var(--teal);
}

.app-sidebar-foot {
  margin-top: auto;
  padding: 12px 10px;
  background: rgba(255, 250, 240, 0.08);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-goal-label {
  font-size: 12px;
  color: var(--teal-soft);
}

.sidebar-goal-val {
  font-size: 14px;
  font-weight: 700;
}

.sidebar-goal-track {
  height: 6px;
  background: rgba(255, 250, 240, 0.16);
  overflow: hidden;
}

.sidebar-goal-fill {
  height: 100%;
  background: var(--gold);
}

.app-list-pane {
  display: flex;
  flex-direction: column;
  background: var(--surface-soft);
}

.app-list-bar {
  padding: 12px;
}

.app-search {
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}

.book-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px 10px;
  overflow-y: auto;
}

.book-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  padding: 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  align-items: center;
}

.book-row:hover {
  background: var(--surface);
}

.book-row.is-selected {
  background: var(--surface);
}

.book-spine {
  width: 42px;
  height: 60px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 6px;
  color: #fffaf0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}

.book-row-title {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}

.book-row-author {
  font-size: 13px;
  color: var(--ink3);
  margin-top: 2px;
}

.book-row-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink2);
}

.app-detail-pane {
  padding: 24px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.detail-header {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 18px;
  align-items: start;
}

.detail-cover {
  width: 84px;
  height: 122px;
  border-radius: 6px;
  padding: 10px 8px;
  color: #fffaf0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
}

.detail-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
}

.detail-author {
  font-size: 15px;
  color: var(--ink2);
  margin-top: 4px;
}

.detail-series {
  font-size: 13.5px;
  color: var(--ink3);
  margin-top: 4px;
}

.detail-stars {
  color: var(--gold);
  font-size: 16px;
  margin-top: 8px;
  letter-spacing: 0.08em;
}

.detail-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.detail-progress-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13.5px;
  font-weight: 600;
}

.detail-progress-top span:last-child {
  white-space: nowrap;
}

.progress-track {
  height: 7px;
  background: var(--ui-border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--emerald);
}

.detail-quote {
  margin: 0;
  padding: 14px 16px;
  background: var(--bg);
  border-left: 3px solid var(--gold);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.detail-btn {
  padding: 9px 13px;
  border: 0;
  border-radius: 0;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.detail-btn.is-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.detail-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.detail-toast {
  font-size: 13px;
  font-weight: 600;
  color: var(--emerald);
  min-height: 20px;
}

/* ============================================================
   CHAPTER 2: LIVE YEAR-IN-REVIEW STATS PANEL (data-ui)
   ============================================================ */
.stats-panel {
  background: var(--surface);
  padding: clamp(22px, 3vw, 34px);
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.stats-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.stats-head h3 {
  font-size: 24px;
  margin: 0;
}

.stats-sub {
  font-size: 14.5px;
  color: var(--ink3);
  margin-top: 3px;
}

.stats-streak {
  padding: 6px 12px;
  background: var(--teal);
  color: var(--teal-ink);
  font-size: 13.5px;
  font-weight: 700;
}

.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.kpi-box {
  background: var(--surface-soft);
  padding: 16px;
}

.kpi-num {
  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 700;
  line-height: 1.05;
}

.kpi-label {
  font-size: 13px;
  color: var(--ink3);
  margin-top: 4px;
}

.stats-chart-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chart-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink2);
}

.month-bars {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  height: 150px;
  padding-top: 12px;
}

.month-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.month-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink2);
}

.month-bar {
  width: 100%;
  background: var(--teal);
  transition: height 280ms var(--ease);
}

.month-bar.is-peak {
  background: var(--accent);
}

.month-name {
  font-size: 12px;
  color: var(--ink3);
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 4px;
}

.heat-cell {
  aspect-ratio: 1;
  background: var(--surface-soft);
}

.heat-cell.l1 { background: rgba(47, 143, 98, 0.28); }
.heat-cell.l2 { background: rgba(47, 143, 98, 0.54); }
.heat-cell.l3 { background: rgba(47, 143, 98, 0.82); }
.heat-cell.l4 { background: var(--teal); }

/* ============================================================
   CHAPTER 3: LIVE SERIES & READING LISTS PANEL (data-ui)
   ============================================================ */
.series-panel {
  background: var(--surface);
  padding: clamp(22px, 3vw, 34px);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.series-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.series-top h3 {
  font-size: 26px;
  margin: 0;
}

.series-author {
  font-size: 15px;
  color: var(--ink3);
  margin-top: 3px;
}

.series-progress-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--teal);
}

:root[data-theme="dark"] .series-progress-label {
  color: var(--gold);
}

.series-volumes {
  display: grid;
  gap: 8px;
}

.volume-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface-soft);
}

.volume-num {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink3);
}

.volume-title {
  font-size: 16px;
  font-weight: 700;
}

.volume-meta {
  font-size: 13.5px;
  color: var(--ink3);
  margin-top: 2px;
}

.volume-toggle {
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-radius: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.volume-toggle.is-done {
  background: var(--emerald);
  color: #ffffff;
}

/* ============================================================
   CHAPTER 4: CLOSING BAND
   ============================================================ */
.closing {
  background: var(--teal);
  color: var(--teal-ink);
  padding: clamp(64px, 8vw, 112px) var(--pad-x);
}

.closing-inner {
  max-width: 1340px;
  margin: 0 auto;
}

.closing-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}

.closing-head p {
  font-size: 17px;
  color: var(--teal-soft);
  max-width: 48ch;
}

.platform-grid {
  margin-top: 40px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.platform-card {
  background: rgba(255, 250, 240, 0.08);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.platform-card h3 {
  font-size: 20px;
  color: var(--teal-ink);
}

.platform-card p {
  font-size: 15px;
  color: var(--teal-soft);
}

.status-tag {
  align-self: flex-start;
  padding: 6px 12px;
  background: rgba(255, 250, 240, 0.14);
  font-size: 13px;
  font-weight: 600;
}

.status-link {
  align-self: flex-start;
  padding: 8px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13.5px;
  font-weight: 600;
}

.foot-meta {
  margin-top: 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 14.5px;
  color: var(--teal-soft);
}

.foot-siblings {
  display: flex;
  gap: 22px;
  font-weight: 600;
  color: var(--teal-ink);
}

.foot-siblings a:hover {
  color: var(--gold);
}

/* Responsive */
@media (max-width: 1080px) {
  .split-chapter {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .rail {
    position: static;
    padding-bottom: 16px;
  }

  .stage {
    padding: 12px var(--pad-x) 52px;
  }

  .app-window {
    grid-template-columns: 1fr;
  }

  .app-list-pane {
    padding-bottom: 8px;
  }

  .stats-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .platform-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .top-links {
    display: none;
  }

  .month-bars {
    gap: 4px;
  }

  .heatmap-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }
}
