/* =====================================================================
   SITE BASE — tokens, type, header, footer shared by index.html and
   machines.html. Page-specific scenes live in stages.css / machines.css.
   ===================================================================== */
:root{
  --bg:#14110d;
  --bg-raised:#1c1812;
  --bg-deep:#0c0a07;
  --hairline:rgba(242,236,227,.1);
  --hairline-strong:rgba(242,236,227,.2);
  --ink:#f2ece3;
  --ink-muted:#b9ad9b;
  --ink-faint:#877b6c;
  --accent:#ab4637;
  --accent-soft:#d9806f;
  --accent-hover:#c2543f;
  --cream:#efe7da;
  --cream-ink:#1b1712;

  --f-latin:'Texturina', 'Song Myung', serif;   /* display words in English (blackletter-ish) */
  --f-kr:'Song Myung', 'Noto Serif KR', serif;    /* Korean headlines */
  --f-body:'IBM Plex Sans KR', system-ui, sans-serif;
  --f-mono:'IBM Plex Mono', ui-monospace, monospace;

  --t-body:clamp(1.02rem, .96rem + .3vw, 1.2rem);
  --t-lead:clamp(1.1rem, 1rem + .5vw, 1.36rem);

  --ease:cubic-bezier(.16,1,.3,1);
  --container:1320px;
  --gutter:clamp(20px, 4vw, 48px);
  --header-h:72px;
}

*{ box-sizing:border-box; margin:0; padding:0; }
html{ scroll-behavior:smooth; -webkit-text-size-adjust:100%; }
@media (prefers-reduced-motion: reduce){ html{ scroll-behavior:auto; } }
body{
  background:var(--bg); color:var(--ink);
  font-family:var(--f-body); font-size:16px; line-height:1.65;
  -webkit-font-smoothing:antialiased; overflow-x:hidden;
}
img{ display:block; max-width:100%; }
a{ color:inherit; text-decoration:none; }
button{ font:inherit; cursor:pointer; }
h1,h2,h3,p{ word-break:keep-all; overflow-wrap:break-word; }
:focus-visible{ outline:2px solid var(--accent-soft); outline-offset:3px; }

.wrap{ width:100%; max-width:var(--container); margin:0 auto; padding-inline:var(--gutter); }
.sr-only{ position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

/* ---------- type roles ---------- */
.latin{ font-family:var(--f-latin); font-weight:800; letter-spacing:-.01em; line-height:.98; }
.kr-title{ font-family:var(--f-kr); font-weight:400; letter-spacing:-.01em; line-height:1.28; }
.label{
  font-family:var(--f-mono); font-size:12px; font-weight:500;
  letter-spacing:.16em; text-transform:uppercase; color:var(--accent-soft);
}

/* ---------- buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:10px;
  white-space:nowrap; padding:14px 26px; border-radius:2px;
  font-family:var(--f-body); font-weight:600; font-size:15px;
  border:1px solid transparent;
  transition:transform .35s var(--ease), background-color .35s var(--ease), border-color .35s var(--ease), color .35s var(--ease);
}
.btn:active{ transform:scale(.97); }
.btn-primary{ background:var(--accent); color:var(--ink); }
.btn-primary:hover{ background:var(--accent-hover); transform:translateY(-2px); }
.btn-line{ border-color:rgba(242,236,227,.55); color:var(--ink); }
.btn-line:hover{ border-color:var(--ink); background:rgba(242,236,227,.08); transform:translateY(-2px); }
.btn-arrow::after{ content:"→"; font-family:var(--f-mono); transition:transform .35s var(--ease); }
.btn-arrow:hover::after{ transform:translateX(4px); }
.text-link{
  font-family:var(--f-mono); font-size:12px; font-weight:500; letter-spacing:.16em; text-transform:uppercase;
  display:inline-flex; gap:10px; align-items:center; padding:8px 0;
  border-bottom:1px solid rgba(242,236,227,.35); transition:border-color .3s var(--ease), color .3s var(--ease);
}
.text-link:hover{ color:var(--accent-soft); border-color:var(--accent-soft); }

/* ---------- header ---------- */
.site-header{
  position:fixed; inset:0 0 auto 0; z-index:100; height:var(--header-h);
  display:flex; align-items:center; border-bottom:1px solid transparent;
  transition:background-color .4s var(--ease), border-color .4s var(--ease);
}
.site-header.scrolled{
  background:rgba(20,17,13,.86);
  -webkit-backdrop-filter:blur(14px) saturate(140%); backdrop-filter:blur(14px) saturate(140%);
  border-bottom-color:var(--hairline);
}
/* over paper-coloured scenes (home: set by stages.js) the header turns to paper with dark ink */
.site-header.on-light{
  --ink:#1d1813; --ink-muted:#5b5147; --hairline:rgba(29,24,19,.12); --hairline-strong:rgba(29,24,19,.24);
  background:rgba(236,228,214,.9); border-bottom-color:var(--hairline); color:var(--ink);
}
.site-header.on-light .brand-mark{ filter:invert(1) brightness(.35) sepia(.3); }
.site-header.on-light .btn-line{ border-color:rgba(29,24,19,.45); color:var(--ink); }
.site-header.on-light .btn-line:hover{ background:rgba(29,24,19,.06); border-color:var(--ink); }
.site-header, .site-header .brand-mark, .site-header .nav-links a{ transition:background-color .4s var(--ease), border-color .4s var(--ease), color .4s var(--ease), filter .4s var(--ease); }
.nav-inner{ display:flex; align-items:center; justify-content:space-between; gap:24px; }
.brand-mark{ height:50px; width:auto; }
.nav-links{ display:flex; gap:36px; font-size:14.5px; color:var(--ink-muted); }
.nav-links a{ position:relative; padding:6px 0; transition:color .25s var(--ease); }
.nav-links a::after{
  content:""; position:absolute; left:0; right:0; bottom:0; height:1px; background:var(--accent-soft);
  transform:scaleX(0); transform-origin:0 50%; transition:transform .35s var(--ease);
}
.nav-links a:hover, .nav-links a[aria-current="page"]{ color:var(--ink); }
.nav-links a:hover::after, .nav-links a[aria-current="page"]::after{ transform:scaleX(1); }
.nav-actions .btn{ padding:10px 20px; font-size:14px; }
.nav-toggle{
  display:none; width:42px; height:42px; border:1px solid var(--hairline-strong); border-radius:2px;
  background:transparent; flex-direction:column; align-items:center; justify-content:center; gap:5px;
}
.nav-toggle span{ display:block; width:18px; height:1.5px; background:var(--ink); transition:transform .3s var(--ease), opacity .3s var(--ease); }
.nav-toggle[aria-expanded="true"] span:nth-child(1){ transform:translateY(6.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2){ opacity:0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3){ transform:translateY(-6.5px) rotate(-45deg); }
.mobile-panel{
  position:fixed; inset:var(--header-h) 0 0 0; z-index:99;
  background:rgba(18,15,11,.98); display:flex; flex-direction:column; gap:2px; padding:28px var(--gutter);
  opacity:0; transform:translateY(-8px); pointer-events:none; visibility:hidden;
  transition:opacity .3s var(--ease), transform .3s var(--ease), visibility 0s linear .3s;
}
.mobile-panel.open{ opacity:1; transform:none; pointer-events:auto; visibility:visible; transition-delay:0s; }
.mobile-panel a{ padding:16px 2px; border-bottom:1px solid var(--hairline); font-size:19px; }
.mobile-panel .btn{ margin-top:22px; border-bottom:0; }
@media (max-width:860px){
  .nav-links, .nav-actions{ display:none; }
  .nav-toggle{ display:flex; }
  .brand-mark{ height:44px; }
}

/* ---------- one-shot reveal (IntersectionObserver adds .in) ---------- */
[data-reveal]{ opacity:0; transform:translateY(26px); transition:opacity .9s var(--ease), transform .9s var(--ease); }
[data-reveal].in{ opacity:1; transform:none; }
[data-reveal="2"]{ transition-delay:.12s; }
[data-reveal="3"]{ transition-delay:.24s; }
[data-reveal="4"]{ transition-delay:.36s; }

/* ---------- footer ---------- */
.site-footer{ background:var(--bg-deep); border-top:1px solid var(--hairline); padding:64px 0 36px; }
.footer-top{ display:flex; justify-content:space-between; gap:48px; flex-wrap:wrap; padding-bottom:40px; border-bottom:1px solid var(--hairline); }
.footer-logo{ height:88px; width:auto; margin-bottom:16px; }
.footer-brand p{ color:var(--ink-muted); max-width:34ch; font-size:.94rem; }
.footer-cols{ display:flex; gap:64px; flex-wrap:wrap; }
.footer-col h4{ font-family:var(--f-mono); font-size:12px; font-weight:500; letter-spacing:.14em; color:var(--ink-faint); margin-bottom:16px; }
.footer-col a, .footer-col p{ display:block; color:var(--ink-muted); font-size:.94rem; margin-bottom:9px; transition:color .25s var(--ease); }
.footer-col a:hover{ color:var(--accent-soft); }
.footer-biz{ display:flex; flex-wrap:wrap; gap:6px 18px; padding:26px 0 18px; color:var(--ink-faint); font-size:.84rem; }
.footer-biz span{ white-space:nowrap; }
.footer-bottom{ display:flex; justify-content:space-between; gap:16px; flex-wrap:wrap; color:var(--ink-faint); font-family:var(--f-mono); font-size:.78rem; letter-spacing:.06em; }

.grain{
  position:fixed; inset:0; z-index:200; pointer-events:none; opacity:.04; mix-blend-mode:overlay;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-reduced-motion: reduce){
  [data-reveal]{ opacity:1; transform:none; transition:none; }
  .btn, .nav-links a::after{ transition:none; }
}
