/* CheatDX — study references. One stylesheet, no dependencies. */

:root {
    --violet-950: #1b0b3b;
    --violet-900: #2e1065;
    --violet-700: #5b21b6;
    --violet-500: #7c3aed;
    --amber: #f59e0b;
    --amber-soft: #fef3c7;
    --teal: #0f766e;
    --rose: #be185d;
    --blue: #1d4ed8;
    --olive: #4d7c0f;

    --ink: #1a1430;
    --muted: #6f6880;
    --paper: #faf7f0;
    --surface: #fffdf8;
    --surface-2: #f3ecdf;
    --border: #e7ddcb;
    --border-strong: #d3c5ab;
    --link: #5b21b6;
    --link-hover: #2e1065;

    --radius-sm: 8px;
    --radius: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 1px 2px rgba(46, 16, 101, .06);
    --shadow: 0 2px 6px rgba(46, 16, 101, .06), 0 18px 44px rgba(46, 16, 101, .08);

    --wrap: 1120px;
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: Georgia, "Times New Roman", "Noto Serif", serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #f2ecff;
        --muted: #b6adc9;
        --paper: #120c24;
        --surface: #1b1233;
        --surface-2: #241743;
        --border: #352457;
        --border-strong: #4a3374;
        --link: #c4b5fd;
        --link-hover: #ede9fe;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow: 0 2px 10px rgba(0, 0, 0, .45), 0 18px 44px rgba(0, 0, 0, .35);
    }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

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

body {
    margin: 0;
    background:
        radial-gradient(900px 300px at 10% -80px, rgba(124, 58, 237, .10), transparent 70%),
        radial-gradient(700px 260px at 95% 0, rgba(245, 158, 11, .10), transparent 70%),
        var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 4px; }

.wrap { width: min(100% - 32px, var(--wrap)); margin-inline: auto; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 100;
    padding: 10px 16px; background: var(--surface); color: var(--ink);
    border-radius: var(--radius-sm); box-shadow: var(--shadow); transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

/* ---------------------------------------------------------------- header */

.site-header {
    background: linear-gradient(150deg, var(--violet-950) 0%, var(--violet-900) 45%, var(--violet-700) 100%);
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .08), 0 10px 30px rgba(27, 11, 59, .25);
}

.header-bar {
    display: flex; align-items: center; gap: 22px;
    padding-block: 14px; flex-wrap: wrap;
}

.brand { line-height: 0; flex: 0 0 auto; }
.brand img { height: 44px; width: auto; }

.search {
    display: flex; align-items: stretch; margin-left: auto;
    width: min(100%, 460px); background: #fff; border-radius: 999px; padding: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}

.search input {
    flex: 1 1 auto; min-width: 0; border: 0; background: transparent;
    color: #1a1430; font: inherit; font-size: 16px; padding: 8px 16px;
    border-radius: 999px; outline: none;
}
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.search button {
    flex: 0 0 auto; border: 0; border-radius: 999px; padding: 8px 20px;
    font: inherit; font-weight: 700; color: #2e1065; background: var(--amber); cursor: pointer;
}
.search button:hover { filter: brightness(1.06); }

.site-nav { border-top: 1px solid rgba(255, 255, 255, .14); background: rgba(0, 0, 0, .12); }
.site-nav .wrap { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.site-nav a {
    display: inline-block; padding: 11px 15px; color: #ede9fe; text-decoration: none;
    font-size: 15px; font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent;
}
.site-nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); border-bottom-color: var(--amber); }

.site-main { padding-block: 30px 56px; }

/* -------------------------------------------------------------- headings */

h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; color: var(--ink); }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.4vw, 3rem); margin: 0 0 .5rem; }
h2 { font-size: clamp(1.3rem, 1.1rem + .7vw, 1.7rem); margin: 1.8rem 0 .7rem; }
h3 { font-size: 1.1rem; margin: 1.1rem 0 .35rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }

.breadcrumbs { margin-bottom: 16px; font-size: 14px; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; color: var(--muted); }
.breadcrumbs li + li::before { content: "›"; margin-right: 6px; color: var(--border-strong); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--link); text-decoration: underline; }

/* ------------------------------------------------------------------ home */

.hero {
    display: grid; grid-template-columns: 1.15fr .85fr; gap: 36px; align-items: center;
    padding: clamp(26px, 5vw, 56px);
    background: linear-gradient(160deg, var(--surface), var(--surface-2));
    border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
    margin-bottom: 34px;
}

.hero h1 { font-size: clamp(2.1rem, 1.4rem + 3vw, 3.6rem); margin-bottom: .6rem; }
.hero h1 em { color: var(--violet-700); font-style: italic; }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 52ch; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.button {
    display: inline-block; padding: 12px 22px; border-radius: 999px;
    background: var(--violet-700); color: #fff; font-weight: 700; text-decoration: none;
    border: 1px solid transparent;
}
.button:hover { background: var(--violet-900); color: #fff; }
.button--ghost { background: transparent; color: var(--violet-700); border-color: var(--border-strong); }
.button--ghost:hover { background: var(--surface); color: var(--violet-900); border-color: var(--violet-500); }
.button--amber { background: var(--amber); color: #2e1065; }
.button--amber:hover { background: #fbbf24; color: #2e1065; }

.hero-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; box-shadow: var(--shadow);
}
.hero-card h2 { margin-top: 0; font-size: 1.1rem; font-family: var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.hero-card ul { margin: 0; padding-left: 20px; }
.hero-card li { margin-bottom: 8px; }

.stat-row { display: flex; flex-wrap: wrap; gap: 10px 26px; color: var(--muted); font-size: 14px; margin-top: 16px; }
.stat-row strong { color: var(--ink); font-size: 16px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-top: 34px; }
.section-head h2 { margin: 0; }
.section-head a { font-size: 14px; text-decoration: none; }

.subject-grid, .sheet-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px; margin-top: 16px;
}

.subject-card {
    display: flex; flex-direction: column; gap: 6px; padding: 20px;
    background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--accent);
    border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow-sm);
    transition: transform .15s ease, border-color .15s ease;
}
.subject-card:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--ink); }
.subject-icon { font-size: 26px; line-height: 1; }
.subject-card strong { font-size: 1.05rem; }
.subject-card span:last-child { color: var(--muted); font-size: 14px; }

.card {
    display: flex; flex-direction: column; gap: 8px; padding: 18px;
    background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--accent, var(--violet-500));
    border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow-sm);
    transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); color: var(--ink); border-color: var(--accent, var(--violet-500)); }
.card-subject { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.card strong { font-size: 1.05rem; }
.card-desc { color: var(--muted); font-size: 14px; }
.card-meta { margin-top: auto; color: var(--muted); font-size: 12px; }

.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
.how-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.how-card .step { font-family: var(--font-display); font-size: 1.6rem; color: var(--violet-700); }
.how-card h3 { margin: .3rem 0; }
.how-card p { color: var(--muted); font-size: 14px; margin: 0; }

/* ----------------------------------------------------------------- sheet */

.sheet-header { max-width: 860px; margin-bottom: 18px; }
.sheet-header h1 { margin-bottom: .4rem; }
.sheet-lead { color: var(--muted); font-size: 1.05rem; max-width: 70ch; }

.meta-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
    border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
    color: var(--muted); font-size: 13px;
}
.chip--accent { background: var(--violet-700); border-color: var(--violet-700); color: #fff; }

.sheet-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 30px; align-items: start; }
.sheet-body { min-width: 0; }
.sheet-side { position: sticky; top: 18px; }
.sheet-side .card { background: var(--surface); padding: 18px; border-top-width: 1px; }
.sheet-side h2 { font-size: 1rem; margin: 0 0 8px; font-family: var(--font-body); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.sheet-side ul { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.sheet-side li { margin-bottom: 7px; }
.sheet-side a { text-decoration: none; }

.sheet-section {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px 24px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.sheet-section > h2 { margin-top: 0; }
.sheet-section > h2:first-child { margin-top: 0; }

.table-wrap { overflow-x: auto; margin: 0 0 8px; }
.sheet-table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 420px; }
.sheet-table th, .sheet-table td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--border); vertical-align: top; }
.sheet-table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 2px solid var(--border-strong); }
.sheet-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.sheet-table code { white-space: nowrap; }

code {
    font-family: var(--font-mono); font-size: .92em;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px;
    padding: 1px 5px;
}

.formula {
    background: var(--surface-2); border-left: 4px solid var(--violet-500);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 12px 16px; margin: 12px 0; overflow-x: auto;
}
.formula code { background: transparent; border: 0; padding: 0; font-size: 1rem; }

.note {
    background: var(--amber-soft); border-left: 4px solid var(--amber);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 12px 16px; margin: 12px 0;
}
@media (prefers-color-scheme: dark) {
    .note { background: #3b2a08; }
}

.example {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 14px 16px; margin: 12px 0; background: var(--surface);
}
.example h3 { margin-top: 0; }
.example .problem { color: var(--muted); }

.faq details { border-bottom: 1px solid var(--border); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { color: var(--muted); margin: 8px 0 0; }

.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 12px; }

.print-button { display: inline-flex; align-items: center; gap: 8px; }

.cornell-template {
    display: grid; grid-template-columns: 32% 68%; grid-template-rows: auto auto;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden;
    background: var(--surface); margin: 12px 0;
}
.cornell-cue, .cornell-notes { padding: 14px; min-height: 150px; }
.cornell-cue { border-right: 1px solid var(--border-strong); }
.cornell-notes { border-left: 0; }
.cornell-summary { grid-column: 1 / -1; border-top: 1px solid var(--border-strong); padding: 14px; min-height: 80px; }
.cornell-template strong { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.cornell-template span, .cornell-template ul { color: var(--muted); font-size: 14px; margin: 0; }
.cornell-template ul { padding-left: 18px; }

/* ------------------------------------------------------------------ quiz */

.quiz-form { display: grid; gap: 16px; }
.quiz-question { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.quiz-question legend { font-weight: 700; font-size: 1.05rem; padding: 0; }
.quiz-options { display: grid; gap: 8px; margin-top: 10px; }
.quiz-option {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
.quiz-option:hover { border-color: var(--violet-500); }
.quiz-option input { width: 18px; height: 18px; accent-color: var(--violet-700); }
.quiz-submit { margin-top: 4px; }
.quiz-result { margin-top: 18px; }
.quiz-score { font-family: var(--font-display); font-size: 2rem; margin: 0 0 6px; }

/* ------------------------------------------------------------------ tool */

.tool-form {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; box-shadow: var(--shadow-sm); max-width: 720px;
}
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.field input, .field select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
    font: inherit; font-size: 16px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tool-result { margin-top: 18px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.tool-value { font-family: var(--font-display); font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.2rem); color: var(--violet-700); margin: 4px 0; }
.tool-error { color: var(--rose); font-weight: 700; }

/* ---------------------------------------------------------------- errors */

.error-state {
    max-width: 620px; margin: 50px auto; text-align: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 38px 26px; box-shadow: var(--shadow-sm);
}
.error-state .button { margin: 6px 4px 0; }

/* ---------------------------------------------------------------- footer */

.site-footer {
    background: linear-gradient(160deg, var(--violet-950), var(--violet-900));
    color: #e9e1ff; padding-block: 34px 26px; margin-top: 30px;
}
.footer-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 28px; }
.footer-grid h2 { font-family: var(--font-body); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: #c4b5fd; margin: 0 0 8px; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.footer-grid li { margin-bottom: 6px; }
.footer-grid a { color: #e9e1ff; text-decoration: none; }
.footer-grid a:hover { color: #fff; text-decoration: underline; }
.footer-grid .muted { color: #bda9e6; font-size: 14px; margin-top: 10px; }
.brand--footer img { height: 38px; }
.footer-copy { border-top: 1px solid rgba(255, 255, 255, .14); margin-top: 24px; padding-top: 16px; color: #bda9e6; font-size: 13px; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 920px) {
    .hero { grid-template-columns: 1fr; }
    .sheet-layout { grid-template-columns: 1fr; }
    .sheet-side { position: static; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .how-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    body { font-size: 16px; }
    .wrap { width: min(100% - 22px, var(--wrap)); }
    .header-bar { gap: 12px; padding-block: 12px; }
    .search { width: 100%; margin-left: 0; }
    .brand img { height: 38px; }
    .hero { padding: 22px; }
    .subject-grid, .sheet-grid { grid-template-columns: 1fr; }
    .field-row { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; }
    .sheet-section { padding: 16px; }
    .cornell-template { grid-template-columns: 1fr; }
    .cornell-cue { border-right: 0; border-bottom: 1px solid var(--border-strong); min-height: 90px; }
}

/* ----------------------------------------------------------------- print */

@media print {
    @page { size: A4; margin: 1.5cm; }

    body { background: #fff !important; color: #000 !important; font-size: 11pt; }
    .site-header, .site-footer, .site-nav, .search, .breadcrumbs, .sheet-side,
    .related-section, .quiz-cta, .print-button, .no-print, .skip-link { display: none !important; }
    .site-main { padding: 0; width: auto; max-width: none; }
    .sheet-header { margin-bottom: 10px; }
    .sheet-header h1 { font-size: 20pt; }
    .sheet-lead { color: #333; }
    .meta-chips { display: none; }
    .sheet-layout { display: block; }
    .sheet-section { border: 0; box-shadow: none; padding: 0; margin: 0 0 12pt; }
    .sheet-section h2 { font-size: 13pt; border-bottom: 1px solid #000; padding-bottom: 3pt; }
    .sheet-table { font-size: 9.5pt; min-width: 0; }
    .sheet-table th, .sheet-table td { border-bottom: 1px solid #bbb; padding: 4pt 6pt; }
    .sheet-table tbody tr:nth-child(even) { background: transparent; }
    .formula, .note, .example { border: 1px solid #999; background: #fff !important; }
    .sheet-table, .example, .formula { break-inside: avoid; }
    a { color: #000; text-decoration: none; }
    code { background: #f2f2f2; border-color: #ccc; }
}

/* ------------------------------------------------------- filter + nav */

.filter-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    margin: 18px 0 22px;
}
.filter-bar input[type="search"] {
    flex: 1 1 260px; min-width: 0; padding: 10px 16px;
    border: 1px solid var(--border-strong); border-radius: 999px;
    background: var(--surface); color: var(--ink); font: inherit; font-size: 15px;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
button.chip { cursor: pointer; font: inherit; }
.chip.is-active { background: var(--violet-700); border-color: var(--violet-700); color: #fff; }
.filter-bar .muted { margin-left: auto; font-size: 13px; }

.subject-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.subject-nav a {
    padding: 7px 13px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--ink); text-decoration: none; font-size: 14px;
}
.subject-nav a:hover { border-color: var(--violet-500); color: var(--violet-700); }
