/* ===================================================================
   Synthetic Covered Call Replication — Scientific Finance
   White canvas. Typography is the architecture. Whitespace is the
   separator. Color appears only where data demands meaning.
   Serif display, mono data, hairline rules, fixed left sidebar.
   =================================================================== */

:root {
    --bg: #ffffff;
    --bg-sidebar: #f5f5f5;
    --bg-subtle: #fafafa;
    --bg-hover: #f7f7f7;
    --surface: #ffffff;

    --hairline: rgba(17, 17, 17, 0.09);
    --hairline-soft: rgba(17, 17, 17, 0.05);
    --hairline-strong: rgba(17, 17, 17, 0.16);

    --text-0: #141414;   /* near-black, primary */
    --text-1: #3f3f3f;   /* body */
    --text-2: #8a8a8a;   /* muted labels */
    --text-3: #b4b4b4;   /* faint / disabled */

    --ink: #141414;      /* monochrome interactive + CTA fill */

    --pos: #0e7a4b;
    --pos-dim: rgba(14, 122, 75, 0.10);
    --neg: #c2362b;
    --neg-dim: rgba(194, 54, 43, 0.10);
    --warn: #b07215;
    --warn-dim: rgba(176, 114, 21, 0.12);
    --accent: var(--ink);
    --accent-dim: rgba(20, 20, 20, 0.05);

    --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Menlo', monospace;
    --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; /* alias used by the standalone public page */

    --gap-section: 6rem;
    --gap-block: 2.5rem;
    --gap-card: 2.25rem;

    --sidebar-w: 232px;
    --max-w: 1180px;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--bg);
    color: var(--text-1);
    font-family: var(--font-sans);
    font-weight: 400;
    font-size: 0.9rem;
    line-height: 1.65;
    min-height: 100vh;
}

/* ===================================================================
   Fixed left sidebar
   =================================================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.25rem 1.75rem;
    z-index: 1000;
}

.wordmark {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-0);
    text-decoration: none;
}

.wordmark-sep { color: var(--text-3); }

.wordmark-tag {
    margin-top: 0.55rem;
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-2);
    font-weight: 500;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin: 2.5rem 0 auto;
}

.side-link {
    position: relative;
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    letter-spacing: -0.005em;
    padding: 0.4rem 0;
    width: fit-content;
    transition: color 0.18s ease;
}

.side-link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0.25rem;
    width: 0;
    height: 1px;
    background: var(--text-0);
    transition: width 0.22s cubic-bezier(0.25, 1, 0.5, 1);
}

.side-link:hover { color: var(--text-0); }
.side-link.active { color: var(--text-0); }
.side-link.active::after { width: 100%; }

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.side-meta {
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-3);
    font-weight: 500;
}

/* ===================================================================
   Shell / top bar
   =================================================================== */
.app-shell {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Standalone public page nav (public.html does not extend base.html) */
.nav-bar {
    border-bottom: 1px solid var(--hairline);
    background: var(--bg-sidebar);
}

.nav-content {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 1.3rem 2.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-0);
    text-decoration: none;
}

.nav-links { display: flex; gap: 1.5rem; }

.nav-link {
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 500;
    transition: color 0.18s ease;
}

.nav-link:hover,
.nav-link.active { color: var(--text-0); }

/* The public page renders without the fixed sidebar, so its main column
   should not be pushed right. */
body > .main-content {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 4.5rem 2.75rem 4rem;
}

/* ===================================================================
   Layout
   =================================================================== */
.main-content {
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 4.5rem 2.75rem 4rem;
    flex: 1 0 auto;
}

/* --- Page header --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--gap-section);
    gap: 2rem;
}

.page-header h1 {
    font-family: var(--font-display);
    font-size: clamp(2.6rem, 5vw, 4rem);
    font-weight: 600;
    color: var(--text-0);
    letter-spacing: -0.01em;
    line-height: 0.98;
}

.page-subtitle {
    font-size: 0.62rem;
    color: var(--text-2);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-weight: 600;
    white-space: nowrap;
}

/* --- Section label (small-caps, widely tracked, muted) --- */
.section-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    margin-bottom: 1.5rem;
    margin-top: var(--gap-section);
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--hairline);
}

.section-label:first-of-type { margin-top: 0; }

/* ===================================================================
   Cards — no fill, no border. Content sits on white; whitespace and
   a single hairline do the separating.
   =================================================================== */
.card {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: var(--gap-card);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.5rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--hairline);
}

.card-header h2 {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* ===================================================================
   Hero  (overview / public)
   =================================================================== */
.hero-section {
    margin-bottom: var(--gap-section);
}

.hero-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 3rem;
    margin-bottom: 3rem;
}

.hero-title {
    font-family: var(--font-sans);
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.hero-title .equity-value {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(2.75rem, 6vw, 4.25rem);
    font-weight: 500;
    color: var(--text-0);
    letter-spacing: -0.03em;
    line-height: 1.0;
    margin-top: 1rem;
    font-feature-settings: "tnum" 1;
}

.hero-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
    padding-top: 0.4rem;
    text-align: right;
}

.track-record-line {
    font-size: 0.6rem;
    color: var(--text-2);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 3rem;
}

.chart-disclaimer {
    font-size: 0.62rem;
    color: var(--text-3);
    letter-spacing: 0.04em;
    margin-top: 1rem;
    font-style: italic;
}

/* --- Status dot --- */
.status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 0.45rem;
    vertical-align: middle;
}

.status-dot.live { background: var(--pos); animation: pulse 3s ease-in-out infinite; }
.status-dot.warn { background: var(--warn); animation: pulse 2s ease-in-out infinite; }
.status-dot.danger { background: var(--neg); animation: pulse 1.2s ease-in-out infinite; }
.status-dot.idle { background: var(--text-3); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ===================================================================
   Stat strips — large mono numerals, tiny tracked labels, separated by
   whitespace + thin vertical hairlines (no boxes).
   =================================================================== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    margin-bottom: var(--gap-section);
    border-top: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
}

.stats-row .stat-card {
    background: transparent;
    border: none;
    border-left: 1px solid var(--hairline);
    border-radius: 0;
    padding: 2rem 1.75rem;
}

.stats-row .stat-card:first-child { border-left: none; }

.stat-card {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.9rem;
    font-weight: 500;
    color: var(--text-0);
    letter-spacing: -0.03em;
    line-height: 1.1;
    font-feature-settings: "tnum" 1;
}

.stat-hint {
    font-size: 0.62rem;
    color: var(--text-2);
    letter-spacing: 0.03em;
    margin-top: 0.1rem;
}

.hero-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: var(--gap-section);
}

/* --- Metrics grid --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0;
    border-top: 1px solid var(--hairline);
    border-left: 1px solid var(--hairline);
}

.metrics-grid .stat-card {
    border: none;
    border-right: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
    border-radius: 0;
    background: transparent;
    padding: 1.6rem 1.5rem;
}

.metrics-section { margin-bottom: var(--gap-section); }

.metrics-section-title {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    margin-bottom: 1.5rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--hairline);
}

/* --- Two-column layout --- */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3.5rem;
    margin-bottom: var(--gap-card);
}

/* Overview: wide primary chart + narrow secondary (e.g. equity curve + gauge) */
.two-col-aside {
    grid-template-columns: 2fr 1fr;
}

/* Three-up stats row (public page) */
.stats-row.stats-row-3 { grid-template-columns: repeat(3, 1fr); }

/* Feature / "how it works" grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border-top: 1px solid var(--hairline);
    border-left: 1px solid var(--hairline);
}

.feature-grid > * {
    border-right: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
    padding: 1.75rem 1.5rem;
}

/* ===================================================================
   Charts
   =================================================================== */
.chart-container {
    position: relative;
    height: 300px;
}

.chart-controls {
    display: flex;
    gap: 0.4rem;
}

.btn-sm {
    background: transparent;
    border: 1px solid var(--hairline);
    color: var(--text-2);
    padding: 0.22rem 0.65rem;
    border-radius: 0;
    font-size: 0.66rem;
    font-family: var(--font-mono);
    font-weight: 500;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-sm:hover {
    color: var(--text-0);
    border-color: var(--hairline-strong);
}

.btn-sm.active {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

/* --- Gauge --- */
.gauge-container {
    position: relative;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gauge-value {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 500;
    color: var(--text-0);
    letter-spacing: -0.02em;
}

.gauge-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 600;
}

.legend-item { color: var(--text-3); }
.legend-item.warn { color: var(--warn); }
.legend-item.crit { color: var(--neg); }
.legend-item.emergency { color: #8a1c14; }

/* ===================================================================
   Tables — terminal-clean: tiny tracked headers, hairline rules.
   =================================================================== */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

th {
    padding: 0.7rem 1rem;
    text-align: left;
    font-size: 0.58rem;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    border-bottom: 1px solid var(--hairline-strong);
    white-space: nowrap;
}

td {
    padding: 0.8rem 1rem;
    text-align: left;
    font-size: 0.82rem;
    color: var(--text-1);
    border-bottom: 1px solid var(--hairline-soft);
    white-space: nowrap;
}

tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--bg-hover); }

.row-warn { border-left: 2px solid var(--warn); }
.row-caution { border-left: 2px solid var(--ink); }

.monthly-returns-table th,
.monthly-returns-table td {
    padding: 0.55rem 0.7rem;
    text-align: right;
}

.monthly-returns-table th:first-child,
.monthly-returns-table td:first-child {
    text-align: left;
}

/* ===================================================================
   Typographic utilities
   =================================================================== */
.mono {
    font-family: var(--font-mono);
    font-size: 0.86em;
    font-feature-settings: "tnum" 1;
}

.positive { color: var(--pos); }
.negative { color: var(--neg); }
.warn-text { color: var(--warn); }
.muted { color: var(--text-2); }

.empty-state {
    text-align: center;
    color: var(--text-3);
    padding: 4rem 2rem;
    font-size: 0.85rem;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.16rem 0.5rem;
    border-radius: 0;
    font-size: 0.58rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: var(--font-mono);
    line-height: 1.5;
}

.badge-ok { background: var(--pos-dim); color: var(--pos); }
.badge-info { background: var(--accent-dim); color: var(--ink); }
.badge-warn { background: var(--warn-dim); color: var(--warn); }
.badge-danger { background: var(--neg-dim); color: var(--neg); }

/* --- State emphasis (left rule instead of tinted box) --- */
.state-danger { border-left: 2px solid var(--neg); padding-left: 1.25rem; }
.state-warn { border-left: 2px solid var(--warn); padding-left: 1.25rem; }

/* ===================================================================
   Buttons / CTAs — the one styled element: a solid black pill.
   =================================================================== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--ink);
    color: #fff;
    padding: 0.6rem 1.35rem;
    border: none;
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: opacity 0.15s ease;
    cursor: pointer;
}

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

/* Text links with the trailing-arrow convention */
.link-arrow {
    color: var(--text-0);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.78rem;
}
.link-arrow::after { content: ' \2192'; }
.link-arrow:hover { color: var(--text-2); }

/* --- Cycle meta --- */
.cycle-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-2);
    align-items: center;
}

.cycle-divider { color: var(--text-3); }

/* ===================================================================
   Scroll reveal
   =================================================================== */
.reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1),
                transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.reveal.visible { opacity: 1; transform: translateY(0); }

.reveal-delay-1 { transition-delay: 0.05s; }
.reveal-delay-2 { transition-delay: 0.10s; }
.reveal-delay-3 { transition-delay: 0.15s; }
.reveal-delay-4 { transition-delay: 0.20s; }

.fade-in { opacity: 0; transform: translateY(16px); }

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1),
                transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

/* ===================================================================
   Footer
   =================================================================== */
.footer {
    flex-shrink: 0;
    padding: 2.5rem 2.75rem;
    color: var(--text-3);
    font-size: 0.6rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    border-top: 1px solid var(--hairline);
    max-width: var(--max-w);
    margin: var(--gap-section) auto 0;
    width: 100%;
}

/* ===================================================================
   Responsive — sidebar collapses to a top strip on narrow screens.
   =================================================================== */
@media (max-width: 900px) {
    .sidebar {
        position: static;
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.25rem;
        border-right: none;
        border-bottom: 1px solid var(--hairline);
    }
    .wordmark-tag { display: none; }
    .side-nav {
        flex-direction: row;
        gap: 1.1rem;
        margin: 0;
    }
    .side-link::after { bottom: 0; }
    .sidebar-bottom { display: none; }
    .app-shell { margin-left: 0; }
}

@media (max-width: 768px) {
    :root { --gap-section: 3.5rem; --gap-block: 1.75rem; --gap-card: 1.75rem; }
    .main-content { padding: 2.5rem 1.25rem 3rem; }
    .two-col { grid-template-columns: 1fr; gap: 2rem; }
    .hero-title-row { flex-direction: column; gap: 1.5rem; }
    .hero-status { align-items: flex-start; text-align: left; }
    .stats-row,
    .stats-row.stats-row-3 { grid-template-columns: 1fr 1fr; }
    .stats-row .stat-card:nth-child(odd) { border-left: none; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .feature-grid { grid-template-columns: 1fr; }
    .chart-container { height: 240px; }
}

@media (max-width: 480px) {
    .side-nav { gap: 0.7rem; }
    .side-link { font-size: 0.82rem; }
    .stats-row,
    .stats-row.stats-row-3,
    .metrics-grid { grid-template-columns: 1fr; }
    .stats-row .stat-card { border-left: none; }
    .stat-value { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .reveal, .fade-in { opacity: 1 !important; transform: none !important; }
}

/* ===================================================================
   Scrollbar + selection
   =================================================================== */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(17,17,17,0.18); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: rgba(17,17,17,0.3); }

::selection { background: rgba(20, 20, 20, 0.12); color: var(--text-0); }

/* ===================================================================
   Overview hero — daily-returns heat grid
   Read-only GitHub-style calendar: 7 weekday rows x N week columns,
   rightmost column = most recent week. Sharp edges per the design rule.
   =================================================================== */
.return-heat {
    display: grid;
    grid-template-rows: repeat(7, 12px);
    grid-auto-flow: column;
    grid-auto-columns: 12px;
    gap: 3px;
    margin-top: 0.5rem;
    justify-content: flex-end;
}
.heat-cell {
    width: 12px;
    height: 12px;
    border-radius: 0;
    background: var(--hairline-soft);
    transition: box-shadow 0.12s ease;
}
/* Faint glow in the cell's own color on hover (black for the grey cells). */
.heat-cell:hover { box-shadow: 0 0 5px 1px var(--glow, rgba(0, 0, 0, 0.4)); }
.heat-future:hover { box-shadow: none; }
.heat-empty   { background: var(--hairline-soft); --glow: rgba(0, 0, 0, 0.4); }
.heat-future  { background: transparent; }
.heat-pos-1   { background: #a8d8c0; --glow: rgba(168, 216, 192, 0.55); }
.heat-pos-2   { background: #5fb38c; --glow: rgba(95, 179, 140, 0.55); }
.heat-pos-3   { background: var(--pos); --glow: rgba(14, 122, 75, 0.55); }   /* #0e7a4b */
.heat-pos-4   { background: #0a5c39; --glow: rgba(10, 92, 57, 0.55); }
.heat-neg-1   { background: #e8b0aa; --glow: rgba(232, 176, 170, 0.55); }
.heat-neg-2   { background: #d3766c; --glow: rgba(211, 118, 108, 0.55); }
.heat-neg-3   { background: var(--neg); --glow: rgba(194, 54, 43, 0.55); }   /* #c2362b */
.heat-neg-4   { background: #8a1c14; --glow: rgba(138, 28, 20, 0.55); }
