/* ==========================================================================
   JACK WILDS — base.css
   Tokens, reset, type, shared components, chrome (nav, thumb bar, toasts).
   Every section stylesheet builds on these tokens. Keep section CSS scoped
   to its own prefix (.hero-, .sel-, .w-, .arc-, .prog-, .studio-, .fx-).
   ========================================================================== */

:root {
  /* ink: warm blacks sampled from the blood-moon shack art */
  --ink: #0c0a08;
  --ink-2: #131009;
  --ink-3: #1b1612;
  --ink-4: #262019;
  --line: rgba(239, 230, 214, .12);
  --line-2: rgba(239, 230, 214, .22);

  /* bone: text */
  --bone: #efe6d6;
  --bone-2: #cfc4b2;
  --fog: #948a7a;
  --fog-2: #6d6457;

  /* seal: the red hanko. Used sparingly: OUT NOW, primary actions, confirmations */
  --seal: #d9482c;
  --seal-hot: #f0603f;
  --seal-deep: #9e2a17;
  /* gold: the crest, the Arcade, WISHLIST */
  --gold: #f2b13e;
  --gold-hot: #ffc75a;
  --gold-deep: #b98322;
  --moon: #a3301f;

  /* per-game accents (overridden on game pages via [data-game]) */
  --acc: var(--seal);
  --acc-2: var(--gold);
  --g-bg: var(--ink);
  --g-surface: var(--ink-3);
  --g-ink: var(--bone);

  --f-display: 'Dela Gothic One', 'Hiragino Kaku Gothic StdN', 'Yu Gothic', 'Arial Black', system-ui, sans-serif;
  --f-body: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Yu Gothic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-pixel: 'DotGothic16', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --ease-back: cubic-bezier(.34, 1.56, .64, 1);
  --ease-snap: cubic-bezier(.2, .9, .25, 1.2);

  --gutter: clamp(16px, 4.2vw, 56px);
  --maxw: 1320px;
  --nav-h: 64px;
  --thumb-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --shadow-hard: 6px 6px 0 rgba(0, 0, 0, .55);
  --shadow-soft: 0 30px 80px -20px rgba(0, 0, 0, .75);

  color-scheme: dark;
}

@media (max-width: 860px) {
  :root { --nav-h: 56px; }
}

/* cross-document view transitions (Chrome 126+, Safari 18.2+); others just navigate */
@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: .55s; animation-timing-function: var(--ease-out); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .35s; }

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html {
  font-synthesis: none; /* Dela Gothic One is one heavy weight: never fake-bold it */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 12px);
  background: var(--ink);
}
body {
  min-height: 100vh;
  min-height: 100svh;
  background: var(--g-bg, var(--ink));
  color: var(--bone);
  font-family: var(--font-override, var(--f-body));
  font-size: 17px;
  line-height: 1.7;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  transition: background-color .9s var(--ease-out);
}
img, video, canvas, svg, picture { display: block; max-width: 100%; }
img { height: auto; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }
ul[role="list"], ol[role="list"] { list-style: none; }
::selection { background: var(--seal); color: var(--bone); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 1px; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--ink-4); border: 2px solid var(--ink); }
::-webkit-scrollbar-thumb:hover { background: var(--seal); }

/* film grain: one static tile, nudged in steps so it never looks like a flat overlay */
body::after {
  content: '';
  position: fixed;
  inset: -50%;
  z-index: 900;
  pointer-events: none;
  opacity: .075;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); }
  80% { transform: translate(3%, 3%); }
  100% { transform: translate(0, 0); }
}

/* ── Type ──────────────────────────────────────────────────────────────── */
.display, h1, h2 {
  font-family: var(--f-display);
  font-weight: 800;
  line-height: .98;
  letter-spacing: -.01em;
  font-feature-settings: 'palt';
}
h3, h4 { font-family: var(--f-display); font-weight: 700; line-height: 1.15; }
.t-xxl { font-size: clamp(56px, 12.5vw, 196px); }
.t-xl  { font-size: clamp(44px, 8vw, 120px); }
.t-l   { font-size: clamp(34px, 5.4vw, 76px); }
.t-m   { font-size: clamp(26px, 3.4vw, 44px); }
.t-s   { font-size: clamp(20px, 2.2vw, 28px); }
.lede  { font-size: clamp(17px, 1.55vw, 21px); color: var(--bone-2); line-height: 1.65; max-width: 62ch; }
.muted { color: var(--fog); }
.jp { font-family: var(--f-display); font-weight: 700; letter-spacing: .08em; }
.tategaki { writing-mode: vertical-rl; text-orientation: upright; letter-spacing: .18em; }
.pixel-font { font-family: var(--f-pixel); letter-spacing: .06em; }

.kicker {
  display: inline-flex;
  align-items: center;
  gap: .7em;
  font-family: var(--f-pixel);
  font-size: 13px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--gold);
}
.kicker .jp-k { color: var(--seal-hot); letter-spacing: .12em; font-family: var(--f-pixel); }
.kicker::before {
  content: '';
  width: 22px;
  height: 2px;
  background: currentColor;
  opacity: .7;
}
.kicker.no-rule::before { display: none; }

.cat-no { font-family: var(--f-pixel); letter-spacing: .12em; color: var(--fog); }

/* ── Layout ────────────────────────────────────────────────────────────── */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.sec { position: relative; padding-block: clamp(84px, 11vw, 168px); }
.sec-head { display: grid; gap: 18px; margin-bottom: clamp(36px, 5vw, 64px); }
.sec-head h2 { font-size: clamp(40px, 7vw, 104px); }
.sec-head h2 .jp-t {
  display: block;
  font-size: .32em;
  color: var(--seal-hot);
  letter-spacing: .3em;
  margin-top: .5em;
  font-weight: 700;
}
.rule { height: 1px; background: var(--line); border: 0; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed;
  left: 12px; top: -80px;
  z-index: 2000;
  background: var(--gold);
  color: var(--ink);
  padding: 10px 16px;
  font-family: var(--f-pixel);
  transition: top .2s;
}
.skip-link:focus { top: 12px; }

.pixel, .is-pixel img, img.is-pixel { image-rendering: pixelated; image-rendering: crisp-edges; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  --b-bg: transparent;
  --b-fg: var(--bone);
  --b-bd: var(--line-2);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .65em;
  min-height: 48px;
  padding: 12px 22px 11px;
  font-family: var(--f-pixel);
  font-size: 15px;
  line-height: 1.1;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--b-fg);
  background: var(--b-bg);
  border: 2px solid var(--b-bd);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .55);
  transition: transform .16s var(--ease-out), box-shadow .16s var(--ease-out), background-color .2s, border-color .2s, color .2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn .ic { width: 18px; height: 18px; flex: none; }
@media (hover: hover) {
  .btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 rgba(0, 0, 0, .55); border-color: var(--bone); }
}
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 rgba(0, 0, 0, .55); }
.btn--seal { --b-bg: var(--seal); --b-bd: var(--seal); --b-fg: #fff7ee; }
.btn--seal:hover { --b-bg: var(--seal-hot); --b-bd: var(--seal-hot); }
.btn--gold { --b-bg: var(--gold); --b-bd: var(--gold); --b-fg: #1a1206; }
.btn--gold:hover { --b-bg: var(--gold-hot); --b-bd: var(--gold-hot); }
.btn--acc { --b-bg: var(--acc); --b-bd: var(--acc); --b-fg: var(--acc-fg, #fff7ee); }
.btn--ghost { --b-bg: rgba(12, 10, 8, .35); }
.btn--quiet { box-shadow: none; --b-bd: transparent; padding-inline: 10px; }
.btn--quiet:hover { box-shadow: none; transform: none; color: var(--gold); }
.btn--lg { min-height: 56px; padding: 15px 28px 14px; font-size: 16px; }
.btn--sm { min-height: 40px; padding: 9px 14px 8px; font-size: 13px; }
.btn--block { display: flex; width: 100%; }
.btn[aria-disabled="true"], .btn:disabled {
  cursor: default;
  opacity: .62;
  box-shadow: none;
  transform: none;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px; height: 42px;
  color: var(--bone-2);
  border: 1px solid transparent;
  transition: color .2s, border-color .2s, background-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { color: var(--gold); border-color: var(--line); }
.icon-btn .ic { width: 20px; height: 20px; }

.ic { width: 1em; height: 1em; fill: currentColor; flex: none; }

/* ── Status chips & stamps ─────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: 5px 10px 4px;
  font-family: var(--f-pixel);
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: .14em;
  text-transform: uppercase;
  border: 1.5px solid currentColor;
  white-space: nowrap;
}
.chip .ic { width: 14px; height: 14px; }
.chip--out { color: var(--seal-hot); background: rgba(217, 72, 44, .12); }
.chip--wish { color: var(--gold); background: rgba(242, 177, 62, .1); }
.chip--soon { color: var(--bone-2); background: rgba(239, 230, 214, .05); }
.chip--itch { color: #ff7a7a; background: rgba(250, 92, 92, .08); }
.chip--solid { background: currentColor; }
.chip--solid > * { color: var(--ink); }

/* hanko stamp: square, rotated, ink edge */
.stamp {
  --st: var(--seal-hot);
  display: inline-grid;
  place-items: center;
  text-align: center;
  padding: 8px 12px 6px;
  font-family: var(--f-pixel);
  font-size: 11px;
  letter-spacing: .22em;
  line-height: 1.25;
  text-transform: uppercase;
  color: var(--st);
  border: 3px solid var(--st);
  transform: rotate(-7deg);
  background: rgba(12, 10, 8, .55);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25) inset;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='r'><feTurbulence baseFrequency='.9' numOctaves='2'/><feComponentTransfer><feFuncA type='discrete' tableValues='1 1 1 1 1 1 0 1'/></feComponentTransfer></filter><rect width='120' height='120' filter='url(%23r)'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='r'><feTurbulence baseFrequency='.9' numOctaves='2'/><feComponentTransfer><feFuncA type='discrete' tableValues='1 1 1 1 1 1 0 1'/></feComponentTransfer></filter><rect width='120' height='120' filter='url(%23r)'/></svg>");
}
.stamp .jp-s { font-family: var(--f-display); font-size: 17px; font-weight: 800; letter-spacing: .1em; display: block; }
.stamp--gold { --st: var(--gold); }
.stamp--bone { --st: var(--bone-2); }

/* square hanko seal with a single kanji */
.hanko {
  --hk: var(--seal);
  display: inline-grid;
  place-items: center;
  width: 1em; height: 1em;
  font-size: 64px;
  background: var(--hk);
  color: #fff4ea;
  font-family: var(--f-display);
  font-weight: 800;
  line-height: 1;
  transform: rotate(-5deg);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .45);
}
.hanko > span { font-size: .62em; }

/* ── Panels & forms ────────────────────────────────────────────────────── */
.panel {
  background: var(--ink-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-hard);
}
.field { display: grid; gap: 6px; }
.field > span, .field-label {
  font-family: var(--f-pixel);
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--fog);
}
.input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, .35);
  border: 1.5px solid var(--line-2);
  color: var(--bone);
  font-size: 16px; /* 16px stops iOS zooming on focus */
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .2s, background-color .2s;
}
.input::placeholder { color: var(--fog-2); }
.input:focus { border-color: var(--gold); background: rgba(0, 0, 0, .5); outline: none; }
textarea.input { min-height: 140px; resize: vertical; line-height: 1.5; }
.form-note { font-size: 13px; color: var(--fog); line-height: 1.5; }
.form-note a { text-decoration: underline; text-underline-offset: 3px; }
.form-status { font-family: var(--f-pixel); font-size: 14px; letter-spacing: .08em; min-height: 1.4em; }
.form-status[data-state="ok"] { color: var(--ok); }
.form-status[data-state="error"] { color: var(--seal-hot); }
.hp-field { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* ── Site nav (top) ────────────────────────────────────────────────────── */
.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 500;
  height: calc(var(--nav-h) + var(--safe-t));
  padding-top: var(--safe-t);
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: background-color .35s, border-color .35s, transform .4s var(--ease-out);
  border-bottom: 1px solid transparent;
}
.site-nav.is-solid {
  background: rgba(12, 10, 8, .9);
  border-bottom-color: var(--line);
}
@supports ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))) {
  .site-nav.is-solid { background: rgba(12, 10, 8, .72); -webkit-backdrop-filter: blur(12px) saturate(1.2); backdrop-filter: blur(12px) saturate(1.2); }
}
.site-nav.is-hidden { transform: translateY(-100%); }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-seal {
  width: 34px; height: 34px;
  image-rendering: pixelated;
  transform: rotate(-4deg);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .5);
  transition: transform .3s var(--ease-back);
}
.brand:hover .brand-seal { transform: rotate(4deg) scale(1.06); }
.brand-word { font-family: var(--f-pixel); font-size: 15px; letter-spacing: .16em; line-height: 1.1; }
.brand-word small { display: block; font-size: 9.5px; letter-spacing: .34em; color: var(--fog); margin-top: 3px; }

.nav-links { display: flex; align-items: center; gap: clamp(14px, 2.2vw, 34px); }
.nav-links a {
  position: relative;
  font-family: var(--f-pixel);
  font-size: 13px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--bone-2);
  padding: 8px 0;
  transition: color .2s;
}
.nav-links a::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 2px;
  height: 2px;
  background: var(--seal);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .35s var(--ease-out);
}
.nav-links a:hover, .nav-links a[aria-current="true"] { color: var(--bone); }
.nav-links a:hover::after, .nav-links a[aria-current="true"]::after { transform: scaleX(1); }
.nav-links .nav-arcade { color: var(--gold); }
.nav-links .nav-arcade::after { background: var(--gold); }
.nav-tools { display: flex; align-items: center; gap: 4px; }

/* ── Thumb bar (phones): everything important within thumb reach ─────── */
.thumb-bar { display: none; }
@media (max-width: 860px) {
  .nav-links { display: none; }
  .thumb-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 500;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    height: calc(var(--thumb-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    background: rgba(12, 10, 8, .94);
    border-top: 1px solid var(--line);
    transition: transform .4s var(--ease-out);
  }
  .thumb-bar.is-hidden { transform: translateY(100%); }
  .thumb-bar a, .thumb-bar button {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 4px;
    font-family: var(--f-pixel);
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--bone-2);
    -webkit-tap-highlight-color: transparent;
    min-width: 0;
  }
  .thumb-bar .ic { width: 20px; height: 20px; }
  .thumb-bar [aria-current="true"] { color: var(--bone); }
  .thumb-bar .tb-arcade { color: var(--gold); }
  .thumb-bar .tb-primary { background: var(--acc); color: var(--acc-fg, #fff7ee); }
  body { padding-bottom: calc(var(--thumb-h) + var(--safe-b)); }
}

/* ── Toasts ────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(16px + var(--safe-b));
  z-index: 1500;
  display: grid;
  gap: 10px;
  justify-items: end;
  pointer-events: none;
}
@media (max-width: 860px) {
  .toasts { left: 12px; right: 12px; bottom: calc(var(--thumb-h) + 12px + var(--safe-b)); justify-items: stretch; }
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 420px;
  padding: 12px 16px;
  background: #16120e;
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--toast-acc, var(--gold));
  box-shadow: var(--shadow-hard);
  font-size: 14.5px;
  line-height: 1.4;
  animation: toastIn .45s var(--ease-back) both;
}
.toast .t-title { font-family: var(--f-pixel); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--toast-acc, var(--gold)); display: block; }
.toast.is-leaving { animation: toastOut .35s var(--ease-io) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ── Reveal helper (JS adds .is-in) ────────────────────────────────────── */
.rv { opacity: 0; transform: translateY(24px); transition: opacity .9s var(--ease-out), transform .9s var(--ease-out); transition-delay: var(--d, 0s); }
.rv.is-in { opacity: 1; transform: none; }
.no-js .rv { opacity: 1; transform: none; }

/* ── Reduced motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  body::after { animation: none; }
  .rv { opacity: 1; transform: none; }
}

/* ── Game page palette hook (values set inline by world.js from data) ──── */
body[data-page="game"] {
  --acc: var(--g-accent, var(--seal));
  --acc-2: var(--g-accent2, var(--gold));
}
