/*
 * static/css/base.css — reset, Inter (self-hosted @font-face from /static/vendor/), the shared controls (button
 * variants, icon buttons, the theme toggle, the home button), the one focus ring, scrollbars, .visually-hidden,
 * the global notice and the reduced-motion block.
 *
 * Owner: WP A-13 (Phase 1), B-13 (Phase 2); restyled by the UI overhaul (plan R-106, batch 4 §9 phase 2;
 * docs/plan/specs/ui-overhaul.md §6.1). Every selector is defined once, in one file (I7; T-CSS checks the
 * critical ones). Screen-specific rules (sidebar, nav, home/auth, notices at #main-area > .context-warning) live in
 * layout.css; chat rules in chat.css. Also loaded by the /opensesame dashboard (its theme toggle is .theme-toggle).
 *
 * Glyph buttons (brief §3.5): a button whose whole text is a glyph ("☀ / ☾", "↑", "+") keeps that text in the DOM
 * (accessible names and tests see no change) and draws a line icon instead: `font-size: 0` on the button, the icon
 * a ::before mask over currentColor (icons.css). Every mask has a forced-colours rule, since forced colours would
 * paint the mask's background in the Canvas colour (tests/js/ui-overhaul.test.mjs checks each one).
 */

/* Inter 4.1 variable fonts (OFL-1.1), vendored by P0-6; replaces the legacy web-font link. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/static/vendor/inter/4.1/InterVariable.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
    src: url('/static/vendor/inter/4.1/InterVariable-Italic.woff2') format('woff2');
}
/* R-126 (Ray 2026-11-16: "That xor symbol is massive"): Inter 4.1 draws its circled and squared operators
   (⊕ ⊗ ⊙ ⊞ …, U+2295–22A1) at about 1.4em, nearly twice a capital's height. These faces give just that range the
   vendored KaTeX Main font (text-sized), and --font-sans lists them FIRST: a face whose unicode-range leaves out the
   space is never the line's primary font, so every other character still comes from Inter. Loaded only when a page
   uses a character in the range. Pinned by tests/browser/render/test_r126_symbol_glyphs.py. */
@font-face {
    font-family: 'AIW Symbols';
    font-style: normal;
    font-weight: 100 549;
    font-display: swap;
    src: url('/static/vendor/katex/0.19.0/dist/fonts/KaTeX_Main-Regular.woff2') format('woff2');
    unicode-range: U+2295-22A1;
}
@font-face {
    font-family: 'AIW Symbols';
    font-style: normal;
    font-weight: 550 900;
    font-display: swap;
    src: url('/static/vendor/katex/0.19.0/dist/fonts/KaTeX_Main-Bold.woff2') format('woff2');
    unicode-range: U+2295-22A1;
}

/* Smooth colour transition on theme switch, for major surfaces only (body, below). #sidebar,
   #main-area, #top-nav, .context-warning and .auth-panel carry the same transition in their own
   layout.css rules, #chat-box and #input-area in chat.css (I7: each selector lives in one file). */

/* ============================================================
   RESET & BASE
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; scrollbar-width: thin; scrollbar-color: var(--c-surface-highest) transparent; }
[hidden] { display: none !important; }
body {
    font: var(--t-body-m); color: var(--c-on);
    display: flex; height: 100vh; height: 100dvh; overflow: hidden;
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
    background: var(--grain), var(--c-bg);
    transition: background-color var(--dur-3) var(--ease-standard), color var(--dur-3) var(--ease-standard);
}
::selection { background: color-mix(in srgb, var(--c-accent) 32%, transparent); }
h1, h2, h3, h4 { letter-spacing: -0.01em; }
button, input, textarea, select { font-family: inherit; }
/* One focus ring for every control (brief §6.16): 2 px, 2 px off the edge; dense bars use an inset ring of their own. */
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--c-focus); outline-offset: 2px;
}

/* thin, themed scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--c-surface-highest); border-radius: var(--radius-pill); border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--c-outline); background-clip: content-box; }

/* Screen-reader-only text (sidebar ", working" labels, the shared live region). */
.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ============================================================
   BUTTONS (shared by every screen; brief §6.1)
   .btn is the text button (Cancel, Close, the recovery choices); a modifier class makes it filled
   (.prompt-primary-btn, .auth-continue), neutral (.stop-btn, .new-incognito-btn) or danger
   (.confirm-danger-btn, modals.css). All pills, 40 px by default.
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: 40px; padding: 0 var(--space-5); border: 0; border-radius: var(--radius-pill);
    background: transparent; color: var(--c-accent-text); font: var(--t-label-l); white-space: nowrap; cursor: pointer;
    transition: background-color var(--dur-1) var(--ease-standard), color var(--dur-1) var(--ease-standard), box-shadow var(--dur-1) var(--ease-standard);
}
.btn:hover { background: var(--c-hover); }
.btn:active { background: var(--c-pressed); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* A borderless text + icon pill: the nav's Files, Side viewer and show-sidebar buttons, the edit pills. */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    height: 40px; min-width: 40px; padding: 0 14px 0 12px; border: 0; border-radius: var(--radius-pill);
    background: transparent; color: var(--c-on-2); font: var(--t-label-l); white-space: nowrap; cursor: pointer;
    transition: background-color var(--dur-1) var(--ease-standard), color var(--dur-1) var(--ease-standard);
}
.icon-btn:hover { background: var(--c-hover); color: var(--c-on); }
.icon-btn:active { background: var(--c-pressed); }

/* The theme toggle ("☀ / ☾", kept in the DOM): a 40 px round icon button, a sun in dark (to light), a moon in light. */
.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--radius-pill);
    background: transparent; color: var(--c-on-2); font-size: 0; line-height: 0; cursor: pointer;
    transition: background-color var(--dur-1) var(--ease-standard), color var(--dur-1) var(--ease-standard);
}
.theme-toggle::before {
    content: ''; width: 20px; height: 20px; background: currentColor;
    -webkit-mask: var(--icon-sun) center / contain no-repeat; mask: var(--icon-sun) center / contain no-repeat;
}
[data-theme="light"] .theme-toggle::before { -webkit-mask-image: var(--icon-moon); mask-image: var(--icon-moon); }
.theme-toggle:hover { background: var(--c-hover); color: var(--c-on); }
.theme-toggle:active { background: var(--c-pressed); }

/* "Back to home" (← Home): a quiet text pill; its arrow is part of the markup and stays */
.home-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 16px 0 12px;
    border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--c-on-2);
    font: var(--t-label-l); white-space: nowrap; cursor: pointer;
    transition: background-color var(--dur-1) var(--ease-standard), color var(--dur-1) var(--ease-standard);
}
.home-btn:hover { background: var(--c-hover); color: var(--c-on); }
.home-btn .home-btn-icon { font-size: 1rem; line-height: 1; }

/* Shared entrance animations (modals, file preview, stage): fade, and dialogs scale from .97. */
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes panel-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

/* ============================================================
   GLOBAL NOTICE (home and auth screens, before the chat shell exists;
   the chat screen uses #main-area > .context-warning, layout.css): a warning callout
   ============================================================ */
.global-notice {
    position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
    z-index: var(--z-system-notice); max-width: min(560px, calc(100vw - 32px));
    padding: 10px 18px; border-radius: var(--radius-md);
    background: var(--c-warning-container); color: var(--c-on-warning-container);
    box-shadow: var(--elev-2); font: var(--t-body-m); text-align: center;
    animation: overlay-in var(--dur-3) var(--ease-standard);
}
.global-notice[data-level="error"] { background: var(--c-danger-container); color: var(--c-on-danger-container); }
/* R-118 (privacy.md §5.1): plain news on the home screen ("Your account has been deleted."): a neutral raised surface */
.global-notice[data-level="info"] { background: var(--c-surface-raised); color: var(--c-on); box-shadow: var(--elev-2), inset 0 0 0 1px var(--c-outline-variant); }

/* Forced colours: a mask's background would take the Canvas colour, so the icons use the button text colour. */
@media (forced-colors: active) {
    .theme-toggle::before { forced-color-adjust: none; background: ButtonText; }
}

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