/* Peak Arena UI. Light theme with a dark variant; readable on a laptop and on a
   projector, so type is large, contrast high and tables airy. */

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-alt: #fbfaf8;
  --border: #dedcd6;
  --border-strong: #c6c3bb;
  --text: #191917;
  --text-soft: #4e4d48;
  --muted: #6f6e68;
  --accent: #12507f;
  --accent-soft: #e6eef6;
  --ok: #16794a;
  --ok-soft: #e3f2e9;
  --warn: #8a5a00;
  --warn-soft: #fbf0dc;
  --bad: #a52418;
  --bad-soft: #fbe7e4;
  --gold: #a7791b;
  --code-inline: #eae8e2;
  --code-bg: #1d2127;
  --code-text: #e9eaec;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1b1e23;
    --surface-alt: #20242a;
    --border: #30353d;
    --border-strong: #434a54;
    --text: #edeef0;
    --text-soft: #c4c7cc;
    --muted: #969ba3;
    --accent: #74b3f0;
    --accent-soft: #1c2c3c;
    --ok: #62c78d;
    --ok-soft: #17301f;
    --warn: #e0b341;
    --warn-soft: #322713;
    --bad: #f0827a;
    --bad-soft: #351c1a;
    --gold: #d9ac4a;
    --code-inline: #2b3038;
    --code-bg: #0f1216;
    --code-text: #e2e4e7;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 var(--sans);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: var(--mono); font-variant-ligatures: none; }

h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

p { margin: 0.6em 0; }

.muted { color: var(--muted); }
.soft { color: var(--text-soft); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack > * + * { margin-top: 1rem; }
.stack > h2 { margin-top: 1.9rem; }

/* ---------- chrome ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 0.7rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; fill: var(--accent); }

.nav { display: flex; gap: 0.35rem; }
.nav a {
  padding: 0.3rem 0.75rem;
  border-radius: 99px;
  color: var(--text-soft);
  font-weight: 550;
}
.nav a:hover { background: var(--surface-alt); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.origin { color: var(--muted); font-size: 0.8rem; }

.view { flex: 1; width: 100%; max-width: 1160px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }

.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- blocks ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

.page-head { display: flex; align-items: baseline; gap: 0.9rem; flex-wrap: wrap; margin-bottom: 0.35rem; }
.page-head h1 { margin-right: 0.2rem; }
.page-sub { color: var(--muted); margin: 0 0 1.4rem; }

.hero h1 { font-size: 2.2rem; }
.hero p { font-size: 1.1rem; max-width: 62ch; color: var(--text-soft); }

/* An author display rule beats the browser's own [hidden] handling, so any
   element toggled with .hidden stays visible. Say it once, first. */
[hidden] { display: none !important; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.5rem;
  border-radius: 5px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
}
.chip--mock { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.12rem 0.55rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--neutral { background: var(--surface-alt); border-color: var(--border); color: var(--text-soft); }
.badge--accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--bad { background: var(--bad-soft); color: var(--bad); }

.badge--daily { background: var(--bad-soft); color: var(--bad); }
.badge--sometimes { background: var(--warn-soft); color: var(--warn); }
.badge--never { background: var(--ok-soft); color: var(--ok); }
.badge--unknown { background: var(--surface-alt); border-color: var(--border); color: var(--muted); }
.badge-repo { font-weight: 500; opacity: 0.75; font-family: var(--mono); font-size: 0.74rem; }

.callout {
  border-left: 4px solid var(--warn);
  background: var(--warn-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.75rem 1rem;
  color: var(--text);
}
.callout strong { display: block; }

/* ---------- commands ---------- */

.cmd {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--code-bg);
  border-radius: 6px;
  overflow: hidden;
  margin: 0.5rem 0;
}
.cmd pre {
  margin: 0;
  padding: 0.6rem 0.85rem;
  overflow-x: auto;
  flex: 1;
  color: var(--code-text);
  font-size: 0.95rem;
}
.cmd pre::before { content: "$ "; color: #7f8d9c; }
.cmd--plain pre::before { content: none; }
.copy {
  border: 0;
  border-left: 1px solid rgb(255 255 255 / 12%);
  background: transparent;
  color: #a9b4c0;
  font: 600 0.8rem var(--sans);
  padding: 0 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.copy:hover { background: rgb(255 255 255 / 8%); color: #fff; }
.copy.done { color: #79d39c; }

pre.block {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.85rem 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  max-height: 26rem;
}
.statement {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  font-size: 1.02rem;
  overflow-wrap: break-word;
}
.statement > * { margin: 0; }
.statement > * + * { margin-top: 0.75rem; }
.statement h2 { font-size: 1.15rem; }
.statement h3 { font-size: 1.02rem; }
.statement > h2, .statement > h3 { margin-top: 1.5rem; }
.statement ul { padding-left: 1.3rem; }
.statement li + li { margin-top: 0.4rem; }
.statement code, .callout code {
  background: var(--code-inline);
  padding: 0 0.25rem;
  border-radius: 3px;
  font-size: 0.92em;
}
/* The <code> inside a command block is the block's own text, not an inline span. */
.statement .cmd code, .cmd code { background: none; padding: 0; border-radius: 0; font-size: inherit; }

/* ---------- steps ---------- */

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 1.4rem 3rem;
  border-left: 2px solid var(--border);
  margin-left: 1rem;
}
.steps > li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: -1rem;
  top: -0.15rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font: 650 0.95rem var(--sans);
}
.steps h3 { margin-bottom: 0.2rem; }
.steps p { margin-top: 0.15rem; }

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.grid thead th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 650;
  background: var(--surface-alt);
  white-space: nowrap;
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid tbody tr.clickable:hover { background: var(--accent-soft); }
table.grid td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid .name { font-weight: 600; }

.cost {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
/* Alignment has to out-specify `table.grid th`. */
table.grid th.right, table.grid td.right,
table.grid th.cost-col, table.grid td.cost-cell { text-align: right; }
table.grid td.cost-cell { background: var(--surface-alt); }
table.grid .name { white-space: nowrap; }

.rank {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
  width: 3rem;
}
.rank--top { color: var(--gold); }

/* ---------- sections ---------- */

.section { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.section > summary {
  cursor: pointer;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 650;
  background: var(--surface-alt);
  list-style: none;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary::before {
  content: "";
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-left-color: var(--muted);
  transition: transform 0.12s ease;
}
.section[open] > summary::before { transform: rotate(90deg) translateX(2px); }
.section > summary .count { color: var(--muted); font-weight: 500; font-family: var(--mono); font-size: 0.85rem; }
.section > summary .hint { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 0.82rem; }
.section-body { padding: 0; border-top: 1px solid var(--border); }
.section-body .table-wrap { border: 0; border-radius: 0; }

.board-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------- key / value ---------- */

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.9rem 1.5rem; }
.kv > div { min-width: 0; }
.kv dt, .kv .k { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650; }
.kv .v { font-size: 1.15rem; font-family: var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv .v--big { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }

/* ---------- cards grid ---------- */

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 1rem; }
.task-card { display: flex; flex-direction: column; gap: 0.6rem; }
.task-card:hover { border-color: var(--border-strong); }
.task-card h2 a { color: var(--text); }
.task-card .meta { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.task-card .leader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
  margin-top: auto;
}
.task-card .counts { display: flex; gap: 1.1rem; color: var(--muted); font-size: 0.88rem; }
.task-card .counts b { color: var(--text); font-family: var(--mono); }

/* ---------- forms ---------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.field > span { font-size: 0.8rem; font-weight: 650; color: var(--text-soft); }
.field > span .mono { font-size: 0.78rem; color: var(--muted); }
input[type="text"], input[type="search"], input[type="password"], select {
  font: inherit;
  font-size: 1rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible, tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
button.primary {
  font: 650 1rem var(--sans);
  padding: 0.5rem 1.2rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button.primary:hover { filter: brightness(1.1); }
button.primary[disabled] { opacity: 0.55; cursor: progress; }
button.ghost {
  font: 550 0.85rem var(--sans);
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
}
button.ghost:hover { background: var(--surface-alt); }
button.ghost.done { color: var(--ok); border-color: var(--ok); }

.search-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.search-row input[type="search"] { flex: 1; max-width: 26rem; }

.uid-panel { background: var(--ok-soft); border: 1px solid var(--ok); }
.uid-big {
  font-family: var(--mono);
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.1;
}
.uid { font-family: var(--mono); font-weight: 600; letter-spacing: 0.04em; }

/* ---------- states ---------- */

.state { display: flex; align-items: center; gap: 0.6rem; padding: 1.5rem 0; color: var(--muted); }
.spinner {
  width: 1.05rem;
  height: 1.05rem;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.error-box {
  border-left: 4px solid var(--bad);
  background: var(--bad-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.85rem 1rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.error-box .msg { font-weight: 600; }
.error-box .detail { color: var(--text-soft); font-size: 0.9rem; }

.empty { padding: 1.1rem; color: var(--muted); font-style: italic; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .view { padding: 1.25rem 1rem 2.5rem; }
  .topbar { padding: 0.6rem 1rem; gap: 0.75rem; }
  .topbar-meta { margin-left: 0; }
  .hero h1 { font-size: 1.7rem; }
  .steps > li { padding-left: 2.5rem; }
  .cost { font-size: 1.15rem; }
}

.task-card { cursor: pointer; }

/* The landing page: a door, so it is centred and quiet rather than dense. */
body.closed .nav,
body.closed .footer-right { visibility: hidden; }

.gate { align-items: center; text-align: center; max-width: 46rem; margin: 0 auto; gap: 1.1rem; }
.peak-mark { width: 100%; max-width: 22rem; height: auto; border-radius: 10px; }
.gate-title { font-size: clamp(2.2rem, 7vw, 3.4rem); letter-spacing: -0.02em; margin: 0; }
.gate-lead { font-size: 1.15rem; color: var(--text-soft); max-width: 34rem; margin: 0 auto; }

.countdown { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.9rem 1.4rem; }
.count-value { font-size: clamp(1.6rem, 5vw, 2.4rem); font-variant-numeric: tabular-nums; font-weight: 600; }
.count-label { font-size: 0.85rem; }

.gate-teaser { display: grid; gap: 0.7rem; text-align: left; width: 100%; }
.tease { display: grid; gap: 0.15rem; padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.tease span { font-size: 0.92rem; }

.gate-form { width: 100%; max-width: 26rem; margin: 0 auto; text-align: left; }

@media (min-width: 44rem) {
  .gate-teaser { grid-template-columns: repeat(3, 1fr); }
}
