/* Shadow Walker: Narco State | landing page
   Palette sampled from the cover. Fonts: Bebas Neue (cover type) for display, the visitor's own system sans-serif for text.
   To use your licensed Bebas Neue Pro, drop its .woff2 into assets/fonts/ and point the @font-face at it. */

@font-face {
  font-family: "Bebas Neue";
  src: url("assets/fonts/bebas-neue-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* sampled from the cover */
  --ink: #121210;         /* background */
  --coral: #e05a57;       /* title */
  --steel: #abaaaa;       /* credits */
  --blood: #652827;       /* darkest wound red */

  /* derived */
  --coral-hi: #ee706c;
  --bone: #ece6df;        /* headline, strong text */
  --bone-soft: #cdc7c0;   /* body text */
  --steel-dim: #8e8c8a;   /* fine print */
  --alert: #ff9b95;       /* error text */
  --on-coral: #140d0c;    /* text on the button (5.2:1) */

  --font-display: "Bebas Neue", "Arial Narrow", Impact, sans-serif;
  --font-text: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --gutter: clamp(1.25rem, 5vw, 3rem);
  --text-w: 40rem;        /* width of the form + copy column */
  --control-h: 2.75rem;   /* input and button height (44px) */
}

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

html {
  -webkit-text-size-adjust: 100%;
  background: var(--ink);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--bone-soft);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  isolation: isolate; /* keeps .atmosphere (z-index -1) above the body background */
}

/* ---------- atmosphere: blurred cover haze + vignette, grain over everything ---------- */

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.atmosphere::before {
  content: "";
  position: absolute;
  inset: -10%;
  background: url("assets/bg-blur.webp") center / cover no-repeat;
  opacity: 0.34;
}
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 75% 65% at 50% 45%, transparent 30%, rgb(8 8 7 / 0.88) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0.09;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

/* ---------- layout ---------- */

/* Reading order everywhere: cover, headline, form, then the story. */
.page {
  --top: clamp(1.5rem, 5vh, 3rem);
  flex: 1;
  width: 100%;
  max-width: 80rem;
  margin-inline: auto;
  padding: var(--top) var(--gutter) clamp(1rem, 3vh, 2rem);
  display: grid;
  justify-items: center;
  align-content: start;
  row-gap: clamp(1.75rem, 4vh, 2.5rem);
  animation: arrive 0.9s ease-out both;
}

.cover {
  position: relative;
  isolation: isolate; /* contains the glow so it sits behind the image, above the page */
  margin: 0;
  width: min(52vw, 16rem);
}

.pitch {
  width: 100%;
  max-width: var(--text-w);
  container-type: inline-size; /* lets the desktop headline size itself to the column (cqw) */
}

/* ---------- cover ---------- */

.cover img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
  box-shadow:
    0 0 0 1px rgb(236 230 223 / 0.07),
    0 40px 70px -24px rgb(0 0 0 / 0.95);
}

/* the light bleeding out from behind the book */
.cover::before {
  content: "";
  position: absolute;
  inset: -14% -22% -10%;
  z-index: -1;
  background: radial-gradient(closest-side, rgb(224 90 87 / 0.30), rgb(101 40 39 / 0.22) 52%, transparent 76%);
  filter: blur(34px);
  animation: glow 2.8s ease-out 0.15s both;
}

/* ---------- headline + copy ---------- */

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(3.25rem, 11vw, 5rem);
  line-height: 0.92;
  letter-spacing: 0.012em;
  color: var(--bone);
  text-wrap: balance;
}

.copy {
  margin-top: 2rem;
}
.copy p {
  margin: 0 0 0.8em;
  text-wrap: pretty;
}
.copy p:last-child { margin-bottom: 0; }

/* the hook */
.copy .lede {
  margin-bottom: 0.8em;
  font-size: 1.16em;
  line-height: 1.3;
  color: var(--bone);
}

/* the turn: "Shadow Walker: Narco State is that story." */
.copy .beat {
  margin-top: 1em;
  color: var(--bone);
}

/* year marker: Bebas at the same size as the text, so its capitals are no taller than the sentence beside it */
.dateline {
  font-family: var(--font-display);
  font-size: 1em;
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--bone);
}

.copy .closer {
  margin-top: 1em;
  font-style: italic;
  color: var(--bone);
}

/* ---------- form ---------- */

.signup {
  margin-top: 1.75rem;
}

.signup__row {
  display: grid;
  gap: 0.6rem;
}
@media (min-width: 36rem) {
  .signup__row { grid-template-columns: minmax(0, 1fr) auto; }
}

.field {
  width: 100%;
  height: var(--control-h);
  padding: 0 0.9rem;
  font: inherit;
  font-size: 1rem; /* 16px keeps iOS from zooming into the field */
  line-height: 1;
  color: var(--bone);
  background: rgb(236 230 223 / 0.06);
  border: 1px solid rgb(236 230 223 / 0.24);
  border-radius: 2px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.field::placeholder { color: var(--steel); opacity: 0.85; }
.field:hover { border-color: rgb(236 230 223 / 0.4); }
.field:focus {
  outline: none;
  background: rgb(236 230 223 / 0.09);
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgb(224 90 87 / 0.28);
}
.field[aria-invalid="true"] { border-color: var(--alert); }

.btn {
  height: var(--control-h);
  padding: 0 1.3rem;
  font-family: var(--font-display);
  font-size: 1.3rem;
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--on-coral);
  background: var(--coral);
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.btn span { position: relative; top: 0.04em; } /* optical centring for Bebas */
.btn:hover {
  background: var(--coral-hi);
  box-shadow: 0 12px 32px -10px rgb(224 90 87 / 0.6);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--bone); outline-offset: 3px; }
.btn[aria-busy="true"] { opacity: 0.7; cursor: progress; pointer-events: none; }

.signup__error {
  margin: 0.65rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--alert);
}
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- download page (chapters.html) ---------- */

/* the same button, as a link */
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
a.btn,
a.btn:hover { color: var(--on-coral); }

/* second choice: outlined, so the EPUB stays the obvious first pick */
.btn--ghost {
  color: var(--bone);
  background: transparent;
  border: 1px solid rgb(236 230 223 / 0.34);
}
a.btn--ghost,
a.btn--ghost:hover { color: var(--bone); }
.btn--ghost:hover {
  background: rgb(236 230 223 / 0.08);
  border-color: var(--bone);
  box-shadow: none;
}

.dl {
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}
.dl__item {
  display: grid;
  gap: 0.75rem;
  padding: 1.1rem 0;
  border-top: 1px solid rgb(236 230 223 / 0.12);
}
.dl__text { line-height: 1.5; }
.dl__what { margin: 0; text-wrap: pretty; }
.dl__tip {
  margin: 0.5rem 0 0;
  font-size: 0.9em;
  line-height: 1.45;
  color: var(--steel);
}
.dl__tip strong { font-weight: 600; color: var(--bone-soft); }

@media (min-width: 36rem) {
  /* button on the left, what it's for on the right; first line of text centred on the button */
  .dl__item {
    grid-template-columns: 13.5rem minmax(0, 1fr);
    column-gap: 1.25rem;
    align-items: start;
  }
  .dl__text { padding-top: calc((var(--control-h) - 1.5em) / 2); }
}

/* ---------- footer + links ---------- */

a {
  color: var(--bone);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  text-decoration-color: rgb(236 230 223 / 0.4);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover { color: var(--coral-hi); text-decoration-color: currentColor; }
a:focus-visible { outline: 2px solid var(--coral); outline-offset: 3px; border-radius: 2px; }

.foot {
  width: 100%;
  max-width: 80rem;
  margin-inline: auto;
  padding: 0.5rem var(--gutter) calc(1rem + env(safe-area-inset-bottom));
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--steel-dim);
}
.foot__links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.foot a { color: var(--steel); }
.foot a:hover { color: var(--coral-hi); }

/* Instagram glyph: same height as the "Privacy" text beside it */
.foot__ig {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.foot__ig svg {
  display: block;
  width: 1.15em;
  height: 1.15em;
}

/* ---------- privacy pop-up ---------- */

/* "Privacy" in the footer is a button (it opens a pop-up) dressed like the other links */
.foot__privacy {
  padding: 0;
  font: inherit;
  color: var(--steel);
  background: none;
  border: 0;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: rgb(236 230 223 / 0.4);
  cursor: pointer;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
.foot__privacy:hover { color: var(--coral-hi); text-decoration-color: currentColor; }
.foot__privacy:focus-visible { outline: 2px solid var(--coral); outline-offset: 3px; border-radius: 2px; }

body:has(dialog[open]) { overflow: hidden; } /* no scrolling the page behind it */

.policy {
  --policy-h: min(88vh, 46rem);
  width: min(40rem, calc(100vw - 2rem));
  max-height: var(--policy-h);
  padding: 0;           /* no padding: a click on the dialog itself means a click outside the panel */
  border: 0;
  background: none;
  color: var(--bone-soft);
  overflow: visible;
}
@supports (height: 1dvh) {
  .policy { --policy-h: min(88dvh, 46rem); }
}
.policy::backdrop {
  background: rgb(8 8 7 / 0.78);
  backdrop-filter: blur(3px);
}
.policy[open] { animation: pop 0.2s ease-out both; }
.policy[open]::backdrop { animation: arrive 0.2s ease-out both; }

.policy__panel {
  display: flex;
  flex-direction: column;
  max-height: var(--policy-h);
  overflow: hidden;
  background: #1a1816;
  border: 1px solid rgb(236 230 223 / 0.12);
  border-top: 2px solid var(--coral);
  border-radius: 3px;
  box-shadow: 0 40px 90px -20px rgb(0 0 0 / 0.9);
}

.policy__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem 0.8rem 1.75rem;
  border-bottom: 1px solid rgb(236 230 223 / 0.1);
}
.policy__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2.25rem;
  line-height: 1;
  letter-spacing: 0.03em;
  color: var(--bone);
}
.policy__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  color: var(--steel);
  background: none;
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.policy__close:hover { color: var(--bone); background: rgb(236 230 223 / 0.08); }
.policy__close:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
.policy__close svg { width: 1.1rem; height: 1.1rem; }

.policy__body {
  padding: 1.1rem 1.75rem 1.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 0.9375rem;
  line-height: 1.6;
}
.policy__body p { margin: 0 0 0.85em; }
.policy__body p:last-child { margin-bottom: 0; }
.policy__body a {
  color: var(--bone);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: rgb(236 230 223 / 0.4);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
.policy__body a:hover { color: var(--coral-hi); text-decoration-color: currentColor; }
.policy__body a:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; border-radius: 2px; }

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

@media (max-width: 36rem) {
  .policy__head { padding-left: 1.25rem; }
  .policy__body { padding: 1rem 1.25rem 1.5rem; }
}

/* ---------- desktop: everything on one screen ---------- */

@media (min-width: 56rem) {
  :root {
    /* as tall as the viewport allows, never wider than 28rem */
    --cover-w: clamp(16rem, calc((100vh - 8rem) / 1.5), 28rem);
    --col-gap: clamp(2.5rem, 5vw, 5rem);
  }

  /* text scales with window height so the whole story fits in view:
     15px in a 650px-tall window, growing to 17px from 900px up */
  body { font-size: clamp(0.9375rem, calc(0.9375rem + (100vh - 650px) * 0.008), 1.0625rem); line-height: 1.5; }
  /* one line, about as wide as the form row below it (22rem field + gap + button) */
  h1 { font-size: clamp(2.25rem, 7.6vh, 4rem); }
  @supports (font-size: 1cqw) {
    h1 { font-size: clamp(2.25rem, min(9cqw, 8vh), 4rem); }
  }

  .page {
    --top: clamp(1.25rem, 4vh, 2.75rem);
    padding-bottom: clamp(0.5rem, 1.5vh, 1.25rem);
    align-content: center; /* tall windows: centre the block instead of leaving it top-heavy */
    grid-template-columns: var(--cover-w) minmax(0, var(--text-w));
    justify-content: center;
    align-items: start;
    column-gap: var(--col-gap);
    row-gap: 0;
  }
  .cover {
    /* stays in view if the window is too short for the whole story */
    position: sticky;
    top: var(--top);
    width: var(--cover-w);
  }

  .copy { margin-top: clamp(1rem, 2.8vh, 1.75rem); }
  .signup { margin-top: clamp(0.875rem, 2.2vh, 1.375rem); }

  /* download page: the short text column sits level with the middle of the cover */
  .page--thanks .pitch { align-self: center; }
  .dl { margin-top: clamp(0.75rem, 2.2vh, 1.5rem); }
  .dl__item { padding-block: clamp(0.75rem, 1.9vh, 1.1rem); }

  /* email field a touch narrower than the full column; the button keeps its size */
  .signup__row { grid-template-columns: minmax(0, 22rem) auto; justify-content: start; }
  .btn { min-width: 13.5rem; } /* keeps the row as wide as the headline now that the label is shorter */

  /* footer sits under the text column: Instagram lines up with the copy, Privacy goes to the far right */
  .foot {
    display: grid;
    grid-template-columns: var(--cover-w) minmax(0, var(--text-w));
    justify-content: center;
    column-gap: var(--col-gap);
  }
  .foot__links { grid-column: 2; justify-content: space-between; }
}

/* ---------- motion: one arrival, nothing else ---------- */

@keyframes arrive {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes glow {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, .policy::backdrop {
    animation: none !important;
    transition: none !important;
  }
}
