/* ==========================================================================
   Absolute Legend — Complete Stylesheet
   Palette: blue-grey wash + warm tan accents from the artwork
   ========================================================================== */

@font-face {
  font-family: 'Legend Sans';
  src: url('/fonts/LegendSans-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-deep: #0e1114;
  --bg-main: #161a1f;
  --bg-panel: #1e2329;
  --bg-card: #252a31;
  --text-primary: #e4e0db;
  --text-muted: #8a919a;
  --text-dim: #555d67;
  --accent: #8aacc4;
  --accent-light: #a3c0d4;
  --accent-glow: rgba(138, 172, 196, 0.12);
  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'Source Serif 4', Georgia, serif;
  --font-comic: 'Legend Sans', 'Comic Sans MS', cursive;
  --panel-size: 190px;
  --gutter: 20px;
  --dialogue-bg: #F6F2EE;
  --dialogue-text: #181317;
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 4rem;
  --space-xl: 6rem;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-body); background-color: var(--bg-deep); color: var(--text-primary); line-height: 1.6; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: var(--accent-light); }
img { max-width: 100%; height: auto; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ==========================================================================
   Site Header
   ========================================================================== */

.site-header { display: flex; justify-content: space-between; align-items: center; padding: 1.2rem 2rem; }
.logo { font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-primary); text-decoration: none; }
.logo span { color: var(--accent); }
.site-nav { display: flex; gap: 2rem; list-style: none; }
.site-nav a { font-family: var(--font-display); font-size: 1rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); text-decoration: none; transition: color 0.2s; }
.site-nav a:hover, .site-nav a.active { color: var(--accent); }

/* ==========================================================================
   Skip Intro
   ========================================================================== */

.skip-intro {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 100;
  font-family: var(--font-display); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-dim); text-decoration: none; padding: 0.5em 1em;
  border: 1px solid var(--bg-card); border-radius: 3px;
  background: rgba(14, 17, 20, 0.8); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: color 0.2s, border-color 0.2s, opacity 0.4s;
}
.skip-intro:hover { color: var(--accent); border-color: var(--accent); }
.skip-intro.hidden { opacity: 0; pointer-events: none; }

/* ==========================================================================
   Scroll-driven Sequence — Desktop Snake Grid
   ========================================================================== */

.scroll-track { position: relative; height: 5400px; }
.sticky-frame { position: sticky; top: 0; height: 100vh; display: flex; align-items: flex-start; justify-content: center; overflow: hidden; }

.snake-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto auto auto auto 1fr 1fr 1fr 1fr;
  gap: var(--gutter);
  max-width: calc(var(--panel-size) * 3 + var(--gutter) * 2 + 2rem);
  width: 100%; padding: 0 1rem; padding-top: 35vh; padding-bottom: 15vh;
  align-items: center; will-change: transform; transition: transform 0.8s ease-out;
}

.r { opacity: 0; transition: opacity 0.8s ease; }
.r.on { opacity: 1; }

.scroll-hint-inline {
  position: absolute; left: 50%; top: calc(50vh + 130px); transform: translateX(-50%);
  font-family: var(--font-display); font-size: 0.85rem; text-transform: uppercase;
  letter-spacing: 0.15em; color: var(--text-dim); opacity: 0; transition: opacity 0.6s ease; z-index: 5;
}
.scroll-hint-inline.on { opacity: 1; }

/* Grid placement */
.r1c2 { grid-row: 1; grid-column: 2; justify-self: center; }
.r1c3 { grid-row: 1; grid-column: 3; justify-self: center; align-self: center; }
.r2c1 { grid-row: 2; grid-column: 1; justify-self: center; align-self: center; }
.r2c2 { grid-row: 2; grid-column: 2; justify-self: center; }
.r2c3 { grid-row: 2; grid-column: 3; justify-self: center; }
.r3c1 { grid-row: 3; grid-column: 1; justify-self: center; }
.r3c2 { grid-row: 3; grid-column: 2; justify-self: center; }
.r3c3 { grid-row: 3; grid-column: 3; justify-self: center; align-self: center; }
.r4c2 { grid-row: 4; grid-column: 2; justify-self: center; align-self: center; }
.r4c3 { grid-row: 4; grid-column: 3; justify-self: center; }
.r5c2 { grid-row: 5; grid-column: 2; justify-self: center; }
.r6c123 { grid-row: 6; grid-column: 1 / 4; justify-self: center; text-align: center; }
.r7c2 { grid-row: 7; grid-column: 2; justify-self: center; }
.r8c123 { grid-row: 8; grid-column: 1 / 4; justify-self: center; text-align: center; }

.panel img {
  display: block; width: var(--panel-size); height: auto; aspect-ratio: 476 / 500;
  object-fit: cover; border: 1px solid var(--bg-card); box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

.dialogue {
  font-family: var(--font-comic); text-transform: uppercase; letter-spacing: 0.03em; line-height: 1.35;
  background: var(--dialogue-bg); color: var(--dialogue-text);
  display: flex; align-items: center; justify-content: center; text-align: center;
  width: var(--panel-size); aspect-ratio: 476 / 500;
}
.dialogue.no-bg { background: none; color: var(--dialogue-bg); width: auto; aspect-ratio: auto; }
.esc-6.no-bg { color: #fff; }
.dialogue.wide { width: auto; aspect-ratio: auto; background: none; color: var(--dialogue-bg); padding: 0; white-space: nowrap; }

.esc-1 { font-size: clamp(0.95rem, 2vw, 1.15rem); }
.esc-2 { font-size: clamp(1rem, 2.2vw, 1.25rem); }
.esc-3 { font-size: clamp(1.05rem, 2.5vw, 1.35rem); }
.esc-4 { font-size: clamp(1.1rem, 2.8vw, 1.5rem); }
.esc-5 { font-size: clamp(1.2rem, 3.2vw, 1.7rem); }
.esc-6 { font-size: clamp(1.5rem, 4vw, 2.2rem); letter-spacing: 0.05em; }

/* ==========================================================================
   Title Reveal
   ========================================================================== */

.title-reveal {
  display: flex; flex-direction: column; justify-content: flex-start; align-items: center;
  text-align: center; padding: 0 2rem 4rem; position: relative;
  background: var(--bg-deep); overflow: visible;
}
.title-reveal::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center top, var(--accent-glow), transparent 50%);
  pointer-events: none;
}

.title-inner { opacity: 0; transition: opacity 1s ease; position: relative; max-width: 750px; width: 100%; overflow: visible; }
.title-inner.on { opacity: 1; }

.title-hero { max-width: 750px; width: 100%; margin: 0 auto; position: relative; line-height: 0; }
.title-hero img { display: block; width: 100%; height: auto; border: 1px solid var(--bg-card); box-shadow: 0 4px 40px rgba(0, 0, 0, 0.4); }

.title-hero .line-main-overlay {
  position: absolute; bottom: -25px; left: 0; right: 0;
  font-family: var(--font-display); font-weight: 400; text-transform: uppercase;
  letter-spacing: 0.04em; line-height: 1;
  font-size: clamp(3.5rem, 11.5vw, 7.8rem);
  color: var(--dialogue-text); white-space: nowrap; text-align: center; padding: 0; margin: 0;
}

.title-text { max-width: 750px; width: 100%; margin: 0 auto; overflow: visible; }

.title-main-sub {
  font-family: var(--font-display); font-weight: 400; text-transform: uppercase;
  letter-spacing: 0.04em; line-height: 1;
  font-size: clamp(3.5rem, 11.5vw, 7.8rem);
  color: var(--dialogue-bg); margin-top: 0.05em;
}

.title-tagline { font-family: var(--font-body); font-style: italic; font-size: clamp(1rem, 2.5vw, 1.3rem); color: var(--text-muted); margin-top: 1.5rem; }

.title-divider { border: none; height: 1px; background: var(--dialogue-bg); width: auto; max-width: 300px; margin: 1.2rem auto 2.4rem; }

.title-pitch {
  font-family: var(--font-comic); font-size: clamp(1.4rem, 3vw, 1.85rem);
  text-transform: uppercase; color: var(--dialogue-bg); line-height: 1.5;
  letter-spacing: 0.02em; margin: 1.5rem auto 0;
  width: 120%; max-width: 900px; margin-left: -10%; padding-bottom: 40px;
}
.title-pitch em { color: var(--accent); font-style: normal; }

.title-cta {
  display: inline-block; font-family: var(--font-display); font-weight: 400; font-size: 1.3rem;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--bg-deep); background: var(--accent);
  padding: 0.8em 2.5em; text-decoration: none; transition: background 0.2s ease, transform 0.2s ease;
}
.title-cta:hover { background: var(--accent-light); transform: translateY(-2px); }

/* ==========================================================================
   Chapter List (Home + Chapter Index)
   ========================================================================== */

.chapters-section { padding: var(--space-xl) var(--space-md); max-width: 800px; margin: 0 auto; }

.section-heading {
  font-family: var(--font-display); font-weight: 400; font-size: 1.8rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-primary);
  margin-bottom: var(--space-lg); text-align: center;
}
.section-heading::after { content: ''; display: block; width: 60px; height: 3px; background: var(--accent); margin: var(--space-sm) auto 0; }

.chapter-list { list-style: none; display: flex; flex-direction: column; gap: 0.8rem; }

.chapter-card {
  display: flex; align-items: baseline; gap: 1.5rem; padding: 1.2rem;
  background: var(--bg-panel); border-left: 3px solid transparent;
  text-decoration: none; color: inherit; transition: border-color 0.2s ease, background 0.2s ease;
}
.chapter-card:hover { border-left-color: var(--accent); background: var(--bg-card); }

.chapter-card .chapter-number { font-family: var(--font-display); font-weight: 400; font-size: 2rem; color: var(--accent); line-height: 1; flex-shrink: 0; min-width: 2.5ch; }
.chapter-card .chapter-info { flex: 1; }
.chapter-card .chapter-title { font-family: var(--font-display); font-weight: 400; font-size: 1.2rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-primary); margin-bottom: 0.25em; }
.chapter-card .chapter-desc { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; }
.chapter-card .chapter-pages { font-family: var(--font-display); font-size: 0.85rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; flex-shrink: 0; }

p.chapter-headsup {text-align: center; font-family: var(--font-display); margin-top: 3rem; font-size: 2rem; opacity: 0.6;}
p.chapter-headsup span {color: #a3c0d4;}

/* ==========================================================================
   Comic Reader — Sidebar Layout
   ========================================================================== */

.reader {
  height: 100dvh; display: flex; overflow: hidden;
  user-select: none; -webkit-user-select: none; background: var(--bg-deep);
}

.reader-sidebar {
  width: 260px; flex-shrink: 0; height: 100dvh;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: var(--space-md); background: var(--bg-main);
  border-right: 1px solid var(--bg-card); overflow-y: auto; z-index: 20;
}

.reader-logo { font-family: var(--font-display); font-weight: 400; font-size: 1.1rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-primary); display: block; margin-bottom: var(--space-lg); }
.reader-logo span { color: var(--accent); }

.reader-chapter-info { margin-bottom: var(--space-md); }
.reader-chapter-label { font-family: var(--font-display); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-dim); display: block; margin-bottom: 0.4em; }
.reader-chapter-title { font-family: var(--font-display); font-weight: 400; font-size: 1.4rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); line-height: 1.2; margin-bottom: 0.5em; }
.reader-chapter-desc { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; font-style: italic; }

.reader-sidebar-middle { padding: var(--space-md) 0; }
.reader-counter { font-family: var(--font-display); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); margin-bottom: var(--space-xs); }
.reader-counter .current-page { color: var(--accent); font-size: 1.1rem; }
.reader-progress-track { height: 3px; background: var(--bg-card); border-radius: 2px; overflow: hidden; }
.reader-progress-bar { height: 100%; background: var(--accent); transition: width 0.3s ease; border-radius: 2px; }

.reader-sidebar-bottom { display: flex; flex-direction: column; gap: var(--space-xs); }
.reader-chapter-link { display: block; font-family: var(--font-display); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); padding: 0.6em 0.8em; border: 1px solid var(--bg-card); transition: all 0.2s ease; }
.reader-chapter-link:hover { color: var(--accent); border-color: var(--accent); }
.reader-chapter-link-label { display: block; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.2em; }
.reader-chapter-link-title { display: block; }

.reader-artwork { flex: 1; height: 100dvh; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.reader-page { height: 100dvh; width: auto; max-width: 100%; object-fit: contain; padding: 12px; transition: opacity 0.2s ease; }
.reader-page.loading { opacity: 0.3; }

.reader-nav-zone { position: absolute; top: 0; bottom: 0; width: 35%; cursor: pointer; z-index: 10; display: flex; align-items: center; }
.reader-nav-zone--prev { left: 0; justify-content: flex-start; padding-left: var(--space-sm); }
.reader-nav-zone--next { right: 0; justify-content: flex-end; padding-right: var(--space-sm); }
.reader-nav-zone .nav-hint { opacity: 0; transition: opacity 0.2s ease; font-family: var(--font-display); font-size: 1.2rem; color: var(--text-dim); padding: 0.5em 0.8em; background: rgba(14, 17, 20, 0.7); border-radius: 4px; }
.reader-nav-zone:hover .nav-hint { opacity: 1; }

.reader-mobile-bar { display: none; }
.reader-mobile-progress { display: none; }

/* Hide site header/footer on reader pages */
body:has(.reader) .site-header,
body:has(.reader) .site-footer { display: none; }

/* ==========================================================================
   About Page
   ========================================================================== */

.about-page { max-width: 650px; margin: 0 auto; padding: calc(70px + var(--space-lg)) var(--space-md) var(--space-xl); }
.about-page h1 { font-family: var(--font-display); font-weight: 400; font-size: 2.5rem; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: var(--space-md); }
.about-page h1 span { color: var(--accent); }
.about-page p { margin-bottom: var(--space-sm); color: var(--text-muted); font-size: 1.05rem; line-height: 1.7; }
.about-page a { text-decoration: underline; text-underline-offset: 3px; }

.about-page p span.legend-sans {font-family: var(--font-comic); text-transform: uppercase; font-size: 1.5rem;}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer { text-align: center; padding: 2rem; border-top: 1px solid var(--bg-panel); color: var(--text-dim); font-size: 0.85rem; }

/* ==========================================================================
   Mobile — Homepage Vertical Stack
   ========================================================================== */

.mobile-sequence { display: none; }

@media (max-width: 768px) {
  .scroll-track { display: none; }

  .mobile-sequence { display: flex; flex-direction: column; align-items: center; padding: 0 1rem; }
  .mobile-spacer { height: calc(50vh - 140px); }

  .mob-beat { opacity: 0; transition: opacity 0.8s ease; width: 100%; max-width: 320px; padding: 1.5rem 0; }
  .mob-beat.on { opacity: 1; }
  .mob-beat.auto-reveal { transition-delay: 1.5s; }
  .mob-beat img { display: block; width: 100%; height: auto; border: 1px solid var(--bg-card); box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4); }
  .mob-beat .dialogue { width: 100%; aspect-ratio: 476 / 500; padding: 1.2em; }
  .mob-beat .dialogue.no-bg { aspect-ratio: auto; padding: 1.2em 0; }
  .mob-beat .dialogue.wide { white-space: normal; width: 100%; aspect-ratio: 476 / 500; padding: 1.2em; }

  .mob-scroll-hint { font-family: var(--font-display); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.15em; color: var(--text-dim); opacity: 0; transition: opacity 0.6s ease; padding: 1rem 0 2rem; text-align: center; }
  .mob-scroll-hint.on { opacity: 1; }

  .title-reveal { padding: 0 1.5rem 3rem; }
  .title-hero { max-width: 100%; }
  .title-hero .line-main-overlay { font-size: clamp(2.5rem, 11.5vw, 4rem);bottom: -10px; }
  .title-main-sub { font-size: clamp(2.5rem, 11.5vw, 4rem); }
  .title-pitch { font-size: clamp(1.1rem, 3vw, 1.4rem); width: 100%; margin-left: 0; }
  .title-cta { padding: 0.8em 1.8em; font-size: 1.1rem; }

  .site-header { padding: var(--space-xs) var(--space-sm); }
  .site-nav { gap: var(--space-sm); }
  .chapter-card { flex-direction: column; gap: var(--space-xs); }
  .chapter-card .chapter-number { font-size: 1.4rem; }

  /* Mobile reader */
  .reader { flex-direction: column; position: relative; }
  .reader-sidebar {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100dvh; z-index: 50;
    background: rgba(14, 17, 20, 0.95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .reader-sidebar.open { display: flex; }
  .reader-artwork { height: 100dvh; width: 100%; }
  .reader-page { padding: 4px; }
  .reader-nav-zone .nav-hint { display: none; }

  .reader-mobile-bar {
    display: flex; position: fixed; top: 0; left: 0; right: 0; z-index: 30;
    align-items: center; justify-content: space-between; padding: 8px 12px;
    background: linear-gradient(to bottom, rgba(14, 17, 20, 0.85) 0%, transparent 100%);
  }
  .reader-logo--small { font-family: var(--font-display); font-weight: 400; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
  .reader-mobile-counter { font-family: var(--font-display); font-size: 0.8rem; letter-spacing: 0.1em; color: var(--text-dim); }
  .reader-mobile-counter .current-page { color: var(--accent); }
  .reader-mobile-menu-btn { background: none; border: 1px solid var(--bg-card); color: var(--text-muted); font-size: 1rem; padding: 4px 8px; cursor: pointer; border-radius: 3px; }

  .reader-mobile-progress { display: block; position: fixed; bottom: 0; left: 0; right: 0; height: 3px; background: var(--bg-panel); z-index: 30; }
  .reader-mobile-progress-bar { height: 100%; background: var(--accent); transition: width 0.3s ease; }
}

@media (max-width: 400px) {
  .mob-beat { max-width: 260px; }
}
