/* header / nav: fixed; shrinks while scrolling (class "scrolled" on <html>) */
.site-header { position: fixed; top: 0; left: 0; right: 0; z-index: 50; background: rgba(250, 250, 248, .95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.site-header .bar { display: flex; align-items: center; gap: var(--s-5); height: var(--header-h-full); transition: height .25s ease; }
.scrolled .site-header .bar { height: var(--header-h-small); }
.brand { display: flex; align-items: center; gap: var(--s-3); color: var(--text-0); font-weight: 800; font-size: 1.3rem; text-decoration: none; letter-spacing: -.02em; }
.brand:hover { color: var(--text-0); }
.site-header .brand img { width: 48px; height: 48px; transition: width .25s ease, height .25s ease; }
.scrolled .site-header .brand img { width: 32px; height: 32px; }
.site-header .brand-name { display: inline-block; white-space: nowrap; }
.nav { display: flex; align-items: center; gap: var(--s-5); margin-left: auto; }
.nav a { color: var(--text-1); text-decoration: none; font-size: var(--fs-sm); font-weight: 600; transition: font-size .25s ease; }
.scrolled .nav a { font-size: .8125rem; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text-0); }
.nav a[aria-current="page"]:not(.btn) { box-shadow: 0 2px 0 var(--accent); }
.nav a.btn-primary { color: var(--primary-ink); }
.scrolled .nav a.btn { padding: .5rem .85rem; }
.nav-toggle { display: none; margin-left: auto; background: transparent; color: var(--text-0); border: 1px solid var(--line-strong); border-radius: var(--r-2); padding: .5rem .8rem; font: 700 var(--fs-sm) var(--font-sans); cursor: pointer; }
@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; background: var(--bg-1); border-bottom: 1px solid var(--line); padding: var(--s-3) var(--s-4); }
  .nav.open { display: flex; }
  .nav a { padding: var(--s-3) 0; }
}

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); padding: .7rem 1.15rem; border-radius: var(--r-2); font: 600 var(--fs-sm)/1 var(--font-sans); text-decoration: none; border: 1px solid transparent; cursor: pointer; transition: background .15s, border-color .15s; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); color: var(--primary-ink); }
.btn-grey { background: var(--grey-btn); color: var(--grey-ink); }
.btn-grey:hover { background: var(--grey-btn-hover); color: var(--grey-ink); }
.btn-secondary { background: transparent; border-color: var(--line-strong); color: var(--text-0); }
.btn-secondary:hover { border-color: var(--accent); color: var(--text-0); }
.btn-ghost { color: var(--accent); padding-inline: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }

/* cards */
.card-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-3); padding: var(--s-5); }
.card h3 { font-size: var(--fs-lg); font-weight: 750; margin-bottom: var(--s-2); }
.card p:last-child, .card ul:last-child { margin-bottom: 0; }
.card .kicker { font: 600 var(--fs-xs)/1 var(--font-mono); color: var(--text-2); letter-spacing: .08em; text-transform: uppercase; margin-bottom: var(--s-3); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font: 600 var(--fs-xs)/1 var(--font-mono); letter-spacing: .04em; padding: .35rem .55rem; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--text-1); white-space: nowrap; }
.badge-proposed { color: var(--info); border-color: color-mix(in srgb, currentColor 55%, transparent); }
.badge-simulated { color: var(--warn); border-color: color-mix(in srgb, currentColor 55%, transparent); }
.badge-confirmed { color: var(--ok); border-color: color-mix(in srgb, currentColor 55%, transparent); }
.badge-hypothesis { color: var(--hyp); border: 1px dashed currentColor; }
.badge-future { color: var(--text-2); border-style: dashed; }
.badge-exists { color: var(--accent); border-color: color-mix(in srgb, currentColor 55%, transparent); }

/* callouts */
.callout { border: 1px solid var(--line-strong); border-left-width: 3px; border-radius: var(--r-2); background: var(--bg-1); padding: var(--s-4) var(--s-5); margin: 0 0 var(--s-5); }
.callout > :last-child { margin-bottom: 0; }
.callout-proposed { border-left-color: var(--info); }
.callout-note { border-left-color: var(--accent); }
.callout-warn { border-left-color: var(--warn); }
.callout strong:first-child { color: var(--text-0); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 0 var(--s-5); border: 1px solid var(--line); border-radius: var(--r-2); }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); min-width: 520px; }
.table-wrap th, .table-wrap td { text-align: left; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap th { color: var(--text-0); background: var(--bg-2); font-weight: 600; }
.table-wrap tr:last-child td { border-bottom: 0; }

/* code */
.codeblock { position: relative; margin: 0 0 var(--s-5); background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-2); }
.codeblock pre { margin: 0; padding: var(--s-4) var(--s-5); overflow-x: auto; font-size: .82rem; line-height: 1.6; color: var(--text-0); }
.codeblock::before { content: attr(data-lang); position: absolute; top: 6px; left: var(--s-4); font: 600 10px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }
.codeblock pre { padding-top: var(--s-6); }
.tk-key { color: var(--info); }
.tk-str { color: var(--ok); }
.tk-num { color: var(--orange); }
.tk-lit { color: var(--hyp); }
.tk-pun { color: var(--text-2); }
.tk-kw { color: var(--hyp); }
.tk-com { color: var(--text-2); font-style: italic; }
.tk-var { color: var(--gold); }
.codeblock .copy { position: absolute; top: 6px; right: 8px; background: var(--bg-3); color: var(--text-1); border: 1px solid var(--line-strong); border-radius: var(--r-1); font: 600 11px/1 var(--font-mono); padding: 5px 8px; cursor: pointer; }
.codeblock .copy:hover { color: var(--text-0); border-color: var(--accent); }
pre.mermaid { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-2); padding: var(--s-5); overflow-x: auto; color: var(--text-1); font-size: .8rem; margin: 0 0 var(--s-5); }

/* tabs */
.tabs { margin: 0 0 var(--s-5); }
.tabs [role="tablist"] { display: flex; flex-wrap: wrap; gap: var(--s-1); border-bottom: 1px solid var(--line); margin-bottom: var(--s-4); }
.tabs [role="tab"] { background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--text-2); font: 600 var(--fs-sm) var(--font-sans); padding: var(--s-3) var(--s-4); cursor: pointer; }
.tabs [role="tab"][aria-selected="true"] { color: var(--text-0); border-bottom-color: var(--accent); }
.tabs [role="tab"]:hover { color: var(--text-0); }
.tabs [role="tabpanel"] > .codeblock:last-child { margin-bottom: 0; }

/* footer */
.site-footer { border-top: 1px solid var(--line); padding-block: var(--s-7); color: var(--text-2); font-size: var(--fs-sm); }
.footer-grid { display: grid; gap: var(--s-6); grid-template-columns: 2fr 1fr 1fr 1fr; }
.footer-grid h2 { font-size: var(--fs-sm); color: var(--text-0); margin-bottom: var(--s-3); }
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin-bottom: var(--s-2); }
.footer-grid a { color: var(--text-1); text-decoration: none; }
.footer-grid a:hover { color: var(--accent); }
.disclaimer { margin-top: var(--s-6); padding-top: var(--s-5); border-top: 1px solid var(--line); max-width: 80ch; }
@media (max-width: 820px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
/* table cells: size columns to their code words instead of breaking identifiers mid-word */
.table-wrap code { white-space: nowrap; }

/* confirm hypothesis: four blocks, left to right */
.confirm { list-style: none; margin: 0 0 var(--s-5); padding: 0; display: grid; gap: var(--s-4); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.confirm li { position: relative; display: grid; gap: var(--s-2); align-content: start; padding: var(--s-4); background: var(--bg-1); border: 1px solid var(--line-strong); border-top: 4px solid var(--info); border-radius: var(--r-2); font-size: var(--fs-sm); color: var(--text-1); }
.confirm li:not(:last-child)::after { content: "→"; position: absolute; top: 50%; right: calc(var(--s-4) / -2); transform: translate(50%, -50%); font: 800 var(--fs-lg)/1 var(--font-mono); color: var(--accent); background: var(--bg-0); z-index: 1; }
.confirm .confirm-guess { border-top: 4px dashed var(--hyp); }
.confirm .confirm-ok { border-top-color: var(--ok); background: color-mix(in srgb, var(--ok) 7%, var(--bg-1)); }
.confirm-icon { font-size: 1.6rem; line-height: 1; }
.confirm strong { color: var(--text-0); font-size: var(--fs-md); }
@media (max-width: 760px) {
  .confirm { grid-template-columns: 1fr; }
  .confirm li:not(:last-child)::after { content: "↓"; top: auto; right: auto; bottom: calc(var(--s-4) / -2); left: 50%; transform: translate(-50%, 50%); }
}

/* lifecycle chain: two big, connected blocks */
.cycle { margin: 0 0 var(--s-5); }
.cycle-zone { --zone: var(--ok); border: 2px solid var(--zone); border-radius: var(--r-3); padding: var(--s-4) var(--s-5) var(--s-5); background: color-mix(in srgb, var(--zone) 7%, var(--bg-1)); }
.cycle-rel { --zone: var(--orange); }
.cycle-title { margin: 0 0 var(--s-4); font: 700 var(--fs-sm)/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--zone); }
.cycle-steps { --gap: 22px; list-style: none; margin: 0; padding: 0; display: flex; gap: var(--gap); }
.cycle-back { flex-direction: row-reverse; }
.cycle-steps li { position: relative; flex: 1 1 0; min-width: 0; text-align: center; padding: var(--s-3) 0; background: var(--bg-1); border: 1px solid var(--zone); border-radius: var(--r-2); color: var(--text-0); font-weight: 600; font-size: .72rem; letter-spacing: -.02em; overflow-wrap: anywhere; }
.cycle-steps li:not(:last-child)::after { content: "→"; position: absolute; top: 50%; right: calc(var(--gap) / -2); transform: translate(50%, -50%); color: var(--zone); font-weight: 800; }
.cycle-back li:not(:last-child)::after { content: "←"; right: auto; left: calc(var(--gap) / -2); transform: translate(-50%, -50%); }
.tip { position: absolute; top: -9px; right: -9px; z-index: 2; width: 1.25rem; height: 1.25rem; padding: 0; border: 1px solid var(--zone); border-radius: 50%; background: var(--bg-0); color: var(--zone); font: 800 .7rem/1 var(--font-mono); cursor: help; }
.tip:hover, .tip:focus-visible { background: var(--zone); color: var(--bg-0); }
.tip-text { position: absolute; z-index: 20; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: min(16rem, 80vw); padding: var(--s-2) var(--s-3); border-radius: var(--r-2); background: var(--text-0); color: var(--bg-0); font-weight: 500; font-size: var(--fs-xs); line-height: 1.45; text-align: left; overflow-wrap: normal; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); visibility: hidden; opacity: 0; pointer-events: none; transition: opacity .12s; }
.tip-text code { display: block; margin-bottom: 2px; padding: 0; border: 0; background: none; color: color-mix(in srgb, var(--bg-0) 70%, transparent); font-size: var(--fs-xs); }
.tip:hover + .tip-text, .tip:focus-visible + .tip-text { visibility: visible; opacity: 1; }
.cycle-links { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); padding: 0 var(--s-2); font: 600 var(--fs-xs)/1.4 var(--font-mono); }
.cycle-link { margin: 0; padding: var(--s-4) var(--s-3); }
.cycle-link strong { display: block; font-size: var(--fs-sm); }
.cycle-link span { display: block; font-weight: 500; color: var(--text-1); }
.cycle-up { color: var(--ok); border-left: 3px solid var(--ok); }
.cycle-down { color: var(--orange); border-right: 3px solid var(--orange); text-align: right; }
@media (max-width: 760px) {
  .cycle-steps, .cycle-back { flex-direction: column; --gap: 28px; }
  .cycle-steps li:not(:last-child)::after, .cycle-back li:not(:last-child)::after { content: "↓"; top: auto; bottom: calc(var(--gap) / -2); left: 50%; right: auto; transform: translate(-50%, 50%); }
  .cycle-links { grid-template-columns: 1fr; }
  .cycle-links .cycle-up { order: 2; }
  .cycle-down { text-align: left; border-right: 0; border-left: 3px solid var(--orange); }
}
