/* Euro-CNS Deep Learning: base and shared components for the new frontend.
 * Needs tokens.css. Taken from the Course Studio prototype; see course-studio-plan.md §7.0. */

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: var(--sans);
    color: var(--ink);
    background: var(--glass);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--brand-ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- site nav ---------- */
.site-nav {
    height: var(--nav-h); background: var(--paper); border-bottom: 1px solid var(--rule);
    display: flex; align-items: center; padding: 0 16px; gap: 20px;
}
.site-nav .logo { font-weight: 700; color: var(--brand); font-size: 16px; text-decoration: none; white-space: nowrap; }
.site-nav .logo span { color: #374151; }
.site-nav nav { display: flex; gap: 4px; min-width: 0; overflow: hidden; }
.site-nav nav a { font-size: 13px; color: var(--ink-2); text-decoration: none; padding: 4px 9px; border-radius: 6px; white-space: nowrap; }
.site-nav nav a:hover { background: var(--rule-2); color: var(--ink); }
.site-nav nav a.on { color: var(--brand); background: var(--brand-wash); font-weight: 500; }
.site-nav .who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.site-nav .who form { margin: 0; }
.site-nav { position: relative; }
/* ---------- the phone tab bar (templates/ui/base.html .tabbar, static/ui/nav.js; audit wave 6 Styling; prototype
   library.css:511-540,720) ----------
   Below 768 px the header keeps the name and the account menu; the four places sit at the bottom of every site screen,
   icon over word. The page keeps room under its content, and the keyboard focus never scrolls under the bar. */
.tabbar { display: none; }
@media (max-width: 767px) {
    .site-nav { gap: 8px; }
    .site-nav nav { display: none; }
    .site-nav .who .name { display: none; }
    .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 110; background: var(--paper); border-top: 1px solid var(--rule); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
    .tabbar a { flex: 1; min-width: 0; display: grid; justify-items: center; gap: 2px; padding: 6px 2px; font-size: 11px; line-height: 1.2; color: var(--ink-3); text-decoration: none; border-radius: 8px; text-align: center; }
    .tabbar a i { font-size: 17px; }
    .tabbar a:hover { color: var(--ink); }
    .tabbar a.on { color: var(--brand); background: var(--brand-wash); font-weight: 600; }
    .tabbar a:focus-visible { outline-offset: -2px; }
    body:has(> .tabbar) { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
    html:has(body > .tabbar) { scroll-padding-bottom: 84px; scroll-padding-top: 72px; }
    body:has(> .tabbar) .a11y-toast { bottom: 84px; }
}

/* ---------- buttons, pills ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
    border-radius: 8px; font-size: 13px; font-weight: 500; border: 1px solid var(--rule);
    background: var(--paper); color: var(--ink); white-space: nowrap; text-decoration: none;
    transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: #f7f9fb; border-color: #cbd3dd; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--rule-2); border-color: transparent; }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; gap: 5px; }
.iconbtn {
    width: 30px; height: 30px; border-radius: 7px; display: inline-grid; place-items: center;
    color: var(--ink-3); transition: background .15s, color .15s;
}
.iconbtn:hover { background: var(--rule-2); color: var(--ink); }

.pill {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
    padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.pill-hidden { background: #eef0f3; color: #4a5568; }
.pill-invite { background: var(--brand-wash); color: var(--brand-ink); }
.pill-open { background: #e5f6ec; color: var(--ok); }

/* ---------- glass slides (signature) ----------
 * A slide is drawn as a 3:1 glass slide: a frosted label on the left, tissue on the right.
 * The label carries only the stain: the platform strips the paper label from every scan.
 * Same component in the tray, library, pickers and viewer. */
.glass {
    --gw: 216px;
    width: var(--gw); aspect-ratio: 3 / 1; border-radius: 4px; position: relative; flex: none;
    background: linear-gradient(115deg, rgba(255,255,255,.95), rgba(236,242,248,.9) 55%, rgba(255,255,255,.97));
    border: 1px solid #cfd8e3; box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 1px 3px rgba(24,32,46,.12);
    display: grid; grid-template-columns: 31% 1fr; overflow: hidden; user-select: none;
}
.glass .label {
    background: repeating-linear-gradient(0deg, #f4f2ec 0 2px, #efece4 2px 3px);
    border-right: 1px solid #ddd8cc; padding: 4px 5px; font-family: var(--mono); font-size: 11px; line-height: 1.25; color: #2b2b2b;
    display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
}
.glass .label .stain { font-weight: 600; font-size: 11px; letter-spacing: .02em; overflow-wrap: anywhere; }
.glass .label .stain.unset { font-weight: 500; font-style: italic; color: #6b6b6b; }
/* the icon sits under the thumbnail and shows when there is none (or it fails to load) */
.glass .tissue { position: relative; display: grid; place-items: center; background: #f7f5f8; color: #9aa4b2; font-size: 18px; }
.glass .tissue img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.glass .status { position: absolute; right: 4px; bottom: 3px; font-size: 11px; font-weight: 600; background: rgba(255,255,255,.88); border-radius: 3px; padding: 0 4px; color: var(--ink-2); }
.glass .status.proc { color: #9a6700; }
.glass.sm { --gw: 150px; }
.glass.lg { --gw: 280px; }
/* A slide picture reacts like something you can pick up (audit wave 6 Styling; prototype studio.css:366-374,389,942-944):
   it lifts 1 px on hover, shows a grab cursor where it can be dragged (a zoom-in one where a click previews it), fades
   while it is carried and gets the 2 px focus ring. A photo (photomicrograph, phone photo) shows its picture beside a
   dark label (prototype studio.css:795-798, library.css:771). */
.glass { transition: transform .18s var(--ease), box-shadow .18s var(--ease); }
.glass:hover { transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 6px 16px rgba(24,32,46,.16); }
[data-glass-preview] { cursor: zoom-in; }
[draggable="true"] .glass, .glass[draggable="true"] { cursor: grab; }
a .glass { cursor: pointer; }
.dragging .glass, .glass.dragging { opacity: .45; }
.glass:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.glass.photo { border-radius: 8px; }
.glass.photo .label { background: #2b3240; color: #e7ebf2; border-right: 0; }
.glass.photo .label i { color: #b8c2d4; }
.glass.photo .label .stain.unset { color: #d5dae3; }

/* ---------- page shell for simple screens ---------- */
.page { max-width: 1000px; margin: 0 auto; padding: 28px 16px 80px; }
.page h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 6px; }
.page .lede { color: var(--ink-2); margin: 0 0 22px; max-width: 66ch; }
.card {
    background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
    box-shadow: var(--shadow-1);
}
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--rule-2); }
.list a.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--ink); text-decoration: none; }
.list a.row:hover { background: #f7f9fb; }
.list a.row .t { font-weight: 600; flex: 1; min-width: 0; }
.list a.row .meta { font-size: 12px; color: var(--ink-3); }

/* ---------- the account menu (templates/ui/_account_menu.html, static/ui/account-menu.js; audit wave 4 row 6; prototype #who, #whoMenu) ---------- */
.site-nav .who { position: relative; }
.who-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; font: inherit; font-size: 13px; color: var(--ink-2); border-radius: 999px; padding: 3px 8px 3px 3px; cursor: pointer; }
.who-btn:hover, .who-btn[aria-expanded="true"] { background: #f1f4f8; }
.who-btn .avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; background: #dbe7ff; color: #1d4ed8; }
@media (max-width: 480px) { .who .join { display: none; } }   /* a visitor on a phone: Log in leads on to Create an account */
.who-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 90; width: 230px; background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow-3); padding: 6px; white-space: normal; }
.who-menu .pr { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: none; font: inherit; font-size: 13px; color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; }
.who-menu .pr:hover, .who-menu .pr:focus-visible { background: var(--brand-wash); }
.who-menu .pr > i { width: 18px; color: var(--ink-3); margin-top: 2px; text-align: center; }
.who-menu .pr small { display: block; color: var(--ink-3); font-size: 11.5px; }
.who-menu form { margin: 0; }
.ai-info { width: 24px; height: 24px; border: 0; border-radius: 50%; background: none; color: var(--tutor); display: inline-grid; place-items: center; vertical-align: middle; margin-left: 2px; font-size: 13px; cursor: pointer; }
.ai-info:hover, .ai-info:focus-visible { background: var(--tutor-wash); }
.ai-off .assist-btn, .ai-off .btn-ai, .ai-off .ai-info, .ai-off .assist-panel, .ai-off .assist-line { display: none !important; }
dialog.ai-about-dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-3); }
dialog.ai-about-dialog::backdrop { background: rgba(15, 20, 30, .48); }
.ai-about-dialog .sheet-head { display: flex; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--rule-2); }
.ai-about-dialog .sheet-head h2 { margin: 0; font-size: 15px; font-weight: 650; flex: 1; }
.ai-about-dialog .sheet-body { padding: 14px 18px; font-size: 13.5px; }
.ai-about-dialog .sheet-foot { padding: 12px 18px; border-top: 1px solid var(--rule); display: flex; justify-content: flex-end; }
.ai-about-dialog ul { padding-left: 18px; margin: 8px 0; }
.ai-about-dialog .linkish { background: none; border: 0; padding: 0; color: var(--brand-ink); text-decoration: underline; font: inherit; cursor: pointer; }
@media (max-width: 1100px) { .who-btn .who-role { display: none; } }
/* Preview as learner (Studio): the learners' page in a frame, without the author's own links and role. */
.as-learner .team-only, .as-learner .who-role { display: none !important; }
@media (max-width: 720px) { .who-btn .who-name { display: none; } }
.site-nav:has(.who-menu:not([hidden])) { z-index: 60; }   /* the open account menu lies over the Studio bar */
.who-menu[hidden] { display: none; }
/* "What your teacher sees" (templates/ui/_teacher_sees.html; prototype studio/10-annotation-learner.js:334-340) */
.teacher-sees .sheet-head > i { color: var(--brand); }
.teacher-sees .ts-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .teacher-sees .ts-cols { grid-template-columns: 1fr; } }
.teacher-sees .ts-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.teacher-sees .ts-list { list-style: none; padding: 0 !important; display: grid; gap: 6px; }
.teacher-sees .ts-list li { display: flex; gap: 8px; align-items: baseline; }
.teacher-sees .ts-list.ok li::before { content: "\2713"; color: var(--ok); font-weight: 700; }
.teacher-sees .ts-list.no li::before { content: "\2715"; color: var(--ink-3); font-weight: 700; }
/* The Euro-CNS editorial board's one status line, Not checked → Checked → Published (prototype library.css:84-90;
   library/_board_line.html), on the Case Library, My cases, the share dialog and the editorial board workspace */
.board-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; vertical-align: middle; }
.board-line .bl-step { color: var(--ink-2); padding: 1px 7px; border-radius: 999px; border: 1px solid var(--rule); background: #fff; white-space: nowrap; }
.board-line .bl-step.done { color: var(--brand-ink); border-color: transparent; background: none; padding-left: 0; padding-right: 0; }
.board-line .bl-step.cur { color: #fff; background: var(--brand-ink); border-color: var(--brand-ink); font-weight: 600; padding: 1px 7px; }
.board-line .bl-step.done:not(.cur):first-child { color: var(--ink-3); }
.board-line .bl-step i { margin-right: 3px; font-size: 10px; }
.board-line .bl-arrow { color: var(--ink-3); font-size: 11px; }
/* ---------- Accessibility layer (audit wave 6; static/ui/a11y.js; prototype library.css:545-557, studio.css:784-786) ---------- */
/* Skip to content: hidden until it has the focus */
.skip-link { position: fixed; left: 12px; top: 12px; z-index: 1000; background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px; font-weight: 600; text-decoration: none; }
.skip-link:not(:focus) { clip-path: inset(50%); width: 1px; height: 1px; padding: 0; overflow: hidden; white-space: nowrap; }
/* One focus ring everywhere (prototype library.css:548-554): 2 px brand, also on fields, editable text, menu items and
   the screens' own controls that used to drop their outline or show a pale halo instead */
:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [contenteditable="true"]:focus { outline: 2px solid var(--brand) !important; outline-offset: 2px; }
[role^="menuitem"]:focus-visible, .menu-pop .pr:focus-visible, .rte-pop .pr:focus-visible, .insert-pop .pr:focus-visible { outline-offset: -2px; }
/* a field inside a framed box (the text editor, a tag field): the ring goes round the box, once */
.rte:focus-within, .tag-input:focus-within { outline: 2px solid var(--brand); outline-offset: 1px; }
.rte .rte-body :focus, .rte .rte-doc:focus, .rte textarea.rte-src:focus, .tag-input input:focus { outline: none !important; }
/* where the skip link or a redraw lands (the page, its heading): not a control, so no ring round it */
main:focus, [role="main"]:focus, main h1:focus, .help-sheet .sheet-head :is(h1, h2):focus, #libResults:focus,
.contribute-page .pg-head h1:focus { outline: none !important; }
/* no text below 11 px (prototype library.css:694-696): small print, badges, slide labels */
small { font-size: max(11px, .83em); }
/* a select browsed by keyboard: not applied until Enter */
select.sel-held { border-color: var(--warn, #b45309) !important; box-shadow: 0 0 0 2px #fde7c8; }
.sel-held-note { display: block; margin-top: 4px; font-size: 12px; font-weight: 500; color: #8a4b00; }
/* "Searched for …": how the shared vocabulary read a search (library/vocab.py) */
.searched-for { margin: 0 0 8px; font-size: 12.5px; line-height: 1.45; }
.searched-for b { color: var(--ink); font-weight: 600; }
/* Help and accessibility: a dialog from the account menu, or a page of its own (templates/ui/help/) */
dialog.help-dialog { border: 0; border-radius: 14px; padding: 0; width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: var(--shadow-3); }
dialog.help-dialog::backdrop { background: rgba(15, 20, 30, .48); }
.help-sheet .sheet-head { display: flex; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--rule-2); }
.help-sheet .sheet-head > i { color: var(--brand); }
.help-sheet .sheet-head :is(h1, h2) { margin: 0; font-size: 17px; flex: 1; }
.help-sheet .sheet-head :is(h1, h2):focus { outline: none; }
.help-sheet .sheet-body { padding: 14px 18px; font-size: 13.5px; line-height: 1.55; }
.help-sheet .sheet-body h3 { font-size: 14px; margin: 14px 0 6px; }
.help-sheet .sheet-body h3:first-child { margin-top: 0; }
.help-sheet .sheet-body p { margin: 0 0 8px; }
.help-sheet .help-list { margin: 0 0 10px; padding-left: 18px; }
.help-sheet .help-list li { margin-bottom: 4px; }
.help-sheet .sheet-foot { padding: 12px 18px; border-top: 1px solid var(--rule); display: flex; gap: 8px; justify-content: flex-end; }
.help-sheet .fld { display: grid; gap: 4px; font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.help-sheet .fld .req { color: var(--danger); margin-left: 2px; }
.help-sheet .help-err { color: var(--danger); margin: 0 0 6px; }
.help-sheet .help-sent { padding: 8px 12px; border-radius: 8px; background: var(--brand-wash); color: var(--brand-ink); }
.help-page { max-width: 760px; }
.help-page > .card { padding: 0; overflow: hidden; }
.a11y-toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1100; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13.5px; max-width: calc(100vw - 32px); }
.a11y-toast[hidden] { display: none; }
/* "AI and your data", the full sheet (templates/ui/_ai_data.html), in a dialog or a fold */
.ai-data .ai-data-h { display: flex; gap: 8px; align-items: center; }
.ai-data ul { margin: 8px 0; padding-left: 18px; }
.ai-data li { margin-bottom: 4px; }
.ai-data .ai-plan { margin: 8px 0 0; padding: 7px 10px; border-left: 3px solid #b45309; background: #fff7ed; color: #6b3507; border-radius: 0 6px 6px 0; }
/* ---------- Dialogs and popovers open with motion, on one dim (audit wave 6 Styling; prototype studio.css:573-588,638) ----------
   Every dialog fades its dim layer in (rgba(15, 20, 30, .48), set on each dialog's ::backdrop) and lifts its sheet
   12 px; menus, pickers and popovers lift too, a little quicker. `translate`/`scale` rather than `transform`, so a
   popover centred with its own transform keeps its place. The reduced-motion rule below stops all of it. */
@keyframes ui-fade { from { opacity: 0; } }
@keyframes ui-rise { from { opacity: 0; translate: 0 12px; scale: .985; } }
dialog[open], .share-dialog:not([hidden]) > .share-box { animation: ui-rise .28s var(--ease); }
dialog[open]::backdrop, .share-dialog:not([hidden]) { animation: ui-fade .2s; }
.menu-pop, .rte-pop, .dx-pop, .collect-pop, .outline-pop, .slide-link-pop, .insert-pop, .insert-menu, .who-menu, .popover { animation: ui-rise .2s var(--ease); }
dialog.help-dialog .sheet-head :is(h1, h2) { font-size: 15px; font-weight: 650; }
/* Small motions (audit wave 6 Styling; prototype studio.css:306-307,430-431): a slot that was just filled, a new module or
   item, a slide just placed rises 6 px and fades in (static/studio/canvas/dom.js fillIn); the AI at work shimmers. */
@keyframes fill-in { from { opacity: 0; translate: 0 6px; scale: .99; } }
.fill-in { animation: fill-in .45s var(--ease); }
.shimmer { height: 12px; border-radius: 4px; background: linear-gradient(90deg, #f6eed6 25%, #fdf8ea 50%, #f6eed6 75%); background-size: 200% 100%; animation: shim 1.1s linear infinite; margin: 8px 0; }
.shimmer.short { width: 70%; }
@keyframes shim { to { background-position: -200% 0; } }
/* Reduced motion: with the system's "reduce motion" on, every animation, transition and smooth scroll stops */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after, ::backdrop { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
