/* howto.hunches.dev — follows the Jens Marions identity (marions.hunches.dev).
   Two surfaces: charcoal (argument) and paper (detail).
   Lime is light on charcoal; on paper it only ever sits behind ink, as a highlighter. */

@font-face { font-family: 'Geist'; src: url('/fonts/geist.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Newsreader'; src: url('/fonts/newsreader.woff2') format('woff2'); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Newsreader'; src: url('/fonts/newsreader-italic.woff2') format('woff2'); font-weight: 200 800; font-style: italic; font-display: swap; }

:root {
  --charcoal: #101319;
  --charcoal-raised: #171b22;
  --lime: #c7ff4d;
  --paper: #f0eee7;
  --paper-deep: #e5e2d8;
  --white: #f8f9fa;
  --grey: #a6afba;
  --grey-dim: #7d8794;
  --ink: #252823;
  --ink-soft: #565b52;
  --rule-dark: rgba(248, 249, 250, 0.14);
  --rule-paper: rgba(37, 40, 35, 0.16);

  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Newsreader', ui-serif, Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;

  --gutter: clamp(1rem, 4vw, 3rem);
  --max: 1280px;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: clamp(1.0625rem, 0.98rem + 0.3vw, 1.25rem);
  --step-2: clamp(1.25rem, 1.1rem + 0.6vw, 1.625rem);
  --step-3: clamp(1.625rem, 1.3rem + 1.4vw, 2.5rem);
  --step-4: clamp(2.125rem, 1.5rem + 2.8vw, 3.75rem);
  --step-5: clamp(2.75rem, 0.4rem + 11vw, 7.75rem);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--charcoal);
  color: var(--white);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.55;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote, pre { margin: 0; }
a { color: inherit; }
::selection { background: var(--lime); color: var(--charcoal); }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; border-radius: 2px; }
.paper :focus-visible { outline-color: var(--ink); }

.skip { position: absolute; left: var(--gutter); top: -100px; z-index: 100; background: var(--lime); color: var(--charcoal); padding: 0.75rem 1rem; font-weight: 600; text-decoration: none; }
.skip:focus { top: 0.75rem; }

.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }

.paper { background: var(--paper); color: var(--ink); color-scheme: light; }
.paper ::selection { background: var(--ink); color: var(--paper); }

code, .mono { font-family: var(--mono); font-size: 0.88em; letter-spacing: -0.01em; }
.on-dark code { color: var(--white); background: rgba(248, 249, 250, 0.07); padding: 0.08em 0.32em; border-radius: 3px; }
.paper code { background: var(--paper-deep); padding: 0.08em 0.32em; border-radius: 3px; }
.lime { color: var(--lime); }

.mark {
  background: linear-gradient(transparent 12%, var(--lime) 12%, var(--lime) 88%, transparent 88%);
  color: var(--ink);
  padding-inline: 0.12em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.6em; min-height: 48px;
  padding: 0.8rem 1.35rem; border: 0; border-radius: 3px; cursor: pointer;
  font-family: var(--sans); font-size: var(--step-0); font-weight: 550; letter-spacing: -0.005em;
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s, transform 0.2s var(--ease);
}
.btn-primary { background: var(--lime); color: var(--charcoal); }
.btn-primary:hover { background: var(--white); }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { background: var(--charcoal); }
.arr { display: inline-block; transition: transform 0.3s var(--ease); }
.btn:hover .arr, .textlink:hover .arr { transform: translateX(3px); }
.btn:hover .arr-up, .textlink:hover .arr-up { transform: translate(2px, -2px); }
.textlink { display: inline-flex; align-items: center; gap: 0.5em; min-height: 48px; font-weight: 500; text-decoration: none; }
.textlink span:first-child {
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px; background-position: 0 100%; background-repeat: no-repeat; padding-bottom: 2px;
}

/* ---------- Header ---------- */
.site-header { position: relative; z-index: 20; background: var(--charcoal); border-bottom: 1px solid var(--rule-dark); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 4.5rem; }
.wordmark { display: inline-flex; align-items: center; gap: 0.6rem; min-height: 48px; font-weight: 600; font-size: 0.9375rem; letter-spacing: 0.14em; text-decoration: none; color: var(--white); }
.wordmark .sq { width: 0.6rem; height: 0.6rem; background: var(--lime); flex: none; }
.nav-list { display: flex; gap: 2.25rem; list-style: none; padding: 0; }
.nav-list a { display: inline-flex; align-items: center; min-height: 48px; color: var(--grey); text-decoration: none; font-size: 0.9375rem; transition: color 0.2s; }
.nav-list a:hover { color: var(--white); }
@media (max-width: 760px) { .site-nav { display: none; } }

/* ---------- Scaffolding ---------- */
.section { padding-block: clamp(4.5rem, 10vw, 9rem); }
.label { font-size: var(--step--1); font-weight: 500; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; color: var(--grey); }
.paper .label { color: var(--ink-soft); }
.h2 { font-size: var(--step-4); font-weight: 500; line-height: 1.04; letter-spacing: -0.035em; text-wrap: balance; }
.prose-serif p { font-family: var(--serif); font-size: var(--step-1); line-height: 1.65; font-weight: 400; text-wrap: pretty; }
.prose-serif p + p { margin-top: 1.1em; }
.on-dark .prose-serif p { color: #dfe3e8; }
.note { font-size: 0.875rem; color: var(--grey); max-width: 40rem; line-height: 1.55; }
.paper .note { color: var(--ink-soft); }

.section-head {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: clamp(1rem, 2.4vw, 2rem); row-gap: 1.25rem;
  margin-bottom: clamp(2.5rem, 6vw, 5rem);
}
.section-head .label { grid-column: 1 / -1; padding-top: 0.6rem; }
.section-head .h2 { grid-column: 1 / -1; max-width: 18ch; }

/* Body column that lines up with the heading on wide screens. */

@media (min-width: 900px) {
  .section-head .label { grid-column: 1 / span 3; }
  .section-head .h2 { grid-column: 4 / -1; }
  .clock-intro, .machine-intro, .sentence, .steps, .flow-note, .budget, .parts, .limits, .clock, .diagram {
    margin-left: calc((100% + 2rem) / 12 * 3);
  }
}

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--rule-dark); }
.hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(to right, rgba(248, 249, 250, 0.045) 1px, transparent 1px);
  background-size: calc(100% / 6) 100%;
  mask-image: linear-gradient(to bottom, transparent, #000 25%, #000 75%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 25%, #000 75%, transparent);
}
.hero .wrap { position: relative; padding-top: clamp(3.5rem, 9vw, 8rem); padding-bottom: clamp(3rem, 6vw, 5rem); }
.hero-title { margin-top: clamp(1.75rem, 4vw, 3rem); font-size: var(--step-5); font-weight: 500; line-height: 0.96; letter-spacing: -0.052em; }
.hero-title .line { display: block; }
.hero-title .was { position: relative; color: var(--grey-dim); white-space: nowrap; }
.hero-title .was::after {
  content: ''; position: absolute; left: -0.04em; right: -0.04em; top: 54%;
  height: 0.055em; min-height: 3px; background: var(--white);
  transform-origin: left center; animation: strike 0.9s var(--ease) 0.45s both;
}
.hero-title .is { color: var(--lime); white-space: nowrap; }
.hero-title .cursor { display: inline-block; width: 0.09em; height: 0.8em; margin-left: 0.06em; vertical-align: -0.04em; background: var(--lime); animation: blink 1.1s steps(1) 1.6s infinite; }
@keyframes strike { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .hero-title .was::after, .hero-title .cursor { animation: none; } }

.hero-foot { margin-top: clamp(2.5rem, 6vw, 4.5rem); display: grid; gap: 2.5rem; }
.hero-statement { font-family: var(--serif); font-size: var(--step-2); line-height: 1.45; font-weight: 380; color: #dfe3e8; max-width: 32ch; text-wrap: pretty; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.75rem; margin-top: 2rem; }

.hero-proof { padding-top: 1.25rem; border-top: 1px solid var(--rule-dark); max-width: 24rem; align-self: end; }
.proof-k { font-size: var(--step--1); letter-spacing: 0.08em; text-transform: uppercase; color: var(--grey); }
.proof-num { margin-top: 0.4rem; font-size: clamp(4rem, 3rem + 5vw, 6.5rem); font-weight: 500; line-height: 1; letter-spacing: -0.05em; font-variant-numeric: tabular-nums; color: var(--lime); }
.proof-note { margin-top: 0.85rem; font-size: 0.9375rem; color: var(--grey); }
.proof-note .mono { color: var(--white); }
@media (min-width: 900px) {
  .hero-foot { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 2rem; }
  .hero-proof { grid-column: 1 / span 4; grid-row: 1; }
  .hero-main { grid-column: 6 / -1; grid-row: 1; }
}

/* ---------- 01 Clock ---------- */
.clock-intro { max-width: 40rem; }
.clock { margin-top: clamp(2.5rem, 6vw, 4rem); }
.clock-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.clock-readout { font-size: clamp(3rem, 2rem + 4vw, 5rem); font-weight: 500; line-height: 1; letter-spacing: -0.05em; font-variant-numeric: tabular-nums; }
.clock-unit { font-size: var(--step-1); letter-spacing: 0; margin-left: 0.4rem; color: var(--ink-soft); font-weight: 450; }

.bar { position: relative; display: flex; height: 14px; background: var(--paper-deep); overflow: hidden; border-radius: 2px; }
.seg { flex: var(--w) 0 0; height: 100%; border-right: 2px solid var(--paper); }
.seg:last-of-type { border-right: 0; }
.s1 { background: var(--ink); }
.s2 { background: var(--ink-soft); }
.s3 { background: var(--ink); }
.s4 { background: #9aa08f; }
/* While replaying, a paper-coloured cover slides off the unplayed part of the bar. */
.bar-fill { position: absolute; inset: 0 0 0 auto; width: 0; background: var(--paper-deep); }
.bar-fill::before { content: ''; position: absolute; left: 0; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
.js .clock:not(.playing) .bar-fill::before { display: none; }

.ticks { list-style: none; padding: 0; margin-top: 1.5rem; display: grid; border-top: 1px solid var(--rule-paper); }
.tick { display: grid; grid-template-columns: 6.25rem 1fr; column-gap: 1rem; row-gap: 0.15rem; padding-block: 0.95rem; border-bottom: 1px solid var(--rule-paper); transition: opacity 0.3s; }
.tick-time { font-family: var(--mono); font-size: 0.875rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; padding-top: 0.12rem; grid-row: span 2; }
.tick-what { font-weight: 600; letter-spacing: -0.01em; }
.tick-detail { color: var(--ink-soft); font-size: 0.9375rem; }
.js .clock.playing .tick { opacity: 0.35; }
.js .clock.playing .tick.on { opacity: 1; }
.tick.on .tick-what::before { content: ''; display: inline-block; width: 0.5rem; height: 0.5rem; background: var(--ink); margin-right: 0.5rem; vertical-align: 0.1em; }
.clock figcaption { margin-top: 1.25rem; }
@media (min-width: 700px) {
  .tick { grid-template-columns: 6.25rem 9rem 1fr; }
  .tick-time { grid-row: auto; }
}

.budget { margin-top: clamp(3.5rem, 8vw, 6rem); }
.budget-k { font-size: var(--step--1); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 1rem; }
.budget-list { display: grid; gap: 0; border-top: 1px solid var(--rule-paper); }
.budget-list > div { display: grid; gap: 0.35rem; padding-block: 1.1rem; border-bottom: 1px solid var(--rule-paper); }
.budget-list dt { font-weight: 600; font-size: var(--step-1); letter-spacing: -0.015em; display: flex; gap: 0.9rem; align-items: baseline; }
.budget-list dt .mono { font-weight: 500; min-width: 3.6rem; color: var(--ink-soft); font-size: 0.9rem; }
.budget-list dd { color: var(--ink-soft); max-width: 36rem; }
@media (min-width: 700px) { .budget-list > div { grid-template-columns: 14rem 1fr; } }
.pull { margin-top: clamp(2.5rem, 6vw, 4rem); font-family: var(--serif); font-size: var(--step-3); line-height: 1.2; font-weight: 400; letter-spacing: -0.015em; max-width: 26ch; text-wrap: balance; }
.budget .note { margin-top: 1.5rem; }

/* ---------- 02 Flow ---------- */
.sentence { padding: clamp(1.5rem, 4vw, 2.5rem); background: var(--charcoal-raised); border: 1px solid var(--rule-dark); border-left: 3px solid var(--lime); max-width: 46rem; }
.sentence-k { font-size: var(--step--1); letter-spacing: 0.08em; text-transform: uppercase; color: var(--grey); }
.sentence-text { margin-top: 0.75rem; font-family: var(--serif); font-size: var(--step-3); line-height: 1.2; font-weight: 400; letter-spacing: -0.01em; overflow-wrap: anywhere; }

.steps { list-style: none; padding: 0; margin-top: clamp(2.5rem, 6vw, 4rem); border-top: 1px solid var(--rule-dark); max-width: 46rem; }
.step { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr); gap: 1rem; padding-block: 1.6rem; border-bottom: 1px solid var(--rule-dark); }
.step-num { width: 2rem; height: 2rem; display: grid; place-items: center; border: 1.5px solid var(--grey-dim); font-size: 0.875rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--grey); }
.step:last-child .step-num { background: var(--lime); border-color: var(--lime); color: var(--charcoal); }
.step h3 { font-size: var(--step-1); font-weight: 600; letter-spacing: -0.015em; padding-top: 0.15rem; }
.step p { margin-top: 0.4rem; color: #c9d0d8; max-width: 38rem; }
.code { margin-top: 1rem; padding: 1rem 1.15rem; background: #0a0c10; border: 1px solid var(--rule-dark); border-radius: 3px; overflow-x: auto; font-size: 0.85rem; line-height: 1.6; }
.code code { background: none; padding: 0; color: #dfe3e8; font-size: 1em; }
.flow-note { margin-top: 2rem; max-width: 40rem; color: var(--grey); }

/* ---------- 03 Machine ---------- */
.machine-intro { max-width: 40rem; }
.diagram { margin-top: clamp(2.5rem, 6vw, 4rem); }
.pipe { list-style: none; padding: 0; display: grid; gap: 0; }
.node { position: relative; display: grid; gap: 0.2rem; padding: 1.1rem 1.2rem; background: var(--white); border: 1px solid var(--rule-paper); }
.node + .node { margin-top: 1.75rem; }
.node + .node::before {
  content: '↓'; position: absolute; left: 1.2rem; top: -1.65rem; font-size: 1.1rem; line-height: 1.5rem; color: var(--ink-soft);
}
.node-k { font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.node-name { font-weight: 600; font-size: var(--step-1); letter-spacing: -0.015em; overflow-wrap: break-word; }
.node-d { font-size: 0.875rem; color: var(--ink-soft); }
.node-end { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.node-end .node-k, .node-end .node-d { color: #c9ccc2; }
.node-end .node-name { color: var(--lime); }
.diagram figcaption { margin-top: 1rem; }
@media (min-width: 1000px) {
  .pipe { grid-template-columns: repeat(5, minmax(0, 1fr)); column-gap: 1.75rem; }
  .node + .node { margin-top: 0; }
  .node + .node::before { content: '→'; left: -1.45rem; top: 50%; transform: translateY(-50%); }
}

.parts { margin-top: clamp(3.5rem, 8vw, 6rem); }
.parts-k { font-size: var(--step--1); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 1rem; }
.part-list { list-style: none; padding: 0; border-top: 1px solid var(--rule-paper); }
.part-list li { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: 1rem; padding-block: 1.4rem; border-bottom: 1px solid var(--rule-paper); }
.part-n { font-size: var(--step--1); font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink-soft); padding-top: 0.3rem; }
.part-list h3 { font-size: var(--step-1); font-weight: 600; letter-spacing: -0.015em; }
.part-list p { margin-top: 0.35rem; color: var(--ink-soft); max-width: 38rem; }

/* ---------- 04 Decisions ---------- */
.decisions { list-style: none; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--rule-dark); }
.decision { display: grid; gap: 0.6rem; padding-block: clamp(1.75rem, 4vw, 2.5rem); border-bottom: 1px solid var(--rule-dark); }
.d-num { font-size: var(--step--1); font-weight: 500; font-variant-numeric: tabular-nums; color: var(--lime); }
.d-title { font-family: var(--serif); font-style: italic; font-weight: 380; font-size: var(--step-3); line-height: 1.12; letter-spacing: -0.015em; text-wrap: balance; max-width: 22ch; }
.d-body { color: #c9d0d8; max-width: 34rem; }
@media (min-width: 900px) {
  .decision { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 2rem; align-items: start; }
  .d-num { grid-column: 1 / span 1; padding-top: 0.7rem; }
  .d-title { grid-column: 2 / span 6; }
  .d-body { grid-column: 8 / -1; padding-top: 0.55rem; }
}

/* ---------- 05 Limits ---------- */
.limits { border-top: 1px solid var(--rule-paper); }
.limits > div { display: grid; gap: 0.35rem; padding-block: 1.25rem; border-bottom: 1px solid var(--rule-paper); }
.limits dt { font-weight: 600; font-size: var(--step-1); letter-spacing: -0.015em; display: flex; align-items: center; gap: 0.6rem; }
.limits dt::before { content: ''; width: 0.55rem; height: 0.55rem; border: 1.5px solid var(--ink-soft); flex: none; }
.limits dd { color: var(--ink-soft); max-width: 38rem; }
@media (min-width: 700px) { .limits > div { grid-template-columns: 17.5rem 1fr; } }

/* ---------- 06 Close ---------- */
.close { border-top: 1px solid var(--rule-dark); }
.close-statement { margin-top: 1.5rem; font-size: var(--step-4); font-weight: 500; line-height: 1.06; letter-spacing: -0.035em; max-width: 22ch; text-wrap: balance; }
.close-body { margin-top: clamp(2rem, 5vw, 3rem); max-width: 40rem; }
.close .hero-actions { margin-top: 2.5rem; }
@media (min-width: 900px) { .close-body, .close .hero-actions { margin-left: calc((100% + 2rem) / 12 * 3); } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule-dark); padding-top: clamp(3rem, 7vw, 5rem); padding-bottom: 2.5rem; color: var(--grey); font-size: 0.9375rem; }
.footer-grid { display: grid; gap: 2.5rem; }
.footer-statement { font-family: var(--serif); font-size: var(--step-2); line-height: 1.4; color: var(--white); max-width: 26ch; }
.footer-nav { list-style: none; padding: 0; display: grid; gap: 0.15rem; }
.footer-nav a { display: inline-flex; min-height: 40px; align-items: center; text-decoration: none; color: var(--grey); }
.footer-nav a:hover { color: var(--white); }
.footer-k { font-size: 0.8125rem; color: var(--grey-dim); margin-bottom: 0.5rem; }
.footer-base { margin-top: clamp(3rem, 7vw, 5rem); padding-top: 1.25rem; border-top: 1px solid var(--rule-dark); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem; font-size: 0.8125rem; color: var(--grey-dim); }
@media (min-width: 900px) {
  .footer-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 2rem; }
  .footer-grid .footer-statement { grid-column: 1 / span 6; }
  .footer-grid .col-a { grid-column: 8 / span 2; }
  .footer-grid .col-b { grid-column: 10 / span 3; }
}

@media print {
  .site-header, .hero-actions, .clock-replay { display: none; }
  body, .on-dark, .hero, .close, .site-footer { background: #fff; color: #000; }
}

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hero-title s.was { text-decoration: none; }
