/* pengar.nu — chart chrome & ink follow the validated reference palette */

:root {
  color-scheme: light;
  --page:          #f9f9f7;
  --surface:       #fcfcfb;
  --ink:           #0b0b0b;
  --ink-2:         #52514e;
  --muted:         #898781;
  --grid:          #e1e0d9;
  --baseline:      #c3c2b7;
  --border:        rgba(11, 11, 11, 0.10);
  --series-1:      #2a78d6;  /* blue — the single data hue */
  --series-1-deep: #1c5cab;
  --accent-wash:   rgba(42, 120, 214, 0.10);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:          #0d0d0d;
    --surface:       #1a1a19;
    --ink:           #ffffff;
    --ink-2:         #c3c2b7;
    --muted:         #898781;
    --grid:          #2c2c2a;
    --baseline:      #383835;
    --border:        rgba(255, 255, 255, 0.10);
    --series-1:      #3987e5;
    --series-1-deep: #6da7ec;
    --accent-wash:   rgba(57, 135, 229, 0.12);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- masthead ---------- */
.masthead { padding: 40px 0 8px; }
.brand { margin: 0; font-weight: 700; letter-spacing: 0.02em; color: var(--ink-2); }
.brand-dot { color: var(--series-1); }
.masthead h1 { margin: 6px 0 4px; font-size: clamp(1.8rem, 4.5vw, 2.6rem); line-height: 1.15; }
.tagline { margin: 0; color: var(--ink-2); }

.loading, .error { color: var(--muted); padding: 40px 0; }

/* ---------- sections ---------- */
section { margin: 36px 0; }
section > h2 { font-size: 1.35rem; margin: 0 0 4px; }
section > .section-sub { margin: 0 0 16px; color: var(--ink-2); max-width: 62ch; }

/* ---------- hero ---------- */
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 26px 10px;
}
.hero-label { margin: 0; color: var(--ink-2); }
.hero-figure {
  margin: 2px 0 0;
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.015em;
}
.hero-note { margin: 4px 0 14px; color: var(--muted); font-size: 0.85rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 14px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.tile .t-label { margin: 0; font-size: 0.85rem; color: var(--ink-2); }
.tile .t-value { margin: 2px 0 0; font-size: 1.5rem; font-weight: 650; }
.tile .t-sub { margin: 2px 0 0; font-size: 0.8rem; color: var(--muted); }

/* ---------- charts ---------- */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 18px 10px;
  margin-top: 14px;
}
.chart-card h3 { margin: 0; font-size: 1.02rem; }
.chart-card .chart-sub { margin: 2px 0 10px; font-size: 0.85rem; color: var(--ink-2); }
.chart-host { position: relative; }
.chart-host svg { display: block; width: 100%; height: auto; }
.chart-host text { font: 12px system-ui, -apple-system, "Segoe UI", sans-serif; fill: var(--muted); font-variant-numeric: tabular-nums; }

.viz-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  padding: 8px 11px;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: nowrap;
  z-index: 5;
  display: none;
}
.viz-tooltip .tt-period { color: var(--ink-2); }
.viz-tooltip .tt-value { font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- share bars ---------- */
.share-rows { margin-top: 6px; }
.share-row { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; padding: 5px 0; }
.share-code { font-weight: 650; font-size: 0.88rem; }
.share-track { position: relative; height: 22px; }
.share-fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--series-1);
  border-radius: 0 4px 4px 0;
  min-width: 2px;
}
.share-val {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 0.8rem; color: var(--ink-2); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.comp-row { grid-template-columns: minmax(150px, 240px) 1fr; }
.comp-label { font-size: 0.85rem; color: var(--ink-2); line-height: 1.25; }
.comp-other { background: var(--baseline); border-radius: 0 4px 4px 0; }
.share-val-inside { color: #fff; }

.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.chart-toggle { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.toggle-btn {
  font: 0.8rem/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 7px 12px;
  background: var(--surface);
  color: var(--ink-2);
  border: 0;
  cursor: pointer;
}
.toggle-btn + .toggle-btn { border-left: 1px solid var(--border); }
.toggle-btn.active { background: var(--accent-wash); color: var(--series-1-deep); font-weight: 600; }

table.data th.sortable, table.data th { cursor: pointer; user-select: none; }

/* ---------- currency cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; margin-top: 14px; }
.ccy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ccy-head { display: flex; align-items: baseline; gap: 8px; }
.ccy-code { font-size: 1.15rem; font-weight: 700; }
.ccy-name { color: var(--ink-2); font-size: 0.9rem; }
.ccy-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ccy-stat .s-label { margin: 0; font-size: 0.78rem; color: var(--ink-2); }
.ccy-stat .s-value { margin: 0; font-weight: 650; font-size: 1.12rem; }
.ccy-stat .s-usd { margin: 0; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ccy-spark { margin-top: 2px; }
.ccy-spark .spark-label { margin: 0 0 2px; font-size: 0.78rem; color: var(--ink-2); }
.ccy-meta { margin: 0; font-size: 0.8rem; color: var(--muted); }
.ccy-meta strong { color: var(--ink-2); font-weight: 600; }
.ccy-debt { margin: 0; font-size: 0.8rem; color: var(--ink-2); border-top: 1px solid var(--grid); padding-top: 8px; }

/* ---------- facts ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 14px; }
.fact {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.fact .f-value { margin: 0; font-size: 1.9rem; font-weight: 650; color: var(--series-1-deep); }
.fact .f-text { margin: 4px 0 0; font-size: 0.85rem; color: var(--ink-2); }

.issuers { margin: 14px 0 0; padding: 0; list-style: none; }
.issuers li { padding: 7px 0; border-top: 1px solid var(--grid); font-size: 0.9rem; color: var(--ink-2); }
.issuers li:first-child { border-top: 0; }
.issuers strong { color: var(--ink); font-weight: 650; }

/* ---------- table view ---------- */
details.table-view { margin-top: 16px; }
details.table-view summary { cursor: pointer; color: var(--ink-2); font-size: 0.9rem; }
.table-scroll { overflow-x: auto; margin-top: 10px; }
table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.86rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
table.data th, table.data td {
  text-align: right;
  padding: 7px 12px;
  border-top: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.data th { color: var(--ink-2); font-weight: 600; border-top: 0; }
table.data th:first-child, table.data td:first-child { text-align: left; }

/* ---------- sources & footer ---------- */
.sources { margin: 10px 0 0; padding: 0; list-style: none; font-size: 0.84rem; color: var(--ink-2); }
/* Source URLs are long and unbreakable; without this they push the whole
   page sideways on a phone. */
.sources li { padding: 6px 0; border-top: 1px solid var(--grid); overflow-wrap: anywhere; }
.sources li:first-child { border-top: 0; }
.sources a { color: var(--series-1-deep); text-decoration: none; }
.sources a:hover { text-decoration: underline; }
.caveats { font-size: 0.85rem; color: var(--ink-2); max-width: 72ch; }
.caveats li { margin: 6px 0; }

.footnote { padding: 26px 20px 40px; color: var(--muted); font-size: 0.82rem; }
.footnote a { color: inherit; }
