/* ════════════════════════════════════════════════════════════════════
   Market Status — public NIFTY option-chain page
   ════════════════════════════════════════════════════════════════════

   Design notes (2026-09-21):

   This is a rewrite rather than a restyle of the internal dashboard tab
   it grew out of. The internal version could assume a reader who already
   knew what every number meant; a public page cannot, so the hierarchy
   is built around "what is the one thing this says?" first (hero), "what
   levels matter?" second (key levels), and detail after that.

   - Two themes, both first-class. A public page gets opened in daylight
     on a phone as often as at night on a desktop, so light mode is a real
     theme here, not an afterthought inversion.
   - Semantic colour is fixed across themes: green = puts/support/up,
     red = calls/resistance/down. Those meanings must not flip with the
     theme, so they live outside the themed token block.
   - Numbers are set in a monospace face at tabular widths so figures
     don't jitter horizontally as they tick.
   ════════════════════════════════════════════════════════════════════ */

:root {
    /* Semantic (theme-independent) */
    --bull: #16a34a;
    --bear: #dc2626;
    --call: #e5484d;   /* resistance side */
    --put:  #30a46c;   /* support side */
    --info: #3b82f6;
    --warn: #d97706;

    --radius: 14px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;
    --maxw: 1180px;
}

/* ─── Dark (default) ─────────────────────────────────────────────── */
:root, :root[data-theme="dark"] {
    --bg: #0a0d12;
    --bg-elev: #12161d;
    --bg-soft: #171c25;
    --surface: #12161d;
    --line: #232a35;
    --line-soft: #1b212a;
    --fg: #eef2f7;
    --fg-2: #97a3b4;
    --fg-3: #67707e;
    --bull: #3fd17b;
    --bear: #ff6b6b;
    --call: #ff6b6b;
    --put:  #3fd17b;
    --info: #5aa2ff;
    --warn: #f0b429;
    --glow: rgba(90, 162, 255, 0.10);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
}

/* ─── Light ──────────────────────────────────────────────────────── */
:root[data-theme="light"] {
    --bg: #f6f7f9;
    --bg-elev: #ffffff;
    --bg-soft: #f0f2f5;
    --surface: #ffffff;
    --line: #e2e6ec;
    --line-soft: #eceff3;
    --fg: #101623;
    --fg-2: #5a6472;
    --fg-3: #8a94a3;
    --bull: #15803d;
    --bear: #c81e1e;
    --call: #d93838;
    --put:  #15803d;
    --info: #2563eb;
    --warn: #b45309;
    --glow: rgba(37, 99, 235, 0.07);
    --shadow: 0 1px 2px rgba(16,22,35,.06), 0 8px 24px rgba(16,22,35,.06);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    /* A very soft top-light so the page doesn't read as a flat slab. */
    background-image: radial-gradient(1000px 420px at 50% -220px, var(--glow), transparent 70%);
    background-repeat: no-repeat;
    min-height: 100vh;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Numbers get tabular figures everywhere so a ticking value doesn't
   shift the layout of everything beside it. */
.hero-value, .metric-value, .level-value, .tbl td, .hero-change,
.metric-trend, .level-dist {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

/* ─── Top bar ────────────────────────────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line-soft);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
    width: 22px; height: 22px; border-radius: 7px;
    background: linear-gradient(135deg, var(--put), var(--info) 55%, var(--call));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--info) 30%, transparent);
}

.brand-text { font-size: 1.02rem; font-weight: 500; letter-spacing: -0.02em; }
.brand-text strong { font-weight: 800; }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.pill {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 0.76rem; font-weight: 500; color: var(--fg-2);
    padding: 5px 11px; border-radius: 999px;
    background: var(--bg-soft); border: 1px solid var(--line);
    white-space: nowrap;
}

.dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--fg-3); flex: none;
}
.dot.live { background: var(--bull); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bull) 22%, transparent); }
.dot.stale { background: var(--warn); }
.dot.error { background: var(--bear); }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--bg-soft); border: 1px solid var(--line);
    color: var(--fg-2); cursor: pointer;
    transition: color .15s, border-color .15s, transform .15s;
}
.icon-btn:hover { color: var(--fg); border-color: var(--info); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.spin svg { animation: spin .7s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Only one of the two theme glyphs is ever shown. */
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: none; }

/* ─── Hero ───────────────────────────────────────────────────────── */

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
    gap: 28px;
    align-items: center;
    padding: 40px 0 32px;
}

.hero-label { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }

.hero-label h1 {
    font-size: 0.82rem; font-weight: 600; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--fg-2);
}

.chip {
    font-size: 0.72rem; font-weight: 600; letter-spacing: .02em;
    padding: 3px 9px; border-radius: 999px;
    background: color-mix(in srgb, var(--info) 14%, transparent);
    color: var(--info);
    border: 1px solid color-mix(in srgb, var(--info) 28%, transparent);
    white-space: nowrap;
}
.chip-quiet {
    background: var(--bg-soft); color: var(--fg-2); border-color: var(--line);
}

.hero-price { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }

.hero-value {
    font-size: clamp(2.6rem, 7vw, 4rem);
    font-weight: 700; letter-spacing: -0.035em; line-height: 1.05;
}

.hero-change { font-size: 1.05rem; font-weight: 600; }

.hero-verdict {
    margin-top: 12px;
    font-size: 1.02rem; color: var(--fg-2); max-width: 46ch;
}

.hero-spark {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.hero-spark-label,
.hero-spark-foot {
    font-size: 0.72rem; color: var(--fg-3);
    text-transform: uppercase; letter-spacing: .07em; font-weight: 600;
}
.hero-spark-foot { text-transform: none; letter-spacing: 0; font-weight: 500; margin-top: 8px; }

.up { color: var(--bull); }
.down { color: var(--bear); }
.flat { color: var(--fg-2); }

/* ─── Panels ─────────────────────────────────────────────────────── */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 24px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.panel-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}

.panel-head h2 { font-size: 1.06rem; font-weight: 650; letter-spacing: -0.015em; }
.panel-sub { font-size: 0.83rem; color: var(--fg-3); margin-top: 2px; }

/* ─── Key levels rail ────────────────────────────────────────────── */

.rail { margin: 4px 0 22px; }
.rail svg { display: block; width: 100%; }

.levels-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
    margin-bottom: 18px;
}

.level-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    background: var(--bg-soft);
    /* The left edge carries the side's colour, so the two cards are
       distinguishable at a glance without reading either label. */
    border-left-width: 3px;
}
.level-support { border-left-color: var(--put); }
.level-resistance { border-left-color: var(--call); }

.level-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }

.level-tag {
    font-size: 0.72rem; font-weight: 700; letter-spacing: .09em;
    text-transform: uppercase;
}
.level-support .level-tag { color: var(--put); }
.level-resistance .level-tag { color: var(--call); }

.level-dist { font-size: 0.76rem; color: var(--fg-3); }
.level-value { font-size: 1.65rem; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0 2px; }
.level-note { font-size: 0.8rem; color: var(--fg-2); }

/* ─── Disclosure ─────────────────────────────────────────────────── */

.disclosure { border-top: 1px solid var(--line-soft); padding-top: 14px; }

.disclosure > summary {
    cursor: pointer; list-style: none;
    font-size: 0.8rem; font-weight: 600; color: var(--fg-2);
    display: inline-flex; align-items: center; gap: 7px;
    padding: 4px 0; user-select: none;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before {
    content: ''; width: 5px; height: 5px; flex: none;
    border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
    transform: rotate(-45deg); transition: transform .18s;
}
.disclosure[open] > summary::before { transform: rotate(45deg); }
.disclosure > summary:hover { color: var(--fg); }

.foot-note { font-size: 0.76rem; color: var(--fg-3); margin-top: 10px; }
.foot-note strong { color: var(--fg-2); font-weight: 600; }

/* ─── Metric grid ────────────────────────────────────────────────── */

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px 18px;
    box-shadow: var(--shadow);
    transition: border-color .18s, transform .18s;
}
.metric:hover { border-color: color-mix(in srgb, var(--info) 45%, var(--line)); }

.metric-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.metric-label {
    font-size: 0.72rem; font-weight: 600; letter-spacing: .08em;
    text-transform: uppercase; color: var(--fg-2);
}
.metric-unit { color: var(--fg-3); font-weight: 500; }
.metric-trend { font-size: 0.74rem; font-weight: 600; white-space: nowrap; }
.metric-value { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 2px; }
.metric-note { font-size: 0.78rem; color: var(--fg-3); margin-top: 8px; line-height: 1.35; }

/* ─── Sparklines & gauges ────────────────────────────────────────── */

.spark { height: 30px; line-height: 0; margin-top: 8px; }
.spark svg { display: block; width: 100%; height: 30px; }
.spark-lg { height: 74px; margin-top: 10px; }
.spark-lg svg { height: 74px; }

/* Keeps the slot's height when there's nothing to draw, so cards in the
   same row stay aligned instead of the grid jumping. */
.spark.is-empty::after {
    content: ''; display: block; height: 100%;
    border-bottom: 1px dashed var(--line);
}

.gauge { height: 30px; line-height: 0; margin-top: 8px; }
.gauge svg { display: block; width: 100%; height: 30px; }

/* ─── Charts ─────────────────────────────────────────────────────── */

.chart-host { width: 100%; }
.chart-host svg { display: block; width: 100%; }

.empty-state {
    text-align: center; color: var(--fg-3);
    font-size: 0.84rem; padding: 46px 16px;
    border: 1px dashed var(--line); border-radius: var(--radius-sm);
}

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.76rem; color: var(--fg-2); }
.lg { display: inline-flex; align-items: center; gap: 7px; }
.lg-sub { color: var(--fg-3); }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-call { background: var(--call); }
.sw-put { background: var(--put); }

/* Hover readout under the OI chart. A fixed min-height stops the panel
   from resizing as the pointer moves across strikes. */
.oi-readout {
    min-height: 34px; margin-top: 12px; padding-top: 12px;
    border-top: 1px solid var(--line-soft);
    font-size: 0.8rem; color: var(--fg-2);
    display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.oi-readout-hint { color: var(--fg-3); }
.oi-readout b { font-family: var(--mono); font-weight: 600; color: var(--fg); }

/* ─── Segmented control ──────────────────────────────────────────── */

.seg {
    display: inline-flex; gap: 2px; padding: 3px;
    background: var(--bg-soft); border: 1px solid var(--line);
    border-radius: 10px; flex-wrap: wrap;
}

.seg-btn {
    font-family: var(--font); font-size: 0.76rem; font-weight: 600;
    padding: 5px 11px; border-radius: 7px;
    background: transparent; border: none; color: var(--fg-3);
    cursor: pointer; transition: background .15s, color .15s;
}
.seg-btn:hover { color: var(--fg); }
.seg-btn.active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }

/* ─── Tables ─────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }

.tbl { width: 100%; border-collapse: collapse; font-size: 0.86rem; }

.tbl thead th {
    text-align: left; font-weight: 600; font-size: 0.7rem;
    text-transform: uppercase; letter-spacing: .07em; color: var(--fg-3);
    padding: 11px 16px; background: var(--bg-soft);
    border-bottom: 1px solid var(--line); white-space: nowrap;
}
.th-note { text-transform: none; letter-spacing: 0; font-weight: 500; }

.tbl tbody td {
    padding: 11px 16px; border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--bg-soft); }
.tbl td.tier { font-family: var(--font); font-weight: 600; color: var(--fg-2); }
.tbl td.empty { text-align: center; color: var(--fg-3); padding: 34px; }

/* ─── Footer ─────────────────────────────────────────────────────── */

.site-foot {
    margin-top: 40px; padding: 32px 0 48px;
    border-top: 1px solid var(--line-soft);
    background: var(--bg-elev);
}

.foot-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 32px;
    align-items: start;
    padding-bottom: 22px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line-soft);
}

.foot-tagline {
    font-size: 0.82rem; color: var(--fg-3);
    max-width: 44ch; margin-top: 10px; line-height: 1.55;
}

/* Definition list rather than a run-on sentence: these are four discrete
   facts, and as labelled pairs they stay scannable and keep their meaning
   when they stack on a phone. */
.foot-meta {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 14px 30px;
    font-size: 0.78rem;
}
.foot-meta dt {
    font-size: 0.68rem; font-weight: 600; letter-spacing: .08em;
    text-transform: uppercase; color: var(--fg-3); margin-bottom: 2px;
}
.foot-meta dd { color: var(--fg-2); white-space: nowrap; }

/* Full bleed across the footer grid, NOT capped at a measure. A reading
   width is right for prose; this is a legal notice sitting under a
   full-width two-column band, and capping it at 78ch left the right half
   of the footer visibly empty while everything above it ran the full
   width. Boxed so it reads as a distinct notice rather than a stray
   paragraph. */
.disclaimer {
    font-size: 0.78rem;
    color: var(--fg-3);
    line-height: 1.65;
    background: var(--bg-soft);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
}
.disclaimer strong { color: var(--fg-2); }

@media (max-width: 720px) {
    .foot-top { grid-template-columns: 1fr; gap: 22px; }
    .foot-meta { grid-template-columns: 1fr 1fr; gap: 12px 18px; }
    .foot-meta dd { white-space: normal; }
}

/* ─── Toast ──────────────────────────────────────────────────────── */

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translate(-50%, 16px);
    z-index: 60;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--fg);
    color: var(--bg);
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ─── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 860px) {
    .hero { grid-template-columns: 1fr; gap: 20px; padding: 28px 0 24px; }
    .levels-grid { grid-template-columns: 1fr; }
    .panel { padding: 18px 16px 20px; }
    .panel-head { flex-direction: column; align-items: stretch; }
}

@media (max-width: 520px) {
    .wrap { padding: 0 14px; }
    .metrics { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .seg { width: 100%; justify-content: space-between; }
    .seg-btn { flex: 1; padding: 5px 6px; }
    .brand-text { font-size: 0.95rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    html { scroll-behavior: auto; }
}
