/* Self-hosted Reddit fonts (SIL OFL) — no external embeds */
@font-face { font-family: 'Reddit Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('/assets/fonts/reddit-sans-400.woff2') format('woff2'); }
@font-face { font-family: 'Reddit Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('/assets/fonts/reddit-sans-600.woff2') format('woff2'); }
@font-face { font-family: 'Reddit Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('/assets/fonts/reddit-sans-700.woff2') format('woff2'); }
@font-face { font-family: 'Reddit Sans'; font-style: normal; font-weight: 800; font-display: swap; src: url('/assets/fonts/reddit-sans-800.woff2') format('woff2'); }
@font-face { font-family: 'Reddit Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/assets/fonts/reddit-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'Reddit Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url('/assets/fonts/reddit-mono-600.woff2') format('woff2'); }
@font-face { font-family: 'Reddit Mono'; font-style: normal; font-weight: 700; font-display: swap; src: url('/assets/fonts/reddit-mono-700.woff2') format('woff2'); }

/* ---- LIGHT theme (default — like Reddit/X default) ---- */
:root {
    --bg: #f6f7f9;        /* light grey page */
    --panel: #ffffff;     /* white cards */
    --panel-2: #ffffff;
    --border: #e3e6e9;    /* light divider */
    --text: #0f1419;      /* near-black (X) */
    --muted: #536471;     /* secondary grey (X) */
    --brand: #1d9bf0;     /* interactive accent (X blue) */
    --up: #0f9d58;        /* gains + market-open line */
    --down: #d61f3a;      /* losses */
    --accent: #5b7cfa;    /* market-closed line */
    --ext: #1f9bbf;       /* pre / after-hours line */
    --open-hi: #0b7a43;   /* hovered-run (bolder on white) */
    --ext-hi: #16809f;
    --closed-hi: #3a5bd9;
    --area-top: rgba(91, 124, 250, 0.14);
    --area-bottom: rgba(91, 124, 250, 0.0);
    --chart-grid: rgba(0, 0, 0, 0.08);
    --chart-axis: #536471;
    --chart-axis-line: rgba(0, 0, 0, 0.18);
    --tip-bg: #ffffff;
    --tip-border: #e3e6e9;
    --tip-text: #0f1419;
    --sans: 'Reddit Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --mono: 'Reddit Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* ---- DARK theme (opt-in toggle) — shared X "lights out" / Reddit dark ---- */
:root[data-theme="dark"] {
    --bg: #0a0a0b;
    --panel: #16181c;
    --panel-2: #1e2024;
    --border: #2f3336;
    --text: #e7e9ea;
    --muted: #7a818b;
    --brand: #1d9bf0;
    --up: #1ce783;
    --down: #ff4d4d;
    --accent: #7193ff;
    --ext: #4fb0cf;
    --open-hi: #7dffb3;
    --ext-hi: #9bdcf0;
    --closed-hi: #aebeff;
    --area-top: rgba(113, 147, 255, 0.18);
    --area-bottom: rgba(113, 147, 255, 0.0);
    --chart-grid: rgba(255, 255, 255, 0.06);
    --chart-axis: #7a818b;
    --chart-axis-line: rgba(255, 255, 255, 0.12);
    --tip-bg: #16181c;
    --tip-border: #2f3336;
    --tip-text: #e7e9ea;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 2;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 0.2px; }
.brand .logo { color: var(--brand); font-size: 14px; }
.brand .name { font-size: 16px; }

/* 24/7 value-prop next to the wordmark */
.pitch {
    margin-left: 4px; padding-left: 14px;
    border-left: 1px solid var(--border);
    font-size: 13px; color: var(--muted); font-weight: 500;
    max-width: 480px; line-height: 1.35;
}
.pitch strong { color: var(--brand); font-weight: 800; }

.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    background: var(--panel); color: var(--muted);
    border: 1px solid var(--border); border-radius: 999px;
    cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }

.tabs {
    display: flex;
    gap: 6px;
    max-width: 980px;
    margin: 14px auto 0;
    padding: 0 20px 2px;
    overflow-x: auto;
}
.tab {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); }
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Market-status pills (top-right): 24/7 always-on, Stocks, Futures */
.markets { display: flex; align-items: center; gap: 8px; }
.mk {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
    padding: 5px 11px; border-radius: 999px;
    background: var(--panel); border: 1px solid var(--border); color: var(--muted);
}
.mk .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.mk .mk-state { font-weight: 700; }
/* open = green pill (bg, border, dot, text) — same treatment as 24/7 */
.mk.open { color: var(--up); background: color-mix(in srgb, var(--up) 14%, transparent); border-color: color-mix(in srgb, var(--up) 30%, transparent); }
.mk.open .dot { background: var(--up); }
.mk.open .mk-state { color: var(--up); }
/* the always-on 24/7 market also pulses its dot */
.mk.always .dot { animation: livepulse 1.6s ease-out infinite; }
@keyframes livepulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 65%, transparent); }
    70%  { box-shadow: 0 0 0 6px color-mix(in srgb, var(--up) 0%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 0%, transparent); }
}

main {
    max-width: 980px;
    margin: 0 auto;
    padding: 24px 20px 8px;
    display: grid;
    gap: 18px;
}

.quote {
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px 24px;
}
.quote-head h1 { margin: 0 0 8px; font-size: 15px; font-weight: 600; color: var(--muted); }
.quote-head .sub {
    font-size: 11px; color: var(--brand); border: 1px solid var(--brand);
    padding: 1px 6px; border-radius: 6px; margin-left: 6px; vertical-align: middle;
    font-weight: 700;
}

.price-row { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.price { font-family: var(--mono); font-size: 52px; font-weight: 700; letter-spacing: -1px; }
.price.flash-up { animation: flashUp 0.7s ease-out; }
.price.flash-down { animation: flashDown 0.7s ease-out; }
@keyframes flashUp { from { color: var(--up); } to { color: var(--text); } }
@keyframes flashDown { from { color: var(--down); } to { color: var(--text); } }

.changes { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; align-items: flex-start; }
.chg { display: flex; align-items: center; gap: 8px; }
.chg-pill {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 13px; font-weight: 700; line-height: 1.5;
    padding: 1px 8px; border-radius: 7px; color: var(--muted);
}
.chg-pill.up { color: var(--up); background: color-mix(in srgb, var(--up) 15%, transparent); }
.chg-pill.down { color: var(--down); background: color-mix(in srgb, var(--down) 15%, transparent); }
.chg-abs { font-family: var(--mono); font-size: 16px; font-weight: 700; color: var(--muted); }
.chg-abs.up { color: var(--up); }
.chg-abs.down { color: var(--down); }
.chg-period { color: var(--muted); font-size: 13px; }

.stats {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}
.stat {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}
.stat label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.stat span { font-family: var(--mono); font-size: 16px; font-weight: 600; }
.stat span.up { color: var(--up); }
.stat span.down { color: var(--down); }

.chart-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
}
.chart-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tf-buttons { display: flex; gap: 6px; }
.tf-buttons button {
    background: var(--bg);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}
.tf-buttons button:hover { color: var(--text); border-color: var(--muted); }
.tf-buttons button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

#chart { width: 100%; height: 420px; }

.legend { display: flex; gap: 18px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch { width: 16px; height: 3px; border-radius: 2px; display: inline-block; }
.swatch-open { background: var(--up); }
.swatch-ext { background: var(--ext); }
.swatch-closed { background: var(--accent); }

.disclaimer {
    max-width: 980px;
    margin: 8px auto 28px;
    padding: 0 20px;
    color: var(--muted);
    font-size: 12px;
    opacity: 0.75;
    text-align: center;
}

@media (max-width: 1024px) { .pitch { display: none; } }
@media (max-width: 760px) { #mkStocks, #mkFutures { display: none; } }
@media (max-width: 560px) {
    .price { font-size: 40px; }
    #chart { height: 320px; }
}
