/* ============================================================
   apparatus.css, Direction D · "Apparatus"
   A standalone Swiss-technical / instrument-datasheet system.
   NO Cadayn tokens, NO base.css, fully self-contained.
   Type:  Space Grotesk (display) · Spline Sans (body) · IBM Plex Mono (labels)
   Color: warm paper · near-black ink · forest green + warm clay (calmer, organic)
   Shares only the brand-agnostic animation engine (reads --anim-*).
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Spline+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --paper:     #F1F0EA;
  --paper-2:   #E8E7DF;
  --surface:   #FBFBF7;
  --ink:       #17150F;
  --ink-2:     #54524A;
  --ink-3:     #8A887E;
  --line:      rgba(23,21,15,.14);
  --line-2:    rgba(23,21,15,.32);
  --blue:      #2F6B47;
  --red:       #B85C38;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body:    'Spline Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, monospace;

  /* animation palette (engine reads these) */
  --anim-paper: #FBFBF7; --anim-hero-bg: #F1F0EA; --anim-fade: rgba(241,240,234,0.06);
  --anim-hero-ink: rgba(23,21,15,0.07); --anim-hero-accent: rgba(47,107,71,0.18);
  --anim-ink: #17150F; --anim-line: rgba(23,21,15,0.16); --anim-line-soft: rgba(23,21,15,0.08);
  --anim-line-strong: rgba(23,21,15,0.42); --anim-muted: #8A887E;
  --anim-coral: #2F6B47; --anim-pink: #B85C38; --anim-plum: #2F6B47; --anim-rose: #B85C38;
  --anim-err: rgba(184,92,56,0.55);

  --ease: cubic-bezier(.2,.7,.2,1);
  --t: 200ms;
  --gutter: clamp(18px, 4vw, 56px);
  --maxw: 1280px;
}

:root[data-theme="dark"] {
  --paper:   #0E0E11;
  --paper-2: #16161B;
  --surface: #16161B;
  --ink:     #F2F1EA;
  --ink-2:   #ACAAA2;
  --ink-3:   #6E6C66;
  --line:    rgba(242,241,234,.14);
  --line-2:  rgba(242,241,234,.30);
  --blue:    #7FB58C;
  --red:     #E0916A;

  --anim-paper: #16161B; --anim-hero-bg: #0E0E11; --anim-fade: rgba(14,14,17,0.07);
  --anim-hero-ink: rgba(242,241,234,0.07); --anim-hero-accent: rgba(127,181,140,0.22);
  --anim-ink: #F2F1EA; --anim-line: rgba(242,241,234,0.18); --anim-line-soft: rgba(242,241,234,0.09);
  --anim-line-strong: rgba(242,241,234,0.42); --anim-muted: #6E6C66;
  --anim-coral: #7FB58C; --anim-pink: #E0916A; --anim-plum: #7FB58C; --anim-rose: #E0916A;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: clip;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--blue); color: #fff; }

.mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- cursor ---------- */
.cursor, .cursor-ring { position: fixed; top: 0; left: 0; pointer-events: none; z-index: 9999; }
.cursor { width: 6px; height: 6px; background: var(--red); transform: translate(-50%,-50%); }
.cursor-ring { width: 30px; height: 30px; border: 1px solid var(--line-2); transform: translate(-50%,-50%); transition: width .22s var(--ease), height .22s var(--ease), border-color .22s var(--ease); }
.cursor-ring.is-hover { width: 52px; height: 52px; border-color: var(--blue); }
@media (hover: none), (pointer: coarse) { .cursor, .cursor-ring { display: none; } }

/* ---------- scroll progress ---------- */
.scroll-progress { position: fixed; top: 0; left: 0; height: 2px; width: 0%; background: var(--blue); z-index: 9000; transition: width .1s linear; }

/* ---------- theme toggle ---------- */
.theme-toggle { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line-2); background: transparent; color: var(--ink-2); cursor: pointer; transition: color var(--t), border-color var(--t); }
.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }
.theme-toggle svg { width: 15px; height: 15px; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* ---------- nav ---------- */
.ap-nav { position: fixed; inset: 0 0 auto 0; z-index: 800; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--gutter); padding: 14px var(--gutter); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.ap-nav__id { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); display: flex; align-items: center; gap: .7ch; }
.ap-nav__id b { width: 8px; height: 8px; background: var(--blue); display: inline-block; }
.ap-nav__links { display: flex; gap: var(--gutter); justify-self: center; }
.ap-nav__links a { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); transition: color var(--t); }
.ap-nav__links a:hover { color: var(--ink); }
.ap-nav__end { justify-self: end; display: flex; align-items: center; gap: 14px; }
.ap-nav__end .mono { color: var(--ink-2); }
@media (max-width: 760px) { .ap-nav { grid-template-columns: 1fr auto; } .ap-nav__links { display: none; } }

/* ---------- hero ---------- */
.ap-hero { position: relative; min-height: 100svh; display: flex; align-items: flex-end; padding: 0 var(--gutter) clamp(40px,7vh,80px); overflow: hidden; }
.ap-hero__canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.ap-hero__frame { position: absolute; inset: clamp(70px,9vh,108px) var(--gutter) clamp(40px,7vh,80px); border: 1px solid var(--line); pointer-events: none; z-index: 1; }
.ap-hero__frame::before, .ap-hero__frame::after { content: ""; position: absolute; width: 9px; height: 9px; border: 1px solid var(--blue); }
.ap-hero__frame::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.ap-hero__frame::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.ap-hero__corner { position: absolute; width: 9px; height: 9px; border: 1px solid var(--blue); z-index: 2; }
.ap-hero__corner.tr { top: calc(clamp(70px,9vh,108px) - 1px); right: calc(var(--gutter) - 1px); border-left: 0; border-bottom: 0; }
.ap-hero__corner.bl { bottom: calc(clamp(40px,7vh,80px) - 1px); left: calc(var(--gutter) - 1px); border-right: 0; border-top: 0; }

.ap-hero__tags { position: absolute; top: clamp(82px,10vh,124px); left: 0; right: 0; display: flex; justify-content: space-between; padding: 0 calc(var(--gutter) + 18px); z-index: 2; }
.ap-hero__tags span { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.ap-hero__inner { position: relative; z-index: 2; width: 100%; padding: 0 18px; }
.ap-hero h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(54px, 13vw, 188px); line-height: .86; letter-spacing: -0.03em; margin: 0; color: var(--ink); }
.ap-hero h1 .dot { color: var(--blue); }
.ap-hero__row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--gutter); margin-top: clamp(20px,3vh,36px); }
.ap-hero__tag { max-width: 44ch; font-size: clamp(15px,1.5vw,19px); color: var(--ink-2); line-height: 1.5; }
.ap-hero__tag b { color: var(--ink); font-weight: 600; }
.ap-hero__meta { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.ap-hero__meta a { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); transition: color var(--t); }
.ap-hero__meta a:hover { color: var(--blue); }

/* ---------- index table (contents) ---------- */
.ap-index { padding: clamp(64px,10vh,120px) 0 clamp(32px,5vh,64px); }
.ap-index__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--ink); padding-bottom: 10px; }
.ap-index__head h2 { font-family: var(--font-display); font-weight: 500; font-size: clamp(13px,1.4vw,15px); letter-spacing: .14em; text-transform: uppercase; margin: 0; white-space: nowrap; }
.ap-index__head span { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); letter-spacing: .08em; white-space: nowrap; }
.ap-row {
  display: grid; grid-template-columns: 46px 1fr 200px 96px; gap: var(--gutter); align-items: center;
  padding: 16px 8px; border-bottom: 1px solid var(--line); color: var(--ink); transition: background var(--t), padding var(--t);
}
.ap-row:hover { background: var(--surface); padding-left: 16px; }
.ap-row .n { font-family: var(--font-mono); font-size: 12px; color: var(--blue); }
.ap-row .ti { font-family: var(--font-display); font-weight: 500; font-size: clamp(16px,1.8vw,21px); letter-spacing: -0.01em; }
.ap-row .dm { font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.ap-row .go { justify-self: end; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); display: inline-flex; gap: .5ch; align-items: center; transition: color var(--t); }
.ap-row:hover .go { color: var(--blue); }
.ap-row .go svg { width: 13px; height: 13px; }
@media (max-width: 760px) { .ap-row { grid-template-columns: 34px 1fr 30px; } .ap-row .dm { display: none; } .ap-row .go span { display: none; } }

/* ---------- entries (datasheet) ---------- */
.ap-work { padding-bottom: clamp(40px,6vh,80px); }
.ap-entry { padding: clamp(56px,9vh,110px) 0; border-bottom: 1px solid var(--line); }
.ap-entry__grid { display: grid; grid-template-columns: 1fr 1.05fr; gap: clamp(28px,5vw,76px); align-items: start; }
.ap-entry__num { font-family: var(--font-mono); font-size: 12px; color: var(--blue); letter-spacing: .1em; }
.ap-entry h3 { font-family: var(--font-display); font-weight: 700; font-size: clamp(26px,3.6vw,46px); line-height: 1.0; letter-spacing: -0.025em; margin: 14px 0 20px; color: var(--ink); overflow-wrap: anywhere; }
.ap-entry h3 em { font-style: normal; color: var(--blue); }
.ap-entry__lede { color: var(--ink-2); max-width: 50ch; margin: 0 0 26px; line-height: 1.6; }
.ap-spec { border-top: 1px solid var(--line); }
.ap-spec div { display: grid; grid-template-columns: 116px 1fr; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.ap-spec dt, .ap-spec .k { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.ap-spec .v { color: var(--ink); }
.ap-link { display: inline-flex; align-items: center; gap: .6ch; margin-top: 24px; font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink); border-bottom: 1px solid var(--blue); padding-bottom: 3px; transition: gap var(--t); }
.ap-link:hover { gap: 1.1ch; color: var(--blue); }
.ap-link svg { width: 14px; height: 14px; }

.ap-frame { position: relative; aspect-ratio: 4/3; width: 100%; background: var(--surface); border: 1px solid var(--line-2); overflow: hidden; }
.ap-frame canvas { display: block; width: 100%; height: 100%; }
.ap-frame__ax { position: absolute; font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; color: var(--ink-3); }
.ap-frame__ax.tl { top: 9px; left: 11px; }
.ap-frame__ax.br { bottom: 9px; right: 11px; color: var(--blue); }
.ap-frame__tick { position: absolute; background: var(--line-2); }
.ap-frame__tick.x { left: 0; right: 0; height: 1px; top: 50%; opacity: .5; }
.ap-frame__tick.y { top: 0; bottom: 0; width: 1px; left: 50%; opacity: .5; }

@media (max-width: 820px) { .ap-entry__grid { grid-template-columns: 1fr; gap: 28px; } .ap-entry__media { order: -1; } }

/* ---------- appendix ---------- */
.ap-appendix { padding: clamp(56px,9vh,110px) 0; }
.ap-appendix__head { font-family: var(--font-display); font-weight: 500; font-size: clamp(13px,1.4vw,15px); letter-spacing: .14em; text-transform: uppercase; border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin: 0 0 4px; }
.ap-notes { display: grid; grid-template-columns: repeat(3,1fr); }
.ap-note { padding: 28px 26px 28px 0; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.ap-note:last-child { border-right: 0; }
.ap-note .k { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--red); }
.ap-note h4 { font-family: var(--font-display); font-weight: 500; font-size: 19px; letter-spacing: -0.01em; margin: 12px 0 8px; line-height: 1.15; color: var(--ink); }
.ap-note h4 em { font-style: normal; color: var(--blue); }
.ap-note p { color: var(--ink-2); font-size: 13px; line-height: 1.55; margin: 0; }
@media (max-width: 820px) { .ap-notes { grid-template-columns: 1fr; } .ap-note { padding-right: 0; border-right: 0; } }

/* ---------- contact ---------- */
.ap-contact { padding: clamp(80px,14vh,170px) 0; }
.ap-contact h2 { font-family: var(--font-display); font-weight: 700; font-size: clamp(40px,8vw,110px); line-height: .92; letter-spacing: -0.03em; margin: 0 0 clamp(28px,5vh,52px); color: var(--ink); }
.ap-contact h2 em { font-style: normal; color: var(--blue); }
.ap-contact__row { display: flex; flex-wrap: wrap; gap: 16px 22px; align-items: center; }
.ap-btn { display: inline-flex; align-items: center; gap: .8ch; padding: 16px 26px; background: var(--blue); color: #fff; font-family: var(--font-mono); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; transition: transform var(--t) var(--ease), background var(--t); will-change: transform; }
.ap-btn:hover { background: var(--ink); }
.ap-btn:active { transform: scale(.98); }
.ap-btn svg { width: 17px; height: 17px; }
.ap-copy { display: inline-flex; align-items: center; gap: .7ch; padding: 15px 20px; border: 1px solid var(--line-2); background: transparent; color: var(--ink-2); font-family: var(--font-mono); font-size: 13px; cursor: pointer; transition: border-color var(--t), color var(--t); }
.ap-copy:hover { border-color: var(--ink); color: var(--ink); }
.ap-copy.copied { color: var(--blue); border-color: var(--blue); }
.ap-copy svg { width: 15px; height: 15px; }
.ap-socials { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--line); }
.ap-socials a { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); display: inline-flex; gap: .5ch; align-items: center; transition: color var(--t); }
.ap-socials a:hover { color: var(--blue); }
.ap-socials svg { width: 12px; height: 12px; }

footer.ap-foot { padding: 22px 0 40px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
footer.ap-foot span { font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; color: var(--ink-3); }

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: .07s; } .reveal.d2 { transition-delay: .14s; } .reveal.d3 { transition-delay: .21s; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } * { scroll-behavior: auto !important; } }
