/* ─── Design Tokens ─────────────────────────────────────── */

html,
html[data-theme='dark'] {
  --bg: #0a1020;
  --paper: #0f1626;
  --paper2: #19223a;
  --ink: #dbe2f1;
  --mut: #7e8aa8;
  --line: #2a3556;
  --fill: #222c46;
  --up: #2ec78c;
  --down: #ff6f5e;
  --hi: #5b8cff;
  --hi-tx: #0a1020;
  --frame: #1c2742;
  --chrome: #0c1322;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

html[data-theme='light'] {
  --bg: #e3e8f2;
  --paper: #f5f7fb;
  --paper2: #eaeef6;
  --ink: #16203a;
  --mut: #6a7691;
  --line: #d3dae8;
  --fill: #dde4f0;
  --up: #1f9d6b;
  --down: #d4503e;
  --hi: #2563eb;
  --hi-tx: #ffffff;
  --frame: #c4cde0;
  --chrome: #eaeef6;
  --shadow: 0 14px 40px rgba(22, 32, 58, 0.14);
}

/* ─── Base Reset ────────────────────────────────────────── */

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui, 'IBM Plex Sans', sans-serif);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--hi);
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
  background: none;
}

input,
select {
  font-family: inherit;
  font-size: inherit;
}

/* ─── Layout ────────────────────────────────────────────── */

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ─── Typography Utilities ──────────────────────────────── */

.num {
  font-family: var(--font-num, 'IBM Plex Mono', monospace);
  font-variant-numeric: tabular-nums;
}

.up {
  color: var(--up);
}

.down {
  color: var(--down);
}

.hi {
  color: var(--hi);
}

.mut {
  color: var(--mut);
}

.label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--mut);
}

/* ─── Arrow Indicators ──────────────────────────────────── */

.arr-up::before {
  content: '▲';
  font-size: 0.62em;
  margin-right: 2px;
}

.arr-dn::before {
  content: '▼';
  font-size: 0.62em;
  margin-right: 2px;
}

/* ─── Card ──────────────────────────────────────────────── */

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper2);
}

/* ─── Buttons ───────────────────────────────────────────── */

.btn-primary {
  background: var(--hi);
  color: var(--hi-tx);
  border-radius: 9px;
  padding: 8px 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  transition: opacity 0.15s;
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-ghost {
  background: transparent;
  color: var(--hi);
  border: 1px solid var(--hi);
  border-radius: 9px;
  padding: 7px 15px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}

.btn-ghost:hover {
  background: var(--fill);
}

/* ─── Pills ─────────────────────────────────────────────── */

.pill {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 10px;
  font-size: 12.5px;
  color: var(--mut);
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.pill:hover,
.pill.active {
  border-color: var(--hi);
  color: var(--hi);
}

/* ─── Table ─────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mut);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--fill);
}

/* ─── Rate Tick Animations ──────────────────────────────── */

/* Text-color flash (font changes color, scales briefly) */
@keyframes tick-up-text {
  0%   { color: var(--up);   transform: scale(1.05); }
  35%  { color: var(--up);   transform: scale(1); }
  100% { color: inherit;     transform: none; }
}
@keyframes tick-down-text {
  0%   { color: var(--down); transform: scale(0.96); }
  35%  { color: var(--down); transform: scale(1); }
  100% { color: inherit;     transform: none; }
}

/* Background flash (highlight behind the value, text stays put).
   box-shadow gives a padded glow without affecting layout. */
@keyframes tick-up-bg {
  0%   { background-color: color-mix(in srgb, var(--up) 38%, transparent);
         box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 38%, transparent); }
  100% { background-color: transparent; box-shadow: 0 0 0 3px transparent; }
}
@keyframes tick-down-bg {
  0%   { background-color: color-mix(in srgb, var(--down) 38%, transparent);
         box-shadow: 0 0 0 3px color-mix(in srgb, var(--down) 38%, transparent); }
  100% { background-color: transparent; box-shadow: 0 0 0 3px transparent; }
}

/* Duration is driven by the runtime-tweakable --flash-duration variable. */
.tick-up, .tick-down {
  display: inline-block;
  border-radius: 3px;
  animation-duration: var(--flash-duration, 650ms);
  animation-timing-function: ease-out;
  animation-fill-mode: forwards;
}

/* Default + 'both' mode: text colour AND background flash together */
.tick-up   { animation-name: tick-up-text, tick-up-bg; }
.tick-down { animation-name: tick-down-text, tick-down-bg; }

/* 'text' mode: only the font colour flashes */
html[data-flash-mode='text'] .tick-up   { animation-name: tick-up-text; }
html[data-flash-mode='text'] .tick-down { animation-name: tick-down-text; }

/* 'bg' mode: only the background flashes, text colour stays constant */
html[data-flash-mode='bg'] .tick-up   { animation-name: tick-up-bg; }
html[data-flash-mode='bg'] .tick-down { animation-name: tick-down-bg; }

/* ─── Live Indicator ────────────────────────────────────── */

@keyframes live-ping {
  0%   { transform: scale(1);   opacity: 0.9; }
  70%  { transform: scale(2.4); opacity: 0;   }
  100% { transform: scale(2.4); opacity: 0;   }
}

.live-ping {
  animation: live-ping 0.55s ease-out forwards;
}

/* ─── Ticker Animation ──────────────────────────────────── */

@keyframes ticker-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

/* ─── Scrollbar ─────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--paper);
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--mut);
}

/* ─── Pinned rates grid ─────────────────────────────────── */

.pinned-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

/* ─── Footer ────────────────────────────────────────────── */
.foot-link:hover { color: var(--ink); }

/* ─── Mobile ────────────────────────────────────────────── */

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }

  .foot-cols {
    grid-template-columns: 1fr 1fr !important;
    gap: 28px 20px !important;
  }
  .foot-cols > div:first-child {
    grid-column: 1 / -1;
  }

  .show-mobile {
    display: flex !important;
  }

  .grid-2col {
    grid-template-columns: 1fr !important;
  }

  /* Pinned: 2 across, no horizontal swipe */
  .pinned-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 769px) {
  .show-mobile {
    display: none !important;
  }
}

/* ── Blog content ─────────────────────────────────────────────────────────── */
.blog-content h1,.blog-content h2,.blog-content h3 { font-weight: 700; line-height: 1.3; margin: 1.8em 0 0.6em; color: var(--ink); }
.blog-content h1 { font-size: 1.6em; }
.blog-content h2 { font-size: 1.3em; }
.blog-content h3 { font-size: 1.1em; }
.blog-content p  { margin: 0 0 1.2em; }
.blog-content a  { color: var(--hi); text-decoration: underline; }
.blog-content strong { font-weight: 700; }
.blog-content em { font-style: italic; }
.blog-content blockquote { border-left: 3px solid var(--line); padding-left: 16px; color: var(--mut); margin: 1.2em 0; }
.blog-content code { font-family: var(--font-num); background: var(--fill); padding: 2px 5px; border-radius: 4px; font-size: 0.88em; }
.blog-content pre  { background: var(--fill); border-radius: 8px; padding: 16px; overflow-x: auto; margin: 1.2em 0; }
.blog-content pre code { background: none; padding: 0; }
.blog-content ul,.blog-content ol { padding-left: 1.5em; margin: 0 0 1.2em; }
.blog-content li { margin-bottom: 0.4em; }
.blog-content hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }
.blog-card { transition: border-color 0.15s, transform 0.15s; }
.blog-card-link:hover .blog-card { border-color: var(--hi) !important; transform: translateY(-1px); }
