/* ============================================================
   EMPIRE OS — Base layer: reset, typography, atmosphere
   ============================================================ */

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

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--text-200);
  background-color: var(--bg);
  overflow: hidden; /* app shell owns scroll */
  font-feature-settings: "cv05" 1, "ss01" 1;
}

/* Calm near-solid backdrop — whisper of texture, no glows. */
.eos-backdrop {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: var(--bg);
}
.eos-backdrop::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 20%, #000 30%, transparent 100%);
  opacity: 0.5;
}

/* Typography */
h1, h2, h3, h4 { color: var(--text-100); font-weight: 600; letter-spacing: -0.012em; line-height: 1.25; }
.display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; }
.serif { font-family: var(--font-display); }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.tnum { font-variant-numeric: tabular-nums; }

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
ul, ol { list-style: none; }
img, svg { display: block; }
/* Inline icons (icon() emits <svg class="ico">). The img,svg reset above makes
   every SVG block-level, which drops icon() glyphs onto their own line above any
   plain inline hint/note/heading label. Give .ico an inline, text-aligned box so
   the icon-beside-text idiom works everywhere (plain inline flow AND inside
   existing flex/grid rows — a flex item may itself be inline-flex, and the
   parent's align-items:center still centers it). flex:none stops any shrink. */
.ico { display: inline-flex; vertical-align: middle; flex: none; }

/* Selection — one visible highlight everywhere, including INSIDE fields.
   ::selection inherits down the tree, but a lot of controls (and the ones the
   browser paints natively: input, textarea, contenteditable) need it spelled
   out, and Firefox still wants ::-moz-selection. text-shadow:none stops any
   glow/soft shadow from muddying the selected glyphs. */
::selection { background: var(--select-bg); color: var(--select-fg); text-shadow: none; }
::-moz-selection { background: var(--select-bg); color: var(--select-fg); text-shadow: none; }
input::selection, textarea::selection, select::selection,
[contenteditable]::selection, [contenteditable] *::selection {
  background: var(--select-bg); color: var(--select-fg); text-shadow: none;
}
input::-moz-selection, textarea::-moz-selection {
  background: var(--select-bg); color: var(--select-fg); text-shadow: none;
}

/* Scrollbars — slim, neutral */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-500); background-clip: content-box; }

/* Utility helpers used across views */
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; } .shrink-0 { flex-shrink: 0; }
.muted { color: var(--text-400); } .faint { color: var(--text-500); }
.gold { color: var(--text-100); }
.up { color: var(--green-400); } .down { color: var(--red-400); }
.center { align-items: center; } .justify-center { justify-content: center; }
.text-c { text-align: center; }
.uppercase { text-transform: uppercase; letter-spacing: 0.08em; }
.text-xs { font-size: var(--fs-xs); } .text-sm { font-size: var(--fs-sm); }
.text-2xs { font-size: var(--fs-2xs); }
.w-full { width: 100%; } .h-full { height: 100%; }
.hidden { display: none !important; }
.clickable { cursor: pointer; }
.eyebrow { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.16em; color: var(--text-400); font-weight: 600; }

/* ============================================================
   TAP TARGETS — the hit area, not the ink.
   Teardown 01 §6.3: 60 of 67 interactive elements measured under 44×44.
   WCAG 2.2 SC 2.5.8 measures the TARGET REGION, which is allowed to be
   larger than the painted control. So where a chip genuinely has to stay
   small, keep the paint and grow the region with a transparent pad.

   `.u-tap44`  — pad out to 44×44 in both axes (icon buttons, close buttons
                 and anything else that sits on its own).
   `.u-tap-v`  — pad out to 44 tall only, at the control's own width. This is
                 the SAFE one in dense toolbars: horizontal neighbours sit
                 shoulder to shoulder, so a horizontal pad would steal its
                 neighbour's clicks, while vertical neighbours nearly always
                 have gap between them.
   Both use ::before, NOT ::after: ::after on a button already belongs to the
   `[data-tip]` tooltip (399 call sites in views/), and to the active-tab
   underline on .subtabs and the knob on .toggle.
   The pad overhangs by at most (44 - size)/2 — 3px for a 38px button, 6px for
   a 32px one — which lands in the gap between controls, not on the next one.
   `verify-a11y-tokens.mjs` reports any control whose own centre stops
   belonging to it, so a pad that ever DID steal a neighbour shows up as a
   regression rather than as a mystery misclick.
   `min-width/height: 100%` means a control that ALREADY meets the floor
   grows no overhang at all.
   ============================================================ */
.u-tap44, .u-tap-v { position: relative; }
.u-tap44::before, .u-tap-v::before {
  content: ""; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  height: var(--tap-pad); min-height: 100%;
  background: none; border: 0; pointer-events: auto;
}
.u-tap44::before { width: var(--tap-pad); min-width: 100%; }
.u-tap-v::before { width: 100%; }

/* Truncation, done once. Teardown 02 §S7: text truncates MID-WORD in at
   least seven user-facing places. Ellipsis is a rendering job, not a
   string-slicing job — and the full value has to stay reachable, which means
   a `title` on the element. (Handoff: the 33-char JS slices in views/*.js
   are the other half of this and are not in CSS scope.) */
.ellip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellip-2 {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; overflow-wrap: break-word;
}

/* Rule 6 (teardown 01 §6.6): decorative and aria-hidden layers never take a
   click. `.nova-orb-grab` — an empty, transparent, aria-hidden, fixed 80×96
   div at z-index 89 — is what covered the setup composer's Send button, and
   it had no symptom until someone tried to press the button.

   A blanket `[aria-hidden] { pointer-events: none }` is WRONG and was tried
   and reverted here: a few aria-hidden elements are deliberately the hit
   surface (the orb's drag pad, the calendar event's resize grip), and the
   blanket rule silently kills them. So:
     · icons/glyphs inside a control never swallow the control's click —
       that part IS safe to do globally, and it also stops `event.target`
       from ever being the <svg> instead of the <button>;
     · everything else that is purely ornamental opts in with `.u-deco`.
   The rule for new code: if it is aria-hidden and you did not deliberately
   make it a target, it gets `.u-deco`. */
:where(a, button, label, summary, [role="button"], [role="tab"], [role="menuitem"])
  :where(svg, img, i, em, b, span)[aria-hidden="true"] { pointer-events: none; }
.u-deco { pointer-events: none; }

/* Reveal animation for view loads */
/* Entrances blur IN — content focuses into place instead of flicking on (rule 5). */
@keyframes eos-rise { from { opacity: 0; transform: translateY(6px); filter: blur(2px); } to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes eos-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes eos-scale-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
.rise { animation: eos-rise var(--t-slow) var(--ease-smooth) both; }

/* Tactile press — a firm 0.98, never a collapse (rule 7). Opt-in so it never fights bespoke states. */
.u-press { transition: transform var(--t-fast) var(--ease-smooth); }
.u-press:active { transform: scale(0.98); }
/* Height reveal the right way — grid rows 0fr→1fr, no max-height hacks (rule 8). */
.reveal { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--t-med) var(--ease-smooth); }
.reveal[data-open="true"], .reveal.open { grid-template-rows: 1fr; }
.reveal > * { overflow: hidden; min-height: 0; }
.stagger > * { animation: eos-rise var(--t-slow) var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: 30ms; }
.stagger > *:nth-child(2) { animation-delay: 70ms; }
.stagger > *:nth-child(3) { animation-delay: 110ms; }
.stagger > *:nth-child(4) { animation-delay: 150ms; }
.stagger > *:nth-child(5) { animation-delay: 190ms; }
.stagger > *:nth-child(6) { animation-delay: 230ms; }
.stagger > *:nth-child(7) { animation-delay: 270ms; }
.stagger > *:nth-child(8) { animation-delay: 310ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
