/* BVB·INFO — phosphor terminal. Dark-committed; one amber accent;
   green/red reserved for price direction. */

:root {
  --ink: #0b0e11;
  --ink-2: #11161c;
  --line: #1e2733;
  --text: #e8ecef;
  --muted: #8a94a6;
  --amber: #ffb000;
  --up: #3fdc97;
  --down: #ff6b6b;
  --mono: "Martian Mono", ui-monospace, "SFMono-Regular", monospace;
  --sans: "Archivo", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  background:
    radial-gradient(1200px 400px at 70% -10%, rgba(255, 176, 0, 0.05), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(255, 255, 255, 0.008) 2px 4px),
    var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--amber); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: 10;
  background: var(--amber); color: var(--ink); font-family: var(--mono);
  font-size: 0.75rem; padding: 0.5rem 0.75rem; transition: top 120ms;
}
.skip-link:focus { top: 0.5rem; text-decoration: none; }

/* ── Masthead ── */
.masthead {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: baseline; gap: 1.25rem; flex-wrap: wrap;
  padding: 0.9rem 1.5rem;
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: baseline; gap: 0.6rem; }
.brand:hover, .brand:focus-visible { text-decoration: none; }
.brand-mark { color: var(--amber); font-size: 0.8rem; letter-spacing: 0.1em; }
.brand-name {
  font-family: var(--mono); font-weight: 800; font-size: 1.15rem;
  color: var(--text); letter-spacing: 0.04em;
}
.masthead-sub { color: var(--muted); font-size: 0.8rem; }
.masthead-nav { margin-left: auto; display: flex; gap: 1.25rem; align-items: baseline; }
.stamp { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }
.stamp-label { color: var(--amber); }
.api-link {
  font-family: var(--mono); font-size: 0.75rem; font-weight: 700;
  border: 1px solid var(--amber); padding: 0.35rem 0.7rem;
}
.api-link:hover, .api-link:focus-visible { background: var(--amber); color: var(--ink); text-decoration: none; }

main { padding: 0 1.5rem 3rem; max-width: 1500px; margin: 0 auto; }

/* ── Stat ticker ── */
.ticker {
  display: flex; flex-wrap: wrap; gap: 0.5rem 2.5rem;
  padding: 1rem 0; border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 0.72rem;
}
.tick-k { color: var(--muted); letter-spacing: 0.08em; }
.tick-v { font-weight: 700; }
.tick-accent { color: var(--amber); }

/* ── Layout ── */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px;
  gap: 2.5rem; align-items: start; padding-top: 1.5rem;
}
@media (max-width: 1000px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.board-head {
  display: flex; align-items: baseline; gap: 1.5rem; flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
h1 { font-family: var(--mono); font-size: 1.05rem; font-weight: 700; letter-spacing: 0.02em; }
h2 { font-family: var(--mono); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; }
.thin { font-weight: 300; color: var(--muted); }

/* prompt-style filter */
.prompt {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border-bottom: 1px solid var(--line); padding: 0.15rem 0.25rem;
}
.prompt:focus-within {
  border-bottom-color: var(--amber);
  outline: 2px solid var(--amber); outline-offset: 3px;
}
.prompt-sign { color: var(--amber); font-family: var(--mono); font-weight: 700; }
.prompt input {
  background: none; border: none; color: var(--text);
  font-family: var(--mono); font-size: 0.8rem; width: 15rem;
}
.prompt input:focus { outline: none; }
.prompt input::placeholder { color: var(--muted); }
.cursor { width: 0.5em; height: 1em; background: var(--amber); }
@media (prefers-reduced-motion: no-preference) {
  .cursor { animation: blink 1.1s steps(1) infinite; }
  @keyframes blink { 50% { opacity: 0; } }
}
.prompt:focus-within .cursor { display: none; }
.row-count { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); margin-left: auto; }

/* legend button + dialog */
.help-btn {
  background: none; border: 1px solid var(--line); color: var(--muted);
  font-family: var(--mono); font-size: 0.65rem; font-weight: 500;
  letter-spacing: 0.06em; padding: 0.35rem 0.6rem; cursor: pointer;
}
.help-btn:hover, .help-btn:focus-visible { border-color: var(--amber); color: var(--amber); }
.help-btn span { color: var(--amber); font-weight: 700; }

.legend {
  margin: auto; /* restore native <dialog> centering lost to the * reset */
  background: var(--ink-2); color: var(--text);
  border: 1px solid var(--line); border-top: 2px solid var(--amber);
  padding: 1.25rem 1.5rem; max-width: 44rem; width: calc(100vw - 2rem);
  max-height: 85vh; overflow-y: auto;
}
.legend::backdrop { background: rgba(4, 6, 8, 0.7); backdrop-filter: blur(2px); }
.legend-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 0.75rem; border-bottom: 1px solid var(--line); margin-bottom: 0.5rem;
}
.legend-close {
  background: none; border: none; color: var(--muted);
  font-size: 1rem; cursor: pointer; padding: 0.2rem 0.4rem;
}
.legend-close:hover, .legend-close:focus-visible { color: var(--amber); }
.legend-list div {
  display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem;
  padding: 0.6rem 0; border-bottom: 1px solid var(--line);
}
.legend-list div:last-child { border-bottom: none; }
.legend-list dt { font-family: var(--mono); font-size: 0.75rem; font-weight: 700; color: var(--amber); }
.legend-list dd { font-size: 0.85rem; color: var(--text); }
@media (max-width: 600px) {
  .legend-list div { grid-template-columns: 1fr; gap: 0.2rem; }
}

/* ── Tables ── */
.table-scroll { overflow-x: auto; }
table.grid {
  border-collapse: collapse; width: 100%;
  font-family: var(--mono); font-size: 0.74rem; font-weight: 400;
}
.grid caption { text-align: left; }
.grid thead th {
  background: var(--ink-2); color: var(--muted);
  font-weight: 500; font-size: 0.65rem; letter-spacing: 0.08em;
  text-align: right; padding: 0.5rem 0.7rem;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
/* Sticky header only where the wrapper doesn't horizontally scroll:
   an overflow container would hijack the sticky positioning. */
@media (min-width: 1001px) {
  .table-scroll { overflow: visible; }
  .grid:not(.slim) thead th { position: sticky; top: 3.7rem; z-index: 2; }
}
.grid td, .grid tbody th { padding: 0.42rem 0.7rem; text-align: right; border-bottom: 1px solid var(--line); }
.grid .t-left { text-align: left; }
.grid tbody tr { position: relative; }
.grid tbody tr:hover { background: rgba(255, 176, 0, 0.05); }
.grid tbody tr:hover .sym a { color: var(--amber); }
.sym a { color: var(--text); font-weight: 700; }
.co { color: var(--muted); font-family: var(--sans); font-size: 0.8rem;
      max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkt { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

/* row hover: amber rule sliding in on the left */
.grid tbody th.sym { border-left: 2px solid transparent; }
.grid tbody tr:hover th.sym { border-left-color: var(--amber); }

/* entrance stagger (first rows only) */
@media (prefers-reduced-motion: no-preference) {
  .grid tbody tr { animation: rise 240ms both; }
  .grid tbody tr:nth-child(n+11) { animation: none; }
  .grid tbody tr:nth-child(1)  { animation-delay: 20ms; }
  .grid tbody tr:nth-child(2)  { animation-delay: 40ms; }
  .grid tbody tr:nth-child(3)  { animation-delay: 60ms; }
  .grid tbody tr:nth-child(4)  { animation-delay: 80ms; }
  .grid tbody tr:nth-child(5)  { animation-delay: 100ms; }
  .grid tbody tr:nth-child(6)  { animation-delay: 120ms; }
  .grid tbody tr:nth-child(7)  { animation-delay: 140ms; }
  .grid tbody tr:nth-child(8)  { animation-delay: 160ms; }
  .grid tbody tr:nth-child(9)  { animation-delay: 180ms; }
  .grid tbody tr:nth-child(10) { animation-delay: 200ms; }
  @keyframes rise { from { opacity: 0; transform: translateY(4px); } }
}

/* ── Right rail ── */
.rail { display: grid; gap: 2rem; }
.rail-block h2 { padding-bottom: 0.6rem; border-bottom: 1px solid var(--line); margin-bottom: 0.4rem; }
.rail-copy { font-size: 0.82rem; color: var(--muted); margin: 0.6rem 0; }
.code {
  background: var(--ink-2); border: 1px solid var(--line);
  padding: 0.7rem 0.8rem; overflow-x: auto;
  font-family: var(--mono); font-size: 0.68rem; color: var(--amber);
}

/* ── Footer ── */
.footer {
  border-top: 1px solid var(--line); margin-top: 2rem;
  padding: 1.25rem 1.5rem 2rem; color: var(--muted); font-size: 0.78rem;
  display: grid; gap: 0.35rem;
}

/* ── Company page ── */
.crumb { padding: 1.25rem 0 0; font-family: var(--mono); font-size: 0.72rem; }
.crumb a { color: var(--muted); }
.crumb a:hover, .crumb a:focus-visible { color: var(--amber); }

.id-block {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 2rem; flex-wrap: wrap;
  padding: 1.5rem 0; border-bottom: 1px solid var(--line);
}
.symbol {
  font-family: var(--mono); font-weight: 800;
  font-size: clamp(2.6rem, 7vw, 4.5rem); line-height: 1;
  letter-spacing: 0.02em;
}
.co-name { font-size: 1.05rem; margin-top: 0.5rem; }
.co-meta { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); margin-top: 0.4rem; }
.co-meta span + span::before { content: " · "; color: var(--muted); }
.id-price { text-align: right; font-family: var(--mono); }
.px { font-size: 2.2rem; font-weight: 700; line-height: 1.1; }
.px-ccy { font-size: 0.9rem; font-weight: 300; color: var(--muted); }
.px-var { font-size: 0.85rem; font-weight: 700; }
.px-date { color: var(--muted); font-weight: 300; }

.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2.5rem; padding-top: 1.75rem;
}
.panel.wide { grid-column: 1 / -1; }
.panel h2 { padding-bottom: 0.6rem; border-bottom: 1px solid var(--line); margin-bottom: 0.5rem; }

.kv div {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.45rem 0; border-bottom: 1px solid var(--line);
}
.kv dt { color: var(--muted); font-size: 0.82rem; }
.kv dd { font-family: var(--mono); font-size: 0.78rem; font-weight: 500; }

.holder { font-family: var(--sans); font-weight: 500; font-size: 0.82rem; }
.pct-cell { position: relative; min-width: 9rem; }
.pct-bar {
  position: absolute; left: 0.4rem; right: auto; top: 50%; transform: translateY(-50%);
  height: 3px; width: calc(var(--w) * 0.55); max-width: 55%;
  background: var(--amber); opacity: 0.6;
}

.news { list-style: none; }
.news li {
  display: flex; gap: 1.25rem; padding: 0.55rem 0;
  border-bottom: 1px solid var(--line); font-size: 0.85rem;
}
.news-date { font-family: var(--mono); font-size: 0.68rem; color: var(--muted); white-space: nowrap; padding-top: 0.15rem; }
.news a { color: var(--text); }
.news a:hover, .news a:focus-visible { color: var(--amber); }

.api-hint {
  margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line);
  display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap;
  font-size: 0.82rem; color: var(--muted);
}

.empty { color: var(--muted); font-size: 0.82rem; padding: 0.5rem 0; }

@media (max-width: 700px) {
  .masthead { padding: 0.75rem 1rem; }
  .masthead-sub { display: none; }
  main { padding: 0 1rem 2rem; }
  .grid thead th { top: 3.1rem; }
  .id-price { text-align: left; }
}
