/* Unified topic pages style based on study/index.html */

:root {
    --bg: #061a2b;
    --bg-soft: #0d2740;
    --surface: rgba(255, 255, 255, 0.08);
    --surface-strong: rgba(255, 255, 255, 0.14);
    --text: #edf4ff;
    --muted: #9eb4d6;
    --line: rgba(255, 255, 255, 0.15);
    --aqua: #3de4d3;
    --lime: #b9f56a;
    --orange: #ff9a3d;
    --accent: #4db8ff;
    --code-text: #b9f56a;
    --max-width: 1160px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --shadow: 0 24px 60px rgba(2, 10, 20, 0.45);
}

body.light-theme {
    --bg: #f4f8ff;
    --bg-soft: #dff0ff;
    --surface: rgba(7, 31, 52, 0.05);
    --surface-strong: rgba(7, 31, 52, 0.1);
    --text: #082033;
    --muted: #43627e;
    --line: rgba(7, 31, 52, 0.18);
    --aqua: #0aa6a8;
    --lime: #4f8f24;
    --orange: #cc7421;
    --accent: #0c6db6;
    --code-text: #2a7a20;
    --shadow: 0 20px 48px rgba(20, 50, 80, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family: "Manrope", sans-serif;
    color: var(--text);
    line-height: 1.65;
    background:
        radial-gradient(circle at 15% 20%, rgba(61, 228, 211, 0.15), transparent 36%),
        radial-gradient(circle at 82% 15%, rgba(255, 154, 61, 0.17), transparent 34%),
        radial-gradient(circle at 60% 80%, rgba(185, 245, 106, 0.12), transparent 30%),
        linear-gradient(135deg, #05101d 0%, #0a2238 52%, #06192b 100%);
    overflow-x: hidden;
    transition: background-color 0.25s ease, color 0.25s ease;
}

body.light-theme {
    background:
        radial-gradient(circle at 15% 20%, rgba(12, 109, 182, 0.1), transparent 38%),
        radial-gradient(circle at 82% 15%, rgba(204, 116, 33, 0.1), transparent 36%),
        radial-gradient(circle at 60% 80%, rgba(79, 143, 36, 0.09), transparent 32%),
        linear-gradient(140deg, #f7fbff 0%, #ecf5ff 52%, #f4f9ff 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 34px 34px;
    opacity: 0.2;
    z-index: -2;
}

body.light-theme::before {
    background-image:
        linear-gradient(rgba(7, 31, 52, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(7, 31, 52, 0.05) 1px, transparent 1px);
    opacity: 0.3;
}

.bg-blobs {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: -1;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(86px);
    opacity: 0.4;
}

.blob-1 {
    width: min(56vw, 620px);
    height: min(56vw, 620px);
    left: -14vw;
    top: -12vw;
    background: rgba(61, 228, 211, 0.28);
}

.blob-2 {
    width: min(45vw, 520px);
    height: min(45vw, 520px);
    right: -11vw;
    bottom: -16vw;
    background: rgba(255, 154, 61, 0.22);
}

nav {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(12px);
    background: rgba(4, 15, 27, 0.7);
    border-bottom: 1px solid var(--line);
}

body.light-theme nav {
    background: rgba(244, 249, 255, 0.82);
}

.nav-container {
    width: min(var(--max-width), calc(100% - 28px));
    min-height: 74px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    font-family: "Bricolage Grotesque", sans-serif;
    font-size: clamp(1.1rem, 2.6vw, 1.28rem);
    font-weight: 700;
    letter-spacing: 0.3px;
}

.logo .brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: conic-gradient(from 200deg, var(--orange), var(--lime), var(--aqua), var(--orange));
    box-shadow: 0 0 28px rgba(61, 228, 211, 0.45);
    flex: 0 0 30px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-links a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 13px;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: 0.2s ease;
}

.nav-links a:hover {
    color: var(--text);
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.06);
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

@media (min-width: 961px) {
    .nav-container {
        justify-content: flex-start;
    }

    .nav-links {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }

    .controls {
        margin-left: auto;
    }
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    display: grid;
    place-items: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.12);
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
}

.hamburger span {
    width: 24px;
    height: 3px;
    border-radius: 2px;
    background: var(--text);
    transition: 0.2s ease;
}

.article-hero {
    width: min(var(--max-width), calc(100% - 28px));
    margin: 20px auto 0 auto;
    border: 1px solid var(--line);
    border-radius: clamp(20px, 3vw, 34px);
    overflow: hidden;
    padding: clamp(26px, 5.2vw, 56px);
    background:
        linear-gradient(145deg, rgba(13, 39, 64, 0.85), rgba(4, 17, 30, 0.88)),
        repeating-linear-gradient(-24deg, rgba(255, 255, 255, 0.02) 0 12px, transparent 12px 24px);
    box-shadow: var(--shadow);
}

body.light-theme .article-hero {
    background:
        linear-gradient(145deg, rgba(236, 245, 255, 0.94), rgba(224, 238, 252, 0.92)),
        repeating-linear-gradient(-24deg, rgba(7, 31, 52, 0.03) 0 12px, transparent 12px 24px);
}

.article-hero h1 {
    font-family: "Bricolage Grotesque", sans-serif;
    font-weight: 800;
    line-height: 0.98;
    letter-spacing: -0.02em;
    font-size: clamp(1.9rem, 5.6vw, 3.5rem);
    margin-bottom: 10px;
    max-width: 16ch;
}

.article-hero p,
.subtitle {
    color: var(--muted);
    max-width: 68ch;
}

.article-container,
.container {
    width: min(960px, calc(100% - 28px));
    margin: 22px auto 50px auto;
}

.article-box {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: rgba(8, 28, 46, 0.58);
    box-shadow: var(--shadow);
    padding: clamp(20px, 4vw, 40px);
}

body.light-theme .article-box {
    background: rgba(255, 255, 255, 0.66);
}

.double-frame {
    padding: clamp(20px, 4vw, 32px);
}

.double-frame .inner-frame {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: clamp(18px, 3vw, 28px);
    background: rgba(5, 25, 43, 0.55);
}

body.light-theme .double-frame .inner-frame {
    background: rgba(255, 255, 255, 0.72);
}

.article-content h2 {
    font-family: "Bricolage Grotesque", sans-serif;
    font-size: clamp(1.4rem, 3vw, 1.95rem);
    margin-top: 2rem;
    margin-bottom: 0.8rem;
}

.article-content h2:first-child {
    margin-top: 0;
}

.article-content h3 {
    font-family: "Bricolage Grotesque", sans-serif;
    font-size: clamp(1.15rem, 2.6vw, 1.4rem);
    margin-top: 1.6rem;
    margin-bottom: 0.65rem;
    color: var(--aqua);
}

.article-content h4 {
    font-family: "Bricolage Grotesque", sans-serif;
    font-size: 1.06rem;
    margin-top: 1.1rem;
    margin-bottom: 0.5rem;
}

.article-content p,
.content-section p,
.support-banner p,
.support-box p {
    color: var(--muted);
    margin-bottom: 1rem;
}

.article-content ul,
.article-content ol,
.content-section ul,
.content-section ol {
    padding-left: 1.2rem;
    margin: 0.6rem 0 1rem 0;
    color: var(--muted);
}

.article-content li,
.content-section li {
    margin-bottom: 0.4rem;
}

.formula,
.matrix,
.math-block,
.formula-block,
.formula-box {
    margin: 1rem 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 0.95rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    color: var(--code-text);
    font-family: "Bricolage Grotesque", sans-serif;
    font-weight: 700;
}

.example-box,
.step,
.example,
.note {
    margin: 1.1rem 0;
    border: 1px solid var(--line);
    border-left: 4px solid var(--aqua);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    background: rgba(255, 255, 255, 0.03);
}

.example-steps {
    display: grid;
    gap: 12px;
}

.content-section {
    margin-top: 1.3rem;
}

.related-grid,
.figure-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 1rem;
}

.card,
.figure-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.04);
}

.card h3,
.figure-card h3 {
    font-family: "Bricolage Grotesque", sans-serif;
    margin-bottom: 0.4rem;
}

.card p,
.figure-card p {
    color: var(--muted);
}

.card-link,
.support-box a,
.support-banner a {
    color: var(--aqua);
    font-weight: 700;
    text-decoration: none;
}

.card-link:hover,
.support-box a:hover,
.support-banner a:hover {
    text-decoration: underline;
}

.support-box,
.support-banner {
    margin-top: 1.8rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 1.1rem 1.2rem;
    background:
        linear-gradient(135deg, rgba(61, 228, 211, 0.08), rgba(185, 245, 106, 0.06));
}

strong {
    color: var(--text);
}

footer {
    width: min(var(--max-width), calc(100% - 28px));
    margin: 26px auto 28px auto;
    text-align: center;
    color: var(--muted);
    border-top: 1px solid var(--line);
    padding: 16px 6px;
}

@media (max-width: 960px) {
    .hamburger {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 74px;
        right: 14px;
        width: min(320px, calc(100% - 28px));
        border: 1px solid var(--line);
        border-radius: 14px;
        background: rgba(7, 21, 37, 0.96);
        display: none;
        flex-direction: column;
        align-items: stretch;
        padding: 8px;
        z-index: 80;
    }

    body.light-theme .nav-links {
        background: rgba(244, 249, 255, 0.98);
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links a {
        padding: 10px;
        border-radius: 10px;
    }

    .article-box {
        padding: 20px;
    }
}
