/*
 * Zion: one dark theme in the ascii-magic-art manner. Everything reads as a
 * character grid: frames with their title set in the top rule, [ bracket ]
 * buttons, █░ bars, split-flap numbers, terminal windows. Accent is the NFT
 * Neon palette.
 */
:root {
  --bg: #0a0b0f;
  --cell: #12141a;
  --raised: #151821;
  --line: #222734;
  --line-hi: #343b4c;
  --fg: #e6e4dc;
  --muted: #8b8fa3;
  --dim: #545a6b;
  --accent: #22ff9e;
  --accent-ink: #04140d;
  --accent-dim: #0f6b4a;
  --warn: #ffc15e;
  --err: #ff7a7a;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  --art: Menlo, "DejaVu Sans Mono", Consolas, monospace;
  --radius: 4px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.6 var(--mono); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; outline: none; padding-block: 32px 72px; }
.page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px; align-content: start; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 700; line-height: 1.25; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(24px, 4vw, 34px); letter-spacing: 0.02em; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.warn { color: var(--warn); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
:focus-visible { outline: 1px dashed var(--accent); outline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 6px 10px; z-index: 10; }
.skip:focus { left: 8px; }
.cursor { color: var(--accent); margin-left: 2px; animation: blink 1.05s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ── header, footer, demo bar ── */
.demo { background: #1a1405; border-bottom: 1px dashed #4a3a12; color: var(--warn); font-size: 13px; }
.demo-row { display: flex; gap: 12px 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding-block: 8px; }
.demo-tools summary { cursor: pointer; color: var(--warn); }
.demo-panel { display: grid; gap: 10px; padding: 12px 0 4px; color: var(--fg); }
.demo-panel label { display: flex; gap: 8px; align-items: center; }
.top { border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(10, 11, 15, 0.94); backdrop-filter: blur(6px); z-index: 5; }
.top-row { display: flex; align-items: center; gap: 24px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 700; letter-spacing: 0.24em; }
.brand:hover { text-decoration: none; color: var(--accent); }
.brand img { border-radius: 50%; }
.nav { display: flex; gap: 2px; flex: 1; }
.nav a { color: var(--muted); padding: 6px 10px; }
.nav a:hover { color: var(--fg); text-decoration: none; }
.nav a[aria-current] { color: var(--accent); }
.nav a[aria-current]::before { content: "> "; }
.social { display: flex; align-items: center; padding: 6px; color: var(--muted); }
.social:hover { color: var(--accent); }
.social svg { width: 18px; height: 18px; fill: currentColor; }
.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.foot-row { display: flex; flex-wrap: wrap; gap: 8px 24px; padding-block: 20px; }
.foot-row span::before { content: "// "; color: var(--dim); }
@media (max-width: 720px) {
  .top-row { flex-wrap: wrap; gap: 4px 12px; padding-block: 8px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; margin-inline: -10px; }
  .social { margin-left: auto; }
}

/* ── controls: [ bracket ] buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.6ch; font: 700 14px var(--mono); color: var(--accent); background: transparent; border: 0; padding: 8px 6px; cursor: pointer; text-decoration: none; min-height: 40px; letter-spacing: 0.02em; }
.btn::before { content: "["; color: var(--accent-dim); }
.btn::after { content: "]"; color: var(--accent-dim); }
.btn:hover { text-decoration: none; background: rgba(34, 255, 158, 0.08); }
.btn:hover::before, .btn:hover::after { color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); padding-inline: 12px; }
.btn.primary::before, .btn.primary::after { color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { color: var(--fg); }
.btn.ghost::before, .btn.ghost::after { color: var(--dim); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.05); }
.btn.small { font-size: 13px; padding: 4px 4px; min-height: 30px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.btn .muted { font-weight: 400; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
input, select, textarea { font: 15px var(--mono); color: var(--fg); background: var(--cell); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; min-height: 40px; }
input:focus, select:focus { border-color: var(--accent-dim); outline: none; }
input[type="checkbox"], input[type="radio"] { min-height: 0; accent-color: var(--accent); }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
label.field input { width: 100%; }
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line-hi); border-radius: var(--radius); background: var(--cell); }
.stepper button { width: 44px; background: none; border: 0; color: var(--accent); font: 700 18px var(--mono); cursor: pointer; }
.stepper button:disabled { color: var(--line-hi); cursor: not-allowed; }
.stepper output { min-width: 56px; display: grid; place-items: center; font-size: 22px; font-weight: 700; border-inline: 1px solid var(--line-hi); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: 700 14px var(--mono); padding: 10px 12px; cursor: pointer; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--accent); border-color: var(--accent); }
.tabs button[aria-selected="true"]::before { content: "> "; }

/* ── frames: the title sits in the top rule ── */
.panel { position: relative; border: 1px solid var(--line-hi); border-radius: var(--radius); padding: 26px 20px 20px; display: grid; gap: 16px; align-content: start; min-width: 0; }
.panel > h1:first-child, .panel > h2:first-child, .panel > h3:first-child {
  position: absolute; top: 0; left: 14px; transform: translateY(-50%); background: var(--bg); padding: 0 8px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: lowercase; color: var(--fg);
  display: flex; gap: 10px; align-items: center; max-width: calc(100% - 28px); white-space: nowrap; overflow: hidden;
}
.panel > h1:first-child::before, .panel > h2:first-child::before, .panel > h3:first-child::before { content: "──"; color: var(--dim); letter-spacing: 0; }
.panel > h1:first-child { font-size: 15px; text-transform: none; color: var(--accent); }
.section { display: grid; gap: 22px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.section-head h2::before { content: "## "; color: var(--accent-dim); }
.section-head h1::before { content: "> "; color: var(--accent-dim); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px 24px; align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 28px 24px; align-items: start; }
@media (max-width: 880px) { .grid-2, .grid-main { grid-template-columns: minmax(0, 1fr); } }

/* ── numbers: split-flap boards, stat strips, bars ── */
.flap { display: inline-flex; gap: 2px; vertical-align: middle; }
.flap > span { display: inline-grid; place-items: center; min-width: 1.15em; height: 1.55em; padding: 0 1px; background: linear-gradient(var(--cell) 0 49%, #000 49% 51%, #171a22 51%); border: 1px solid var(--line); border-radius: 2px; font-weight: 700; color: var(--fg); }
.flap > span.sep { min-width: 0.5em; background: none; border-color: transparent; }
.board { border: 1px solid var(--line-hi); border-radius: var(--radius); padding: 18px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; font-size: 20px; }
.board .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.board .s { font-size: 12px; color: var(--muted); }
.board-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.board-row .flap { font-size: 26px; }
.board-row .bar { flex: 1 1 0; min-width: 0; }
.board-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.board-grid > div { display: grid; gap: 6px; justify-items: start; min-width: 0; }
@media (max-width: 720px) { .board-grid { grid-template-columns: minmax(0, 1fr); } .board-row .flap { font-size: 20px; } }
.status { font-size: 12px; letter-spacing: 0.1em; margin-left: auto; }
.status.on { color: var(--accent); }
.status.off { color: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line-hi); border-radius: var(--radius); }
.stat { padding: 14px 16px; display: grid; gap: 2px; min-width: 0; border-right: 1px dashed var(--line); }
.stat:last-child { border-right: 0; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.stat .v { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.stat .s { color: var(--muted); font-size: 12px; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat:nth-child(2) { border-right: 0; } .stat:nth-child(-n + 2) { border-bottom: 1px dashed var(--line); } }
.bar { white-space: pre; letter-spacing: -0.02em; overflow: hidden; max-width: 100%; display: inline-block; vertical-align: middle; }
.bar .on { color: var(--accent); }
.bar .off { color: var(--line-hi); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 20px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dt::after { content: ":"; color: var(--dim); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; color: var(--muted); font-weight: 400; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--line-hi); padding: 4px 12px 8px 0; }
.tbl td { border-bottom: 1px dashed var(--line); padding: 8px 12px 8px 0; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; }
.tbl tr.mine td { color: var(--accent); }
.tbl tr.you td { background: rgba(34, 255, 158, 0.06); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.empty::before { content: "∅ "; color: var(--dim); }
.note { font-size: 13px; color: var(--muted); border-left: 1px solid var(--line-hi); padding-left: 12px; }
.note.warn { color: var(--warn); border-color: #5c4513; }
ol.steps, ul.list { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; }
ol.steps li { display: grid; grid-template-columns: 3ch 1fr; gap: 12px; }
ol.steps li::before { content: attr(data-n); color: var(--accent); font-weight: 700; }
ul.list li { display: grid; grid-template-columns: 2ch 1fr; gap: 8px; }
ul.list li::before { content: ">"; color: var(--accent-dim); }
ul.list.no li::before { content: "×"; color: var(--err); }
code, .code { font-family: var(--mono); background: var(--cell); border: 1px solid var(--line); border-radius: 3px; padding: 1px 6px; font-size: 13px; overflow-wrap: anywhere; }
.badge { display: inline-block; font-size: 11px; padding: 0 6px; border: 1px solid var(--line-hi); color: var(--muted); letter-spacing: 0.08em; }
.badge.on { color: var(--accent); border-color: var(--accent-dim); }
.badge.off { color: var(--warn); border-color: #5c4513; }

/* ── terminal window ── */
.term { border: 1px solid var(--line-hi); border-radius: 6px; background: #07080b; overflow: hidden; }
.term-bar { display: flex; align-items: center; gap: 12px; padding: 4px 6px 4px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.term-bar > span:nth-child(2) { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lights { display: inline-flex; gap: 6px; }
.lights i { width: 9px; height: 9px; border-radius: 50%; background: #ff5f56; }
.lights i:nth-child(2) { background: #ffbd2e; }
.lights i:nth-child(3) { background: #27c93f; }
.term-body { padding: 14px 16px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.prompt-sign { color: var(--accent); font-weight: 700; }

/* ── art ── */
pre.art { margin: 0; font-family: var(--art); line-height: 1.2; white-space: pre; overflow: hidden; color: #333; user-select: none; }
pre[data-divider] { margin: 0; width: 100%; line-height: 1; }
.frame { background: #000; border: 1px solid var(--line-hi); border-radius: var(--radius); padding: 14px; min-width: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
@media (max-width: 480px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card { background: #000; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: grid; gap: 6px; color: var(--fg); min-width: 0; }
.card:hover { border-color: var(--accent-dim); text-decoration: none; }
.card:hover .card-meta span:first-child { color: var(--accent); }
.card-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; }

/* ── home ── */
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; justify-items: center; text-align: center; }
.hero pre { width: 100%; min-width: 0; }
.hero .tag { letter-spacing: 0.3em; color: var(--accent); font-size: clamp(11px, 1.6vw, 14px); font-weight: 700; }
.hero .lead { max-width: 62ch; color: var(--muted); }

/* ── market ── */
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.filters select { width: 100%; }
.jump input { width: 100%; min-width: 0; }
@media (max-width: 720px) { .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card.preview .card-meta span:first-child { color: var(--warn); }

/* ── mint ── */
.ladder td:first-child { width: 4ch; color: var(--muted); }
.reveal { display: grid; gap: 16px; }

/* ── toasts ── */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 20; max-width: min(440px, calc(100vw - 32px)); }
.toast { background: #07080b; border: 1px solid var(--line-hi); border-radius: var(--radius); padding: 10px 14px; font-size: 14px; transition: opacity 0.4s, transform 0.4s; }
.toast b { color: var(--muted); }
.toast.ok b { color: var(--accent); }
.toast.error b { color: var(--err); }
.toast.out { opacity: 0; transform: translateY(6px); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } .cursor { animation: none; } }
