/* ==========================================================================
   GrindWill: shared design system (site.css)
   Red ink in dark water. One saturated colour (the seal red), paper-white type,
   blue-black ground. Every page loads this file; page files only add layout.
   Sections:
     1. Tokens            6. Header + mobile nav    11. Stats + spec list
     2. Base              7. Footer                 12. Media frames
     3. Type scale        8. Buttons + links        13. Ink canvas, tone stage, thread
     4. Layout            9. Eyebrow + katakana     14. Reveal states (html.fx / html.fx-rm)
     5. Utilities        10. Copy-to-clipboard      15. Reduced motion
   See /DESIGN.md for usage and snippets.
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  /* ground: blue-black ink, lightest last */
  --ink: #0a0d14;
  --ink-1: #0e121b;
  --ink-2: #151b27;
  --ink-3: #1e2534;
  /* type: warm paper */
  --paper: #eee8de;
  --paper-2: #cbc5ba;
  --mute: #8d94a3;            /* 6.3:1 on --ink, AA for small text */
  --line: rgba(238, 232, 222, 0.12);
  --line-2: rgba(238, 232, 222, 0.24);
  /* the only saturated accent */
  --red: #E60026;
  --red-hover: #f0123a;
  --red-deep: #8f0019;
  /* room tones: full-viewport tints faded in by [data-tone="<name>"] */
  --tone-ic: #17122a;          /* Internet Cafe 98 purple */
  --tone-pp: #061829;          /* Pupple Pop deep sea */
  --tone-dd: #120b0e;          /* Dirty Dispatch, sealed */
  --tone-warm: #110f13;        /* studio */

  /* fonts */
  --fd: "Funnel Display", "Helvetica Neue", Arial, sans-serif;
  --fs: "Funnel Sans", "Helvetica Neue", Arial, sans-serif;
  --fj: "Zen Old Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;

  /* type scale (fluid) */
  --t-display: clamp(2.6rem, 6.1vw, 6.6rem);
  --t-h2: clamp(2.3rem, 4.8vw, 4.8rem);
  --t-h3: clamp(2.1rem, 3.8vw, 4rem);
  --t-h4: clamp(1.5rem, 2.4vw, 2.4rem);
  --t-num: clamp(2.2rem, 3.4vw, 3.4rem);
  --t-lede: clamp(1.0625rem, 1.35vw, 1.25rem);
  --t-body: 1.0625rem;          /* 17px */
  --t-small: 0.875rem;          /* 14px */
  --t-label: 0.8125rem;         /* 13px, uppercase labels */

  /* spacing scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 72px; --s-9: 96px;
  --g: clamp(16px, 4.2vw, 72px);                 /* side gutter */
  --max: 1520px;                                  /* content max width incl. gutters */
  --section: clamp(72px, 8vw, 128px);             /* vertical section padding */
  --head-h: 72px;                                 /* fixed header height */

  /* motion */
  --ease: cubic-bezier(.16, 1, .3, 1);            /* expo.out */
  --ease-soft: cubic-bezier(.22, 1, .36, 1);      /* power3.out-ish */
}
@media (max-width: 760px) { :root { --head-h: 64px; } }

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html {
  color-scheme: dark; background: var(--ink); -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth; scroll-padding-top: calc(var(--head-h) + 16px);
}
html, body { background: var(--ink); }
body {
  margin: 0; color: var(--paper); font-family: var(--fs); font-size: var(--t-body); line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: clip;
}
img, picture, svg, canvas { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-family: var(--fd); font-weight: 500; letter-spacing: -0.02em; }
ul, ol, dl, dd { margin: 0; padding: 0; list-style: none; }
figure { margin: 0; }
button { font: inherit; color: inherit; }
::selection { background: var(--red); color: #fff; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 4px; border-radius: 2px; }
/* everything a page renders sits above the fixed tone stage */
main, .site-foot { position: relative; z-index: 1; }

/* 3. Type scale -------------------------------------------------------------- */
.t-display { font-size: var(--t-display); line-height: 0.98; letter-spacing: -0.035em; text-wrap: balance; }
.t-h2 { font-size: var(--t-h2); line-height: 1.02; letter-spacing: -0.03em; text-wrap: balance; }
.t-h3 { font-size: var(--t-h3); line-height: 1.02; letter-spacing: -0.03em; text-wrap: balance; }
.t-h4 { font-size: var(--t-h4); line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance; }
.t-lede { font-size: var(--t-lede); color: var(--paper-2); line-height: 1.6; text-wrap: pretty; }
.t-body { color: var(--paper-2); text-wrap: pretty; }
.t-small { font-size: var(--t-small); color: var(--mute); }
.t-label {
  font-family: var(--fs); font-size: var(--t-label); font-weight: 500; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--mute);
}
.measure { max-width: 34em; }

/* 4. Layout ---------------------------------------------------------------- */
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--g); }
.section { position: relative; padding: var(--section) 0; }
.section--rule { border-top: 1px solid var(--line); }
.section-head > .eyebrow + * { margin-top: 22px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(28px, 6vw, 96px); }
@media (max-width: 999px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* 5. Utilities --------------------------------------------------------------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.nowrap { white-space: nowrap; }
.skip {
  position: fixed; left: var(--g); top: -80px; z-index: 200; background: var(--paper); color: var(--ink);
  padding: 10px 14px; font-weight: 600; text-decoration: none; border-radius: 2px; transition: top .3s var(--ease);
}
.skip:focus { top: 12px; }

/* 6. Header + mobile nav ----------------------------------------------------- */
.site-head {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50; height: var(--head-h);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 0 max(var(--g), calc((100% - var(--max)) / 2 + var(--g)));
  padding-top: env(safe-area-inset-top);
}
.head-bg {
  position: absolute; inset: 0; z-index: -1; background: rgba(10, 13, 20, 0.97);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); transition: opacity .6s var(--ease-soft);
}
html.js .head-bg { opacity: 0; }
html.js .site-head.is-scrolled .head-bg { opacity: 1; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-family: var(--fd); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; border-radius: 2px; }
.brand img { width: 34px; height: auto; transition: transform .9s var(--ease); }
.nav ul { display: flex; gap: clamp(14px, 2.2vw, 34px); }
.nav a {
  position: relative; display: inline-block; text-decoration: none; font-size: 15px; color: var(--paper-2);
  padding: 6px 0; transition: color .4s var(--ease);
}
.nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--red);
  transform: scaleX(0); transform-origin: 100% 50%; transition: transform .6s var(--ease);
}
.nav a:focus-visible, .nav a.is-active, .nav a[aria-current="page"] { color: var(--paper); }
.nav a:focus-visible::after, .nav a.is-active::after, .nav a[aria-current="page"]::after { transform: scaleX(1); transform-origin: 0 50%; }
.nav-toggle { display: none; }

@media (max-width: 760px) {
  .brand span { display: none; }
  /* no JS: header scrolls away with the page and the links wrap under the seal */
  html:not(.js) .site-head { position: absolute; height: auto; min-height: var(--head-h); flex-wrap: wrap; padding-top: 14px; padding-bottom: 10px; }
  html:not(.js) .nav ul { flex-wrap: wrap; gap: 6px 16px; }
  html:not(.js) .nav a { font-size: 14px; }

  /* JS: a menu button opens a full-screen sheet */
  html.js .nav-toggle {
    display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 4px 0 12px; margin-right: -4px;
    background: none; border: 0; cursor: pointer; font-size: 15px; font-weight: 500; color: var(--paper);
    border-radius: 2px;
  }
  .nav-toggle i { position: relative; display: block; width: 22px; height: 10px; }
  .nav-toggle i::before, .nav-toggle i::after {
    content: ""; position: absolute; left: 0; right: 0; height: 1.5px; background: currentColor;
    transition: transform .6s var(--ease), top .6s var(--ease);
  }
  .nav-toggle i::before { top: 0; }
  .nav-toggle i::after { top: 8.5px; }
  html.nav-open .nav-toggle i::before { top: 4.25px; transform: rotate(45deg); }
  html.nav-open .nav-toggle i::after { top: 4.25px; transform: rotate(-45deg); }
  html.js .nav {
    position: fixed; inset: 0; z-index: -2; background: var(--ink); padding: calc(var(--head-h) + 32px) var(--g) 40px;
    display: flex; flex-direction: column; justify-content: space-between;
    opacity: 0; visibility: hidden; transition: opacity .5s var(--ease-soft), visibility 0s linear .5s;
    overflow-y: auto;
  }
  html.nav-open .nav { opacity: 1; visibility: visible; transition: opacity .5s var(--ease-soft); }
  html.js .nav ul { flex-direction: column; gap: 4px; }
  html.js .nav a { font-family: var(--fd); font-size: clamp(2rem, 9vw, 2.6rem); letter-spacing: -0.02em; color: var(--paper); padding: 4px 0; }
  html.js .nav li { transform: translateY(14px); opacity: 0; transition: transform .7s var(--ease), opacity .5s var(--ease-soft); }
  html.nav-open .nav li { transform: none; opacity: 1; }
  html.nav-open .nav li:nth-child(2) { transition-delay: .04s; }
  html.nav-open .nav li:nth-child(3) { transition-delay: .08s; }
  html.nav-open .nav li:nth-child(4) { transition-delay: .12s; }
  html.nav-open .nav li:nth-child(5) { transition-delay: .16s; }
  html.nav-open .nav li:nth-child(6) { transition-delay: .20s; }
  .nav-foot { display: none; }
  html.js .nav-foot { display: block; font-size: var(--t-small); color: var(--mute); }
  html.nav-open { overflow: hidden; }
  html.nav-open .head-bg { opacity: 0 !important; }
}
@media (min-width: 761px) { .nav-foot { display: none; } }

/* 7. Footer ------------------------------------------------------------------ */
.site-foot { padding: clamp(72px, 9vw, 128px) 0 calc(28px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); overflow: hidden; }
.foot-word {
  font-family: var(--fd); font-weight: 600; font-size: clamp(4rem, 17.2vw, 20.6rem);
  line-height: 0.82; letter-spacing: -0.055em; white-space: nowrap; margin-left: -0.04em;
}
.foot-word .r { color: var(--red); }
.foot-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px clamp(24px, 4vw, 64px);
  margin-top: clamp(40px, 5vw, 72px); padding-top: 32px; border-top: 1px solid var(--line);
}
.foot-grid h2 { margin-bottom: 14px; }
.foot-grid li + li { margin-top: 8px; }
.foot-grid a { color: var(--paper-2); text-decoration: none; font-size: 15px; transition: color .4s var(--ease); }
.foot-grid a:focus-visible { color: var(--paper); text-decoration: underline; text-decoration-color: var(--red); text-underline-offset: 4px; }
.foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 32px; margin-top: clamp(40px, 5vw, 64px); font-size: var(--t-small); color: var(--mute); }
.foot-row a { color: var(--paper-2); text-underline-offset: 4px; }
.foot-legal { display: inline-flex; flex-wrap: wrap; gap: 6px 20px; }
@media (max-width: 860px) { .foot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .foot-grid { grid-template-columns: minmax(0, 1fr); } }

/* 8. Buttons + links --------------------------------------------------------- */
.btn {
  --b: var(--red);
  position: relative; display: inline-flex; align-items: center; gap: 14px; min-height: 56px; padding: 0 26px;
  background: var(--b); color: #fff; text-decoration: none; font-weight: 600; font-size: 16px; border-radius: 2px;
  border: 1px solid var(--b); cursor: pointer; transition: background-color .5s var(--ease), border-color .5s var(--ease);
}
.btn:focus-visible { outline-color: var(--paper); }
.btn--ghost { background: transparent; border-color: var(--line-2); color: var(--paper); }
.btn-t { position: relative; display: block; overflow: hidden; height: 1.4em; line-height: 1.4em; }
.btn-t > span { display: block; transition: transform .7s var(--ease); }
.btn-t > span::after { content: attr(data-t); position: absolute; left: 0; top: 100%; }
.btn:focus-visible .btn-t > span { transform: translateY(-100%); }
.btn svg { width: 16px; height: 16px; flex: none; transition: transform .7s var(--ease); }
.btn:focus-visible svg { transform: translate(3px, -3px); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 32px; }

.link {
  position: relative; display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
  font-weight: 500; color: var(--paper); padding: 6px 0;
}
.link::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--line-2); }
.link::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--red); z-index: 1;
  transform: scaleX(0); transform-origin: 100% 50%; transition: transform .7s var(--ease);
}
.link:focus-visible::before { transform: scaleX(1); transform-origin: 0 50%; }
.link svg { width: 13px; height: 13px; flex: none; transition: transform .7s var(--ease); }
.link:focus-visible svg { transform: translateX(3px); }
.link[target="_blank"]:focus-visible svg { transform: translate(2px, -2px); }

/* 9. Eyebrow + katakana -------------------------------------------------------- */
.eyebrow {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; font-size: var(--t-label);
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--mute); font-weight: 500;
}
.kj { font-family: var(--fj); letter-spacing: 0.08em; text-transform: none; color: var(--red); font-size: 14px; }

/* 10. Copy-to-clipboard -------------------------------------------------------- */
.mail { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.mail-addr {
  font-family: var(--fd); font-size: clamp(1.5rem, 2.6vw, 2.6rem); letter-spacing: -0.025em; line-height: 1.15;
  user-select: all; -webkit-user-select: all; overflow-wrap: anywhere;
}
.mail-addr--sm { font-size: clamp(1.25rem, 1.6vw, 1.5rem); }
.copy {
  font-size: 14px; font-weight: 600; color: var(--paper); background: transparent; border: 1px solid var(--line-2);
  height: 40px; padding: 0 16px; border-radius: 2px; cursor: pointer; white-space: nowrap;
  transition: border-color .5s var(--ease), background-color .5s var(--ease), color .5s var(--ease);
}
.copy[data-done] { background: var(--red); border-color: var(--red); color: #fff; }

/* Hover states only where a real pointer can hover, so they never stick after a tap. */
@media (hover: hover) {
  .brand:hover img { transform: rotate(-12deg); }
  .nav a:hover { color: var(--paper); }
  .nav a:hover::after { transform: scaleX(1); transform-origin: 0 50%; }
  .foot-grid a:hover { color: var(--paper); text-decoration: underline; text-decoration-color: var(--red); text-underline-offset: 4px; }
  .foot-row a:hover { color: var(--paper); text-decoration-color: var(--red); }
  .btn:hover { --b: var(--red-hover); }
  .btn--ghost:hover { --b: var(--red); background: transparent; border-color: var(--red); }
  .btn:hover .btn-t > span { transform: translateY(-100%); }
  .btn:hover svg { transform: translate(3px, -3px); }
  .link:hover::before { transform: scaleX(1); transform-origin: 0 50%; }
  .link:hover svg { transform: translateX(3px); }
  .link[target="_blank"]:hover svg { transform: translate(2px, -2px); }
  .copy:hover { border-color: var(--red); }
}

/* 11. Stats + spec list --------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.stat { display: flex; flex-direction: column; }
.stat dt { order: 2; font-size: var(--t-small); color: var(--mute); line-height: 1.4; margin-top: 6px; text-wrap: balance; }
.stat dd { order: 1; font-family: var(--fd); font-size: var(--t-num); line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat dd.is-word { font-size: clamp(1.6rem, 2.2vw, 2.2rem); line-height: 1.1; padding-top: 0.28em; }

.spec { border-top: 1px solid var(--line); }
.spec > div { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.spec dt { font-size: var(--t-label); letter-spacing: 0.14em; text-transform: uppercase; color: var(--mute); font-weight: 500; }
.spec dd { color: var(--paper); }
.spec--inline { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px 32px; border-top: 0; }
.spec--inline > div { display: block; padding: 0; border: 0; }
.spec--inline dd { font-family: var(--fd); font-size: clamp(1.3rem, 1.8vw, 1.7rem); letter-spacing: -0.015em; margin-top: 6px; }

.tags { font-size: var(--t-small); color: var(--mute); }

/* 12. Media frames ------------------------------------------------------------- */
.frame { position: relative; overflow: hidden; background: var(--ink-2); }
.frame--wide { aspect-ratio: 16 / 9; }
.frame > picture, .frame > img, .frame .px, .frame .px > picture { position: absolute; inset: 0; width: 100%; height: 100%; }
.frame img { width: 100%; height: 100%; object-fit: cover; }
.frame--pixel img { image-rendering: pixelated; }

/* 13. Ink canvas, tone stage, progress thread --------------------------------------- */
.ink-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.stage { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.stage i { position: absolute; inset: 0; opacity: 0; transition: opacity 1.2s var(--ease-soft); }
.stage i.is-on { opacity: 1; }
.thread { position: fixed; right: 0; top: 0; bottom: 0; width: 2px; z-index: 60; pointer-events: none; display: none; }
.thread i { position: absolute; inset: 0; background: var(--red); transform-origin: 50% 0; transform: scaleY(0); }
/* The progress thread is retired (owner: it stood out); the markup stays inert. */

/* 14. Reveal states -------------------------------------------------------------- */
/* line-split wrappers created by GW.split() */
.sl { display: block; overflow: hidden; padding-bottom: 0.1em; margin-bottom: -0.1em; }
.sli { display: inline-block; will-change: transform; }
/* Hidden only while motion is active; site.js reveals them, and the boot failsafe
   removes html.fx / html.fx-rm if scripts never take over. */
.fx [data-split], .fx [data-fade], .fx [data-wipe],
.fx-rm [data-split], .fx-rm [data-fade], .fx-rm [data-wipe] { opacity: 0; }
.fx [data-stroke] { transform: scaleX(0); transform-origin: 0 50%; }

/* 15. Reduced motion ------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn-t > span, .btn svg, .link::before, .link svg, .nav a::after, .brand img, .nav li { transition: none !important; }
}
