/* Shell styles shared by every editor page (index, courses): design tokens,
   reset, sidebar/topbar chrome, user menu, locale picker, responsive drawer.
   Canonical source: extracted from index.html's inline block (2026-07); the
   courses.html copy was diffed and reconciled (it contributed .newcourse's
   text-decoration and .allcourses.active).

   NOT here on purpose:
   - .brand-logo — needs `static_asset()` for its mask URL, so it lives in a
     small inline <style> in base.html (plain CSS can't cache-bust the SVG).
   - .settings-trigger — injected by settings.js at runtime.
   - Page layout (composer, grid, dialogs) — home.css / courses.css. */

:root {
    /* --ivory retains its name but now holds okudemia's neutral bg. */
    --ivory: #F6F5F3;
    --surface: #FFFFFF;
    --sidebar: #F6F5F3;
    --border: #E0E0E0;
    --hairline: #E0E0E0;
    --text: #1A1A1A;
    --text-2: #666666;
    /* text-3 clears WCAG AA (4.5:1) on white, bg, and sidebar — it
       styles real interactive text (All courses, Log out) and meta
       lines, not just decoration (~5.3:1 on #F6F5F3). */
    --text-3: #666666;
    --accent: #0E6B62;
    --accent-hover: #0B5750;
    --error: #B3261E;
    --ok: #1B7A43;
    --display: 'Literata', Georgia, 'Times New Roman', serif;
    --ui: 'Golos Text', -apple-system, 'Segoe UI', sans-serif;
}
html[lang="ka"] {
    /* Noto for Mkhedruli; keep Literata/Golos so Cyrillic titles retain cyrillic-ext. */
    --display: 'Noto Serif Georgian', 'Literata', Georgia, 'Times New Roman', serif;
    --ui: 'Noto Sans Georgian', 'Golos Text', -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
/* display rules on sections/chips must never beat the hidden attribute */
[hidden] { display: none !important; }
html { overflow-x: auto; }
body {
    /* Reflows down to mobile; below 768px the sidebar becomes an overlay
       and a header with a hamburger appears (see media query below). */
    font-family: var(--ui); font-size: 15px; line-height: 1.5;
    background: var(--ivory); color: var(--text);
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: flex; min-height: 100vh; }

/* ============ Sidebar ============ */
.sidebar {
    width: 236px; flex: 0 0 236px;
    background: var(--sidebar); border-right: 1px solid var(--hairline);
    padding: 16px 0 0; display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100vh;
}
.brand {
    display: flex; align-items: center; gap: 4px;
    font-family: var(--display); font-weight: 600; font-size: 15px;
    color: var(--text); padding: 0 16px 14px;
}
.newcourse {
    display: flex; align-items: center; gap: 8px;
    border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px; font-size: 13.5px; color: var(--text-2);
    background: var(--surface); cursor: pointer; text-align: left;
    text-decoration: none;   /* it renders as an <a> on every page but home */
    justify-content: space-between;
    margin: 0 16px;
}
.newcourse:hover { border-color: var(--text-3); color: var(--text); }
.sec {
    font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
    color: var(--text-3); padding: 16px 16px 6px;
}
#recentsList {
    padding: 0 16px;
}
.recents { flex: 1; overflow-y: auto; min-height: 0; }
.recent {
    display: flex; align-items: center; gap: 8px; width: 100%;
    font-size: 13.5px; color: var(--text-2); padding: 7px 8px;
    border: none; background: none; border-radius: 6px;
    cursor: pointer; text-align: left;
}
.recent:hover { background: rgba(0,0,0,.045); color: var(--text); }
.recent.active { background: rgba(0,0,0,.06); color: var(--text); }
.recent .rtitle {
    flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rbadges { display: inline-flex; gap: 3px; flex: none; }
.rbadge {
    font-size: 11px; font-weight: 600; letter-spacing: .3px;
    color: var(--text-2); border: 1px solid var(--border);
    border-radius: 4px; padding: 1px 4px; line-height: 1.3;
}
.rprog {
    flex: none; display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--accent); font-weight: 500;
}
.rprog svg { display: block; }
.recents-empty { font-size: 13px; color: var(--text-3); padding: 16px; }
.allcourses {
    font-size: 12.5px; color: var(--text-3); text-decoration: none;
    padding: 8px; border-radius: 6px; margin: 0 16px;
}
.allcourses:hover { color: var(--text-2); background: rgba(0,0,0,.045); }
.allcourses.active { color: var(--text); background: rgba(0,0,0,.06); }
.locale-picker { padding: 4px 0 8px; }
.locale-picker label {
    display: flex; align-items: center; gap: 8px;
    border: 1px solid transparent; border-radius: 8px;
    padding: 7px 8px; color: var(--text-2);
}
.locale-picker label:hover, .locale-picker label:focus-within {
    background: rgba(0,0,0,.045); color: var(--text);
}
.locale-picker svg { flex: none; }
.locale-picker select {
    width: 100%; min-width: 0; border: 0; outline: 0;
    color: inherit; background: transparent; cursor: pointer;
    font: inherit; font-size: 13px;
}
.user-area {
    position: relative; border-top: 1px solid var(--hairline);
    margin-top: 4px; padding: 0;
}
.userchip {
    width: 100%; display: flex; align-items: center; gap: 9px;
    border: none; border-radius: 0; padding: 12px 16px;
    background: none; color: var(--text); cursor: pointer; text-align: left;
}
.userchip:hover, .userchip[aria-expanded="true"] {
    background: #F0EFED;
}
.user-avatar {
    width: 36px; height: 36px; flex: none; display: grid; place-items: center;
    border: 1px solid var(--border); border-radius: 50%;
    background: var(--surface); font-size: 13px; font-weight: 600; letter-spacing: .2px;
}
.user-name {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 13px; color: var(--text-2);
}
.user-menu-icon { flex: none; margin-left: auto; color: var(--text-3); }
.user-menu {
    position: absolute; left: 8px; bottom: calc(100% + 8px);
    min-width: 200px; padding: 6px; z-index: 20;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.14);
}
.user-menu button {
    width: 100%; display: flex; align-items: center; gap: 10px;
    border: none; border-radius: 6px; padding: 9px 10px;
    background: none; color: var(--text); cursor: pointer;
    font-size: 13.5px; text-align: left;
}
.user-menu button:hover, .user-menu button:focus-visible { background: var(--ivory); }
.user-menu svg { flex: none; }
.user-menu .locale-picker { padding: 0; }
.user-menu .locale-picker label { border-radius: 6px; padding: 9px 10px; }
.user-menu .locale-picker label:hover,
.user-menu .locale-picker label:focus-within { background: var(--ivory); }
/* The select carries outline:0, so the label must show keyboard focus. */
.user-menu .locale-picker label:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
.menu-sep { height: 1px; background: var(--hairline); margin: 6px 4px; }

/* ============ Main pane (structure only) ============ */
/* The shell owns .main's place in the layout and its padding; each page's own
   stylesheet (home.css / courses.css — loaded AFTER this file) adds the inner
   layout (e.g. home centers a composer, courses hosts a container). */
.main { flex: 1; min-width: 0; padding: 48px 32px; }

/* ============ Mobile header + sidebar overlay ============ */
/* Header and backdrop only exist below the breakpoint; hidden on desktop. */
.topbar { display: none; }
.hamburger {
    display: grid; place-items: center; width: 40px; height: 40px;
    border: none; background: none; border-radius: 8px;
    color: var(--text); cursor: pointer;
}
.hamburger:hover { background: rgba(0,0,0,.045); }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
    .topbar {
        display: flex; align-items: center; justify-content: space-between;
        position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 700;
        padding: 0 12px 0 16px;
        background: var(--sidebar); border-bottom: 1px solid var(--hairline);
    }
    .topbar-logo {
        display: flex;
        align-items: center;
        gap: 4px;
        font-family: var(--display);
        font-weight: 600;
        font-size: 15px;
        color: var(--text);
    }
    /* `.app .main` (0,2,0) beats the base `.main` (0,1,0) above: media queries
       add no specificity, and page stylesheets (home.css/courses.css) load
       after this file, so their bare `.main` additions would win a same-
       specificity tie. Keep this override selector at (0,2,0) so the mobile
       padding survives the cascade regardless of file order. */
    .app .main { padding: 72px 16px 40px; }   /* clear the 56px fixed header; tighter side padding on mobile */

    /* Sidebar becomes an off-canvas drawer, overriding the sticky desktop
       layout. visibility:hidden (not transform alone) takes the closed
       drawer out of the tab order and the accessibility tree. */
    .sidebar {
        position: fixed; top: 0; left: 0;
        /* dvh tracks the *visible* viewport as iOS Safari's toolbars show/hide;
           plain 100vh overshoots (URL/toolbar chrome excluded) and pushes the
           bottom-pinned .user-area off-screen. 100vh stays as the fallback. */
        height: 100vh; height: 100dvh;
        /* keep .user-area clear of the iOS home-indicator safe area */
        padding-bottom: env(safe-area-inset-bottom);
        z-index: 900; width: 264px; flex: none;
        transform: translateX(-100%); visibility: hidden;
        transition: transform .2s ease, visibility .2s;
        box-shadow: 0 10px 28px rgba(0,0,0,.18);
    }
    .app.sidebar-open .sidebar { transform: translateX(0); visibility: visible; }

    /* Visible only when its [hidden] attribute is removed by the toggle JS. */
    .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 800;
        background: rgba(26,26,26,.4);
    }
}

/* ============ Popovers ============ */
/* Shared primitives (anchored inside a .pillwrap; open/close/keyboard logic
   in shell.js): the composer's language/theme pickers on / and the course
   toolbar's "…" menu on both pages. Page-specific sizing (e.g. #themePop's
   grid) stays in the page stylesheets. */
.pillwrap { position: relative; }
.popover {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.08);
    padding: 6px;
}
.popover[hidden] { display: none; }
/* Menus that hang off a toolbar's right edge, not its left. */
.popover.right { left: auto; right: 0; }
.pop-opt {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border-radius: 8px; border: none; background: none;
    font-size: 13.5px; color: var(--text); cursor: pointer; text-align: left;
}
.pop-opt:hover, .pop-opt:focus-visible { background: var(--ivory); }
.pop-opt .mark { margin-left: auto; color: var(--accent); visibility: hidden; }
.pop-opt[aria-checked="true"] .mark, .pop-opt[aria-selected="true"] .mark { visibility: visible; }
.pop-opt.danger { color: var(--error); }
.pop-sep { height: 1px; background: var(--hairline); margin: 4px 6px; }

@media (max-width: 768px) {
    /* Keep popovers inside the viewport (the theme popover is a fixed 320px). */
    .popover { max-width: calc(100vw - 48px); }
}

/* ============ Course action toolbar ============ */
/* Built by renderCourseActions (shell.js) for the course view on / and every
   completed /courses card: three sibling pills sharing one neutral style —
   View label button, Download export menu, and an icon-only Delete. */
.course-toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
/* View — neutral labeled pill (icon + text). */
.course-toolbar .btn-pill {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .4rem .8rem; border-radius: 999px; white-space: nowrap;
    font-size: .8rem; font-weight: 500; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
    transition: border-color .2s, color .2s, background .2s;
}
.course-toolbar .btn-pill:hover { border-color: var(--text-3); color: var(--text); }
.course-toolbar .btn-pill svg { flex: none; }
/* Download — same neutral pill as View, a trigger for the exports menu; caret
   via ::after so the busy label (set through textContent while packaging)
   never wipes it. */
.course-toolbar .btn-download {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .4rem .85rem; border-radius: 999px; white-space: nowrap;
    font-size: .8rem; font-weight: 500; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
    transition: border-color .2s, color .2s, background .2s;
}
.course-toolbar .btn-download::after {
    content: ''; width: 0; height: 0; margin-left: .05rem;
    border-left: 3.5px solid transparent; border-right: 3.5px solid transparent;
    border-top: 4px solid currentColor;
}
.course-toolbar .btn-download:hover { border-color: var(--text-3); color: var(--text); }
.course-toolbar .btn-download:disabled { opacity: .6; cursor: default; }
.course-toolbar .btn-download:disabled::after { display: none; }
.icon-btn {
    flex: none; width: 31px; height: 31px; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
    cursor: pointer; transition: border-color .2s, color .2s, background .2s;
}
.icon-btn:hover { border-color: var(--text-3); color: var(--text); }
.icon-btn[aria-expanded="true"] { background: var(--sidebar); color: var(--text); }
/* Delete — neutral at rest like its siblings, red on hover to flag the
   destructive action (the click still routes through a confirm dialog). */
.course-toolbar .icon-btn.danger:hover { border-color: var(--error); color: var(--error); }
.course-menu { min-width: 220px; }

/* Confirmation dialogs (shared: courses delete, preset editor). margin:auto
   restores the UA centering that the global `* { margin: 0 }` reset wipes out
   (a modal dialog centers via position:fixed + inset:0 + margin:auto from the
   UA stylesheet). */
dialog.confirm {
    border: 0; border-radius: 12px; padding: 0; max-width: 400px;
    margin: auto;
    background: var(--surface); color: var(--text);
    box-shadow: 0 10px 28px rgba(0,0,0,.18);
}
dialog.confirm::backdrop { background: rgba(26,26,26,.4); }
.confirm-body { padding: 20px 22px; }
.confirm-body h2 { font-family: var(--display); font-size: 1.1rem; font-weight: 500; margin-bottom: .5rem; }
.confirm-body p { font-size: .85rem; color: var(--text-2); overflow-wrap: break-word; }
.confirm-actions {
    display: flex; justify-content: flex-end; gap: .5rem;
    padding: 14px 22px; border-top: 1px solid var(--hairline);
}
.confirm-actions button {
    padding: .45rem .9rem; border-radius: 999px;
    font-size: .8rem; font-weight: 500; cursor: pointer;
    transition: border-color .2s, background .2s;
}
.confirm-cancel { background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.confirm-cancel:hover { border-color: var(--text-3); color: var(--text); }
.confirm-danger { background: var(--error); border: 1px solid var(--error); color: #fff; }
.confirm-danger:hover { background: #9A1F18; border-color: #9A1F18; }
.confirm-primary { background: var(--accent); border: 1px solid var(--accent); color: #fff; }
.confirm-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.confirm-primary:disabled { opacity: .6; cursor: default; }
