/* decode-page overrides — palette + fonts INHERITED from /styles.css.
 *
 * COUPLING CONTRACT — grep public/decode/ before renaming anything here:
 * depends on shared tokens --primary, --primary-dark, --ink, --grey,
 * --grey-dark, --grey-lighter; on @font-face families 'Bagel Fat One',
 * 'Source Sans 3', 'JetBrains Mono'; and (in index.html) on two woff2
 * preload paths. Rename/move any in /styles.css or /fonts and DECODE breaks
 * SILENTLY (CSS falls back to system defaults).
 *
 * Per-card --ac = the accent (magenta=system · red=blocker · green=fix ·
 * blue/purple=auth method · orange=timing). --ac-ink (set in app.js) is its
 * WCAG-AA text shade: bright --ac for fills/borders, dark --ac-ink for text. */

html:has(body.decode-page),
body.decode-page {
  height: auto;
  min-height: 100vh;
  max-height: none;
  overflow: auto;
}

body.decode-page {
  --card: #fff;
  --bg: #fafafa;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Source Sans 3', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

/* ---- House header: now the shared canonical .house / .house-nav from
 *      /styles.css (unified across Watch · Start · Decode). No local override
 *      so the header is byte-identical across pillars. ---- */

/* ---- Page shell ---- */
.decode-page #page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 28px 56px;
}

.decode-page .lede { margin-bottom: 24px; }
.decode-page .kicker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--grey);
  margin: 0 0 10px;
}
.decode-page .lede h1 {
  font-family: 'Bagel Fat One', cursive;
  font-size: 56px;
  font-weight: 400;
  line-height: 1;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.decode-page .lede .dek {
  max-width: 720px;
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--grey);
  margin: 0;
}

/* ---- Finder (search + lenses) ---- */
.decode-page .finder { margin-bottom: 20px; }
.decode-page .finder-lead {
  font-family: 'Bagel Fat One', cursive;
  font-size: 17px;
  color: var(--ink);
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.decode-page .lenses { display: flex; flex-wrap: wrap; gap: 7px; }
.decode-page .lens {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--grey-dark);
  background: var(--card);
  border: 1px solid var(--grey-lighter);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  transition: .12s;
}
.decode-page .lens:hover { border-color: var(--primary); }
.decode-page .lens.on {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

/* ---- Card grid ---- */
.decode-page .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.decode-page .card {
  display: flex;
  flex-direction: column;
  --ac: var(--primary-dark);
  background: var(--card);
  border: 1px solid var(--grey-lighter);
  border-left: 3px solid var(--ac);
  border-radius: 14px;
  box-shadow: 0 2px 6px -4px rgba(60, 30, 50, .18);
  overflow: hidden;
  transition: .12s;
}
.decode-page .card:hover { border-color: var(--primary); transform: translateY(-3px); }
.decode-page .card.open {
  grid-column: 1 / -1;
  transform: none;
  border-color: var(--ac-ink);
  box-shadow: 0 6px 22px -10px rgba(60, 30, 50, .3);
}

/* compact head — the always-visible "stuck moment" */
.decode-page .card-head {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: 14px 16px;
  font: inherit;
  color: inherit;
}
.decode-page .card-head .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.decode-page .card-head .glyph { font-size: 24px; line-height: 1; }
.decode-page .card-head .term {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--ac-ink);
  background: color-mix(in srgb, var(--ac) 18%, var(--card));
  padding: 3px 8px;
  border-radius: 6px;
}
.decode-page .card-head h3 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.27;
  margin: 0 0 5px;
  color: var(--ink);
}
.decode-page .card-head .teaser {
  font-size: 13px;
  line-height: 1.4;
  color: var(--grey-dark);
  margin: 0 0 10px;
}
.decode-page .card-head .foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.decode-page .card-head .layer { color: var(--grey); }
.decode-page .card-head .cue { color: var(--ac-ink); font-weight: 700; }
.decode-page .card.open .card-head .cue::after { content: " ↑"; }
.decode-page .card:not(.open) .card-head .cue::after { content: " ↓"; }

/* expanded body — the decode */
.decode-page .card-body {
  display: none;
  padding: 4px 18px 18px;
  border-top: 1px solid var(--grey-lighter);
  max-width: 760px;
}
.decode-page .card.open .card-body { display: block; }
.decode-page .reg { margin-top: 16px; }
.decode-page .reg-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ac-ink);
  display: block;
  margin-bottom: 5px;
}
.decode-page .reg p { margin: 0; font-size: 14.5px; line-height: 1.58; color: var(--ink); }
/* dependency chain diagram (hub) — horizontal arrow flow (style A) */
.decode-page .chain { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin: 8px 0 2px; }
.decode-page .chain .node {
  flex: 1 1 140px; min-width: 120px;
  display: flex; flex-direction: column; justify-content: center;
  background: color-mix(in srgb, var(--ac) 8%, var(--card));
  border: 1px solid color-mix(in srgb, var(--ac) 32%, var(--grey-lighter));
  border-radius: 10px; padding: 9px 11px;
}
.decode-page .chain .node .k { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; color: var(--ink); }
.decode-page .chain .node .g { font-size: 11px; color: var(--grey); margin-top: 2px; }
.decode-page .chain .node.pay { background: var(--ac); border-color: var(--ac-ink); }
.decode-page .chain .node.pay .k, .decode-page .chain .node.pay .g { color: #fff; }
.decode-page .chain .arr { align-self: center; color: var(--ac-ink); font-weight: 700; font-size: 17px; }

/* "Your move" decision steps — directives + if/then branches on a spine */
.decode-page .steps { list-style: none; margin: 8px 0 0; padding: 0; }
.decode-page .steps .step {
  position: relative;
  padding: 0 0 13px 18px;
  border-left: 2px solid var(--grey-lighter);
}
.decode-page .steps .step:last-child { padding-bottom: 2px; border-left-color: transparent; }
.decode-page .steps .step::before {
  content: "";
  position: absolute; left: -6px; top: 4px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ac);
}
.decode-page .steps .s-do { font-size: 14.5px; line-height: 1.5; color: var(--ink); }
.decode-page .steps .step--branch .s-if {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ac-ink);
  background: color-mix(in srgb, var(--ac) 18%, var(--card));
  padding: 2px 8px; border-radius: 5px; margin-bottom: 4px;
}
.decode-page .steps .step--branch .s-then { display: block; font-size: 14px; line-height: 1.5; color: var(--ink); }
.decode-page .reg--do .contacts {
  margin: 9px 0 0;
  font-size: 13px;
  color: var(--grey-dark);
}
.decode-page .reg--do .sources {
  margin: 5px 0 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--grey);
  letter-spacing: 0.01em;
}
.decode-page .reg--do .sources a {
  color: var(--primary-dark);
  text-decoration: underline;
  text-decoration-color: var(--grey-lighter);
  text-underline-offset: 2px;
}
.decode-page .reg--do .sources a:hover { text-decoration-color: var(--primary-dark); }
.decode-page .card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px dotted var(--grey-lighter);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--grey);
  letter-spacing: 0.02em;
}
.decode-page .card-meta .conf-explicit { color: #1c7a3a; }
.decode-page .card-meta .conf-inferred { color: #2c5cb0; }
.decode-page .card-proximity {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--grey-dark);
}

/* ---- Methodology + footer (mirrors the bakeries pattern) ---- */
.decode-page .methodology { max-width: 720px; margin: 36px 0 28px; font-size: 14px; color: var(--ink); }
.decode-page .meth-label {
  font-family: 'Bagel Fat One', cursive;
  font-weight: 400;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 22px 0 8px;
}
.decode-page .meth-label:first-of-type { margin-top: 0; }
.decode-page .methodology p { font-size: 13.5px; line-height: 1.6; margin: 0 0 8px; }
.decode-page .methodology strong { color: var(--primary-dark); font-weight: 700; }
.decode-page .empty { color: var(--grey); font-size: 14px; margin: 8px 0 0; }
.decode-page .proximity-note {
  max-width: 720px;
  margin: 0 0 20px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--grey-dark);
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .decode-page #page { padding: 24px 18px 40px; }
  .decode-page .lede h1 { font-size: 40px; }
  .decode-page .grid { grid-template-columns: 1fr; }
}
