/* cheat_sheet.css — Quant Interview Core-30 reference card.
   Mobile-first; 412px viewport friendly; no horizontal scroll.
   Reuses --primary / --text / --bg from styles.css. */

.cs-container {
    max-width: 920px;
    margin: 0 auto;
    padding: 20px 14px 64px;
}

.cs-header {
    margin-bottom: 18px;
}

.cs-header h1 {
    margin: 6px 0 6px;
    font-size: 28px;
    line-height: 1.15;
    color: var(--text);
}

.cs-subtitle {
    color: var(--text-secondary);
    margin: 0 0 12px;
    font-size: 14.5px;
    line-height: 1.5;
}

.cs-meta {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(37, 99, 235, 0.08);
    /* WCAG fix: var(--primary)=#2563EB on rgba blue bg = 4.17:1 fails 4.5.
       Use blue-700 (#1d4ed8) = 5.53:1 on this background. */
    color: #1d4ed8;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
}

/* ── Sticky pill nav ───────────────────────────────────────────────── */
.cs-jump {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0;
    margin: 8px -14px 18px;
    padding-left: 14px;
    padding-right: 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cs-jump a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.cs-jump a:hover,
.cs-jump a:focus {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(37, 99, 235, 0.06);
}

/* ── Worked examples ───────────────────────────────────────────────── */
.cs-examples {
    margin-bottom: 28px;
}

.cs-examples h2 {
    font-size: 18px;
    margin: 0 0 12px;
    color: var(--text);
}

.cs-examples-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 720px) {
    .cs-examples-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.cs-example {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 14px 12px;
    box-shadow: var(--shadow);
    transition: border-color 0.15s;
}

.cs-example[open] {
    border-color: var(--primary);
}

.cs-example summary {
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.35;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cs-example summary::-webkit-details-marker { display: none; }

.cs-example summary::before {
    content: "+";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
    line-height: 1;
}

.cs-example[open] summary::before {
    content: "\2212"; /* minus sign */
}

.cs-example-body {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13.8px;
    line-height: 1.55;
}

.cs-example-body p { margin: 0 0 8px; }
.cs-example-body p:last-child { margin-bottom: 0; }

.cs-example-tag {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(37, 99, 235, 0.12);
    /* WCAG fix: var(--primary)=#2563EB on rgba blue bg = 4.37:1 fails 4.5.
       Use blue-700 (#1d4ed8) = 5.53:1 on this background. */
    color: #1d4ed8;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    margin: 0 4px 4px 0;
}

/* ── Sections & fact rows ──────────────────────────────────────────── */
.cs-section {
    margin: 22px 0 0;
    scroll-margin-top: 80px;
}

/* Stronger section headings (Batch 6 of AI-review punch-list — was 4-star hierarchy
   "indistinguishable from formula card titles below them"). Left-rail accent +
   bigger weight + size bump so scrolling past gives a clear visual break. */
.cs-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 4px 0 6px 14px;
    border-left: 4px solid var(--primary, #2563EB);
    border-bottom: 1px solid var(--border);
}

.cs-section-head h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text);
}

.cs-section-count {
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 600;
}

.cs-facts {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 720px) {
    .cs-facts {
        grid-template-columns: 1fr 1fr;
    }
}

.cs-fact {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 10px;
    padding: 12px 12px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: border-color 0.15s, transform 0.05s;
}

.cs-fact:hover {
    border-color: var(--primary);
}

.cs-fact-num {
    grid-row: 1 / span 3;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.cs-fact-formula {
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: break-word;
    position: relative;
}

.cs-fact-formula .katex { font-size: 1em; }
.cs-fact-formula .katex-display { margin: 0.4em 0; overflow-x: auto; }

/* ── Practice mode (Wozniak rule #5 — cloze deletion) ── */
.cs-practice-banner {
    background: #DBEAFE;
    border: 1px solid #93C5FD;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.88em;
    color: #1E40AF;
    margin: 0 0 12px;
}
@media (prefers-color-scheme: dark) {
    .cs-practice-banner {
        background: rgba(37,99,235,0.15);
        border-color: #3B82F6;
        color: #93C5FD;
    }
}

.cs-mode-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 14px 0 4px;
    flex-wrap: wrap;
}
.cs-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #F3F4F6;
    color: #1F2937;
    border: 1px solid #E5E7EB;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.cs-mode-btn:hover { background: #E5E7EB; }
.cs-mode-btn[aria-pressed="true"] {
    background: #2563EB;
    color: #FFFFFF;
    border-color: #2563EB;
}
.cs-mode-icon {
    font-size: 14px;
    line-height: 1;
}
.cs-mode-hint {
    font-weight: 400;
    color: #6B7280;
    font-size: 0.92em;
}
.cs-mode-btn[aria-pressed="true"] .cs-mode-hint { color: #DBEAFE; }
.cs-mode-btn-ghost {
    background: transparent;
    border-color: #D1D5DB;
    color: #4B5563;
}

/* When practice mode is active, hide formulas behind a tap-to-reveal pill. */
body.cs-practice .cs-fact-formula {
    cursor: pointer;
    min-height: 28px;
}
body.cs-practice .cs-fact-formula:not(.cs-revealed) {
    overflow: hidden;
}
body.cs-practice .cs-fact-formula::before {
    content: "Tap to reveal";
    position: absolute;
    inset: -2px -4px -2px -4px;
    background: #F3F4F6;
    border: 1.5px dashed #D1D5DB;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6B7280;
    font-size: 0.82em;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
body.cs-practice .cs-fact-formula:hover::before {
    background: #DBEAFE;
    color: #1D4ED8;
    border-color: #2563EB;
}
body.cs-practice .cs-fact-formula.cs-revealed::before {
    display: none;
}

@media (prefers-color-scheme: dark) {
    .cs-mode-btn {
        background: #1E293B;
        color: #F1F5F9;
        border-color: #334155;
    }
    .cs-mode-btn:hover { background: #334155; }
    .cs-mode-btn[aria-pressed="true"] {
        background: #2563EB;
        color: #FFFFFF;
        border-color: #2563EB;
    }
    .cs-mode-hint { color: #94A3B8; }
    body.cs-practice .cs-fact-formula::before {
        background: #1E293B;
        border-color: #475569;
        color: #94A3B8;
    }
    body.cs-practice .cs-fact-formula:hover::before {
        background: #1E3A8A;
        color: #93C5FD;
        border-color: #60A5FA;
    }
}

.cs-fact-why {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
    font-style: italic;
}

.cs-fact-link {
    align-self: start;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 4px 10px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-radius: 999px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.cs-fact-link:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.cs-fact-link.is-disabled {
    opacity: 0.45;
    pointer-events: none;
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
    font-style: italic;
}

/* ── Footer ────────────────────────────────────────────────────────── */
.cs-footer {
    margin-top: 36px;
    padding: 16px 14px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 13.5px;
    text-align: center;
    line-height: 1.5;
}

.cs-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.cs-footer a:hover { text-decoration: underline; }

/* ── Mobile tightening: 412px and below ────────────────────────────── */
@media (max-width: 480px) {
    .cs-container { padding: 16px 12px 56px; }
    .cs-header h1 { font-size: 24px; }
    .cs-section-head h2 { font-size: 17px; }
    .cs-fact { padding: 14px 12px; gap: 10px; grid-template-columns: 28px 1fr; }
    .cs-fact-num { width: 26px; height: 26px; font-size: 13px; }
    .cs-fact-name { font-size: 15px; }
    .cs-fact-formula { font-size: 16px; line-height: 1.5; }
    .cs-fact-formula .katex { font-size: 1.05em; }
    .cs-fact-why { font-size: 14px; line-height: 1.5; }
    .cs-jump { padding: 8px 12px; margin-left: -12px; margin-right: -12px; }
    .cs-jump a { padding: 8px 12px; font-size: 13.5px; }
}

/* ── Zebra striping on fact cards (light) ──────────────────────────── */
.cs-facts li.cs-fact:nth-child(odd) {
    background: var(--surface);
}
.cs-facts li.cs-fact:nth-child(even) {
    background: rgba(0, 0, 0, 0.025);
}

/* ── Sticky section headers ─────────────────────────────────────────── */
.cs-section-head {
    position: sticky;
    top: 57px;   /* sits just below the sticky pill-nav (~57px tall) */
    z-index: 3;
    background: var(--bg);
}

/* ── Dark mode ─────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .cs-meta {
        background: rgba(59, 130, 246, 0.18);
        color: #93c5fd;
    }
    .cs-jump {
        background: var(--bg);
        border-bottom-color: var(--border);
    }
    /* WCAG fix: --primary in dark (#3b82f6) on itself = 3.68:1 fails 4.5:1.
       Use blue-700 (#1d4ed8) background + white text = 7.2:1. */
    .cs-fact-num {
        background: #1d4ed8;
        color: #fff;
    }
    .cs-fact-link {
        background: rgba(59, 130, 246, 0.16);
        /* WCAG fix: #93c5fd on dark surface = 3.98:1 fails 4.5:1.
           #60a5fa on #1e293b = 5.5:1, passes AA. */
        color: #60a5fa;
        border-color: rgba(59, 130, 246, 0.35);
    }
    .cs-fact-link:hover {
        background: var(--primary);
        color: #fff;
    }
    .cs-fact-link.is-disabled {
        background: transparent;
        color: var(--text-secondary);
        border-color: var(--border);
    }
    .cs-example-tag {
        background: rgba(59, 130, 246, 0.18);
        color: #93c5fd;
    }
    .cs-section-head {
        border-bottom-color: var(--border);
        background: var(--bg);
    }
    .cs-facts li.cs-fact:nth-child(even) {
        background: rgba(255, 255, 255, 0.03);
    }
    /* "Browse all tutorials →" / "Math Dojo" footer links: default --primary
       (#3b82f6) on dark surface = 3.98:1 fails AA. Lighten to #60a5fa. */
    .cs-footer a { color: #60a5fa; }
    .cs-footer a:hover { color: #93c5fd; }
}
