/* ==========================================================================
   Topic summaries — printable A4 revision sheets
   Roomier redesign (2026-06): larger type, generous whitespace, GDC-first.
   Extracted from the inline <style> in detail.html.
   All colours come from theme.css tokens (no raw brand hex).
   ========================================================================== */

.ts-wrap {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 10.5pt;
    line-height: 1.5;
    color: var(--text);
    background: var(--color-border);
    padding: 28px 16px;
    min-height: 80vh;
}

/* Layout helpers so this page is edge-to-edge under the app shell */
.ts-wrap-page .page-wrapper { padding-bottom: 0 !important; }
.ts-wrap-page .container-fluid { padding: 0 !important; }

/* ---- A4 sheet -------------------------------------------------------------
   One .a4-sheet = one printed A4 page. Generous 1.4cm padding so content
   breathes; each sheet breaks onto its own page when printing.            */
.a4-sheet {
    width: 21cm;
    min-height: 29.7cm;
    margin: 0 auto 24px;
    padding: 1.4cm;
    background: var(--color-bg);
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.14);
    box-sizing: border-box;
}
.a4-sheet + .a4-sheet { break-before: page; }

/* ---- Floating controls bar (screen only) -------------------------------- */
.ts-controls {
    position: sticky; top: 56px; z-index: 100;
    background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    padding: 10px 16px; border-radius: 0 0 10px 10px;
    display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
    max-width: 21cm; margin: 0 auto 16px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}
.ts-controls label { font-size: 10pt; font-weight: 500; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.ts-controls select { font-size: 10pt; padding: 5px 8px; border-radius: 5px; border: 1px solid var(--border); }
.ts-controls .btn-teal { background: var(--primary); color: #fff; border: none; padding: 6px 16px; border-radius: 5px; cursor: pointer; font-size: 10pt; font-weight: 500; }
.ts-controls .btn-teal:hover { background: var(--primary-hover); }
.ts-controls .btn-outline { background: var(--color-bg); color: var(--text-muted); border: 1px solid var(--border); padding: 6px 16px; border-radius: 5px; cursor: pointer; font-size: 10pt; }

/* ---- Sheet header / footer ---------------------------------------------- */
.sheet-header { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 3px solid var(--primary); }
.sheet-header h1 { font-size: 19pt; font-weight: 800; color: var(--text); margin: 0 0 2px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sheet-header > div { font-size: 9.5pt; color: var(--text-muted); }

.level-badge {
    display: inline-block; font-size: 9pt; font-weight: 700; letter-spacing: 0.4px;
    color: #fff; background: var(--primary); padding: 2px 10px; border-radius: 999px;
    vertical-align: middle;
}
.level-badge.hl { background: var(--info); }
.level-badge.slhl { background: var(--primary-hover); }

.sheet-footer, .ts-footer {
    margin-top: 18px; padding-top: 8px; border-top: 2px solid var(--primary);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 8pt; color: var(--text-light);
}

/* ---- Section header ------------------------------------------------------ */
.section-header {
    display: flex; align-items: center; gap: 12px;
    margin: 22px 0 12px; padding-bottom: 6px;
    border-bottom: 2px solid var(--primary);
    break-after: avoid;
}
.section-badge {
    width: 30px; height: 30px; background: var(--primary); color: #fff;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14pt; flex-shrink: 0;
}
.section-title { font-size: 13.5pt; font-weight: 700; color: var(--text); }
.section-subtitle { font-size: 9.5pt; color: var(--text-muted); margin-left: 4px; }

/* ---- Formula box --------------------------------------------------------- */
.formula-box {
    background: var(--color-primary-bg); border-left: 4px solid var(--primary);
    padding: 11px 16px; margin: 10px 0; border-radius: 0 6px 6px 0;
    font-size: 11pt; line-height: 1.55; break-inside: avoid;
}

/* ---- Worked example ------------------------------------------------------ */
.example-box, .worked-example {
    background: var(--color-bg-subtle); border: 1px solid var(--border);
    padding: 12px 16px; margin: 10px 0; border-radius: 6px; break-inside: avoid;
}
.example-box .label, .worked-example .ex-label {
    font-weight: 700; color: var(--primary-hover); font-size: 8.5pt;
    text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px;
}
.worked-example .ex-q { font-weight: 600; margin-bottom: 6px; }
.worked-example .ex-step { margin: 3px 0; padding-left: 6px; }
.worked-example .ex-answer { margin-top: 6px; font-weight: 700; color: var(--primary-hover); }

/* ---- GDC steps ----------------------------------------------------------- */
.gdc-block {
    background: var(--color-bg-muted); border: 1px solid var(--border);
    border-left: 4px solid var(--info);
    padding: 10px 14px; margin: 8px 0; border-radius: 0 6px 6px 0;
    font-size: 10pt; line-height: 1.6; break-inside: avoid;
}
.gdc-title { font-weight: 700; color: var(--info-hover, var(--info)); font-size: 9.5pt; margin-bottom: 4px; }
.gdc-key {
    display: inline-block; font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 9pt; background: var(--color-bg); border: 1px solid var(--border);
    border-radius: 4px; padding: 0 5px; color: var(--text);
}

/* ---- Callout boxes: error / tip / key ------------------------------------ */
.error-box, .tip-box, .key-box {
    padding: 10px 14px; margin: 10px 0; border-radius: 0 6px 6px 0;
    font-size: 10.5pt; line-height: 1.5; break-inside: avoid;
}
.error-box { background: var(--color-danger-bg); border-left: 4px solid var(--danger); }
.tip-box   { background: var(--color-info-bg);   border-left: 4px solid var(--info); }
.key-box   { background: var(--color-success-bg); border-left: 4px solid var(--success); font-weight: 500; }
.error-box .icon { color: var(--danger); font-weight: 700; margin-right: 5px; }
.tip-box .icon   { color: var(--info); margin-right: 5px; }
.key-box .icon   { color: var(--success); margin-right: 5px; }

/* ---- GDC reference comparison table (TI-84 / Nspire / Casio side by side) - */
.gdc-table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: 9.5pt; break-inside: avoid; }
.gdc-table th, .gdc-table td { border: 1px solid var(--border); padding: 7px 9px; vertical-align: top; text-align: left; }
.gdc-table thead th { background: var(--color-primary-bg); color: var(--primary-hover); font-weight: 700; font-size: 9pt; }
.gdc-table td:first-child { font-weight: 600; width: 26%; background: var(--color-bg-subtle); }
.gdc-table .gdc-key { font-size: 8.5pt; }
.gdc-table tbody tr:nth-child(even) td:not(:first-child) { background: var(--color-bg-subtle); }

/* ---- Two-column flow inside a sheet (optional, for dense formula lists) --- */
.cols-2 { column-count: 2; column-gap: 20px; }
.cols-2 > * { break-inside: avoid; }

/* ---- Mark annotation ----------------------------------------------------- */
.mark { float: right; font-weight: 700; font-size: 9.5pt; color: var(--text-muted); }

/* ---- Diagrams ------------------------------------------------------------ */
.a4-sheet svg { max-width: 100%; height: auto; }

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
    .ts-wrap { padding: 0 !important; background: #fff !important; font-size: 10.5pt; }
    .a4-sheet { box-shadow: none !important; margin: 0 !important; width: 100% !important; min-height: 0 !important; padding: 1.2cm !important; }
    .ts-controls { display: none !important; }
    nav, footer, #beta-banner, .page-wrapper > .container-fluid:first-child { display: none !important; }
    @page { size: A4 portrait; margin: 1cm; }
    .section-header, .section-badge, .level-badge,
    .formula-box, .example-box, .worked-example, .gdc-block,
    .error-box, .tip-box, .key-box, .sheet-header, .sheet-footer, .ts-footer {
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
}
