/* Kambridge Math & Physics — Site CSS */

:root {
    --navy-900: #061025;
    --navy-800: #0a1a36;
    --navy-700: #102347;
    --navy-600: #15315f;
    --blue-500: #5a8dee;
    --blue-400: #7da9f5;
    --blue-300: #a8c4f7;
    --white: #ffffff;
    --grey-50: #f5f7fb;
    --grey-100: #e9eef7;
    --grey-200: #d6dfee;
    --grey-400: #8a94ac;
    --grey-600: #5a6477;
    --grey-800: #232a3a;

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 2px 8px rgba(10, 20, 50, 0.06);
    --shadow: 0 8px 28px rgba(10, 20, 50, 0.10);
    --shadow-lg: 0 24px 60px rgba(10, 20, 50, 0.18);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --container: 1180px;
}

/* Light theme (default) */
:root, [data-theme="light"] {
    --bg: #ffffff;
    --bg-soft: #f5f7fb;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --fg: #0a1a36;
    --fg-soft: #4a5468;
    --fg-muted: #6b7488;
    --border: #e1e7f1;
    --border-strong: #c9d3e6;
    --accent: var(--blue-500);
    --accent-hover: #4577d5;
    --accent-soft: rgba(90, 141, 238, 0.10);
    --navy: var(--navy-800);
    --header-bg: rgba(255, 255, 255, 0.92);
    --hero-grad-1: #f1f5fb;
    --hero-grad-2: #ffffff;
}

[data-theme="dark"] {
    --bg: var(--navy-900);
    --bg-soft: var(--navy-800);
    --bg-card: var(--navy-800);
    --bg-elevated: var(--navy-700);
    --fg: #eef2ff;
    --fg-soft: #c5cde0;
    --fg-muted: #8a96b3;
    --border: #1a2a4f;
    --border-strong: #233566;
    --accent: var(--blue-400);
    --accent-hover: #95b6f6;
    --accent-soft: rgba(125, 169, 245, 0.14);
    --navy: var(--navy-900);
    --header-bg: rgba(10, 26, 54, 0.92);
    --hero-grad-1: #0a1a36;
    --hero-grad-2: #0e2148;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}

img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 { font-family: 'Inter', sans-serif; font-weight: 700; line-height: 1.25; color: var(--fg); margin: 0 0 0.6em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1rem; color: var(--fg-soft); }

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.2;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-outline {
    background: transparent;
    color: var(--fg);
    border-color: var(--border-strong);
}
.btn-outline:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-lg { padding: 16px 28px; font-size: 16px; }
.btn-block { display: flex; width: 100%; }

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.nav { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--fg); font-weight: 700; font-size: 17px; }
.brand img { width: 40px; height: 40px; border-radius: 50%; }
.brand strong { letter-spacing: -0.01em; }
.brand .tagline { display: block; font-size: 10px; color: var(--fg-muted); letter-spacing: 0.16em; text-transform: uppercase; font-weight: 500; margin-top: 1px; }

.nav-links { display: none; gap: 6px; align-items: center; list-style: none; padding: 0; margin: 0; }
.nav-links a { color: var(--fg-soft); padding: 8px 14px; border-radius: 8px; font-weight: 500; font-size: 14px; }
.nav-links a:hover, .nav-links a.active { color: var(--accent); background: var(--accent-soft); }

.nav-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--fg);
    transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

.menu-toggle {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--fg);
}

@media (min-width: 880px) {
    .nav-links { display: flex; }
    .menu-toggle { display: none; }
}

.mobile-menu {
    display: none;
    border-top: 1px solid var(--border);
    background: var(--bg);
    padding: 10px 0;
}
.mobile-menu.open { display: block; }
.mobile-menu ul { list-style: none; padding: 0; margin: 0; }
.mobile-menu a { display: block; padding: 12px 20px; color: var(--fg-soft); font-weight: 500; }
.mobile-menu a:hover { background: var(--accent-soft); color: var(--accent); }

/* Hero */
.hero {
    background: linear-gradient(180deg, var(--hero-grad-1), var(--hero-grad-2));
    padding: 80px 0 70px;
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, var(--accent-soft), transparent 65%);
    top: -200px; right: -200px;
    border-radius: 50%;
    pointer-events: none;
}
.hero-inner { display: grid; gap: 36px; align-items: center; position: relative; z-index: 1; }
.hero-tag { display: inline-block; background: var(--accent-soft); color: var(--accent); padding: 6px 14px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 18px; }
.hero h1 { margin: 0 0 18px; }
.hero p { font-size: 1.1rem; max-width: 620px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.hero-logo { display: flex; justify-content: center; }
.hero-logo img { width: min(320px, 80vw); height: auto; border-radius: 50%; box-shadow: var(--shadow-lg); }

@media (min-width: 880px) {
    .hero { padding: 110px 0 90px; }
    .hero-inner { grid-template-columns: 1.2fr 1fr; gap: 60px; }
}

/* Sections */
section { padding: 70px 0; }
.section-head { text-align: center; max-width: 720px; margin: 0 auto 48px; }
.section-tag { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }

/* Cards */
.card-grid { display: grid; gap: 24px; }
.card-grid.cols-2 { grid-template-columns: 1fr; }
.card-grid.cols-3 { grid-template-columns: 1fr; }
.card-grid.cols-4 { grid-template-columns: 1fr; }

@media (min-width: 600px) {
    .card-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
    .card-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
    .card-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 920px) {
    .card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
    .card-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all var(--transition);
    color: inherit;
    display: flex;
    flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent); }
.card h3 { margin: 0 0 8px; }
.card .meta { font-size: 12px; color: var(--fg-muted); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 10px; }
.card p { font-size: 14px; flex: 1; }
.card .card-foot { margin-top: 14px; display: flex; gap: 10px; align-items: center; }
.card-arrow { color: var(--accent); font-weight: 600; }

.feature-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.feature-icon svg { width: 22px; height: 22px; }

/* Paper cards (used on home/related) */
.paper-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    transition: all var(--transition);
    display: block;
    color: inherit;
}
.paper-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.paper-code { font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--accent); font-weight: 700; font-size: 14px; }
.paper-title { font-weight: 600; color: var(--fg); margin: 6px 0; font-size: 15px; line-height: 1.4; }
.paper-meta { display: flex; gap: 12px; font-size: 12px; color: var(--fg-muted); }
.paper-meta span { white-space: nowrap; }

/* ============================================
   Past papers — full-width premium card list
   ============================================ */
.paper-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.paper-card {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 26px 28px;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.paper-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}
@media (min-width: 720px) {
    .paper-card { padding: 30px 34px; }
}

/* Card header */
.paper-card-head {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.paper-card-meta-top {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.paper-card-code {
    display: inline-flex;
    align-items: center;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.02em;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 6px 12px;
    border-radius: 8px;
}
.paper-card-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.10em;
}
.paper-card-title {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.01em;
}
.paper-card-title a {
    color: var(--fg);
    text-decoration: none;
    transition: color var(--transition);
}
.paper-card-title a:hover { color: var(--accent); }
.paper-card-title-sub {
    display: inline-block;
    margin-left: 4px;
    font-weight: 500;
    color: var(--fg-muted);
}
@media (min-width: 720px) {
    .paper-card-title { font-size: 20px; }
}

/* File panels — three columns on desktop, stacked on mobile */
.paper-card-files {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
@media (min-width: 720px) {
    .paper-card-files { grid-template-columns: repeat(3, 1fr); gap: 16px; }
}

.paper-file {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: border-color var(--transition), background var(--transition);
}
.paper-file:hover { border-color: var(--border-strong); }
.paper-file.is-unavailable { opacity: 0.65; }

.paper-file-head {
    display: flex;
    align-items: center;
    gap: 10px;
}
.paper-file-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.paper-file-icon svg { width: 16px; height: 16px; }
.paper-file-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--fg);
    line-height: 1.2;
}

.paper-file-actions {
    display: flex;
    gap: 8px;
}

.paper-file-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1;
}
.paper-file-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.paper-file-btn-view {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.paper-file-btn-view:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
    transform: translateY(-1px);
}

.paper-file-btn-download {
    background: var(--bg-card);
    color: var(--fg);
    border-color: var(--border-strong);
}
.paper-file-btn-download:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.paper-file-btn-disabled {
    flex: 1;
    background: transparent;
    color: var(--fg-muted);
    border-color: var(--border);
    cursor: not-allowed;
    font-size: 12px;
}
.paper-file-btn-disabled:hover { transform: none; }

/* Filters */
.filter-bar {
    display: grid;
    gap: 14px;
    padding: 20px 22px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}
.filter-bar input, .filter-bar select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--accent); }
.filter-bar .hint {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}
@media (min-width: 720px) {
    .filter-bar { grid-template-columns: 2fr 1fr 1fr 1fr auto; align-items: end; }
    .filter-bar .filter-search { grid-column: 1 / 2; }
}

/* Tables */
table.simple { width: 100%; border-collapse: collapse; }
table.simple th, table.simple td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
table.simple th { color: var(--fg-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

/* Forms */
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-size: 13px; color: var(--fg-soft); margin-bottom: 6px; font-weight: 500; }
.form-row input, .form-row select, .form-row textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-size: 14px;
    font-family: inherit;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: var(--accent); }
.form-row textarea { min-height: 120px; resize: vertical; }
.form-row .hint { font-size: 12px; color: var(--fg-muted); margin-top: 4px; }
.form-grid { display: grid; gap: 16px; }
@media (min-width: 720px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } .form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }

/* Alerts */
.alert { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; border: 1px solid; }
.alert-success { background: rgba(34,197,94,.10); border-color: rgba(34,197,94,.35); color: #15803d; }
.alert-error { background: rgba(239,68,68,.10); border-color: rgba(239,68,68,.35); color: #b91c1c; }
.alert-info { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
[data-theme="dark"] .alert-success { color: #86efac; }
[data-theme="dark"] .alert-error { color: #fca5a5; }

/* Breadcrumbs */
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--fg-muted); margin: 24px 0 16px; }
.breadcrumbs a { color: var(--fg-soft); }
.breadcrumbs span.sep { color: var(--border-strong); }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent); letter-spacing: 0.04em; }

/* Footer */
.site-footer { background: var(--bg-soft); border-top: 1px solid var(--border); padding: 60px 0 28px; margin-top: 80px; }
.footer-grid { display: grid; gap: 32px; }
@media (min-width: 720px) { .footer-grid { grid-template-columns: 1.5fr 1fr 1fr 1fr; } }
.footer-grid h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.10em; color: var(--fg-muted); margin: 0 0 14px; font-weight: 600; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 8px; }
.footer-grid a { color: var(--fg-soft); font-size: 14px; }
.footer-grid a:hover { color: var(--accent); }
.footer-brand { display: flex; gap: 14px; align-items: flex-start; }
.footer-brand img { width: 56px; height: 56px; border-radius: 50%; }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 40px; padding-top: 20px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--fg-muted); }
.social-links { display: flex; gap: 10px; }
.social-links a {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--bg-card); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--fg-soft);
    transition: all var(--transition);
}
.social-links a:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.social-links svg { width: 16px; height: 16px; }

/* Hero CTA highlight box */
.cta-box { background: linear-gradient(135deg, var(--accent), #2a5dc5); color: #fff; border-radius: var(--radius-lg); padding: 48px 32px; text-align: center; }
.cta-box h2 { color: #fff; }
.cta-box p { color: rgba(255,255,255,0.85); max-width: 540px; margin: 0 auto 24px; }
.cta-box .btn { background: #fff; color: var(--navy-800); border-color: #fff; }
.cta-box .btn:hover { background: var(--grey-50); color: var(--navy-800); }

/* Article / prose */
.prose { max-width: 760px; margin: 0 auto; }
.prose h2 { margin-top: 1.8em; }
.prose h3 { margin-top: 1.4em; }
.prose ul, .prose ol { padding-left: 1.4em; color: var(--fg-soft); }
.prose code { background: var(--bg-soft); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }

/* Paper detail action buttons */
.paper-actions { display: grid; gap: 12px; margin-top: 24px; }
@media (min-width: 600px) { .paper-actions { grid-template-columns: 1fr 1fr; } }
.paper-action {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    transition: all var(--transition);
}
.paper-action:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.paper-action-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.paper-action-text { font-size: 14px; font-weight: 600; color: var(--fg); }
.paper-action-text small { display: block; font-weight: 400; color: var(--fg-muted); font-size: 12px; }

/* Code variant chips */
.code-formats { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.code-formats span { font-family: 'JetBrains Mono', monospace; padding: 6px 12px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; font-size: 12px; color: var(--fg-soft); }

/* Empty state */
.empty { text-align: center; padding: 60px 20px; color: var(--fg-muted); }
.empty-state {
    background: var(--bg-card);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 56px 28px;
    text-align: center;
}
.empty-state h3 { margin: 0 0 8px; color: var(--fg); }
.empty-state p { color: var(--fg-muted); margin: 0; }

/* Page header */
.page-header {
    margin: 28px 0 32px;
    max-width: 760px;
}
.page-header h1 { margin: 10px 0 12px; }
.page-header p { font-size: 16px; color: var(--fg-soft); margin: 0; }
.page-header code {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-soft);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.88em;
    color: var(--accent);
}

/* Result meta line */
.result-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 4px 18px;
    color: var(--fg-muted);
    font-size: 14px;
}
.result-meta strong { color: var(--fg); }

/* Utilities */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; } .mt-5 { margin-top: 48px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.gap-2 { gap: 16px; }

/* Animations */
@media (prefers-reduced-motion: no-preference) {
    .fade-in { animation: fadeIn 0.5s ease-out both; }
    @keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
}
