/* ============================================
   StudyWith Addi — Shared stylesheet
   ============================================ */

:root {
    --primary: #1c3d5a;
    --primary-dark: #132a3e;
    --secondary: #3d6b8a;
    --accent: #b4532a;
    --accent-soft: #f4e6dc;
    --background: #f6f3ee;
    --surface: #ffffff;
    --text: #1c1c1c;
    --muted: #5a6168;
    --border: #ddd6cc;
    --demo: #8a5a24;
    --demo-bg: #f8f0e4;
    --answer-bg: #eef5ef;
    --answer-border: #3d6b4f;
    --focus: #1c3d5a;
    --shadow: 0 1px 2px rgba(28, 61, 90, 0.06);
    --radius: 10px;
    --header-h: 4rem;
    --max: 68rem;
    --font-sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--text);
    background: var(--background);
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--primary);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

a:hover {
    color: var(--accent);
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
}

.skip-link {
    position: absolute;
    left: 0.75rem;
    top: -3rem;
    z-index: 100;
    padding: 0.5rem 0.85rem;
    background: var(--primary);
    color: #fff;
    border-radius: 6px;
}

.skip-link:focus {
    top: 0.75rem;
}

.container {
    width: min(100% - 2rem, var(--max));
    margin-inline: auto;
}

/* ---------- Header / Nav ---------- */

.header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-h);
    gap: 1rem;
}

.logo {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--primary-dark);
    line-height: 1.2;
}

.logo:hover {
    color: var(--primary);
}

.logo-name {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}

.logo-tag {
    font-size: 0.7rem;
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.nav-toggle {
    display: none;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    padding: 0;
}

.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
    display: block;
    width: 1.15rem;
    height: 2px;
    margin: 0 auto;
    background: var(--primary);
    position: relative;
}

.nav-toggle-bars::before,
.nav-toggle-bars::after {
    content: "";
    position: absolute;
    left: 0;
}

.nav-toggle-bars::before {
    top: -6px;
}

.nav-toggle-bars::after {
    top: 6px;
}

.navbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-list {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-list > li > a,
.nav-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.8rem;
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    background: none;
    border: 0;
    cursor: pointer;
    font-family: inherit;
}

.nav-list > li > a:hover,
.nav-dropdown-toggle:hover,
.nav-list > li > a[aria-current="page"] {
    background: var(--background);
    color: var(--primary);
}

.nav-item-dropdown {
    position: relative;
}

.nav-dropdown {
    display: none;
    position: absolute;
    top: calc(100% - 0.15rem);
    right: 0;
    min-width: 18rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.4rem;
    list-style: none;
    margin: 0;
    z-index: 20;
}

.nav-item-dropdown:hover .nav-dropdown,
.nav-item-dropdown:focus-within .nav-dropdown,
.nav-item-dropdown.is-open .nav-dropdown {
    display: block;
}

.nav-dropdown a {
    display: block;
    padding: 0.55rem 0.75rem;
    text-decoration: none;
    color: var(--text);
    border-radius: 6px;
    font-size: 0.92rem;
}

.nav-dropdown a:hover {
    background: var(--background);
    color: var(--primary);
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0.55rem 1.15rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
}

.btn-secondary {
    background: transparent;
    color: var(--primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--surface);
    color: var(--primary-dark);
    border-color: var(--secondary);
}

.btn-block {
    width: 100%;
}

/* ---------- Hero ---------- */

.hero {
    padding: 4.75rem 0 3.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.hero .container {
    max-width: 46rem;
}

.hero-rule {
    width: 3.5rem;
    height: 3px;
    margin: 0 0 1.15rem;
    background: var(--accent);
    border: 0;
}

.hero-kicker {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--secondary);
    font-weight: 600;
}

.hero h1 {
    margin: 0 0 0.5rem;
    font-family: var(--font-serif);
    font-size: clamp(2.1rem, 5vw, 3.35rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--primary-dark);
}

.hero-tagline {
    margin: 0 0 1.1rem;
    font-size: 1.35rem;
    color: var(--accent);
    font-weight: 600;
}

.hero p {
    margin: 0 0 1.5rem;
    max-width: 38rem;
    color: var(--muted);
    font-size: 1.08rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-bottom: 1.5rem;
}

.notice {
    display: inline-block;
    padding: 0.65rem 0.9rem;
    background: var(--demo-bg);
    border: 1px solid #ead9c4;
    border-radius: 8px;
    color: var(--demo);
    font-weight: 600;
    font-size: 0.95rem;
}

/* ---------- Subjects grid ---------- */

.section {
    padding: 3.25rem 0;
}

.section-title {
    margin: 0 0 0.4rem;
    font-family: var(--font-serif);
    font-size: clamp(1.6rem, 3vw, 2rem);
    color: var(--primary-dark);
}

.section-lead {
    margin: 0 0 1.75rem;
    color: var(--muted);
    max-width: 40rem;
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.1rem;
}

.subject-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.3rem 1.35rem;
    box-shadow: var(--shadow);
}

.subject-card h3 {
    margin: 0 0 0.5rem;
    font-family: var(--font-serif);
    font-size: 1.2rem;
    line-height: 1.3;
    color: var(--primary-dark);
}

.subject-card p {
    margin: 0 0 1rem;
    color: var(--muted);
    font-size: 0.95rem;
    flex: 1;
}

.subject-meta {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary);
}

/* ---------- Page header / breadcrumb ---------- */

.page-header {
    padding: 2rem 0 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    list-style: none;
    margin: 0 0 0.9rem;
    padding: 0;
    font-size: 0.88rem;
    color: var(--muted);
}

.breadcrumb li:not(:last-child)::after {
    content: "→";
    margin-left: 0.35rem;
    color: var(--border);
}

.breadcrumb a {
    color: var(--secondary);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.page-header h1 {
    margin: 0 0 0.5rem;
    font-family: var(--font-serif);
    font-size: clamp(1.7rem, 3.5vw, 2.25rem);
    color: var(--primary-dark);
}

.page-header p {
    margin: 0;
    color: var(--muted);
    max-width: 40rem;
}

/* ---------- Search ---------- */

.search-box {
    margin: 1.5rem 0 1.75rem;
}

.search-box label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--primary-dark);
}

.search-box input[type="search"] {
    width: 100%;
    max-width: 28rem;
    min-height: 2.75rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
}

.search-empty {
    margin: 0 0 1.25rem;
    color: var(--muted);
}

.search-empty[hidden] {
    display: none;
}

/* ---------- Question list ---------- */

.question-list {
    display: grid;
    gap: 0.85rem;
}

.question-list + .notice {
    margin-top: 1.5rem;
}

.question-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    color: inherit;
    box-shadow: var(--shadow);
}

.question-card:hover {
    border-color: var(--secondary);
}

.question-card[hidden] {
    display: none;
}

.question-card-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.45rem;
}

.question-card-subject {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--secondary);
}

.question-card h2 {
    margin: 0 0 0.35rem;
    font-family: var(--font-serif);
    font-size: 1.15rem;
    color: var(--primary-dark);
}

.question-card p {
    margin: 0 0 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.question-card .btn {
    margin-top: auto;
}

.badge {
    display: inline-block;
    margin-bottom: 0.45rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: var(--demo-bg);
    color: var(--demo);
}

/* ---------- Empty state ---------- */

.empty-state {
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.75rem 1.5rem;
}

.empty-icon {
    width: 3.5rem;
    height: 4.1rem;
    margin: 0 auto 1.1rem;
    border: 2px solid var(--secondary);
    border-radius: 4px 10px 4px 4px;
    position: relative;
    opacity: 0.7;
}

.empty-icon::before {
    content: "";
    position: absolute;
    left: 0.55rem;
    right: 0.55rem;
    top: 1.1rem;
    height: 2px;
    background: var(--border);
    box-shadow: 0 8px 0 var(--border), 0 16px 0 var(--border);
}

.empty-state h2 {
    margin: 0 0 0.5rem;
    font-family: var(--font-serif);
    font-size: 1.4rem;
    color: var(--primary-dark);
}

.empty-state p {
    margin: 0 0 0.55rem;
    color: var(--muted);
}

.empty-state p:last-child {
    margin-bottom: 0;
    margin-top: 1rem;
    font-weight: 600;
    color: var(--demo);
}

/* ---------- Question content (reusable for all solutions) ---------- */

.demo-banner {
    margin-bottom: 1.5rem;
    padding: 0.9rem 1rem;
    background: var(--demo-bg);
    border: 1px solid #ead9c4;
    border-left: 4px solid var(--demo);
    border-radius: 6px;
    color: var(--demo);
}

.demo-banner strong {
    display: block;
    margin-bottom: 0.2rem;
}

.question-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.6rem 1.5rem 1.8rem;
    max-width: 56rem;
}

.question-content h1 {
    margin: 0 0 0.35rem;
    font-family: var(--font-serif);
    font-size: 1.7rem;
    line-height: 1.3;
    color: var(--primary-dark);
}

.question-subject-label {
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--secondary);
}

.qc-section,
.question-section,
.solution-section,
.solution,
.final-answer {
    margin-bottom: 1.75rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.qc-section:last-child,
.question-section:last-child,
.solution-section:last-child,
.back-link-wrap {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.qc-section h2,
.question-section h2,
.solution-section h2 {
    margin: 0 0 0.85rem;
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--secondary);
    font-weight: 600;
}

.qc-section p,
.qc-section li,
.question-section p,
.solution-section p {
    font-size: 1.08rem;
    line-height: 1.75;
}

.qc-section p,
.question-section p,
.solution-section p {
    margin: 0 0 0.7rem;
}

.qc-section p:last-child,
.question-section p:last-child,
.solution-section p:last-child {
    margin-bottom: 0;
}

.question-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0 1rem;
    font-size: 0.98rem;
}

.question-content th,
.question-content td {
    border: 1px solid var(--border);
    padding: 0.45rem 0.65rem;
    text-align: left;
}

.question-content th {
    background: var(--background);
}

.qc-formula {
    font-family: var(--font-serif);
}

.formula-block,
.MathJax {
    overflow-x: auto;
}

.qc-step {
    margin: 0 0 1rem;
    padding-left: 0.9rem;
    border-left: 2px solid var(--border);
}

.qc-step h3 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    color: var(--primary-dark);
}

.qc-final-answer,
.final-answer {
    background: var(--answer-bg);
    border: 1px solid #c9ddd0;
    border-left: 4px solid var(--answer-border);
    border-radius: 8px;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid #c9ddd0;
}

.qc-final-answer h2,
.final-answer h2 {
    color: var(--answer-border);
}

.qc-notes,
.notes-section {
    color: var(--muted);
    font-size: 0.98rem;
}

.placeholder-text {
    font-style: italic;
    color: var(--muted);
}

/* Question / solution images */

.question-image,
.solution-images,
.question-content figure {
    margin: 0 0 1rem;
}

.question-content img,
.solution-image {
    display: block;
    width: 100%;
    max-width: 900px;
    height: auto;
    margin: 0 auto 1.5rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--background);
    cursor: zoom-in;
}

.question-content img:last-child,
.solution-images .solution-image:last-child {
    margin-bottom: 0;
}

.question-pdf {
    margin: 1rem 0 0;
    font-size: 0.95rem;
}

.back-link-wrap {
    margin-top: 1.75rem;
}

.back-link {
    font-weight: 600;
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

/* Lightbox */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(12, 20, 28, 0.88);
}

.lightbox[hidden] {
    display: none;
}

.lightbox img {
    max-width: min(96vw, 1100px);
    max-height: 90vh;
    width: auto;
    height: auto;
    border-radius: 8px;
    cursor: default;
    background: #fff;
}

.lightbox-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
    background: rgba(255, 255, 255, 0.22);
}

body.lightbox-open {
    overflow: hidden;
}

/* ---------- Simple pages ---------- */

.prose {
    max-width: 40rem;
}

.prose h1 {
    margin: 0 0 1rem;
    font-family: var(--font-serif);
    font-size: clamp(1.7rem, 3.5vw, 2.25rem);
    color: var(--primary-dark);
}

.prose p {
    margin: 0 0 1rem;
    color: var(--text);
}

/* ---------- Footer ---------- */

.footer {
    margin-top: 2rem;
    padding: 2.5rem 0 1.5rem;
    background: var(--primary-dark);
    color: #e8eef3;
}

.footer a {
    color: #d5e4ef;
    text-decoration: none;
}

.footer a:hover {
    color: #fff;
    text-decoration: underline;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1.3fr;
    gap: 2rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.footer-brand {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: #fff;
}

.footer-tag {
    margin: 0;
    color: #b9c9d6;
    font-size: 0.95rem;
}

.footer h2 {
    margin: 0 0 0.65rem;
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #9eb4c6;
    font-weight: 600;
}

.footer ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer li {
    margin-bottom: 0.4rem;
}

.footer-bottom {
    padding-top: 1.15rem;
    font-size: 0.88rem;
    color: #9eb4c6;
}

.footer-bottom p {
    margin: 0 0 0.35rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
    .subject-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 720px) {
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .navbar {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        top: var(--header-h);
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        padding: 0.5rem 1rem 1rem;
    }

    .header.is-open .navbar {
        display: block;
    }

    .nav-list {
        flex-direction: column;
        align-items: stretch;
    }

    .nav-dropdown {
        position: static;
        display: none;
        min-width: 0;
        box-shadow: none;
        border: 0;
        padding: 0 0 0 0.6rem;
    }

    .nav-item-dropdown.is-open .nav-dropdown {
        display: block;
    }

    .nav-item-dropdown:hover .nav-dropdown {
        display: none;
    }

    .nav-item-dropdown.is-open .nav-dropdown {
        display: block;
    }

    .subject-grid,
    .footer-grid {
        grid-template-columns: 1fr;
    }

    .hero {
        padding: 2.75rem 0 2.35rem;
    }

    .hero-actions .btn {
        flex: 1 1 100%;
    }

    .question-content {
        padding: 1.2rem 1rem 1.4rem;
    }

    .lightbox {
        padding: 3.5rem 0.5rem 0.75rem;
    }

    .lightbox img {
        max-height: 82vh;
    }
}
/* ---------- Support button ---------- */
/* ================================
   Support Study with Aadi
   ================================ */

.support-aadi {
    max-width: 600px;
    margin: 45px auto 30px;
    padding: 24px 20px;
    text-align: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}

.support-aadi p {
    margin: 0 0 15px;
    font-size: 15px;
    color: #475569;
}

.support-button {
    display: inline-block;
    padding: 10px 20px;
    background: #1e4668;
    color: #ffffff !important;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.support-button:hover {
    background: #163750;
    transform: translateY(-1px);
}

/* Mobile */
@media (max-width: 600px) {
    .support-aadi {
        margin: 35px 15px 25px;
        padding: 20px 15px;
    }

    .support-aadi p {
        font-size: 14px;
    }

    .support-button {
        padding: 10px 18px;
        font-size: 14px;
    }
}