/* ==========================================================================
   Atid College – Premium theme layer (cosmetic only)
   --------------------------------------------------------------------------
   * Loaded AFTER the legacy styles and the Tailwind CDN, so every selector is
     prefixed with `html body` to win the cascade without touching the HTML.
   * Remove the <link> to this file (and assets/js/theme.js) to get the old
     look back – nothing else in the pages was modified.
   * Light is the default. Dark is opt-in via <html data-theme="dark">.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@300;400;500;600;700;800&display=swap');

/* ---------- 1. Design tokens ------------------------------------------- */
:root {
    --bg: #f4f6fc;
    --bg-glow-1: rgba(120, 134, 240, .20);
    --bg-glow-2: rgba(92, 190, 200, .16);
    --bg-glow-3: rgba(240, 176, 128, .12);

    --surface: rgba(255, 255, 255, .72);
    --surface-solid: #ffffff;
    --surface-2: rgba(238, 241, 252, .72);
    --glass-blur: 16px;

    --text: #2c3452;
    --muted: #6a7394;
    --heading: #4350b8;
    --link: #4f5fd8;

    --primary: #6272e8;
    --primary-2: #8a97f2;
    --primary-ink: #ffffff;
    --accent: #8d72d8;
    --accent-2: #b39ae8;
    --teal: #4fb0bd;
    --warm: #eaa670;
    --rose: #e07f93;
    --success: #5db98c;

    --chip: rgba(98, 114, 232, .11);
    --chip-strong: rgba(98, 114, 232, .20);
    --border: rgba(92, 104, 170, .16);
    --line: rgba(98, 114, 232, .34);

    --shadow-sm: 0 2px 8px rgba(50, 62, 130, .07);
    --shadow: 0 10px 34px rgba(50, 62, 130, .10);
    --shadow-lg: 0 18px 50px rgba(50, 62, 130, .16);

    --radius-sm: 12px;
    --radius: 18px;
    --radius-lg: 26px;
    --pill: 999px;

    --code-bg: #f6f7fd;
    --code-text: #333b5c;

    --ease: cubic-bezier(.22, .8, .3, 1);
}

:root[data-theme="dark"] {
    --bg: #10142b;
    --bg-glow-1: rgba(110, 124, 255, .20);
    --bg-glow-2: rgba(70, 170, 190, .12);
    --bg-glow-3: rgba(200, 130, 170, .09);

    --surface: rgba(30, 36, 70, .66);
    --surface-solid: #1b2145;
    --surface-2: rgba(44, 53, 98, .55);

    --text: #e2e6fa;
    --muted: #9ea7cf;
    --heading: #b2bcff;
    --link: #9fb0ff;

    --primary: #7d8cff;
    --primary-2: #a2adff;
    --primary-ink: #0f1330;
    --accent: #b79cff;
    --accent-2: #cdbcff;
    --teal: #6ccad6;
    --warm: #f0b88a;
    --rose: #f09aab;
    --success: #78d0a6;

    --chip: rgba(125, 140, 255, .15);
    --chip-strong: rgba(125, 140, 255, .26);
    --border: rgba(160, 172, 255, .16);
    --line: rgba(140, 154, 255, .38);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .25);
    --shadow: 0 10px 34px rgba(0, 0, 0, .32);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .45);

    --code-bg: #171c3b;
    --code-text: #d7dcf5;
}

/* ---------- 2. Base ----------------------------------------------------- */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 110px;
    -webkit-text-size-adjust: 100%;
}

html body {
    font-family: 'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(900px 520px at 100% -5%, var(--bg-glow-1), transparent 70%),
        radial-gradient(800px 520px at -5% 35%, var(--bg-glow-2), transparent 70%),
        radial-gradient(700px 500px at 60% 110%, var(--bg-glow-3), transparent 70%);
    background-attachment: fixed;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    transition: background-color .4s var(--ease), color .3s var(--ease);
    overflow-x: hidden;
}

html ::selection { background: var(--chip-strong); }

html body :focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 6px;
}

html body img, html body video { max-width: 100%; }
html body img { height: auto; }

/* Soft custom scrollbars */
html ::-webkit-scrollbar { width: 10px; height: 10px; }
html ::-webkit-scrollbar-track { background: transparent; }
html ::-webkit-scrollbar-thumb {
    background: var(--chip-strong); border-radius: var(--pill);
    border: 2px solid transparent; background-clip: content-box;
}
html ::-webkit-scrollbar-thumb:hover { background: var(--primary-2); background-clip: content-box; border: 2px solid transparent; }
html { scrollbar-width: thin; scrollbar-color: var(--chip-strong) transparent; }

/* Documents rendered inside the header / menu / footer iframes */
html.is-embedded body {
    background: transparent !important;
    background-image: none !important;
    height: auto !important;
    min-height: 0 !important;
    overflow-x: hidden;
}

/* ---------- 3. Page frame (header / menu / content / footer) ------------ */
html body .content-area-container {
    width: 100%;
    max-width: 1480px;
    margin: 14px auto 0;
    padding: 0 14px;
    gap: 18px;
    align-items: flex-start;
    box-sizing: border-box;
}

/* Floating header */
html body iframe.header-iframe {
    display: block;
    position: sticky;
    top: 10px;
    z-index: 60;
    width: calc(100% - 28px);
    max-width: 1452px;
    height: 84px;
    margin: 10px auto 0;
    border-radius: var(--radius-lg);
    background: var(--surface);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    flex: none;
}

/* Floating menu card - part of the normal page flow (never scrolls on its own).
   Its height is fitted to the menu content by progress.js / theme.js. */
html body iframe.menu-iframe {
    flex: none;
    width: 320px;
    height: 900px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Content card */
html body .content-area-container .main-content,
html body article.main-content {
    background: var(--surface);
    -webkit-backdrop-filter: blur(var(--glass-blur));
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: clamp(1rem, 2.6vw, 2.2rem);
    min-width: 0;
    overflow: visible;
    box-sizing: border-box;
}

html body .main-content-inner {
    width: 100%;
    max-width: 1020px;
    margin: 0 auto;
    overflow-wrap: break-word;
}

/* Stand-alone pages (exercises / solutions) */
html body > article.main-content {
    width: min(100% - 28px, 1120px);
    max-width: 1120px;
    margin: 18px auto 0;
    flex-grow: 0;
}

/* Floating footer */
html body iframe.footer-iframe {
    display: block;
    width: calc(100% - 28px);
    max-width: 1452px;
    height: 56px;
    margin: 18px auto 14px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    -webkit-backdrop-filter: blur(var(--glass-blur));
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    flex: none;
}

/* Footer of the stand-alone pages */
html:not(.is-embedded) body > footer {
    width: min(100% - 28px, 1120px);
    margin: 18px auto 14px !important;
    padding: .9rem 1rem !important;
    border-radius: var(--radius);
    background: var(--surface) !important;
    color: var(--muted) !important;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur));
    backdrop-filter: blur(var(--glass-blur));
}

/* ---------- 4. Typography & Tailwind colour remap ----------------------- */
html body .main-content h1,
html body .main-content h2,
html body .main-content h3,
html body .main-content h4 { letter-spacing: -.01em; line-height: 1.35; }

html body .text-blue-700,
html body .text-blue-600,
html body .text-blue-800,
html body .text-blue-500 { color: var(--heading); }
html body .text-purple-600,
html body .text-purple-500 { color: var(--accent); }
html body .text-gray-500 { color: var(--muted); }
html body .text-gray-600,
html body .text-gray-700,
html body .text-gray-800,
html body .text-slate-800,
html body .text-slate-700,
html body .text-slate-600 { color: var(--text); }
html body .text-red-600 { color: var(--rose); }

html body .main-content h3.text-2xl,
html body .main-content h3.text-xl {
    font-weight: 700;
    border-bottom-width: 2px;
    padding-bottom: .55rem;
}
html body .border-blue-500,
html body .border-blue-400 { border-color: var(--line); }
html body .border-gray-300,
html body .border-gray-200,
html body .border-gray-100 { border-color: var(--border); }

html body .bg-gray-100,
html body .bg-gray-50,
html body .bg-slate-50,
html body .bg-slate-100 { background-color: var(--surface-2); }
html body .bg-gray-200 { background-color: var(--chip); }
html body .bg-white { background-color: var(--surface-solid); }
html body .bg-blue-50,
html body .bg-blue-100,
html body .bg-amber-50 { background-color: var(--chip); }
html body .bg-blue-500,
html body .bg-blue-600,
html body .bg-blue-700 { background-color: var(--primary); color: var(--primary-ink); }
html body .bg-blue-900 { background-color: #5865c9; color: #fff; }
html body .bg-purple-500 { background-color: var(--accent); color: #fff; }
html body .bg-green-600 { background-color: var(--success); color: #fff; }
html body .bg-gray-800 { background-color: var(--surface); color: var(--muted); }

html body .main-content p { line-height: 1.85; }
html body .main-content a:not([class*="bg-"]):not(.pagination-button):not(.anchor-btn):not(.lx-link) {
    color: var(--link);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: color .2s var(--ease);
}
html body .main-content a:not([class*="bg-"]):hover { text-decoration: underline; }

html body .main-content strong { color: var(--heading); font-weight: 700; }

/* Banner with the course title */
html body .bg-gradient-to-r {
    background-image:
        linear-gradient(135deg, rgba(98, 114, 232, .17), rgba(79, 176, 189, .15) 58%, rgba(234, 166, 112, .13));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1rem .4rem;
    text-align: center;
}
html body .bg-gradient-to-r img {
    max-width: min(100%, 560px);
    max-height: 190px;
    object-fit: contain;
    margin-bottom: .8rem;
}
html body .bg-gradient-to-r h2 { font-size: clamp(1.15rem, 2.6vw, 1.6rem); margin-bottom: .9rem; }

/* Rounded media, soft shadows */
html body .rounded-lg { border-radius: var(--radius); }
html body .shadow-lg,
html body .shadow-xl,
html body .shadow-md { box-shadow: var(--shadow-sm); }
html body .video-container { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); }
html body .main-content iframe { border-radius: var(--radius); }
/* Google Slides embeds: 16:9 slide + ~40px of built-in controls bar. Without the extra
   height the slide is letter-boxed with black bars on both sides. */
html body .video-container:has(> iframe[src*="docs.google.com/presentation"]) { padding-top: calc(56.25% + 40px) !important; }
html body .main-content div[style*="padding-top"]:has(> iframe[src*="docs.google.com/presentation"]) { padding-top: calc(56.25% + 40px) !important; }
html body .main-content div[style*="padding-top"] { border-radius: var(--radius); overflow: hidden; }

/* Emoji chips (wrapped by theme.js – text content untouched) */
.emo {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 1.9em; height: 1.9em; padding: 0 .35em; margin-inline: .15em;
    border-radius: var(--pill);
    background: linear-gradient(135deg, var(--chip), rgba(79, 176, 189, .12));
    border: 1px solid var(--border);
    font-size: .82em; line-height: 1; vertical-align: .08em;
    filter: saturate(.72);
    -webkit-text-fill-color: initial;
}

/* Lists, tables, code */
html body .main-content table { border-collapse: separate; border-spacing: 0; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); max-width: 100%; }
html body .main-content th { background: var(--chip); color: var(--heading); }
html body .main-content th, html body .main-content td { padding: .6rem .85rem; border-bottom: 1px solid var(--border); }
html body .main-content tr:last-child td { border-bottom: none; }

html body .main-content pre {
    border-radius: var(--radius-sm); max-width: 100%; overflow-x: auto;
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
html body pre code.hljs, html body .hljs { background: var(--code-bg); color: var(--code-text); border-radius: var(--radius-sm); }
html body :not(pre) > code {
    background: var(--chip); color: var(--accent); border-radius: 8px; padding: .1em .4em; font-size: .92em;
}

/* Dark-mode syntax colours (replaces atom-one-light) */
:root[data-theme="dark"] .hljs-comment, :root[data-theme="dark"] .hljs-quote { color: #7c86b3; font-style: italic; }
:root[data-theme="dark"] .hljs-keyword, :root[data-theme="dark"] .hljs-selector-tag, :root[data-theme="dark"] .hljs-literal { color: #c3a8ff; }
:root[data-theme="dark"] .hljs-string, :root[data-theme="dark"] .hljs-addition, :root[data-theme="dark"] .hljs-meta .hljs-string { color: #9fdca4; }
:root[data-theme="dark"] .hljs-number, :root[data-theme="dark"] .hljs-symbol, :root[data-theme="dark"] .hljs-bullet { color: #f2b988; }
:root[data-theme="dark"] .hljs-title, :root[data-theme="dark"] .hljs-section, :root[data-theme="dark"] .hljs-function .hljs-title { color: #8fb4ff; }
:root[data-theme="dark"] .hljs-built_in, :root[data-theme="dark"] .hljs-type, :root[data-theme="dark"] .hljs-class .hljs-title { color: #f2d089; }
:root[data-theme="dark"] .hljs-attr, :root[data-theme="dark"] .hljs-variable, :root[data-theme="dark"] .hljs-template-variable, :root[data-theme="dark"] .hljs-attribute, :root[data-theme="dark"] .hljs-name, :root[data-theme="dark"] .hljs-tag { color: #f09aa8; }
:root[data-theme="dark"] .hljs-deletion { color: #f09aa8; }
:root[data-theme="dark"] .hljs-meta { color: #8fb4ff; }

/* ---------- 5. Buttons -------------------------------------------------- */
html body .pagination-buttons { gap: .75rem; flex-wrap: wrap; }
html body .pagination-button {
    border-radius: var(--pill);
    padding: .7rem 1.5rem;
    color: var(--primary-ink);
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 6px 18px rgba(98, 114, 232, .30);
    text-decoration: none;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), filter .25s var(--ease);
}
html body .pagination-button:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    transform: translateY(-2px); filter: brightness(1.05);
    box-shadow: 0 10px 24px rgba(98, 114, 232, .38);
}

html body .copy-btn {
    border-radius: var(--pill);
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: var(--primary-ink);
    padding: .5rem 1.1rem;
    font-family: inherit; font-weight: 600;
    box-shadow: 0 6px 18px rgba(98, 114, 232, .28);
    transition: transform .25s var(--ease), filter .25s var(--ease);
}
html body .copy-btn:hover { background: linear-gradient(135deg, var(--primary), var(--primary-2)); transform: translateY(-2px); filter: brightness(1.06); }
html body .copied-notice { color: var(--success); }

html body .anchor-btn { border-radius: var(--pill); }

/* ---------- 6. Header iframe document ----------------------------------- */
html.is-embedded header {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}
html.is-embedded header .header-inner-container { max-width: none; padding: 0 1.1rem; }
html.is-embedded header img.h-16 { height: 3rem; width: auto; }
html.is-embedded header .py-3 { padding-top: .55rem; padding-bottom: .55rem; }
html.is-embedded header .text-gray-700 { color: var(--muted); font-size: .8rem; }
html.is-embedded header #user-greeting { color: var(--heading); font-weight: 600; filter: none; text-shadow: none; }

html.is-embedded header a.bg-blue-500,
html.is-embedded header a.bg-red-500 {
    border-radius: var(--pill);
    padding: .5rem 1.15rem;
    font-weight: 600; font-size: .85rem;
    text-decoration: none;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s var(--ease);
}
html.is-embedded header a { white-space: nowrap; }
html.is-embedded header .atid-hdr-toggle { flex: none; }
html.is-embedded header a.bg-blue-500 {
    color: var(--primary-ink);
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 6px 16px rgba(98, 114, 232, .28);
}
html.is-embedded header a.bg-red-500 {
    color: var(--rose);
    background: rgba(224, 127, 147, .12);
    border: 1px solid rgba(224, 127, 147, .35);
}
html.is-embedded header a.bg-blue-500:hover { transform: translateY(-2px); background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
html.is-embedded header a.bg-red-500:hover { transform: translateY(-2px); background: rgba(224, 127, 147, .22); }

/* ---------- 7. Footer iframe document ----------------------------------- */
html.is-embedded footer {
    background: transparent !important;
    color: var(--muted) !important;
    padding: 1rem .75rem !important;
    font-size: .85rem;
}
html.is-embedded footer font { color: var(--muted) !important; }

/* ---------- 8. Menu iframe document ------------------------------------- */
html.is-embedded .left-nav {
    background: transparent !important;
    box-shadow: none !important;
    padding: 1rem .8rem 1.4rem !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    box-sizing: border-box;
}
html.is-menu, html.is-menu body { overflow: hidden !important; }
html.is-menu ::-webkit-scrollbar { display: none; }
html.is-menu { scrollbar-width: none; }
html.is-embedded .left-nav > div.text-lg {
    font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700;
    color: var(--muted); border: none !important; margin-bottom: .9rem !important; padding-bottom: 0 !important;
}
html.is-embedded .left-nav .mb-4 {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .35rem;
    margin-bottom: .8rem !important;
    box-shadow: var(--shadow-sm);
}
html.is-embedded .left-nav .mb-4 > div.bg-gray-200 {
    background: transparent !important;
    color: var(--heading) !important;
    font-size: .88rem; font-weight: 700;
    padding: .55rem .8rem !important;
    border-radius: 0 !important;
}
html.is-embedded .left-nav a {
    border-radius: var(--radius-sm) !important;
    padding: .5rem .8rem !important;
    margin: 2px 0;
    color: var(--text);
    text-decoration: none;
    font-size: .93rem;
    transition: background .22s var(--ease), transform .22s var(--ease), color .22s var(--ease);
}
html.is-embedded .left-nav a:hover { background: var(--chip) !important; transform: translateX(3px); }
html.is-embedded .left-nav a.is-current,
html.is-embedded .left-nav a.active-class,
html.is-embedded .left-nav a.active-chapter {
    background: var(--chip-strong) !important;
    color: var(--heading) !important;
    font-weight: 700;
    border-left: none !important;
    box-shadow: inset 3px 0 0 var(--primary);
}
html.is-embedded .class-number {
    min-width: 26px; width: auto; height: 26px; padding: 0 .45rem;
    border-radius: var(--pill);
    font-size: .74rem; font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-2)) !important;
    color: var(--primary-ink);
    box-shadow: 0 3px 8px rgba(98, 114, 232, .25);
    flex: none;
}
html.is-embedded .class-number.bg-purple-500 { background: linear-gradient(135deg, var(--accent), var(--accent-2)) !important; }
html.is-embedded .class-number.bg-blue-900 { background: linear-gradient(135deg, #5967cf, #7c88e6) !important; }

/* ---------- 9. "Explain & examples" accordion (learn.css) -------------- */
html body .lx {
    --lx-accent: var(--primary);
    --lx-accent-soft: var(--chip);
    --lx-border: var(--border);
    --lx-text: var(--text);
    --lx-muted: var(--muted);
}
html body .lx-item { background: var(--surface-solid); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
html body .lx-item:hover { border-color: var(--line); }
html body .lx-item[open], html body .lx-item.lx-opening { border-color: var(--line); box-shadow: var(--shadow); }
html body .lx-item > summary { color: var(--heading); background: transparent; }
html body .lx-item > summary:hover { background: var(--chip); }
html body .lx-item[open] > summary, html body .lx-item.lx-opening > summary { background: var(--chip); }
html body .lx-num { background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 3px 8px rgba(98, 114, 232, .3); }
html body .lx-item[open] .lx-num, html body .lx-item.lx-opening .lx-num { background: linear-gradient(135deg, var(--primary), var(--accent)); }
html body .lx-chevron { background: var(--chip); }
html body .lx-chevron::before { border-color: var(--primary); }
html body .lx-body strong { color: var(--heading); }
html body .lx-toolbar button { background: var(--surface-solid); color: var(--primary); border-color: var(--border); }
html body .lx-toolbar button:hover { background: var(--chip); }
html body .lx-body code { background: var(--chip); color: var(--accent); }
html body .lx-code { border-radius: var(--radius-sm); }

/* ---------- 9b. Student progress tracking (classes injected by progress.js) ---- */
html body .fpp-bar { font-family: inherit; }
html body .fpp-track { height: 10px; background: var(--chip); border-radius: var(--pill); box-shadow: inset 0 1px 2px rgba(50, 62, 130, .10); }
html body .fpp-fill { background: linear-gradient(90deg, var(--teal), var(--success)); border-radius: var(--pill); }

html body .fpp-btn {
    border-radius: var(--pill); padding: .65rem 1.4rem; font-family: inherit; font-weight: 600;
    background: linear-gradient(135deg, var(--teal), var(--success)); color: #fff;
    box-shadow: 0 6px 16px rgba(79, 176, 189, .30);
    transition: transform .25s var(--ease), filter .25s var(--ease), box-shadow .25s var(--ease);
}
html body .fpp-btn:hover { background: linear-gradient(135deg, var(--teal), var(--success)); transform: translateY(-2px); filter: brightness(1.05); }
html body .fpp-btn.fpp-done { background: var(--chip); color: var(--success); box-shadow: none; border: 1px solid var(--border); }
html body .fpp-btn.fpp-done:hover { background: var(--chip-strong); filter: none; }
html body .fpp-link { color: var(--link); font-family: inherit; text-underline-offset: 3px; }
html body .fpp-link:hover { color: var(--primary); }

html body .fpp-page {
    background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.1rem 1.4rem; box-shadow: var(--shadow-sm);
}
html body .fpp-page .fpp-text { color: var(--muted); font-weight: 500; }
html body .fpp-card {
    background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.3rem 1.5rem; box-shadow: var(--shadow-sm);
}
html body .fpp-card h3 { color: var(--heading); }
html body .fpp-card .fpp-text { color: var(--text); }

html body .fpp-toast {
    background: var(--surface-solid); color: var(--text); border: 1px solid var(--border);
    border-radius: var(--pill); padding: .65rem 1.3rem; box-shadow: var(--shadow-lg); font-family: inherit;
}

/* progress block + marks inside the menu iframe */
html.is-embedded .fpp-menu-box {
    background: linear-gradient(135deg, rgba(79, 176, 189, .14), rgba(93, 185, 140, .12));
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: .9rem; margin-bottom: .9rem; color: var(--text); font-family: inherit; font-size: .88rem;
    box-shadow: var(--shadow-sm); direction: rtl;
}
html.is-embedded .fpp-menu-box a {
    border-radius: var(--pill); padding: .5rem .8rem; margin-top: .65rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-ink) !important;
    box-shadow: 0 5px 14px rgba(98, 114, 232, .28); font-weight: 600; text-decoration: none;
    transform: none !important;
}
html.is-embedded .fpp-menu-box a:hover { background: linear-gradient(135deg, var(--primary), var(--primary-2)) !important; filter: brightness(1.06); }
html.is-embedded .fpp-mark { color: var(--muted); }
html.is-embedded .fpp-mark.fpp-c { color: var(--success); }
html.is-embedded .fpp-mark.fpp-v { color: var(--primary); }
html.is-embedded .fpp-count {
    background: var(--chip); color: var(--muted); border-radius: var(--pill);
    padding: .05rem .5rem; opacity: 1; font-weight: 600; margin-inline-start: .6rem;
}
html.is-embedded .left-nav a.fpp-current {
    background: var(--chip-strong) !important; color: var(--heading) !important; font-weight: 700;
    box-shadow: inset 3px 0 0 var(--primary);
}

/* ---------- 10. Floating controls (created by theme.js) ----------------- */
.atid-progress {
    position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 200; pointer-events: none;
    background: linear-gradient(90deg, var(--teal), var(--primary), var(--accent));
    transform: scaleX(0); transform-origin: 100% 50%;
}
.atid-dock {
    position: fixed; z-index: 150;
    inset-inline-start: 14px; inset-block-end: 18px;
    display: flex; flex-direction: column; gap: 10px;
}
.atid-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 46px; height: 46px; padding: 0;
    border-radius: var(--pill);
    border: 1px solid var(--border);
    background: var(--surface);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
    color: var(--heading);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform .25s var(--ease), background .25s var(--ease), opacity .3s var(--ease), box-shadow .25s var(--ease);
}
.atid-btn:hover { transform: translateY(-2px) scale(1.05); background: var(--surface-solid); box-shadow: var(--shadow-lg); }
.atid-btn:active { transform: scale(.96); }
.atid-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.atid-btn .i-sun { display: none; }
:root[data-theme="dark"] .atid-btn .i-sun { display: block; }
:root[data-theme="dark"] .atid-btn .i-moon { display: none; }
.atid-top { opacity: 0; pointer-events: none; transform: translateY(8px); }
.atid-top.show { opacity: 1; pointer-events: auto; transform: none; }
.atid-menu-btn { display: none; }
.atid-backdrop {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(18, 22, 50, .38);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity .3s var(--ease);
}

@media (min-width: 768px) { body.has-hdr .atid-theme-btn { display: none; } }

/* Theme toggle inside the header iframe */
html.is-embedded .atid-hdr-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; padding: 0; border-radius: var(--pill);
    border: 1px solid var(--border); background: var(--chip); color: var(--heading); cursor: pointer;
    transition: transform .25s var(--ease), background .25s var(--ease);
}
html.is-embedded .atid-hdr-toggle:hover { transform: translateY(-2px); background: var(--chip-strong); }
html.is-embedded .atid-hdr-toggle svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
html.is-embedded .atid-hdr-toggle .i-sun { display: none; }
:root[data-theme="dark"] html.is-embedded .atid-hdr-toggle .i-sun,
html.is-embedded[data-theme="dark"] .atid-hdr-toggle .i-sun { display: block; }
html.is-embedded[data-theme="dark"] .atid-hdr-toggle .i-moon { display: none; }
@media (max-width: 767px) { html.is-embedded .atid-hdr-toggle { display: none; } }

/* Dark mode: assets drawn for light backgrounds get a soft light backing
   (images swapped by theme.js to a dark-friendly variant carry data-themed and need none) */
:root[data-theme="dark"] html body .bg-gradient-to-r img:not([data-themed]),
html[data-theme="dark"] body .bg-gradient-to-r img:not([data-themed]) {
    background: rgba(255, 255, 255, .92); border-radius: var(--radius); padding: .35rem .9rem; max-height: 150px;
}
html.is-embedded[data-theme="dark"] header img:not([data-themed]) { background: rgba(255, 255, 255, .92); border-radius: 12px; padding: 3px 10px; }
html.is-embedded[data-theme="dark"] .copyright { filter: invert(.92) hue-rotate(180deg) saturate(1.3); }

/* ---------- 11. Entrance animation ------------------------------------- */
@keyframes atid-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
html body .main-content-inner > section,
html body .main-content-inner > .bg-gradient-to-r,
html body .main-content-inner > .lx { animation: atid-rise .6s var(--ease) both; }
html body .main-content-inner > section:nth-of-type(2) { animation-delay: .06s; }
html body .main-content-inner > section:nth-of-type(3) { animation-delay: .12s; }

/* ---------- 12. Tablet & mobile ---------------------------------------- */
/* Below 1024px the menu is a collapsible block above the content (scrolls with the page) */
@media (max-width: 1023px) {
    html body .content-area-container { display: block; margin-top: 12px; padding: 0 12px; }
    html body .content-area-container .main-content { width: 100%; }

    html body iframe.menu-iframe {
        display: block;
        width: 100%;
        margin: 0;
        height: 0 !important;
        border-width: 0;
        opacity: 0;
        pointer-events: none;
        box-shadow: none;
        transition: opacity .3s var(--ease);
    }
    html body.nav-open iframe.menu-iframe {
        height: var(--menu-h, 900px) !important;
        margin-bottom: 14px;
        border-width: 1px;
        opacity: 1;
        pointer-events: auto;
        box-shadow: var(--shadow);
    }
    .atid-menu-btn { display: inline-flex; }
}

@media (max-width: 767px) {
    html { scroll-padding-top: 16px; }

    /* Header scrolls away on phones – the floating dock keeps navigation reachable */
    html body iframe.header-iframe { position: relative; top: 0; width: calc(100% - 20px); margin-top: 8px; border-radius: var(--radius); }
    html body iframe.footer-iframe { width: calc(100% - 20px); border-radius: var(--radius); }
    html body .content-area-container { padding: 0 10px; }

    html body .content-area-container .main-content,
    html body article.main-content { border-radius: var(--radius); padding: 1rem .95rem 1.4rem; }
    html body > article.main-content { width: calc(100% - 20px); margin-top: 10px; }
    html:not(.is-embedded) body > footer { width: calc(100% - 20px); }

    html body .main-content-inner { font-size: 1rem; }
    html body .main-content h3.text-2xl { font-size: 1.28rem; }
    html body .bg-gradient-to-r { padding: .8rem .7rem .2rem; }
    html body .bg-gradient-to-r img { max-height: 120px; }

    html body .main-content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    html body .pagination-buttons { flex-direction: column; }
    html body .pagination-button { justify-content: center; width: 100%; box-sizing: border-box; }

    /* Dock becomes a bottom bar */
    .atid-dock {
        inset-inline-start: 50%; transform: translateX(50%);
        inset-block-end: 12px; flex-direction: row; gap: 8px;
        padding: 6px; border-radius: var(--pill);
        background: var(--surface-solid); border: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
    }
    .atid-btn { width: 44px; height: 44px; box-shadow: none; background: transparent; border-color: transparent; }
    .atid-top { display: none; }
    .atid-top.show { display: inline-flex; }
    html:not(.is-embedded) body { padding-bottom: 78px; }

    /* Fixed-position copy button of the solution pages would overflow */
    html body .copy-container { right: 14px !important; top: auto !important; bottom: 84px; }
    html body .fpp-toast { bottom: 5.5rem; }
    html body .fpp-page { flex-direction: column; align-items: stretch; }
    html body .fpp-page .fpp-btn { justify-content: center; }
}

@media (max-width: 480px) {
    html body .main-content-inner { font-size: .98rem; }
    html body .shadow-xl { box-shadow: var(--shadow-sm); }
}

/* ---------- 13. Motion preferences ------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    html body *, html body *::before, html body *::after {
        animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important;
    }
}

/* ---------- 12. Dark-mode fixes -------------------------------------------- */
/* Menu iframe document: let the dark card show through (the document itself is opaque white) */
html[data-theme="dark"].is-menu, html[data-theme="dark"].is-menu body,
html[data-theme="dark"].is-menu .left-nav { background: transparent !important; }

/* "Continue where you stopped" button: deep teal with light text */
html[data-theme="dark"] body .fpp-btn {
    background: linear-gradient(135deg, #1d5f6b, #26694f); color: #e6fbf2;
    border: 1px solid rgba(108, 202, 214, .35); box-shadow: 0 6px 16px rgba(0, 0, 0, .35);
}
html[data-theme="dark"] body .fpp-btn:hover { background: linear-gradient(135deg, #24717f, #2e7b5c); filter: brightness(1.08); }
html[data-theme="dark"] body .fpp-btn.fpp-done { background: var(--chip); color: var(--success); box-shadow: none; border: 1px solid var(--border); }

/* Course intro card on the cluster index pages (inline light styles) */
html[data-theme="dark"] body section > div[style*="backdrop-filter"] {
    background: var(--surface-solid) !important;
    border: 1px solid var(--border) !important;
    border-top: 4px solid var(--primary) !important;
    box-shadow: var(--shadow) !important;
}
html[data-theme="dark"] body section > div[style*="backdrop-filter"] p { color: var(--text) !important; }
