/* =========================================================
   The Machine Before the Machine — shared system
   Themes only redefine tokens + a few signature treatments.
   ========================================================= */

/* No italic type anywhere on the site. */
*, *::before, *::after { font-style: normal !important; font-synthesis: none; }
em, i, cite, dfn, var { font-weight: 700; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 90px; }
body { margin: 0; }
img, svg, canvas, video { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p, figure, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; }

:root {
  /* fallback tokens (workbench values) */
  --bg: #e9dfcb; --bg-2: #ded2b9; --paper: #f6efe1; --paper-2: #efe5d1;
  --ink: #1f1b16; --ink-2: #4f463c; --ink-3: #6e6457;
  --accent: #a3271f; --accent-ink: #fff8ee; --accent-text: #9b241c;
  --line: rgba(31, 27, 22, .2); --line-strong: rgba(31, 27, 22, .55);
  --focus: #0b5cad;
  --font-display: 'Fraunces', 'Source Serif 4', Georgia, serif;
  --font-body: 'Source Serif 4', Georgia, serif;
  --font-label: 'Courier Prime', ui-monospace, monospace;
  --font-hand: 'Courier Prime', 'Courier Prime', monospace;
  --radius: 2px;
  --shadow: 0 1px 1px rgba(40, 28, 12, .12), 0 8px 22px -10px rgba(40, 28, 12, .45);
  --shadow-lift: 0 2px 2px rgba(40, 28, 12, .12), 0 22px 40px -16px rgba(40, 28, 12, .55);
  --wrap: 1240px;
  --gutter: clamp(16px, 4vw, 48px);
  --ease: cubic-bezier(.2, .7, .1, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color .4s var(--ease);
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; outline: none; overflow-x: clip; }

.wrap { width: min(100% - 2 * var(--gutter), var(--wrap)); margin-inline: auto; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.skip { position: absolute; left: 12px; top: -60px; z-index: 1000; background: var(--ink); color: var(--bg); padding: 10px 16px; text-decoration: none; font-family: var(--font-label); }
.skip:focus { top: 12px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }

/* ---------- type primitives ---------- */
.eyebrow {
  font-family: var(--font-label);
  font-size: .78rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent-text);
  font-weight: 600;
}
.display { font-family: var(--font-display); line-height: .98; letter-spacing: -.01em; font-weight: 400; }
.lede { font-size: clamp(1.1rem, 1.5vw, 1.3rem); line-height: 1.55; color: var(--ink-2); max-width: 60ch; }
.prose p + p { margin-top: .9em; }
.prose { max-width: 66ch; }
.muted { color: var(--ink-2); }
.small { font-size: .9rem; }
.mono { font-family: var(--font-label); }
kbd { font-family: var(--font-label); font-size: .82em; border: 1px solid var(--line-strong); border-bottom-width: 2px; padding: 0 .35em; border-radius: 3px; background: var(--paper); }

/* ---------- buttons ---------- */
.btn {
  --b-bg: transparent; --b-fg: var(--ink); --b-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: .6em;
  min-height: 46px; padding: .6em 1.15em;
  border: 1.5px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg);
  font-family: var(--font-label); font-size: .86rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  text-decoration: none; border-radius: var(--radius);
  transition: transform .18s var(--ease), background-color .2s, color .2s, box-shadow .2s, border-color .2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled='true'] { opacity: .45; cursor: not-allowed; transform: none; }
.btn--primary { --b-bg: var(--accent); --b-fg: var(--accent-ink); --b-bd: var(--accent); }
.btn--primary:hover { box-shadow: 0 10px 22px -12px var(--accent); }
.btn--ink { --b-bg: var(--ink); --b-fg: var(--bg); --b-bd: var(--ink); }
.btn--quiet { --b-bd: var(--line); min-height: 40px; font-size: .78rem; }
.btn--sm { min-height: 36px; padding: .35em .8em; font-size: .74rem; }
.btn--icon { min-width: 40px; min-height: 40px; padding: 0; }
.btn .arrow { transition: transform .25s var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }

.chip {
  display: inline-flex; align-items: center; gap: .4em;
  font-family: var(--font-label); font-size: .74rem; letter-spacing: .06em; text-transform: uppercase;
  padding: .25em .6em; border: 1px solid var(--line-strong); border-radius: 999px;
}
.chip--gen { border-color: var(--accent); color: var(--accent-text); }

/* ---------- form fields ---------- */
.field { display: grid; gap: .4rem; }
.field + .field { margin-top: 1rem; }
.field__label { font-weight: 700; font-size: .98rem; }
textarea, input[type='text'], select {
  width: 100%; padding: .75rem .85rem; background: var(--paper); color: var(--ink);
  border: 1.5px solid var(--line-strong); border-radius: var(--radius);
  font-size: 1rem; line-height: 1.5; resize: vertical;
}
textarea::placeholder, input::placeholder { color: var(--ink-3); opacity: 1; }
input[type='range'] { width: 100%; accent-color: var(--accent); min-height: 28px; }
input[type='checkbox'], input[type='radio'] { accent-color: var(--accent); width: 1.15em; height: 1.15em; }

/* ---------- masthead ---------- */
.masthead { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.masthead__inner { width: min(100% - 2 * var(--gutter), 1440px); margin-inline: auto; display: flex; align-items: center; gap: 1.5rem; min-height: 68px; }
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; flex-shrink: 0; }
.brand__mark { color: var(--accent); display: grid; place-items: center; transition: transform .5s var(--ease-out); }
.brand:hover .brand__mark { transform: rotate(-18deg) scale(1.06); }
.brand__name { font-family: var(--font-display); font-size: 1.02rem; line-height: 1.02; letter-spacing: .01em; text-transform: uppercase; font-weight: 700; }
.primary { display: flex; align-items: center; gap: 1.2rem; margin-left: auto; }
.primary__exps { display: flex; gap: .15rem; }
.primary__exps a, .primary__util > a {
  display: inline-flex; align-items: baseline; gap: .35em; padding: .5em .6em; text-decoration: none;
  font-family: var(--font-label); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; position: relative; border-radius: var(--radius);
}
.primary__n { color: var(--accent-text); font-weight: 600; }
.primary__done { font-size: .5rem; color: var(--accent-text); transform: translateY(-.4em); }
.primary a[aria-current='page'] { background: var(--ink); color: var(--bg); }
.primary a[aria-current='page'] .primary__n, .primary a[aria-current='page'] .primary__done { color: inherit; }
.primary__exps a:hover, .primary__util > a:hover { background: color-mix(in srgb, var(--ink) 9%, transparent); }
.primary__util { display: flex; align-items: center; gap: .3rem; padding-left: 1rem; border-left: 1px solid var(--line); }

.theme-switch { display: flex; gap: 4px; margin-left: .6rem; padding: 4px; border: 1px solid var(--line); border-radius: 999px; }
.theme-switch__btn { display: flex; align-items: center; gap: .4em; border: 0; background: transparent; padding: .3em .55em .3em .35em; border-radius: 999px; font-family: var(--font-label); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; min-height: 32px; }
.theme-switch__chip { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.35); flex-shrink: 0; }
.theme-switch__btn--workbench .theme-switch__chip { background: radial-gradient(circle at 35% 35%, #f6efe1 0 45%, #a3271f 46% 60%, #c9b896 61%); }
.theme-switch__btn--expressionist .theme-switch__chip { background: linear-gradient(135deg, #141210 0 50%, #e0261b 50% 75%, #f0e8d8 75%); }
.theme-switch__btn--cinema .theme-switch__chip { background: radial-gradient(circle at 50% 40%, #efe6d2 0 22%, #0d0b0a 23% 60%, #7d1219 61%); }
.theme-switch__btn[aria-pressed='true'] { background: var(--ink); color: var(--bg); }
.theme-switch__label { display: none; }
.theme-switch__btn[aria-pressed='true'] .theme-switch__label { display: inline; }

.menu-btn { display: none; margin-left: auto; align-items: center; gap: .55em; border: 1.5px solid var(--line-strong); background: transparent; padding: .5em .8em; min-height: 44px; font-family: var(--font-label); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; border-radius: var(--radius); }
.menu-btn__bars, .menu-btn__bars::before, .menu-btn__bars::after { display: block; width: 18px; height: 2px; background: currentColor; position: relative; transition: transform .25s var(--ease); }
.menu-btn__bars::before, .menu-btn__bars::after { content: ''; position: absolute; left: 0; }
.menu-btn__bars::before { top: -6px; } .menu-btn__bars::after { top: 6px; }
.menu-btn[aria-expanded='true'] .menu-btn__bars { background: transparent; }
.menu-btn[aria-expanded='true'] .menu-btn__bars::before { transform: translateY(6px) rotate(45deg); }
.menu-btn[aria-expanded='true'] .menu-btn__bars::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 1240px) {
  .menu-btn { display: inline-flex; }
  .primary { position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch; gap: 0; background: var(--bg); border-bottom: 1px solid var(--line); padding: .5rem var(--gutter) 1rem; display: none; max-height: calc(100vh - 68px); overflow: auto; }
  .primary.is-open { display: flex; }
  .primary__exps { flex-direction: column; }
  .primary__exps a { width: 100%; padding: .8em .4em; font-size: .95rem; border-bottom: 1px solid var(--line); }
  .primary__util { border-left: 0; padding: .8rem 0 0; flex-wrap: wrap; gap: .5rem; }
  .theme-switch { margin-left: 0; }
  .theme-switch__label { display: inline; }
}

/* ---------- colophon ---------- */
.colophon { border-top: 1px solid var(--line); margin-top: 4rem; }
.colophon__inner { width: min(100% - 2 * var(--gutter), var(--wrap)); margin-inline: auto; padding: 3rem 0 3.5rem; display: grid; grid-template-columns: 1.2fr 1.4fr auto; gap: 2.5rem; align-items: start; }
.colophon__thesis { font-family: var(--font-display); font-size: 1.35rem; line-height: 1.25; }
.colophon__meta { display: grid; gap: .7rem; font-size: .95rem; color: var(--ink-2); }
.colophon__meta strong { color: var(--ink); }
.colophon__tools { display: grid; gap: .5rem; }
.ai-label__tag { display: inline-block; font-family: var(--font-label); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; border: 1px solid currentColor; padding: .05em .45em; margin-right: .35em; color: var(--accent-text); }
@media (max-width: 860px) { .colophon__inner { grid-template-columns: 1fr; gap: 1.5rem; } }

/* ---------- page transitions ---------- */
.wipe { position: fixed; inset: 0; z-index: 200; pointer-events: none; background: var(--bg); }
[data-theme='workbench'] .wipe { transform: translateY(102%); box-shadow: 0 -30px 60px rgba(40, 28, 12, .35); background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.8' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .22 0 0 0 0 .1 0 0 0 .08 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E"); transition: transform .34s var(--ease); }
[data-theme='workbench'] .wipe--in { transform: translateY(0) rotate(0deg); }
[data-theme='workbench'] .wipe--out { transform: translateY(-104%) rotate(-1.5deg); transition-duration: .42s; }
[data-theme='expressionist'] .wipe { background: var(--accent); clip-path: polygon(0 0, 0 0, -30% 100%, -30% 100%); transition: clip-path .34s cubic-bezier(.7, 0, .3, 1); }
[data-theme='expressionist'] .wipe--in { clip-path: polygon(0 0, 130% 0, 100% 100%, -30% 100%); }
[data-theme='expressionist'] .wipe--out { clip-path: polygon(130% 0, 130% 0, 100% 100%, 100% 100%); transition-duration: .42s; }
[data-theme='cinema'] .wipe { background: #000; clip-path: circle(150% at 50% 50%); opacity: 0; transition: opacity .2s, clip-path .34s var(--ease); }
[data-theme='cinema'] .wipe--in { opacity: 1; }
[data-theme='cinema'] .wipe--out { clip-path: circle(0% at 50% 50%); opacity: 1; transition: clip-path .42s var(--ease-out); }

/* ---------- shared components ---------- */
.reflect { display: grid; gap: 1rem; padding: clamp(1.25rem, 3vw, 2.25rem); border: 1.5px solid var(--line-strong); background: var(--paper); border-radius: var(--radius); }
.reflect__q { font-family: var(--font-display); font-size: clamp(1.5rem, 2.6vw, 2.1rem); line-height: 1.1; font-weight: 400; }

.callout { border-left: 4px solid var(--accent); padding: .8rem 1rem; background: color-mix(in srgb, var(--accent) 7%, var(--paper)); }

.tag-gen { display: inline-flex; align-items: center; gap: .4em; font-family: var(--font-label); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; background: var(--ink); color: var(--bg); padding: .2em .5em; }
.tag-gen::before { content: ''; width: .6em; height: .6em; border: 1.5px solid currentColor; border-radius: 50%; }

.boot-guard { position: fixed; inset: auto 16px 16px 16px; z-index: 999; background: #141210; color: #f6efe1; padding: 1rem 1.2rem; display: flex; gap: 1rem; align-items: center; font-family: system-ui, sans-serif; border-radius: 4px; }
.boot-guard button { background: #e0261b; color: #fff; border: 0; padding: .6em 1em; }

/* figure captions */
.cap { font-family: var(--font-label); font-size: .76rem; line-height: 1.45; color: var(--ink-2); letter-spacing: .02em; margin-top: .5rem; }

/* reduced motion: kill every animation and transition, keep state changes */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- lightbox ---------- */
.lightbox { border: 0; padding: 0; background: transparent; max-width: min(1100px, 94vw); max-height: 94vh; color: var(--ink); }
.lightbox::backdrop { background: rgba(10, 8, 6, .82); backdrop-filter: blur(3px); }
.lightbox__frame { background: var(--paper); padding: clamp(10px, 2vw, 22px); box-shadow: 0 30px 80px rgba(0,0,0,.5); animation: lb-in .4s var(--ease-out); }
.lightbox img { max-height: 72vh; width: auto; margin-inline: auto; cursor: zoom-in; }
.lightbox__bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: .8rem; }
.lightbox__actions { display: flex; gap: .5rem; }
@keyframes lb-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }

/* ---------- type refinement (v2): warmer, more readable labels ---------- */
.eyebrow { letter-spacing: .08em; font-weight: 700; font-size: .8rem; }
.btn { letter-spacing: .05em; }
.cx-sub { letter-spacing: .07em; }
h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }
