/* ===================================================================
   SayNative design system — "Academic & trustworthy"
   Navy + teal, serif headings, calm institutional feel.
   Light theme is the default; dark theme re-maps the same tokens via
   prefers-color-scheme. Brand navy used AS A SURFACE (footer, logo tile)
   is a fixed literal so it stays navy in both themes.
   =================================================================== */

:root {
    color-scheme: light dark;

    /* Brand */
    --lg-navy:        #0f2a4a;
    --lg-navy-700:    #163a63;
    --lg-navy-300:    #9fb3cc;
    --lg-teal:        #0d9488;
    --lg-teal-600:    #0b7d73;
    --lg-teal-700:    #095f57;
    --lg-teal-100:    #d3ebe8;
    --lg-crimson:     #9f1239;

    /* Surfaces & ink */
    --lg-ink:         #16202b;
    --lg-ink-soft:    #475569;
    --lg-ink-faint:   #64748b;   /* AA on white for small text */
    --lg-paper:       #ffffff;
    --lg-surface:     #f6f8fb;
    --lg-surface-2:   #eef2f7;
    --lg-line:        #dde4ec;
    --lg-header-bg:   rgba(255,255,255,.88);

    /* Type */
    --lg-serif: Georgia, 'Times New Roman', 'Iowan Old Style', serif;
    --lg-sans:  -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Shape */
    --lg-radius:   14px;
    --lg-radius-s: 10px;
    --lg-shadow:   0 1px 2px rgba(15,42,74,.06), 0 8px 24px rgba(15,42,74,.06);
    --lg-shadow-lg:0 12px 40px rgba(15,42,74,.12);
    --lg-maxw: 1200px;
}

/* Dark theme: driven by the .dark class on <html> (set by the pre-paint
   script in App.razor from the saved choice or the system preference), so
   the header toggle can override the OS setting. */
:root.dark {
        /* "Navy" ink flips light so headings/labels stay readable */
        --lg-navy:        #d9e4f4;
        --lg-navy-700:    #c3d3ea;
        --lg-navy-300:    #56708f;
        --lg-teal:        #16a99c;
        --lg-teal-600:    #3cc4b6;
        --lg-teal-700:    #5ecfc3;
        --lg-teal-100:    #10403b;
        --lg-crimson:     #e56a8b;

        --lg-ink:         #e4eaf3;
        --lg-ink-soft:    #a8b5c6;
        --lg-ink-faint:   #8494a8;
        --lg-paper:       #151f2b;
        --lg-surface:     #0e151e;
        --lg-surface-2:   #1c2836;
        --lg-line:        #2c3b4e;
        --lg-header-bg:   rgba(14,21,30,.85);

        --lg-shadow:   0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
        --lg-shadow-lg:0 12px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--lg-sans);
    color: var(--lg-ink);
    background: var(--lg-surface);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { font-family: var(--lg-serif); color: var(--lg-navy); line-height: 1.2; letter-spacing: -.01em; font-weight: 700; }
h1 { font-size: clamp(2.1rem, 4vw, 3.2rem); margin: 0 0 .4em; }
h2 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); margin: 0 0 .5em; }
h3 { font-size: 1.2rem; margin: 0 0 .4em; }
p  { margin: 0 0 1em; }
a  { color: var(--lg-teal-600); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--lg-teal); outline-offset: 2px; }
/* FocusOnNavigate moves focus to the h1 after route changes (for screen
   readers); a heading isn't interactive, so no visible ring. */
h1:focus, h1:focus-visible { outline: none; }

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

/* ── Lessons shell: sidebar course nav + content column ── */
.ln-shell { display: grid; grid-template-columns: 276px minmax(0, 1fr); gap: 48px;
    align-items: start; max-width: 1160px; margin: 0 auto; padding: 44px 24px 72px; }
/* Clear the sticky 68px header: without the offset the sidebar's bottom
   hangs below the viewport and the last unit can never scroll into view. */
.ln-side { position: sticky; top: 84px; max-height: calc(100vh - 108px);
    overflow-y: auto; overscroll-behavior: contain; padding: 4px;
    scrollbar-width: thin; scrollbar-color: var(--lg-line) transparent; }
@media (max-width: 940px) {
    .ln-shell { display: block; padding-top: 24px; }
    .ln-side { position: static; max-height: none; overflow: visible; padding: 0; margin-bottom: 28px; }
}

/* ── Buttons ───────────────────────────────────────────── */
.lg-btn {
    display: inline-flex; align-items: center; gap: .5em;
    font: 600 1rem/1 var(--lg-sans);
    padding: .85em 1.5em; border-radius: 999px; border: 1.5px solid transparent;
    cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
    text-decoration: none;
}
.lg-btn:hover { text-decoration: none; transform: translateY(-1px); }
/* Teal-600 base (not teal): white text needs it for 4.5:1 AA at button size. */
.lg-btn--primary { background: var(--lg-teal-600); color: #fff; box-shadow: 0 6px 18px rgba(13,148,136,.28); }
.lg-btn--primary:hover { background: var(--lg-teal-700); color: #fff; }
.lg-btn--ghost { background: transparent; color: var(--lg-navy); border-color: var(--lg-line); }
.lg-btn--ghost:hover { border-color: var(--lg-navy-300); color: var(--lg-navy); background: var(--lg-paper); }
.lg-btn--lg { font-size: 1.08rem; padding: 1em 1.9em; }
.lg-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
/* Dark ink on teal already clears AA; keep the original dark fills. */
:root.dark .lg-btn--primary { background: var(--lg-teal); color: #06231f; }
:root.dark .lg-btn--primary:hover { background: var(--lg-teal-600); color: #06231f; }

/* ── Header ────────────────────────────────────────────── */
.lg-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--lg-header-bg); backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--lg-line);
}
.lg-header__row { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 16px; }
/* Auto margin (not space-between) pins the nav + theme button to the right
   edge as a cluster; on mobile the nav is absolute and the theme button
   takes over the auto margin (see the 720px block). */
.lg-nav { display: flex; align-items: center; gap: 28px; margin-left: auto; }
.lg-nav__links { display: flex; align-items: center; gap: 28px; }
.lg-nav a { color: var(--lg-ink-soft); font-weight: 500; font-size: .96rem; }
.lg-nav a:hover { color: var(--lg-navy); text-decoration: none; }
.lg-nav a.lg-btn--primary { color: #fff; }
:root.dark .lg-nav a.lg-btn--primary { color: #06231f; }

/* Theme toggle: moon shown in light mode (click → dark), sun in dark. */
.lg-theme-btn { display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border: 1px solid var(--lg-line); border-radius: 999px;
    background: transparent; color: var(--lg-ink-soft); cursor: pointer; flex: 0 0 auto;
    transition: background .12s ease, color .12s ease, border-color .12s ease; }
.lg-theme-btn:hover { background: var(--lg-paper); color: var(--lg-teal-600); border-color: var(--lg-navy-300); }
.lg-theme-btn__sun { display: none; }
:root.dark .lg-theme-btn__sun { display: block; }
:root.dark .lg-theme-btn__moon { display: none; }

/* Mobile menu: CSS-only (checkbox) so it works during static SSR too */
.lg-nav__toggle { position: absolute; opacity: 0; pointer-events: none; }
.lg-nav__burger { display: none; }
@media (max-width: 720px) {
    .lg-nav__burger {
        display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
        width: 44px; height: 44px; padding: 10px; cursor: pointer;
        border: 1px solid var(--lg-line); border-radius: 10px; background: var(--lg-paper);
    }
    .lg-nav__burger span { display: block; height: 2px; border-radius: 2px; background: var(--lg-navy); transition: transform .15s ease, opacity .15s ease; }
    .lg-nav__toggle:checked ~ .lg-nav__burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .lg-nav__toggle:checked ~ .lg-nav__burger span:nth-child(2) { opacity: 0; }
    .lg-nav__toggle:checked ~ .lg-nav__burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
    .lg-nav__toggle:focus-visible ~ .lg-nav__burger { outline: 2px solid var(--lg-teal); outline-offset: 2px; }

    .lg-nav {
        display: none;
        position: absolute; left: 0; right: 0; top: 68px;
        flex-direction: column; align-items: stretch; gap: 4px;
        background: var(--lg-paper); border-bottom: 1px solid var(--lg-line);
        padding: 12px 24px 18px; box-shadow: var(--lg-shadow-lg);
    }
    .lg-nav__toggle:checked ~ .lg-nav { display: flex; }
    .lg-nav__links { flex-direction: column; align-items: stretch; gap: 4px; }
    .lg-nav__links a { padding: 10px 4px; font-size: 1.05rem; border-bottom: 1px solid var(--lg-surface-2); }
    .lg-nav a.lg-btn--primary { justify-content: center; margin-top: 10px; }
    /* The nav leaves the flow on mobile — the theme button carries the
       auto margin so it clusters with the burger on the right. */
    .lg-theme-btn { margin-left: auto; width: 44px; height: 44px; border-radius: 10px; }
}

/* ── Logo ──────────────────────────────────────────────── */
.lg-logo { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.lg-logo:hover { text-decoration: none; }
.lg-logo__mark { display: block; border-radius: 10px; box-shadow: 0 2px 8px rgba(15,42,74,.18); }
.lg-logo__word { font-family: var(--lg-serif); font-weight: 700; font-size: 1.32rem; letter-spacing: -.015em; }
.lg-logo__lingo { color: var(--lg-navy); }
.lg-logo__graph { color: var(--lg-teal); }
.lg-logo--compact .lg-logo__word { font-size: 1.1rem; }
.lg-logo--ondark .lg-logo__lingo { color: #fff; }

/* ── Footer ────────────────────────────────────────────── */
.lg-footer { background: #0f2a4a; color: #c8d4e4; margin-top: 64px; }
.lg-footer__row { display: flex; flex-wrap: wrap; gap: 32px; justify-content: space-between; padding: 48px 0 28px; }
.lg-footer a { color: #c8d4e4; }
.lg-footer a:hover { color: #fff; }
.lg-footer__col h4 { color: #fff; font-family: var(--lg-sans); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 12px; }
.lg-footer__col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: .92rem; }
.lg-footer__brand { max-width: 300px; }
.lg-footer__brand p { color: #9fb0c6; font-size: .9rem; margin-top: 12px; }
.lg-footer__bar { border-top: 1px solid rgba(255,255,255,.1); padding: 18px 0; font-size: .82rem; color: #8ea1ba; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ── Cards / surfaces ──────────────────────────────────── */
.lg-card { background: var(--lg-paper); border: 1px solid var(--lg-line); border-radius: var(--lg-radius); box-shadow: var(--lg-shadow); }

/* ── Ad slots ──────────────────────────────────────────── */
.lg-ad {
    position: relative; display: flex; align-items: center; justify-content: center;
    background: repeating-linear-gradient(45deg, var(--lg-surface), var(--lg-surface) 10px, var(--lg-surface-2) 10px, var(--lg-surface-2) 20px);
    border: 1px dashed var(--lg-line); border-radius: var(--lg-radius-s);
    color: var(--lg-ink-faint); font-size: .8rem; overflow: hidden;
}
.lg-ad::before { content: "Advertisement"; position: absolute; top: 6px; left: 8px; font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--lg-ink-faint); }
.lg-ad__inner { text-align: center; padding: 8px; }
.lg-ad--rect    { width: 300px; height: 250px; }
.lg-ad--leader  { width: 100%; max-width: 728px; height: 90px; margin: 0 auto; }
.lg-ad--inline  { width: 100%; height: 110px; margin: 20px 0; }
@media (max-width: 980px) { .lg-ad--rect { width: 100%; } }

/* ── Utility ───────────────────────────────────────────── */
.lg-eyebrow { display: inline-block; font: 700 .78rem/1 var(--lg-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--lg-teal-600); margin-bottom: 14px; }
.lg-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.lg-muted { color: var(--lg-ink-soft); }
.lg-section { padding: 64px 0; }

/* Prose pages (About, Privacy, Terms) */
.lg-prose { max-width: 760px; padding: 56px 24px; }
.lg-prose__lead { font-size: 1.18rem; color: var(--lg-ink-soft); margin-bottom: 36px; }
.lg-prose h2 { margin-top: 40px; }
.lg-prose p, .lg-prose li { color: var(--lg-ink-soft); }
.lg-prose ul { padding-left: 1.3em; margin: 0 0 1em; }
.lg-prose__updated { font-size: .85rem; color: var(--lg-ink-faint); margin-bottom: 28px; }

/* Styled error / 404 hero */
.lg-oops { text-align: center; padding: 96px 24px 72px; }
.lg-oops__code { font: 700 5rem/1 var(--lg-serif); color: var(--lg-navy-300); letter-spacing: -.02em; margin-bottom: 8px; }
.lg-oops p { color: var(--lg-ink-soft); max-width: 34em; margin: 0 auto 28px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

#blazor-error-ui { position: fixed; bottom: 0; left: 0; right: 0; background: #fff3cd; border-top: 1px solid #ffe69c; padding: 12px 20px; display: none; z-index: 1000; color: #533f03; }
#blazor-error-ui .reload { color: #0b7d73; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }
