@font-face { font-family: Kalam; src: url(../public/fonts/kalam-400.woff2) format('woff2'); font-weight: 400; }
@font-face { font-family: Kalam; src: url(../public/fonts/kalam-700.woff2) format('woff2'); font-weight: 700; }
@font-face { font-family: 'Rozha One'; src: url(../public/fonts/rozha-400.woff2) format('woff2'); }
@font-face { font-family: 'Special Elite'; src: url(../public/fonts/elite-400.woff2) format('woff2'); }

:root { --paper: #e8e0cf; --ink: #141214; --red: #8f1d10; }
* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0; color: var(--ink); font-family: Kalam, cursive; overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 40%, rgba(60, 40, 20, .22)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .25 0 0 0 0 .2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    var(--paper);
  background-attachment: fixed;
}
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 1; }
#comic { position: relative; z-index: 2; }
section { position: relative; }
.stage { position: sticky; top: 0; height: 100vh; height: 100svh; display: flex; align-items: center; justify-content: center; }

/* frames: transparent window the GL canvas paints into */
.frame { position: relative; outline: 3px solid var(--ink); outline-offset: 0; box-shadow: 6px 8px 0 rgba(20, 18, 20, .18); }
.frame .tag { position: absolute; right: 8px; bottom: 6px; font: 11px 'Special Elite', monospace; letter-spacing: .1em; text-transform: uppercase; color: #7a1d12; opacity: .7; }
.overlay { position: absolute; inset: 0; pointer-events: none; }

/* ---- narration: the storyteller's voice. Square ink boxes pinned to the panel's top edge, typewriter */
.captions { position: absolute; left: 0; top: 0; max-width: 46%; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.caption {
  background: #161314; color: #efe6d2; padding: .55em .9em .6em; font: .93em/1.42 'Special Elite', monospace; letter-spacing: .01em;
  outline: 1px solid rgba(239, 230, 210, .28); outline-offset: -4px;
  transform: translateY(calc((1 - var(--q, 0)) * -6px));
}
.captions .caption:first-child { border-bottom-right-radius: 0; }
.captions.tr { left: auto; right: 0; align-items: flex-end; }
.captions.bl { top: auto; bottom: 0; }
.captions.br { top: auto; bottom: 0; left: auto; right: 0; align-items: flex-end; }
/* someone else narrating (a flashback told to Vikram): aged paper, italic, named */
.caption.quoted { background: #ece0bd; color: var(--ink); font-style: italic; outline-color: rgba(20, 18, 20, .35); }
.caption .who { display: block; font: 700 .68em Kalam, cursive; font-style: normal; letter-spacing: .14em; text-transform: uppercase; color: var(--red); margin-bottom: .1em; }

/* ---- dialogue: people talking. White hand-lettered balloons with a tail toward the speaker */
.balloon {
  position: absolute; width: max-content; max-width: 34%; padding: .5em 1em .6em; background: #fffdf6; border: 2px solid var(--ink); color: #141214;
  border-radius: 48% 52% 50% 50% / 55% 50% 50% 45%; font: 1.24em/1.22 Kalam, cursive; text-align: center;
  box-shadow: 2px 3px 0 rgba(20, 18, 20, .25);
  transform: translate(-50%, -100%) scale(calc(.85 + .15 * var(--q, 0)));
  transform-origin: 50% 120%;
}
.balloon[data-side='l'] { transform: translate(-15%, -100%) scale(calc(.85 + .15 * var(--q, 0))); transform-origin: 15% 120%; }
.balloon[data-side='r'] { transform: translate(-85%, -100%) scale(calc(.85 + .15 * var(--q, 0))); transform-origin: 85% 120%; }
.balloon::before, .balloon::after { content: ''; position: absolute; left: var(--tx, 50%); width: 0; height: 0; border-style: solid; transform: translateX(-50%); }
.balloon::before { bottom: -17px; border-width: 17px 7px 0 9px; border-color: var(--ink) transparent transparent transparent; }
.balloon::after { bottom: -12px; border-width: 13px 5px 0 6px; border-color: #fffdf6 transparent transparent transparent; }
.balloon.up::before { bottom: auto; top: -17px; border-width: 0 7px 17px 9px; border-color: transparent transparent var(--ink) transparent; }
.balloon.up::after { bottom: auto; top: -12px; border-width: 0 5px 13px 6px; border-color: transparent transparent #fffdf6 transparent; }
.balloon .who { display: block; font: 700 .56em Kalam, cursive; letter-spacing: .16em; text-transform: uppercase; color: var(--red); margin-bottom: .05em; }
/* whisper: dashed, small, grey */
.balloon.whisper { border-style: dashed; font-size: 1.06em; color: #3d3a3a; }
/* thought: cloud with trailing bubbles, italic */
.balloon.thought { border-radius: 50%; background: #f7f3ea; font-style: italic; padding: .7em 1.2em; }
.balloon.thought::before { width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 50%; bottom: -20px; background: #f7f3ea; }
.balloon.thought::after { width: 7px; height: 7px; border: 2px solid var(--ink); border-radius: 50%; bottom: -32px; background: #f7f3ea; }
/* radio / phone / recording: squared with a double electric edge and a lightning tail */
.balloon.radio { border-radius: 3px; background: #f3f7f6; font-style: italic; box-shadow: 0 0 0 3px #f3f7f6, 0 0 0 5px var(--ink), 3px 4px 0 5px rgba(20, 18, 20, .2); }
.balloon.radio::after { display: none; }
.balloon.radio::before { border: 0; width: 16px; height: 22px; bottom: -26px; background: var(--ink);
  clip-path: polygon(40% 0, 100% 0, 55% 45%, 85% 45%, 10% 100%, 35% 55%, 5% 55%); }
/* shout: heavy outline, bold capitals, a little jolt */
.balloon.shout { border-width: 3.5px; font-weight: 700; text-transform: uppercase; border-radius: 18px; letter-spacing: .02em; }
.balloon.roar {
  border: 4px solid var(--red); font: 1.55em 'Rozha One', serif; background: #1c1414; color: #f3c9a0;
  border-radius: 6px; text-transform: uppercase; letter-spacing: .04em; max-width: 46%;
  clip-path: polygon(0 10%, 6% 0, 30% 6%, 50% 0, 72% 6%, 94% 0, 100% 12%, 96% 50%, 100% 88%, 94% 100%, 70% 94%, 50% 100%, 28% 94%, 6% 100%, 0 88%, 4% 50%);
}
.balloon.roar .who { color: #f3c9a0; opacity: .7; }
.balloon.roar::before, .balloon.roar::after { display: none; }
.sfx {
  position: absolute; right: 6%; bottom: 10%; font: 3.2em 'Rozha One', serif; color: #f2e6cf; letter-spacing: .06em;
  -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--red);
  transform: rotate(-6deg) scale(calc(.6 + .4 * var(--q, 0)));
}

/* title cards */
.title-card { text-align: center; max-width: 900px; padding: 0 30px; --p: 0; }
.title-card h2 { font-family: 'Rozha One', serif; font-weight: 400; margin: .1em 0; line-height: 1.05;
  clip-path: inset(0 calc((1 - min(1, var(--p) * 2.2)) * 100%) 0 0); }
.title-card h2 { font-size: clamp(34px, 5.5vw, 76px); }
.title-card .kicker { font: 15px 'Special Elite', monospace; letter-spacing: .3em; text-transform: uppercase; opacity: calc(var(--p) * 3); }
.title-card .rule { height: 4px; background: var(--ink); margin: 18px auto 0; border-radius: 3px; width: calc(min(1, max(0, var(--p) * 2.2 - .4)) * 60%); }

.landing {
  width: min(100%, 1472px);
  min-height: 100svh;
  margin-inline: auto;
  padding: 0 clamp(22px, 4.3vw, 68px) clamp(38px, 5vw, 76px);
  display: flex;
  flex-direction: column;
}
.landing-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 18px;
  min-height: 69px;
  border-bottom: 1px solid #82786a;
  font: 12px/1.35 'Special Elite', Georgia, serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.landing-header p { margin: 0; }
.landing-header p::before {
  content: '';
  display: inline-block;
  width: .55em;
  height: .55em;
  margin: 0 .85em .08em 0;
  background: var(--red);
  transform: rotate(45deg);
}
.landing-header a {
  display: inline-flex;
  align-items: center;
  gap: .55em;
  min-height: 44px;
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: .3em;
}
.landing-header a:hover { color: var(--red); }
.landing-grid {
  display: grid;
  grid-template-columns: minmax(0, .86fr) minmax(0, 1.14fr);
  align-items: center;
  gap: clamp(30px, 4.25vw, 68px);
  margin-block: auto;
  padding-top: clamp(36px, 5vw, 78px);
}
.landing-copy { padding-bottom: clamp(0px, 2vw, 28px); }
.landing-genre {
  margin: 0 0 1.5em;
  color: var(--red);
  font: 13px/1.4 'Special Elite', Georgia, serif;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.landing h1 {
  margin: 0 0 .3em;
  font: 400 clamp(46px, 6.6vw, 106px)/.95 'Rozha One', Georgia, serif;
  letter-spacing: -.048em;
}
.landing h1 span { display: block; }
.landing-hook { margin: 0 0 .45em; font: 400 clamp(21px, 2.2vw, 32px)/1.18 'Rozha One', Georgia, serif; }
.landing-summary { max-width: 35ch; margin: 0; color: #44392f; font: clamp(16px, 1.5vw, 20px)/1.55 Georgia, serif; }
.landing-actions { margin-top: clamp(24px, 3vw, 36px); }
#read-comic {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.8em;
  min-height: 52px;
  padding: 0 17px 0 19px;
  border: 2px solid var(--red);
  background: var(--red);
  color: #fff4df;
  font: 14px/1.1 'Special Elite', Georgia, serif;
  letter-spacing: .09em;
  text-decoration: none;
  text-transform: uppercase;
}
#read-comic span { font: 23px/1 Georgia, serif; }
#read-comic:hover { background: #64190f; border-color: #64190f; }
#reader-note, #reader-error { margin: 12px 0 0; color: #4c4035; font: 13px/1.45 Georgia, serif; }
#reader-error { color: var(--red); }
.landing-art { min-width: 0; margin: 0; align-self: center; }
.landing-art img {
  display: block;
  width: 100%;
  height: clamp(370px, 43vw, 630px);
  border: 1px solid var(--ink);
  background: #45413a;
  object-fit: cover;
  object-position: 67% center;
}
.landing-art figcaption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding-top: 13px;
  color: #4c4035;
  font: 11px/1.4 'Special Elite', Georgia, serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.landing-art figcaption span:first-child { color: var(--red); }

@media (max-width: 640px) {
  .landing-header { min-height: 53px; font-size: 11px; letter-spacing: .075em; }
  .landing-grid { grid-template-columns: minmax(0, 1fr); gap: 26px; margin-block: 0; }
  .landing h1 { font-size: clamp(46px, 10vw, 74px); letter-spacing: -.042em; }
  .landing-genre { font-size: 11px; margin-bottom: 1.15em; }
  .landing-art img { height: auto; aspect-ratio: 1.72; object-position: 62% center; }
}

:where(.landing a, #sound, #play, #page-btn, #page-go, #credits-link):focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 4px;
}

#hud { position: fixed; left: 18px; top: 14px; z-index: 5; font: 13px 'Special Elite', monospace; letter-spacing: .08em; opacity: 0; transition: opacity .5s; }
#hud.show { opacity: .75; }
#rail { position: fixed; right: 14px; top: 50%; transform: translateY(-50%); z-index: 5; display: flex; flex-direction: column; gap: 9px; }
#rail .dot { width: 9px; height: 9px; border: 2px solid var(--ink); border-radius: 50%; cursor: pointer; opacity: .5; transition: .3s; }
#rail .dot.act-start { margin-top: 10px; }
#rail .dot.on { background: var(--red); border-color: var(--red); opacity: 1; transform: scale(1.3); }
#rail .dot:hover { opacity: 1; }

@media (max-width: 700px) { .balloon { max-width: 64%; min-width: 8.5em; } .captions { max-width: 86%; } .caption { font-size: .98em; } .sfx { font-size: 2.4em; } #rail { display: none; } }

#pager { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 7; display: flex; gap: 6px; align-items: center; }
#page-btn, #page-go { font: 12px 'Special Elite', monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--ink);
  background: color-mix(in srgb, var(--paper) 85%, transparent); border: 1.5px solid var(--ink); border-radius: 14px; padding: 5px 12px; opacity: .75; }
#page-btn { cursor: pointer; } #page-btn:hover { opacity: 1; }
#page-go { width: 9em; text-transform: none; opacity: 1; }
#sound, #play { position: fixed; left: 16px; bottom: 14px; z-index: 6; font: 12px 'Special Elite', monospace; letter-spacing: .1em; text-transform: uppercase;
  background: transparent; border: 2px solid var(--ink); color: var(--ink); padding: 5px 10px; cursor: pointer; opacity: .6; }
#sound.on, #play.on { background: var(--ink); color: var(--paper); opacity: .9; }
#play { left: 130px; }
#sound:hover, #play:hover { opacity: 1; }

#credits-link { position: fixed; right: 16px; bottom: 14px; z-index: 6; font: 12px 'Special Elite', monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); opacity: .5; }
#credits-link:hover { opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Show reader controls once the cover gives way to the first panel. */
#hud, #rail, .frame .tag { display: none !important; }
body:not(.reading) :is(#pager, #sound, #play, #credits-link) { visibility: hidden; }
#sound, #play, #credits-link { opacity: 1; background: var(--paper); }
#credits-link { padding: 6px 5px; }
/* tall panels are narrow: narration may run wider and a touch larger */
.frame.tall .captions { max-width: 88%; }
.frame.tall .caption { font-size: 1.05em; }
.frame.tall .balloon { max-width: 70%; }
@media (max-width: 700px) { .balloon.roar { font-size: 1.1em; max-width: 80%; } }
