/* ============================================================================
   base.css -- shared cross-shell primitives: things that look the same
   regardless of which shell (dashboard/guest/website) is loading them,
   so they live once instead of three times. Loaded after tokens.css and
   before the shell identity file on every page.

   Holds the toast system (replacing three separate Django-messages
   renderers and converging five ad-hoc toast implementations that had
   drifted into five slightly different shapes) and .seg, a segmented
   tab control (replacing three more independent implementations, two of
   which carried a live bug -- see .seg's own comment below). .bento
   turned out to belong in dashboard/overview.html's own <style> instead:
   its hero tile and billing rail are specific to that one page's data,
   not a general-purpose component another page would reuse as-is.
   ========================================================================== */

/* --------------------------------------------------------------------------
   TOASTS

   One #toasts region per shell, a direct child of <body> (see
   partials/_toasts.html) -- never inside <main>, for the same reason
   base.html's `rise` keyframe stays opacity-only: an ancestor transform
   would hijack this region's fixed positioning away from the real
   viewport.

   .toasts itself is NOT the toast's background -- it's a transparent,
   click-through (pointer-events:none) stacking column; only individual
   .toast elements (and their buttons) are interactive. That is what lets
   it sit on top of literally everything (z-index: var(--z-toast), the
   ceiling of the whole ladder) without ever intercepting a click meant
   for the page underneath it.
   -------------------------------------------------------------------------- */
.toasts {
  position: fixed; z-index: var(--z-toast);
  top: var(--space-4); right: var(--space-4); left: var(--space-4);
  display: flex; flex-direction: column; align-items: stretch; gap: var(--space-2);
  pointer-events: none;
}
@media (min-width: 640px) {
  .toasts { left: auto; width: 360px; align-items: flex-end; }
}

.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: .6rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: var(--space-3) .9rem; box-shadow: var(--shadow-pop);
  font-size: .88rem; line-height: 1.4; color: var(--text);
  width: 100%;
  animation: toast-in .25s var(--ease) both;
}
.toast.leaving { animation: toast-out .2s var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-8px) scale(.97); } }
@media (prefers-reduced-motion: reduce) {
  .toast, .toast.leaving { animation: none; }
}

.toast-icon { width: 18px; height: 18px; flex-shrink: 0; margin-top: .1rem; }
.toast-success .toast-icon { color: var(--success); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-info    .toast-icon { color: var(--info); }

.toast-body { flex: 1; min-width: 0; overflow-wrap: break-word; }

/* No shell-specific accent colour here on purpose -- the dashboard calls
   it --accent, the guest/website shells call it --brand, and nothing
   spans all three. Underline + the page's own text colour reads as
   "actionable" everywhere without guessing which token a given shell
   defines. */
.toast-action {
  all: unset; flex-shrink: 0; cursor: pointer; font-weight: 700; font-size: .85rem;
  color: var(--text); text-decoration: underline; text-underline-offset: .15em; padding: 0 .1rem;
}
.toast-dismiss {
  all: unset; flex-shrink: 0; cursor: pointer; color: var(--text-faint); font-size: 1.1rem;
  line-height: 1; padding: 0 .1rem; margin-left: .1rem;
}
.toast-dismiss:hover { color: var(--text); }
.toast-action:focus-visible, .toast-dismiss:focus-visible { outline: 2px solid var(--text-faint); outline-offset: 2px; border-radius: 3px; }

/* --------------------------------------------------------------------------
   SEGMENTED CONTROL (.seg)

   Replaces three independent tab implementations (event_detail.html's
   .tab-btn, client_detail.html's .client-tab-btn, dashboard/website.html's
   .site-tab-btn) that had drifted in a way that mattered: the latter two
   baked the server-rendered initial active/inactive look into each
   button's own inline style="" attribute (so the *first* tab always
   looked right on page load without JS), then only ever toggled an
   `.active` CLASS on click. An inline style always wins over a class
   selector regardless of specificity, so neither button's visible
   underline ever actually moved after the first click -- only the panel
   underneath it switched. `aria-selected` fixes this by construction:
   it is the one flag JS ever needs to set (both for the browser's
   accessibility tree and, via the attribute selector below, for the
   visual state), so there is no second, independently-stale mechanism
   left to forget about.

   Markup is the standard ARIA tabs pattern -- a `role="tablist"`
   container, each `role="tab"` carrying `aria-controls="<panel id>"`
   and `aria-selected`, each target a `role="tabpanel"` with that id and
   `hidden` when not current:

     <div class="seg" role="tablist" data-seg-auto>
       <button type="button" role="tab" aria-selected="true"  aria-controls="panel-a">A</button>
       <button type="button" role="tab" aria-selected="false" aria-controls="panel-b">B</button>
     </div>
     <div id="panel-a" role="tabpanel">...</div>
     <div id="panel-b" role="tabpanel" hidden>...</div>

   data-seg-auto opts a group into static/js/segmented.js's shared click
   handler. event_detail.html's own tab bar does NOT set it -- its
   activate() also lazy-loads the Faces/Analytics/e-Album panels on
   first visit and is called programmatically on page load from a
   `?tab=` query param, so it keeps driving its own tabs by hand (just
   onto this same CSS/ARIA shape, for the visual and accessibility fix).

   --seg-accent is deliberately NOT set here: this file is shell-
   agnostic and has no shell's accent colour to reach for (the dashboard
   calls it --accent, nothing else currently uses .seg). Each shell that
   wants the indicator in its own colour sets --seg-accent once in its
   own identity file -- see shell-app.css. The currentColor fallback
   means an unset --seg-accent still renders correctly, just without a
   distinct accent tint on the active tab. */
.seg { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.seg [role="tab"] {
  all: unset; cursor: pointer; padding: var(--space-2) 0 .8rem; font-weight: 700; font-size: inherit;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  display: inline-flex; align-items: center; gap: .4rem;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.seg [role="tab"]:hover { color: var(--text); }
.seg [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--seg-accent, currentColor); }
.seg [role="tab"]:focus-visible { outline: 2px solid var(--seg-accent, currentColor); outline-offset: 2px; border-radius: 3px; }

/* Pill variant -- a compact switcher for 2-4 short labels inside a card
   header, as opposed to the underline variant's wider, icon-bearing row
   (event_detail.html's 7-8 tabs). Add .seg-pill alongside .seg. */
.seg.seg-pill {
  display: inline-flex; gap: .2rem; border-bottom: none;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: var(--space-1);
}
.seg.seg-pill [role="tab"] { padding: .45rem 1rem; border-radius: var(--radius-pill); border-bottom: none; }
.seg.seg-pill [role="tab"][aria-selected="true"] {
  background: var(--surface-2); color: var(--text); border-bottom: none; box-shadow: var(--shadow-sm);
}
