/*
 * ScrollCAT website - shared styles.
 *
 * Same design system as the app (src/constants/theme.ts): neobrutalism x
 * Kindle Lite. OBJECTS you can hold (cards, keys, sheets) are brutal: 2px ink
 * border, hard zero-blur shadow, they sink into the shadow when pressed. The
 * PRINT on them is the Digest: warm paper, desaturated pigments, hairlines,
 * Redaction as the reading voice, system mono as the device voice.
 * One loud colour: marker yellow.
 */

@font-face {
  font-family: 'Redaction35';
  src: url('/assets/fonts/Redaction35-Regular.otf') format('opentype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Redaction35';
  src: url('/assets/fonts/Redaction35-Bold.otf') format('opentype');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Redaction35';
  src: url('/assets/fonts/Redaction35-Italic.otf') format('opentype');
  font-weight: 400; font-style: italic; font-display: swap;
}

/* ── Tokens (mirrors Palettes in theme.ts) ─────────────────────────────── */

:root {
  color-scheme: light;
  --ground: #E8E3D6;
  --sheet: #FBF8F1;
  --sheet-deep: #F1EDE3;
  --ink: #1F1D18;
  --ink-soft: #46433B;
  --ink-mute: #77736A;
  --ink-faint: #A09B90;
  --hair: #CFCABD;
  --hair-soft: #E2DDD1;
  --shadow: #1F1D18;
  --on-ink: #FBF8F1;
  --ink-tint: rgba(31, 29, 24, 0.06);
  --marker: #F4CB4E;
  --on-marker: #1F1D18;
  --easy: #4E8A3C;
  --easy-tint: rgba(78, 138, 60, 0.10);
  --hard: #C2463A;
  --hard-tint: rgba(194, 70, 58, 0.09);
  --bb: #2A7A5E;
  --bb-tint: rgba(42, 122, 94, 0.10);
  --cp: #2F62A3;
  --cp-tint: rgba(47, 98, 163, 0.10);
  --ps: #8A4A86;
  --ps-tint: rgba(138, 74, 134, 0.10);
  --flash: #1F1D18;
  --grain: 0.035;

  --serif: 'Redaction35', Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;

  --border: 2px;
  --print: 1.5px;
  --r-sheet: 6px;
  --r-key: 4px;
  --r-tag: 3px;
  --sh-sheet: 5px;
  --sh-key: 3px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #12110E;
    --sheet: #221F19;
    --sheet-deep: #1B1914;
    --ink: #ECE6D6;
    --ink-soft: #C4BDAC;
    --ink-mute: #8F887A;
    --ink-faint: #67615A;
    --hair: #3A362E;
    --hair-soft: #2C2923;
    --shadow: #000000;
    --on-ink: #1B1914;
    --ink-tint: rgba(236, 230, 214, 0.07);
    --on-marker: #1B1914;
    --easy: #9CC27A;
    --easy-tint: rgba(156, 194, 122, 0.12);
    --hard: #F07C6C;
    --hard-tint: rgba(240, 124, 108, 0.12);
    --bb: #5DBB97;
    --bb-tint: rgba(93, 187, 151, 0.13);
    --cp: #6FA2E6;
    --cp-tint: rgba(111, 162, 230, 0.13);
    --ps: #C88BC4;
    --ps-tint: rgba(200, 139, 196, 0.13);
    --flash: #ECE6D6;
    --grain: 0.05;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #12110E;
  --sheet: #221F19;
  --sheet-deep: #1B1914;
  --ink: #ECE6D6;
  --ink-soft: #C4BDAC;
  --ink-mute: #8F887A;
  --ink-faint: #67615A;
  --hair: #3A362E;
  --hair-soft: #2C2923;
  --shadow: #000000;
  --on-ink: #1B1914;
  --ink-tint: rgba(236, 230, 214, 0.07);
  --on-marker: #1B1914;
  --easy: #9CC27A;
  --easy-tint: rgba(156, 194, 122, 0.12);
  --hard: #F07C6C;
  --hard-tint: rgba(240, 124, 108, 0.12);
  --bb: #5DBB97;
  --bb-tint: rgba(93, 187, 151, 0.13);
  --cp: #6FA2E6;
  --cp-tint: rgba(111, 162, 230, 0.13);
  --ps: #C88BC4;
  --ps-tint: rgba(200, 139, 196, 0.13);
  --flash: #ECE6D6;
  --grain: 0.05;
}

/* ── Base ──────────────────────────────────────────────────────────────── */

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scroll-padding-top: 84px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  background: var(--ground);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Paper grain: one fixed layer, never on a scrolling container. */
body::after {
  content: '';
  position: fixed; inset: 0;
  z-index: 90;
  pointer-events: none;
  background-image: url('/assets/images/grain.png');
  background-size: 256px 256px;
  opacity: var(--grain);
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::after { mix-blend-mode: screen; }
}
:root[data-theme="dark"] body::after { mix-blend-mode: screen; }

img { display: block; max-width: 100%; }
a { color: inherit; }

::selection { background: var(--marker); color: var(--on-marker); }

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

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 24px; }

/* ── Type ──────────────────────────────────────────────────────────────── */

.display {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(2.6rem, 5.4vw, 4.4rem);
  line-height: 1.02; letter-spacing: -0.025em;
}
.heading {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(2rem, 3.6vw, 2.9rem);
  line-height: 1.06; letter-spacing: -0.02em;
}
.subhead {
  font-family: var(--serif); font-weight: 700;
  font-size: 1.3rem; line-height: 1.2; letter-spacing: -0.01em;
}
.reading { font-size: 1.06rem; line-height: 1.6; color: var(--ink-soft); max-width: 60ch; }
.caption { font-size: 0.94rem; line-height: 1.5; color: var(--ink-soft); }

/* Device voice: kickers, keys, counters. */
.label {
  font-family: var(--mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-mute);
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── Objects ───────────────────────────────────────────────────────────── */

.sheet {
  background: var(--sheet);
  border: var(--border) solid var(--ink);
  border-radius: var(--r-sheet);
  box-shadow: var(--sh-sheet) var(--sh-sheet) 0 var(--shadow);
}

/* Key: opaque face on a hard shadow; sinks flat onto it under a finger. */
.key {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 20px;
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap;
  text-decoration: none; cursor: pointer;
  color: var(--ink);
  background: var(--sheet);
  border: var(--border) solid var(--ink);
  border-radius: var(--r-key);
  box-shadow: var(--sh-key) var(--sh-key) 0 var(--shadow);
  transition: transform 120ms var(--ease-out), box-shadow 120ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.key:hover { transform: translate(-1px, -1px); box-shadow: calc(var(--sh-key) + 1px) calc(var(--sh-key) + 1px) 0 var(--shadow); }
.key:active { transform: translate(var(--sh-key), var(--sh-key)); box-shadow: 0 0 0 var(--shadow); transition-duration: 60ms; }
.key svg { width: 17px; height: 17px; flex-shrink: 0; }
.key--marker { background: var(--marker); color: var(--on-marker); }
.key--ink { background: var(--ink); color: var(--on-ink); }
.key--lg { padding: 15px 24px; font-size: 14px; }
.key--sm { padding: 8px 14px; font-size: 12px; }

/* Quiet control: print, not an object. */
.quiet {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink); text-decoration: none;
  padding: 12px 4px;
  border-bottom: var(--print) solid var(--hair);
  transition: border-color 160ms;
}
.quiet:hover { border-color: var(--ink); }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 7px;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap;
  border: var(--print) solid currentColor;
  border-radius: var(--r-tag);
}
.tag--marker { background: var(--marker); color: var(--on-marker); border-color: var(--ink); }

.rule { height: 0; border: 0; border-top: var(--print) solid var(--hair); }

/* ── Nav ───────────────────────────────────────────────────────────────── */

.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--ground);
  border-bottom: var(--border) solid var(--ink);
}
/* iOS Safari paints page content under the status bar, above a sticky nav.
   Extend the nav's ground upward so text never shows through up there. */
.nav::before {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 100%;
  height: 120px;
  background: var(--ground);
}
.nav-inner {
  max-width: 1160px; margin: 0 auto; padding: 0 24px;
  height: 66px;
  display: flex; align-items: center; gap: 36px;
}

/* Brand: the scroll-and-cat mark is the illuminated initial S of the
   wordmark, so it reads "ScrollCAT" rather than icon + name. */
.brand {
  --mark: 46px;
  display: inline-flex; align-items: flex-end;
  font-family: var(--serif); font-weight: 700; font-size: 1.5rem; line-height: 1; letter-spacing: -0.015em;
  text-decoration: none; color: var(--ink); flex-shrink: 0;
}
.brand-mark {
  height: var(--mark); width: auto;
  margin-right: 1px;
  transform-origin: 50% 85%;
  transition: transform 320ms var(--ease-pop);
}
.brand-word { padding-bottom: calc(var(--mark) * 0.06); }
.brand:hover .brand-mark { transform: rotate(-6deg) scale(1.06); }
@media (prefers-reduced-motion: reduce) { .brand-mark { transition: none; } }
.brand.brand--lg { --mark: 84px; font-size: 2.5rem; letter-spacing: -0.025em; }
.brand--lg .brand-mark { margin-right: 2px; }
.nav-links { display: flex; gap: 26px; list-style: none; flex: 1; }
.nav-links a {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  text-decoration: none; color: var(--ink-soft);
  padding: 6px 0; border-bottom: var(--print) solid transparent;
  transition: color 160ms, border-color 160ms;
}
.nav-links a:hover { color: var(--ink); border-color: var(--ink); }
.nav-cta { margin-left: auto; }
@media (max-width: 860px) {
  .nav-links { display: none; }
  .nav-inner { height: 60px; gap: 16px; }
  .brand { --mark: 42px; font-size: 1.4rem; }
}

/* ── Footer ────────────────────────────────────────────────────────────── */

.footer {
  border-top: var(--border) solid var(--ink);
  padding: 44px 0 56px;
}
.footer-inner {
  max-width: 1160px; margin: 0 auto; padding: 0 24px;
  display: grid; grid-template-columns: 1fr auto; gap: 28px 40px; align-items: start;
}
.footer-brand { display: grid; gap: 12px; justify-items: start; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 26px; list-style: none; justify-content: flex-end; }
.footer-links a {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-soft); text-decoration: none;
}
.footer-links a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.footer-note {
  grid-column: 1 / -1;
  font-size: 0.86rem; color: var(--ink-soft); max-width: 72ch;
}
@media (max-width: 640px) {
  .footer-inner { grid-template-columns: 1fr; }
  .footer-links { justify-content: flex-start; gap: 0 28px; margin: -10px 0; }
  .footer-links a { display: inline-block; padding: 12px 0; }
}

/* ── Scroll reveal (only when JS is on and motion is welcome) ──────────── */

@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(18px); transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out); }
  .js .reveal.is-in { opacity: 1; transform: none; }
  .js .reveal[data-delay="1"] { transition-delay: 80ms; }
  .js .reveal[data-delay="2"] { transition-delay: 160ms; }
  .js .reveal[data-delay="3"] { transition-delay: 240ms; }
}

/* ── Simple content pages (about, legal, beta, report) ─────────────────── */

.page { padding: 56px 0 96px; }
.page-head { max-width: 760px; margin: 0 auto 36px; padding: 0 24px; }
.page-head .label { display: block; margin-bottom: 14px; }
.page-head p { margin-top: 14px; }
.page-sheet { max-width: 760px; margin: 0 auto; padding: 40px 44px 48px; }
@media (max-width: 640px) {
  .page { padding: 36px 0 72px; }
  .page-sheet { margin: 0 16px; padding: 28px 22px 32px; }
}

.prose { color: var(--ink-soft); font-size: 1.04rem; line-height: 1.7; }
.prose > * + * { margin-top: 1em; }
.prose h2 {
  font-family: var(--serif); font-weight: 700; color: var(--ink);
  font-size: 1.45rem; line-height: 1.2; letter-spacing: -0.01em;
  margin-top: 2em; padding-top: 1.1em; border-top: var(--print) solid var(--hair);
}
.prose h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose h3 { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink); margin-top: 1.6em; }
.prose strong { color: var(--ink); }
.prose a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.prose a:hover { background: var(--marker); color: var(--on-marker); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--ink-mute); }
.prose code { font-family: var(--mono); font-size: 0.88em; background: var(--ink-tint); padding: 1px 5px; border-radius: var(--r-tag); }
.prose blockquote { border-left: 4px solid var(--marker); padding: 4px 0 4px 18px; color: var(--ink); }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.96rem; }
.prose th, .prose td { text-align: left; padding: 10px 12px 10px 0; border-bottom: var(--print) solid var(--hair); vertical-align: top; }
.prose th { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); }

/* Forms (report-bug, beta). Label above, error below. */
.field { display: grid; gap: 8px; }
.field + .field { margin-top: 20px; }
.field label { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); }
.field .hint { font-size: 0.9rem; color: var(--ink-soft); }
.input, .textarea, .select {
  width: 100%;
  font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--sheet);
  border: var(--border) solid var(--ink);
  border-radius: var(--r-key);
  padding: 12px 14px;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-mute); }
.textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus { outline: none; box-shadow: var(--sh-key) var(--sh-key) 0 var(--marker); }
.field .error { font-size: 0.92rem; color: var(--hard); }
