/* Vibe Coding 101 — shared styles
   Plain CSS, no build step.

   Palette: knowledge-blue, from the house flat-animation style guide
   (FlatAnimationStudio / muyang-flat-animation), the preset tagged for
   knowledge · AI · learning · tools · methodology.

   Visual signature: warm uncoated paper, ink contours, selective colour,
   generous unpainted space. Colour carries information; it is not the
   identity. The paper and the whitespace are. */

:root {
  /* paper + ink */
  --paper:    #EEE9DB;   /* warm ivory, the ground */
  --paper-2:  #F5F2E8;   /* raised card, a shade lighter */
  --paper-3:  #E4DECB;   /* recessed / code */
  --ink:      #23201A;   /* charcoal fineliner */
  --ink-soft: #6B6459;   /* secondary text */
  --line:     #D5CDB8;   /* hairline rules */

  /* semantic accents — 2-4 only, each doing a job */
  --primary:  #1556A4;   /* the method, structure */
  --primary-2:#2877C7;
  --grow:     #4D8760;   /* confirmation, growth, done */
  --accent:   #D9893D;   /* attention, the gate, caution */
  --fx:       #66C7F2;   /* connection, transformation */
  --bad:      #B4453A;

  --radius: 12px;
  --maxw: 700px;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17.5px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;

  /* paper: a very faint square notebook grid, per the style guide */
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(35,32,26,0.030) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35,32,26,0.030) 1px, transparent 1px);
  background-size: 26px 26px;
}

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.wide { max-width: 1020px; margin: 0 auto; padding: 0 24px; }
section { padding: 84px 0; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; }

/* ---------- type ---------- */
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.14; margin: 0 0 14px; color: var(--ink); }
h1 { font-size: clamp(34px, 6vw, 54px); font-weight: 800; }
h2 { font-size: clamp(24px, 3.4vw, 33px); font-weight: 750; }
h3 { font-size: 19px; font-weight: 700; margin-top: 34px; }
p  { margin: 0 0 16px; }
.lede { font-size: clamp(18px, 2.2vw, 20.5px); color: var(--ink-soft); }
.kicker {
  display: inline-block; font-size: 12px; font-weight: 800;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--primary); margin-bottom: 15px;
}
.g { color: var(--primary); }
a { color: var(--primary); text-decoration: none; border-bottom: 1px solid rgba(21,86,164,0.32); }
a:hover { border-bottom-color: var(--primary); }
strong { font-weight: 700; }
em { color: var(--ink-soft); }

code {
  font-family: var(--mono); font-size: 0.85em;
  background: var(--paper-3); border: 1px solid var(--line);
  padding: 0.1em 0.36em; border-radius: 4px; color: #17406f;
}
pre {
  position: relative;
  background: var(--paper-2); border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: 8px; padding: 15px 17px; overflow-x: auto; margin: 18px 0;
}

/* Copy button — always visible, not hover-revealed. Our readers won't hover
   to discover controls, and hover doesn't exist on a phone. */
.copy {
  position: absolute; top: 8px; right: 8px;
  font-family: var(--sans); font-size: 11.5px; font-weight: 650;
  line-height: 1; letter-spacing: 0.02em;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 11px; cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.copy:hover { color: var(--ink); border-color: var(--ink-soft); }
.copy:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.copy.done   { color: var(--grow);   border-color: var(--grow);   background: var(--paper-2); }
.copy.failed { color: var(--accent); border-color: var(--accent); }

/* Screen-reader announcement only. */
.copy-status {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Long blocks scroll; keep the button clear of the first line of text. */
pre > code { display: block; padding-right: 68px; }
pre code { background: none; border: 0; padding: 0; font-size: 13.5px; line-height: 1.6; color: #2c2822; }

/* ---------- nav ---------- */
nav.top {
  position: sticky; top: 0; z-index: 50;
  background: rgba(238,233,219,0.88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
nav.top .inner {
  max-width: 1020px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 24px;
}
nav.top .brand { font-weight: 800; font-size: 15.5px; letter-spacing: -0.02em; border: 0; color: var(--ink); }
nav.top .brand span { color: var(--primary); }
nav.top .links { margin-left: auto; display: flex; gap: 20px; flex-wrap: wrap; }
nav.top .links a { color: var(--ink-soft); font-size: 14.5px; border: 0; }
nav.top .links a:hover, nav.top .links a[aria-current="page"] { color: var(--ink); }

/* ---------- hero ---------- */
header.hero { padding: 72px 0 60px; border-bottom: 1px solid var(--line); }
.hero .lede { max-width: 560px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.pill {
  font-size: 12.5px; color: var(--ink-soft);
  background: var(--paper-2); border: 1px solid var(--line);
  padding: 5px 12px; border-radius: 99px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-block; border: 1px solid var(--primary); border-radius: 9px;
  padding: 11px 21px; font-size: 15.5px; font-weight: 650;
  background: var(--primary); color: var(--paper-2);
}
.btn:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--primary); background: var(--paper-2); }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 16px; }
.grid.two   { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.card {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 21px 23px;
}
.card h3 { margin-top: 0; font-size: 17px; }
.card p:last-child { margin-bottom: 0; }
.card .num {
  font-family: var(--mono); font-size: 11.5px; font-weight: 700;
  color: var(--primary); letter-spacing: 0.09em;
}

/* callout */
.note {
  border-left: 3px solid var(--grow);
  background: var(--paper-2); border-radius: 0 10px 10px 0;
  padding: 15px 19px; margin: 22px 0;
}
.note.warn { border-left-color: var(--accent); }
.note p:last-child { margin-bottom: 0; }

/* ---------- figures ---------- */
figure { margin: 34px 0; }
figure svg { width: 100%; height: auto; display: block; }

/* Pen-on-paper: shapes get the hand-ink displacement filter, text never does.
   This is what keeps the diagrams in the house visual family while staying
   exact — the thing diffusion could not do (see DECISIONS.md D8). */
.inked { filter: url(#ink); }
figure text { filter: none; }
figcaption {
  margin-top: 11px; font-size: 14px; color: var(--ink-soft); text-align: center;
}

/* ---------- session list ---------- */
.session { display: flex; gap: 20px; padding: 20px 0; border-top: 1px solid var(--line); }
.session:last-child { border-bottom: 1px solid var(--line); }
.session .n {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  color: var(--primary); padding-top: 3px; min-width: 30px;
}
.session h3 { margin: 0 0 4px; font-size: 17px; }
.session p { margin: 0; color: var(--ink-soft); font-size: 15px; }

/* ---------- footer ---------- */
footer { padding: 40px 0 66px; color: var(--ink-soft); font-size: 14px; }
footer a { color: var(--ink-soft); }

/* ---------- motion ----------
   House motion grammar: motion must do semantic work — grouping,
   contrasting, progression, causal transformation, result confirmation.
   No decorative movement. Growth means an object forming from a fixed
   origin along its own structure, never a finished thing fading in.
   Soft ease-out; no bounce, jelly, jitter or continuous looping pulse. */

/* draw-on: a line drawn along its own path, from a fixed origin */
.draw {
  stroke-dasharray: var(--len, 600);
  stroke-dashoffset: var(--len, 600);
  animation: draw 1.5s cubic-bezier(.33,.72,.36,1) forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

/* relay: a response that follows the main action, staggered */
.relay { opacity: 0; animation: relay .55s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes relay { to { opacity: 1; } }

/* emphasis: brief, once — not a loop */
.settle { animation: settle .7s cubic-bezier(.2,.8,.3,1) both; transform-origin: center; }
@keyframes settle {
  0%   { transform: scale(.97); opacity: 0; }
  70%  { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.rise { animation: rise .7s cubic-bezier(.2,.7,.3,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .draw { stroke-dashoffset: 0; }
  .relay { opacity: 1; }
  html { scroll-behavior: auto; }
}

/* ---------- print: replaces the separate handout ---------- */
@media print {
  @page { margin: 15mm 14mm; }
  body { background: #fff; background-image: none; font-size: 10.5pt; line-height: 1.45; }
  nav.top, .btn-row, .no-print, .copy { display: none !important; }
  pre > code { padding-right: 0; }
  section { padding: 18px 0; }
  .wrap, .wide { max-width: none; padding: 0; }
  a { color: inherit; border: 0; }
  .card, .note, pre, figure, .session { page-break-inside: avoid; }
  h1, h2, h3 { page-break-after: avoid; }
  .page-break { page-break-before: always; }
}

@media (max-width: 640px) {
  section { padding: 56px 0; }
  header.hero { padding: 48px 0 40px; }
  nav.top .links { gap: 13px; }
}

/* ── Language toggle — English / 中文 ─────────────────────────────────────
   Paired blocks carry lang="en" / lang="zh". Anything with no lang attribute
   shows in both, so a page can be translated one section at a time without
   leaving a hole. See lang.js. */

/* Hide only the language you are NOT reading — never "hide then un-hide".
   An earlier version used `display: revert` to bring zh blocks back, which
   discards any author display value the element needed (flex, grid, list-item)
   and silently breaks layout. Hiding one side only means the visible side keeps
   whatever display it was given.

   Scoped to body descendants: a bare [lang|="zh"] also matches <html> itself,
   and the whole page would vanish. Do not unscope these.

   `|=` matches "zh" and "zh-Hans" alike, so a future zh-Hant/zh-Hans block
   cannot leak through an exact-match selector. */
html[data-lang="en"] body [lang|="zh"],
html[data-lang="zh"] body [lang|="en"] { display: none; }

/* CJK needs its own stack and a little more line height — the default sans
   stack has no Chinese, so the browser falls back to whatever it finds and
   the page loses its typographic voice halfway down. */
/* Latin family FIRST, CJK as fallback. Font stacks resolve per character, so
   this gives inline English terms (Terminal, Claude, ChatGPT) their proper Latin
   shapes while Han characters fall through to the CJK face. Putting PingFang
   first — the obvious order — renders Latin in PingFang's Latin glyphs, which is
   why an `.en-term` helper class looked necessary. It isn't; ordering fixes it. */
[lang|="zh"] {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
               "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  line-height: 1.85;
}
[lang|="zh"] h1, [lang|="zh"] h2, [lang|="zh"] h3 { line-height: 1.4; letter-spacing: 0; }

[lang|="zh"] code { font-family: var(--mono); }

nav.top .lang-toggle {
  margin-left: 2px;
  padding: 3px 10px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
nav.top .lang-toggle:hover { color: var(--ink); border-color: var(--ink-soft); }

/* Print: give the reader whichever language is on screen, not both. */
@media print { nav.top .lang-toggle { display: none !important; } }
