/* ===================================================================
   JDN720 Study Guides — design tokens & site styles
   =================================================================== */

:root {
    --color-primary: #2B3A55;
    --color-secondary: #5B6472;
    --color-bg: #FBFAF7;
    --color-bg-alt: #F3F1EA;
    --color-border: #E4E0D6;
    --color-text: #1B1F2A;
    --color-text-muted: #5B6472;
    --color-link: #3A5A78;

    --color-trap: #B5762A;
    --color-trap-bg: #F6E9D7;
    --color-exam: #3A5A78;
    --color-exam-bg: #E4EBEF;
    --color-ahead: #6B4C6E;
    --color-ahead-bg: #EBE3EC;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

[data-theme="dark"] {
    --color-bg: #14171F;
    --color-bg-alt: #1C2029;
    --color-border: #2B303C;
    --color-text: #ECEAE3;
    --color-text-muted: #9BA3AF;
    --color-primary: #8CA3C7;
    --color-link: #8CA3C7;

    --color-trap: #E0AE68;
    --color-trap-bg: #34291A;
    --color-exam: #8CA3C7;
    --color-exam-bg: #1E2A38;
    --color-ahead: #C79FCB;
    --color-ahead-bg: #2A2333;
}

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

body {
    font-family: var(--font-sans);
    font-size: 17px;
    line-height: 1.65;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* ===================================================================
   Layout — study guide pages get a fixed TOC rail + fluid content column
   =================================================================== */

body.study-guide main.container {
    max-width: 1320px;
    display: flex;
    align-items: flex-start;
    gap: 3rem;
    margin-top: 2.5rem;
}

body.study-guide .site-header .container {
    max-width: 1320px;
}

@media (max-width: 968px) {
    body.study-guide main.container {
        flex-direction: column;
    }
}

/* ===================================================================
   Theme toggle & back-to-top
   =================================================================== */

.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.2s;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    stroke: var(--color-text);
}

.theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--color-primary);
    color: var(--color-bg);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.2s;
}

.back-to-top.show {
    opacity: 1;
    pointer-events: auto;
}

.back-to-top:hover {
    transform: translateY(-4px);
}

/* ===================================================================
   Index page — top nav, hero, week cards, about
   =================================================================== */

.top-nav {
    background: var(--color-bg-alt);
    border-bottom: 1px solid var(--color-border);
    padding: 1.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.nav-meta {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.nav-meta span {
    margin-right: 0.5rem;
}

.hero {
    padding: 4.5rem 0 3rem;
}

.hero h2 {
    font-size: 2.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.lead {
    font-size: 1.2rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    max-width: 640px;
}

.weeks-list {
    margin: 2.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.week-card {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 2rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.week-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.week-card.upcoming {
    opacity: 0.55;
    border-style: dashed;
}

.week-number {
    font-size: 0.8rem;
    color: var(--color-primary);
    font-weight: 600;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.week-card h3 {
    font-size: 1.65rem;
    margin-bottom: 0.6rem;
    font-weight: 700;
}

.week-description {
    color: var(--color-text-muted);
    margin-bottom: 1.25rem;
}

.week-highlights {
    list-style: none;
    margin-bottom: 1.5rem;
}

.week-highlights li {
    padding: 0.4rem 0;
    font-size: 0.95rem;
}

.week-highlights li:before {
    content: "→ ";
    color: var(--color-primary);
    font-weight: bold;
    margin-right: 0.4rem;
}

.btn-primary {
    display: inline-block;
    background: var(--color-primary);
    color: var(--color-bg);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: opacity 0.2s;
}

.btn-primary:hover {
    opacity: 0.85;
    text-decoration: none;
}

.about {
    margin-top: 2rem;
    padding: 3.5rem 0;
    background: var(--color-bg-alt);
    border-top: 1px solid var(--color-border);
}

.about h3 {
    font-size: 1.9rem;
    margin-bottom: 2.5rem;
    text-align: center;
    font-weight: 700;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 2rem;
}

.feature h4 {
    font-size: 1.05rem;
    margin-bottom: 0.6rem;
    font-weight: 600;
    position: relative;
    padding-top: 0.9rem;
}

.feature h4::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 3px;
    background: var(--color-primary);
}

.feature p {
    font-size: 0.92rem;
    color: var(--color-text-muted);
    line-height: 1.6;
}

/* ===================================================================
   Badges
   =================================================================== */

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-trap {
    background: var(--color-trap-bg);
    color: var(--color-trap);
}

.badge-exam {
    background: var(--color-exam-bg);
    color: var(--color-exam);
}

.badge-ahead {
    background: var(--color-ahead-bg);
    color: var(--color-ahead);
}

/* ===================================================================
   Footer
   =================================================================== */

footer, .site-footer {
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    padding: 2rem 0;
    text-align: center;
}

footer {
    margin-top: 0;
}

.site-footer {
    margin-top: 4rem;
}

footer p, .site-footer p {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 0.4rem;
}

footer a, .site-footer a {
    color: var(--color-link);
}

.disclaimer {
    font-size: 0.8rem;
    font-style: italic;
}

/* ===================================================================
   Study guide header
   =================================================================== */

.site-header {
    background: var(--color-bg-alt);
    border-bottom: 1px solid var(--color-border);
    padding: 2rem 0;
}

.site-nav {
    margin-bottom: 1rem;
}

.nav-link {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    text-decoration: none;
}

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

.header-content h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.header-content .subtitle {
    color: var(--color-text-muted);
    font-size: 1.05rem;
    margin-bottom: 1rem;
}

.meta {
    font-size: 0.9rem;
}

.meta p {
    margin: 0.2rem 0;
}

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

/* ===================================================================
   Table of contents
   =================================================================== */

.toc {
    flex: 0 0 260px;
    width: 260px;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.5rem;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.toc h2 {
    font-size: 0.8rem;
    margin-bottom: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

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

.toc li {
    padding: 0.2rem 0;
}

.toc ul ul {
    padding-left: 1rem;
}

.toc a {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.875rem;
    display: block;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.toc a:hover {
    background: var(--color-border);
}

.toc a.active {
    background: var(--color-primary);
    color: var(--color-bg);
    font-weight: 600;
}

@media (max-width: 968px) {
    .toc {
        position: static;
        width: 100%;
        flex: none;
        max-height: none;
        margin-bottom: 1.5rem;
    }
}

/* ===================================================================
   Content typography
   =================================================================== */

.content {
    min-width: 0;
    flex: 1 1 auto;
}

.content section {
    margin-bottom: 3rem;
    scroll-margin-top: 100px;
}

.content h2 {
    font-size: 1.85rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--color-border);
    font-weight: 700;
}

.content h2:first-child {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

.content h3 {
    font-size: 1.4rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.content h4 {
    font-size: 1.15rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--color-primary);
    font-weight: 700;
}

.content h5 {
    font-size: 1rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.content p {
    margin-bottom: 1rem;
}

.content ul, .content ol {
    margin: 1rem 0 1rem 1.5rem;
}

.content li {
    margin-bottom: 0.5rem;
}

blockquote {
    border-left: 4px solid var(--color-border);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: var(--color-text-muted);
    font-style: italic;
}

/* ===================================================================
   Codal text quotes (article text)
   =================================================================== */

.codal-article, .article-box, .article-text {
    background: var(--color-trap-bg);
    border: 1px solid var(--color-trap);
    border-radius: 8px;
    padding: 1.5rem 1.75rem;
    margin: 1.5rem 0;
    font-style: italic;
    line-height: 1.8;
}

.codal-article p, .article-box p, .article-text p {
    margin-bottom: 0.75rem;
}

.codal-article p:last-child, .article-box p:last-child, .article-text p:last-child {
    margin-bottom: 0;
}

.article-header {
    background: var(--color-bg-alt);
    border-left: 4px solid var(--color-primary);
    padding: 1.5rem;
    margin: 2rem 0 1rem;
    border-radius: 4px;
}

.article-number {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--color-primary);
    font-weight: 600;
}

/* ===================================================================
   Case boxes
   =================================================================== */

.case-box {
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
    border-radius: 8px;
    padding: 1.75rem;
    margin: 2rem 0;
    background: var(--color-bg);
}

.case-box h4 {
    font-size: 1.35rem;
    margin-bottom: 0.4rem;
    color: var(--color-primary);
}

.case-citation {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 1.25rem;
}

/* ===================================================================
   Case links — signal that these open the full text elsewhere
   =================================================================== */

a.case-link {
    color: var(--color-link);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}

a.case-link:hover {
    text-decoration-thickness: 2px;
}

.external-icon {
    font-size: 0.75em;
    opacity: 0.65;
    margin-left: 0.1em;
}

/* ===================================================================
   Tables
   =================================================================== */

.case-table {
    width: 100%;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.case-table th,
.case-table td {
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: top;
}

.case-table th:nth-child(1), .case-table td:nth-child(1) { width: 90px; }
.case-table th:nth-child(2), .case-table td:nth-child(2) { width: 240px; }

.case-table thead th {
    background: var(--color-bg-alt);
    font-weight: 600;
}

.case-table tbody tr:last-child td {
    border-bottom: none;
}

.case-table tbody tr:hover {
    background: var(--color-bg-alt);
}

.comparison-table, .content-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.92rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}

.comparison-table th,
.comparison-table td,
.content-table th,
.content-table td {
    border: 1px solid var(--color-border);
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: top;
    word-wrap: break-word;
}

.comparison-table th:first-child,
.comparison-table td:first-child {
    width: 22%;
    font-weight: 600;
}

.comparison-table th,
.content-table th {
    background: var(--color-bg-alt);
    font-weight: 600;
}

.comparison-table tr:hover,
.content-table tr:hover {
    background: var(--color-bg-alt);
}

/* ===================================================================
   Footnotes
   =================================================================== */

.footnote-ref {
    display: inline-block;
    color: var(--color-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    vertical-align: super;
    cursor: help;
    border-bottom: 1px dotted var(--color-primary);
    margin: 0 0.125rem;
}

.footnote-tooltip {
    position: absolute;
    background: var(--color-text);
    color: var(--color-bg);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    max-width: 400px;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    display: none;
}

.footnote-tooltip.show {
    display: block;
}

/* ===================================================================
   Callout boxes
   =================================================================== */

.callout {
    border-left: 4px solid var(--color-border);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 4px;
    background: var(--color-bg-alt);
}

.callout.trap {
    border-left-color: var(--color-trap);
    background: var(--color-trap-bg);
}

.callout.exam-angle {
    border-left-color: var(--color-exam);
    background: var(--color-exam-bg);
}

.callout.ahead {
    border-left-color: var(--color-ahead);
    background: var(--color-ahead-bg);
}

/* ===================================================================
   Responsive
   =================================================================== */

@media (max-width: 768px) {
    body {
        font-size: 16px;
    }

    .container {
        padding: 0 1rem;
    }

    .hero h2 {
        font-size: 2rem;
    }

    .lead {
        font-size: 1.1rem;
    }

    .week-card {
        padding: 1.5rem;
    }

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

    .case-box {
        padding: 1.25rem;
    }

    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }
}
