/* ===========================================================================
   Ideogram 4 — A prompt is a scene graph. House style: dark editorial.
   OKLCH amber + teal on near-black. EB Garamond prose, JetBrains Mono system.
   =========================================================================== */

:root {
  --bg:        oklch(0.16 0.012 250);
  --surface:   oklch(0.21 0.015 250);
  --surface-2: oklch(0.25 0.016 250);
  --ink:       oklch(0.92 0.01 250);
  --muted:     oklch(0.66 0.012 250);
  --amber:     oklch(0.80 0.13 75);
  --amber-dim: oklch(0.80 0.13 75 / 0.14);
  --teal:      oklch(0.78 0.10 195);
  --teal-dim:  oklch(0.78 0.10 195 / 0.14);
  --rose:      oklch(0.70 0.16 18);
  --rule:      oklch(0.30 0.01 250);

  --serif: "EB Garamond", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --mono:  "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --maxw: 1080px;
  --pad: clamp(1rem, 4vw, 2.5rem);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* faint grain + cool vignette for atmosphere, not decoration */
  background-image:
    radial-gradient(120% 80% at 50% -10%, oklch(0.22 0.02 250 / 0.6), transparent 60%),
    radial-gradient(80% 60% at 100% 100%, oklch(0.20 0.03 230 / 0.4), transparent 70%);
  background-attachment: fixed;
}

/* ---------- typography ---------- */
h1, h2, h3 { font-weight: 600; line-height: 1.12; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.7rem, 4vw, 2.6rem); margin: 0 0 0.4em; }
h3 { font-size: 1.4rem; margin: 1.6em 0 0.5em; }
p { margin: 0 0 1em; max-width: 68ch; }
a { color: var(--teal); text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--teal); }
code, .mono, kbd { font-family: var(--mono); font-size: 0.86em; }
.kicker {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--amber); margin: 0 0 1rem;
}
.lead { font-size: 1.25rem; color: var(--ink); }
.muted { color: var(--muted); }

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding-inline: var(--pad); }
section { padding-block: clamp(3rem, 8vw, 6rem); border-top: 1px solid var(--rule); }
section:first-of-type { border-top: none; }
.section-num {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.2em;
  color: var(--teal); text-transform: uppercase;
}

/* ---------- skip link ---------- */
.skip {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--amber); color: var(--bg); padding: 0.6rem 1rem;
  font-family: var(--mono); font-size: 0.8rem; border-radius: 0 0 6px 0;
}
.skip:focus { left: 0; }

/* ---------- top nav / tabs ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
  background: oklch(0.16 0.012 250 / 0.82);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0.6rem var(--pad);
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
}
.brand {
  font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.12em;
  color: var(--ink); white-space: nowrap;
}
.brand b { color: var(--amber); font-weight: 500; }
.tabs { display: flex; gap: 0.25rem; margin-left: auto; }
.tab {
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.04em;
  background: none; border: 1px solid transparent; color: var(--muted);
  padding: 0.4rem 0.9rem; border-radius: 999px; cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
  color: var(--bg); background: var(--amber); border-color: var(--amber);
}
.tab:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.view { display: none; }
.view.active { display: block; animation: fade 0.4s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- hero ---------- */
.hero { padding-block: clamp(4rem, 12vw, 8rem) clamp(3rem, 8vw, 5rem); }
.hero h1 {
  font-size: clamp(2.6rem, 8vw, 5.2rem);
  font-style: italic; font-weight: 500; margin: 0 0 0.4em;
  max-width: 16ch;
}
.hero h1 .gx { color: var(--amber); font-style: normal; }
.hero .lead { max-width: 56ch; }
.hero-meta {
  margin-top: 2.5rem; display: flex; gap: 2rem; flex-wrap: wrap;
  font-family: var(--mono); font-size: 0.78rem; color: var(--muted);
}
.hero-meta b { color: var(--teal); font-weight: 500; }

/* staggered reveal */
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.in { animation: rise 0.7s cubic-bezier(0.22,1,0.36,1) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ---------- terms (hover-to-define) ---------- */
.term {
  color: var(--amber); cursor: help; border-bottom: 1px dotted var(--amber);
  background: none; border-left: none; border-right: none; border-top: none;
  font: inherit; padding: 0; line-height: inherit;
}
.term:hover, .term:focus-visible { background: var(--amber-dim); outline: none; }
.term:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

.popover {
  position: fixed; z-index: 120; max-width: 320px;
  background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: 10px; padding: 0.8rem 0.95rem;
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.5;
  color: var(--ink); box-shadow: 0 14px 40px oklch(0 0 0 / 0.5);
  pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}
.popover.show { opacity: 1; transform: none; }
.popover .pt { color: var(--amber); display: block; margin-bottom: 0.3rem; letter-spacing: 0.05em; }
.popover .more { color: var(--muted); display: block; margin-top: 0.4rem; font-size: 0.72rem; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: oklch(0.1 0.01 250 / 0.72); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 1.5rem;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 14px; max-width: 480px; width: 100%; padding: 1.8rem;
  box-shadow: 0 30px 80px oklch(0 0 0 / 0.6);
  animation: pop 0.25s cubic-bezier(0.22,1,0.36,1);
}
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: none; } }
.modal h3 { margin: 0 0 0.2rem; font-family: var(--mono); font-size: 1rem; color: var(--amber); letter-spacing: 0.04em; }
.modal .tag { font-family: var(--mono); font-size: 0.7rem; color: var(--teal); text-transform: uppercase; letter-spacing: 0.2em; }
.modal p { font-size: 1.02rem; margin: 0.9rem 0 0; color: var(--ink); }
.modal-close {
  position: absolute; top: 1rem; right: 1rem; background: none; border: 1px solid var(--rule);
  color: var(--muted); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-family: var(--mono);
}
.modal-close:hover { color: var(--ink); border-color: var(--ink); }
.modal-wrap { position: relative; }

/* ---------- two eras diagram ---------- */
.eras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-top: 2rem; }
.era {
  border: 1px solid var(--rule); border-radius: 12px; padding: 1.3rem;
  background: var(--surface); position: relative;
}
.era h3 { margin: 0 0 0.2rem; font-size: 1.05rem; font-family: var(--mono); letter-spacing: 0.02em; }
.era .enc { font-family: var(--mono); font-size: 0.7rem; color: var(--teal); text-transform: uppercase; letter-spacing: 0.15em; }
.era .sample {
  margin-top: 0.9rem; font-family: var(--mono); font-size: 0.74rem; line-height: 1.5;
  color: var(--muted); background: var(--bg); border: 1px solid var(--rule);
  border-radius: 8px; padding: 0.7rem; min-height: 6.5rem; overflow: hidden;
}
.era.now { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber-dim); }
.era.now h3 { color: var(--amber); }
.kw { color: var(--rose); }
.era .arrow { display: none; }
.eras-arrows { color: var(--rule); }

/* ---------- schema tree ---------- */
.tree { font-family: var(--mono); font-size: 0.86rem; margin-top: 1.5rem; }
.tree details { border-left: 1px solid var(--rule); margin-left: 0.4rem; padding-left: 0.9rem; }
.tree > details { border-left: none; margin-left: 0; padding-left: 0; }
.tree summary {
  cursor: pointer; padding: 0.35rem 0; list-style: none; display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap;
}
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "▸"; color: var(--teal); transition: transform 0.2s; display: inline-block; }
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree .fkey { color: var(--amber); }
.tree .ftype { color: var(--muted); }
.tree .node-desc { color: var(--muted); font-family: var(--serif); font-size: 1rem; margin: 0.1rem 0 0.6rem 1.4rem; max-width: 60ch; }
.badge {
  font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.12em;
  padding: 0.1rem 0.45rem; border-radius: 999px; border: 1px solid;
}
.badge.req { color: var(--amber); border-color: var(--amber); }
.badge.opt { color: var(--muted); border-color: var(--rule); }
.order-chip {
  font-family: var(--mono); font-size: 0.72rem; color: var(--teal);
  background: var(--teal-dim); border-radius: 6px; padding: 0.05rem 0.4rem;
}

/* ---------- generic card grid ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1.8rem; }
.card { border: 1px solid var(--rule); border-radius: 12px; padding: 1.4rem; background: var(--surface); }
.card h3 { margin-top: 0; }
.card.fork-photo { border-top: 3px solid var(--teal); }
.card.fork-art { border-top: 3px solid var(--amber); }

/* key-order table */
table.ko { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.78rem; margin-top: 0.8rem; }
table.ko td, table.ko th { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.ko th { color: var(--teal); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.66rem; }
table.ko .seq { color: var(--amber); }

/* swatches */
.swatches { display: flex; gap: 0; margin-top: 1rem; border-radius: 8px; overflow: hidden; border: 1px solid var(--rule); }
.swatch { flex: 1; height: 46px; position: relative; }
.swatch span {
  position: absolute; inset: auto 0 4px 0; text-align: center; font-family: var(--mono);
  font-size: 0.58rem; color: oklch(1 0 0 / 0.85); text-shadow: 0 1px 2px oklch(0 0 0 / 0.7);
}

/* ---------- signature: caption inspector ---------- */
.inspector {
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 1.5rem; margin-top: 2rem;
  align-items: start;
}
.json-panel {
  background: var(--bg); border: 1px solid var(--rule); border-radius: 12px;
  padding: 1.1rem 1.2rem; font-family: var(--mono); font-size: 0.78rem; line-height: 1.7;
  overflow-x: auto; white-space: pre; tab-size: 2;
}
.json-panel .j-key { color: var(--amber); }
.json-panel .j-str { color: var(--teal); }
.json-panel .j-num { color: oklch(0.85 0.13 75); }
.json-panel .j-punct { color: var(--muted); }
.el { display: inline; border-radius: 5px; transition: background 0.15s, box-shadow 0.15s; cursor: pointer; }
.el:hover, .el.active { background: oklch(0.30 0.02 250 / 0.9); box-shadow: inset 0 0 0 1px var(--rule); }
.el.active { box-shadow: inset 0 0 0 1px var(--amber); }
.el:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

.canvas-wrap { position: sticky; top: 5rem; }
.canvas-stage {
  position: relative; border: 1px solid var(--rule); border-radius: 12px;
  background: var(--surface); padding: 0.9rem; aspect-ratio: 1; width: 100%;
}
#bboxCanvas { width: 100%; height: 100%; display: block; border-radius: 6px; cursor: crosshair; }
.axis-note {
  font-family: var(--mono); font-size: 0.68rem; color: var(--muted);
  margin-top: 0.7rem; display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap;
}
.axis-note b { color: var(--teal); }
.el-readout {
  margin-top: 0.8rem; min-height: 2.5rem; font-family: var(--mono); font-size: 0.74rem;
  color: var(--muted); border-left: 2px solid var(--rule); padding-left: 0.7rem;
}
.el-readout.on { border-color: var(--amber); color: var(--ink); }

/* ---------- footguns ---------- */
.guns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.2rem; margin-top: 1.8rem; }
.gun { border: 1px solid var(--rule); border-left: 3px solid var(--rose); border-radius: 10px; padding: 1.1rem 1.2rem; background: var(--surface); }
.gun h3 { margin: 0 0 0.3rem; font-family: var(--mono); font-size: 0.9rem; color: var(--rose); }
.gun .bad, .gun .good { font-family: var(--mono); font-size: 0.76rem; display: block; padding: 0.15rem 0; }
.gun .bad { color: var(--rose); }
.gun .bad::before { content: "✗ "; }
.gun .good { color: var(--teal); }
.gun .good::before { content: "✓ "; }

/* ---------- comparison ---------- */
.cmp-scroll { overflow-x: auto; margin-top: 1.8rem; border: 1px solid var(--rule); border-radius: 12px; }
table.cmp { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 640px; }
table.cmp th, table.cmp td { padding: 0.8rem 1rem; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.cmp thead th { font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); background: var(--surface); }
table.cmp tbody th { font-family: var(--mono); font-size: 0.8rem; color: var(--teal); font-weight: 500; }
table.cmp td { color: var(--ink); font-size: 0.86rem; }
table.cmp col.now, table.cmp .now-col { background: var(--amber-dim); }
table.cmp thead .now-col { color: var(--amber); }

/* ---------- pipeline ---------- */
.pipe { display: flex; align-items: stretch; gap: 0; margin-top: 2rem; flex-wrap: wrap; }
.stage {
  flex: 1 1 120px; border: 1px solid var(--rule); border-radius: 10px; padding: 0.9rem;
  background: var(--surface); text-align: center; position: relative; min-width: 120px;
}
.stage .sl { font-family: var(--mono); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--teal); }
.stage .sn { font-family: var(--serif); font-size: 1.05rem; margin-top: 0.3rem; }
.stage.hot { border-color: var(--amber); }
.stage.hot .sl { color: var(--amber); }
.pipe .sep { display: flex; align-items: center; color: var(--rule); font-family: var(--mono); padding: 0 0.4rem; }
.pipe-note { margin-top: 1.2rem; font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.pipe-note b { color: var(--amber); }

/* ---------- skill view ---------- */
.skill-head { padding-block: clamp(2.5rem, 6vw, 4rem) 1.5rem; }
.file-tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; margin: 1.5rem 0 0; }
.file-tab {
  font-family: var(--mono); font-size: 0.74rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--rule); border-bottom: none;
  padding: 0.45rem 0.9rem; border-radius: 8px 8px 0 0; cursor: pointer;
}
.file-tab[aria-selected="true"] { color: var(--amber); background: var(--bg); border-color: var(--rule); position: relative; top: 1px; }
.file-tab:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
.file-bar { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--rule); padding-top: 0.8rem; margin-top: -1px; gap: 1rem; flex-wrap: wrap; }
.file-path { font-family: var(--mono); font-size: 0.74rem; color: var(--teal); }
.copy-btn {
  font-family: var(--mono); font-size: 0.72rem; color: var(--bg); background: var(--teal);
  border: none; border-radius: 7px; padding: 0.4rem 0.9rem; cursor: pointer;
}
.copy-btn:hover { background: var(--amber); }
.copy-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.doc { margin-top: 1.2rem; }
/* rendered markdown */
.doc h1 { font-family: var(--serif); font-size: 2rem; color: var(--ink); margin: 1.2em 0 0.3em; }
.doc h2 { font-size: 1.5rem; border-top: 1px solid var(--rule); padding-top: 1rem; margin-top: 1.6em; }
.doc h3 { font-size: 1.15rem; color: var(--amber); font-family: var(--mono); }
.doc table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.78rem; margin: 1em 0; }
.doc th, .doc td { border: 1px solid var(--rule); padding: 0.4rem 0.6rem; text-align: left; }
.doc th { color: var(--teal); background: var(--surface); }
.doc ul, .doc ol { max-width: 70ch; }
.doc li { margin: 0.3em 0; }
.doc p code, .doc li code, .doc td code { background: var(--surface-2); color: var(--amber); padding: 0.1em 0.35em; border-radius: 4px; }
.doc pre {
  background: var(--bg); border: 1px solid var(--rule); border-radius: 10px;
  padding: 1rem 1.1rem; overflow-x: auto; font-family: var(--mono); font-size: 0.78rem; line-height: 1.6;
}
.doc pre code { color: var(--ink); }
.raw-code {
  background: var(--bg); border: 1px solid var(--rule); border-radius: 10px;
  padding: 1rem 1.1rem; overflow-x: auto; font-family: var(--mono); font-size: 0.76rem;
  line-height: 1.6; white-space: pre; color: var(--ink); margin-top: 1.2rem;
}
.skill-intro { max-width: 70ch; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--rule); padding-block: 2.5rem; font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }
footer a { color: var(--teal); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .eras { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .inspector { grid-template-columns: 1fr; }
  .canvas-wrap { position: static; }
  .guns { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  body { font-size: 1.05rem; }
  .hero-meta { gap: 1rem; }
  .tabs { width: 100%; }
}
