/* The design tokens and the handful of element rules the portal is built on.

   The palette is Western's: Western purple for the brand, orchid beside it,
   deep focus for text and the dark theme, soft lavender for every surface a
   card or control sits on. The four brights (sky, spring, vivid, tiger) are
   too light to carry text on white, so they are kept for the dark theme's
   focus ring and for decoration.
   pom2.css extends these, and every block page overrides the --q-accent trio
   in its own inline :root. Change the palette here and the whole portal
   follows. */

:root{
    --western-purple:#4f2683;
    --orchid:#8f55e0;
    --deep-focus:#201436;
    --soft-lavender:#f5f0fc;
    --sky:#7deafb;
    --spring:#b9f876;
    --vivid:#fcf05e;
    --tiger:#f0a757;

    --bg:#ffffff;
    --card-bg:var(--soft-lavender);
    --text:var(--deep-focus);
    /* 6.0:1 on the page and 5.3:1 on a card, so the quiet text - the uplink,
       the lead, every count and label - clears WCAG AA */
    --muted:#6a5e7e;
    --border:#e5dcef;
    --accent:var(--western-purple);
    --accent-soft:#e9def8;
    --shadow:0 1px 2px rgba(32,20,54,.06),0 8px 24px -12px rgba(79,38,131,.28);
    --hero:#3a1f63;
    --serif:"Fraunces",Georgia,serif;
    --sans:"Inter",-apple-system,BlinkMacSystemFont,sans-serif;
}

/* The dark theme. The inline script in every page's head sets data-theme on
   the root before the stylesheets apply, from the reader's stored choice or,
   failing that, the OS setting; with scripting off there is no attribute and
   the page stays light. The page is a shade under deep focus and the cards
   are deep focus itself, so the two themes read as one palette. Measured
   against the bg: text 18.6:1, muted 10.7:1, accent 9.0:1; on a card, muted
   9.8:1, and the border 2.2:1, so a card reads as a shape at a glance.

   Wrapped in "not print" rather than reverted under print, so the light values
   above are what a PDF gets and there is only one copy of them. color-scheme
   tells the browser the form controls and scrollbars should follow. */
@media not print{
    :root[data-theme="dark"]{
        --bg:#140c22;
        --card-bg:var(--deep-focus);
        --text:#fbf9fe;
        --muted:#c9bde0;
        --border:#5e4a88;
        --accent:#c4a3f5;
        --accent-soft:#3a2560;
        --shadow:0 1px 2px rgba(0,0,0,.3),0 10px 28px -12px rgba(0,0,0,.6);
        color-scheme:dark;
    }
}

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

/* The one type lever for the whole portal. Ninety-four of the ninety-five
   font sizes in fom.css are in rem, and rem resolves against the ROOT element,
   not against body - so this is what scales the portal, and setting a size on
   body would have moved almost nothing. Nudge this and every size, gap and
   rule that is expressed in rem follows in proportion. */
html{
    font-size:17px;
}

body{
    background:var(--bg);
    color:var(--text);
    font-family:var(--sans);
    font-size:1rem;
    line-height:1.7;
    -webkit-font-smoothing:antialiased;
}

a{
    color:inherit;
    text-decoration:none;
}

/* One focus ring for the whole portal, shown only to the keyboard
   (:focus-visible), so a mouse click leaves no outline behind. It takes the
   block's accent where the page has one and the portal's otherwise; in the
   dark theme that is the lightened ink, since the accent itself is too dark to
   see on the dark bg. */
:focus-visible{
    outline:2px solid var(--q-accent-text,var(--accent));
    outline-offset:2px;
    border-radius:3px;
}

:root[data-theme="dark"] :focus-visible{outline-color:var(--sky);}

/* Moving between pages fades rather than blinks, in browsers that can do a
   cross-document view transition (the rest just navigate as before), and not
   at all for a reader who has asked for less motion. */
@media (prefers-reduced-motion:no-preference){
    @view-transition{navigation:auto;}
    ::view-transition-old(root),
    ::view-transition-new(root){animation-duration:.22s;}
}

/* "Skip to content", the first stop for a keyboard: it stays off screen until
   it has focus, then drops in at the top left. Every page has one, pointing
   past the nav to the page's own content. */
.skip{
    position:absolute;
    top:8px;
    left:8px;
    z-index:100;
    padding:8px 14px;
    font-size:.85rem;
    font-weight:600;
    color:var(--card-bg);
    background:var(--text);
    border-radius:6px;
    transform:translateY(-200%);
}

.skip:focus{transform:none;}

/* the skip link's target takes focus only so the next Tab starts from there */
#content:focus{outline:none;}

/* the one way back up to the hub, on pages that carry no block nav.
   A plain link, not a bar: the portal is its own place, and the route out
   of it belongs in the footer of the mind, not the top of the page.
   Hidden in print with the rest of the chrome, see portal.css. */
.uplink{
    display:inline-block;
    margin-bottom:26px;
    font-size:.85rem;
    font-weight:500;
    color:var(--muted);
    transition:color .15s;
}

.uplink:hover{
    color:var(--text);
}

/* the uplink and the theme toggle on one line, on the course pages */
.topline{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    margin-bottom:26px;
}

.topline .uplink{margin-bottom:0;}

/* The theme toggle. One small round button on every page, set like the other
   quiet controls: a border, no fill, the muted colour until hovered. It shows
   the moon while the page is light and the sun while it is dark, and it is
   not shown at all until the head script has set data-theme, because with
   scripting off it could do nothing. */
.theme-btn{
    display:none;
    align-items:center;
    justify-content:center;
    flex:none;
    width:30px;
    height:30px;
    padding:0;
    color:var(--muted);
    background:var(--card-bg);
    border:1px solid var(--border);
    border-radius:999px;
    cursor:pointer;
    transition:color .15s,border-color .15s;
}

:root[data-theme] .theme-btn{display:inline-flex;}
.theme-btn:hover{color:var(--text);border-color:var(--muted);}

.theme-btn svg{
    width:16px;
    height:16px;
    fill:none;
    stroke:currentColor;
    stroke-width:2;
    stroke-linecap:round;
    stroke-linejoin:round;
}

:root:not([data-theme="dark"]) .theme-btn .sun{display:none;}
:root[data-theme="dark"] .theme-btn .moon{display:none;}

/* Sign in to sync, drawn by sync.js beside the toggle and only when
   tools/portal.py has a Firebase config. The same round button; signed in it
   shows the reader's Google photo (or initial) with a dot for the sync state,
   and opens a small panel under it. */
.sync-wrap{position:relative;display:inline-flex;flex:none;}
.blocknav .sync-wrap,.topline .sync-wrap{margin-left:auto;}
.blocknav .sync-wrap + .theme-btn{margin-left:0;}
.sync-btn{position:relative;overflow:visible;}
.sync-btn > *{pointer-events:none;}
.sync-btn img,.sync-btn .initial{
    width:100%;height:100%;border-radius:50%;object-fit:cover;
}
.sync-btn .initial{
    display:flex;align-items:center;justify-content:center;
    font-size:.72rem;font-weight:600;color:#fff;background:var(--western-purple);
}
.sync-btn .dot{
    position:absolute;right:-2px;bottom:-2px;width:9px;height:9px;border-radius:50%;
    background:#2e9d5b;border:2px solid var(--bg);
}
.sync-btn[data-state="busy"] .dot{background:var(--tiger);}
.sync-btn[data-state="error"] .dot{background:#c2410c;}
.sync-pop{
    position:fixed;z-index:60;
    width:min(300px,calc(100vw - 32px));
    padding:16px;
    font-size:.82rem;line-height:1.45;text-align:left;
    color:var(--text);background:var(--bg);
    border:1px solid var(--border);border-radius:14px;
    box-shadow:var(--shadow);
}
.sync-pop[hidden]{display:none;}
.sync-pop p{margin:0 0 10px;}
.sync-pop .sync-h{font-family:var(--serif);font-size:1rem;font-weight:600;margin-bottom:6px;}
.sync-pop .sync-email{margin-top:-6px;color:var(--muted);font-size:.76rem;word-break:break-all;}
.sync-pop .sync-status{color:var(--muted);}
.sync-pop .sync-err{color:#c2410c;}
.sync-pop button{
    font:inherit;cursor:pointer;color:var(--text);background:var(--card-bg);
    border:1px solid var(--border);border-radius:999px;padding:6px 14px;
}
.sync-pop button:hover:not(:disabled){border-color:var(--muted);}
.sync-pop button:disabled{opacity:.6;cursor:default;}
.sync-pop .sync-google{
    display:flex;align-items:center;justify-content:center;gap:10px;width:100%;
    padding:9px 14px;font-weight:600;background:#fff;color:#1f1f1f;border-color:#dadce0;
}
.sync-pop .sync-google svg{width:18px;height:18px;}
.sync-pop .sync-row{display:flex;gap:8px;margin-bottom:10px;}
.sync-pop .sync-wipe{
    padding:0;border:0;background:none;color:var(--muted);font-size:.74rem;text-decoration:underline;
}

/* on the hub, top right of the hero beside the visitor counter; on a block
   page, the right end of the block nav */
.hero-corner{
    position:absolute;
    top:18px;
    right:18px;
    display:flex;
    align-items:center;
    gap:10px;
}

/* The visitor counter, filled by the presence script in tools/portal.py and
   hidden until it has numbers. Same quiet pill as the toggle beside it. */
.presence{
    display:flex;
    align-items:center;
    gap:5px;
    height:22px;
    padding:0 8px;
    margin:0;
    font-size:.62rem;
    color:var(--muted);
    background:var(--card-bg);
    border:1px solid var(--border);
    border-radius:999px;
    white-space:nowrap;
}

.presence[hidden]{display:none;}
.presence b{color:var(--text);font-weight:600;}
.presence-live{display:inline-flex;align-items:center;gap:4px;}
.presence-dot{width:5px;height:5px;border-radius:50%;background:#2e9d5b;box-shadow:0 0 0 2px rgba(46,157,91,.18);}

/* on a phone the title fills the width, so the corner gets its own line */
@media (max-width:640px){
    .hero-corner{position:static;justify-content:flex-end;margin-bottom:16px;}
}
.blocknav .theme-btn{margin-left:auto;}

/* The Still link (tools/portal.py) leads the corner, before the sign-in
   button and the toggle, so it takes the push to the right and they sit
   beside it. It is a link, so it is shown with scripting off too. */
.still-btn,:root[data-theme] .still-btn{display:inline-flex;}
.topline .still-btn{margin-left:auto;}
.blocknav .still-btn ~ .theme-btn,
.blocknav .still-btn ~ .sync-wrap,
.topline .still-btn ~ .sync-wrap{margin-left:0;}
.blocknav a.still-btn{padding:0;border-radius:999px;}
.blocknav a.still-btn:hover{color:var(--text);}
.page-hero a.still-btn{text-decoration:none;}

@media print{
    .theme-btn,.skip,.sync-wrap{display:none !important;}
}

/* the landing page masthead: the one deep band in the portal, a flat brand
   purple with white type on it, so the front door of every course looks
   like the same place. White on it is better than 10:1. */
.page-hero{
    position:relative;
    margin-bottom:48px;
    padding:56px 48px 52px;
    color:#ffffff;
    background:var(--hero);
    border-radius:20px;
    box-shadow:0 24px 48px -28px rgba(32,20,54,.55);
    overflow:hidden;
    isolation:isolate;
}

/* a course's front door is a smaller band than the hub's */
.page-hero.compact{margin-bottom:28px;padding:24px 32px 22px;border-radius:16px;}
.page-hero.compact h1{font-size:clamp(1.9rem,5vw,2.6rem);margin-bottom:8px;}
.page-hero.compact p{font-size:.98rem;line-height:1.5;max-width:760px;}

.page-hero a{color:#ffffff;text-decoration:underline;text-underline-offset:2px;}
.page-hero :focus-visible{outline-color:var(--sky);}

/* the controls in the hero's corner turn into glass on the band */
.page-hero .theme-btn,
.page-hero .presence{
    color:#ffffff;
    background:rgba(255,255,255,.12);
    border-color:rgba(255,255,255,.32);
}
.page-hero .theme-btn:hover{border-color:#ffffff;}
.page-hero .presence b{color:#ffffff;}

@media print{
    .page-hero{color:var(--text);background:none;box-shadow:none;padding:0;}
    .page-hero p,.page-hero .eyebrow{color:var(--muted) !important;}
}

/* who the portal belongs to, above the title. Small and letter-spaced so it
   reads as a standing line rather than a subtitle competing with the headline. */
.page-hero .eyebrow{
    font-size:.8rem;
    font-weight:600;
    letter-spacing:.08em;
    text-transform:uppercase;
    color:var(--sky);
    margin-bottom:16px;
}

.page-hero h1{
    font-family:var(--serif);
    font-size:clamp(2.5rem,8vw,4.5rem);
    font-weight:600;
    letter-spacing:-.02em;
    margin-bottom:20px;
}

.page-hero p{
    max-width:640px;
    color:rgba(255,255,255,.88);
    font-size:1.05rem;
    line-height:1.6;
}

/* the sync panel opens out of the hero's corner but is a card, not the band */
.page-hero .sync-pop p{max-width:none;color:var(--text);font-size:inherit;line-height:inherit;}
.page-hero .sync-pop .sync-email,.page-hero .sync-pop .sync-status{color:var(--muted);}
.page-hero .sync-pop .sync-err{color:#c2410c;}

footer{
    padding:60px 0 80px;
    margin-top:80px;
    border-top:1px solid var(--border);
    color:var(--muted);
    font-size:.85rem;
}

footer a{
    color:var(--accent);
    text-decoration:underline;
    text-underline-offset:2px;
}

@media (max-width:800px){
    .page-hero{
        margin-bottom:32px;
        padding:36px 24px 32px;
        border-radius:16px;
    }
}
