/**
 * TEMPO THERAPIST PLATFORM - UNIFIED DESIGN SYSTEM
 * =================================================
 * Core design tokens and components for consistent UI/UX
 * Version: 2.0
 */

/* ==========================================================================
   DESIGN TOKENS
   ========================================================================== */

:root {
  /* COLOR PALETTE — Tempo Brand Teal */
  --primary-50: #eefcf8;
  --primary-100: #d0f7ec;
  --primary-200: #a4eed9;
  --primary-300: #6adec3;
  --primary-400: #38c6a8;
  --primary-500: #1eab90;
  --primary-600: #148a76;
  --primary-700: #136f61;
  --primary-800: #14584f;
  --primary-900: #144a43;

  /* SEMANTIC COLORS */
  --success: #10b981;
  --success-light: #34d399;
  --success-dark: #059669;
  --warning: #f59e0b;
  --warning-light: #fbbf24;
  --warning-dark: #d97706;
  --error: #ef4444;
  --error-light: #f87171;
  --error-dark: #dc2626;
  --info: #1eab90;
  --info-light: #38c6a8;
  --info-dark: #148a76;

  /* NEUTRAL */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* SEMANTIC */
  --background: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f9fafb;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-lg: rgba(0, 0, 0, 0.15);

  /* TYPOGRAPHY */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;

  /* SPACING */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* SIZING */
  --sidebar-width: 240px;
  /* Authoritative top-header height. Value is the `<header>` element's
     real box (`base.html:508` `h-16` = 64px + its `border-b` = 1px), not the
     `#appHeaderRow` inner row alone. Condensed value is set below, inside
     the same `@media (min-width: 768px)` query as the 46px rule it mirrors
     (base.html:365) -- custom properties are NOT media-scoped, so setting
     it bare on `:root[data-topbar="condensed"]` would hand every viewport
     under 768px a 46px token against an unchanged 65px header. Replaces
     --header-height (deleted below), which had exactly one consumer. See
     docs/claude/laptop-chrome-budget-shell-plan.md §12 Step 3. */
  --app-header-h: 65px;
  --max-content-width: 1200px;

  /* BORDER RADIUS */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-full: 9999px;

  /* Z-INDEX */
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-toast: 1080;

  /* TRANSITIONS */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;
}

/* Condensed top bar: header shrinks 65px -> 46px, matching base.html:365's
   `#appHeaderRow` height rule exactly -- same selector, same media query, so
   the token can never disagree with the box it describes. */
@media (min-width: 768px) {
  :root[data-topbar="condensed"] {
    --app-header-h: 46px;
  }
}

/* ==========================================================================
   COMPACT DENSITY (opt-in, per-browser -- user menu -> Density)
   ==========================================================================
   Therapist feedback: zooming the browser to 75% made every page more
   compact and let more real content show without scrolling, and asked
   whether that could be a setting instead of something everyone does to
   their own browser. This is that setting: app/static/js/tt_density.js
   stamps [data-density="compact"] on <html> (localStorage 'tt-density',
   same tier/mechanism as tt-theme and the nav-rail/topbar-condense prefs
   above -- a display preference, not an org policy, so no DB/migration).

   Shrinks the shared spacing tokens -- consumed directly by .btn, .card*,
   .form-hint/.form-error, .modal-header/body/footer, .tabs/.tab, .alert-*,
   .empty-state*, .toast*, .container, and .gap-sm/md/lg below, plus
   table.table via the explicit override just under this comment -- AND
   adds explicit overrides for the classes that main.css / standardization.css
   redefine with hardcoded (non-token) padding and would otherwise win the
   cascade (those explicit values are hand-tuned and intentionally don't
   always equal what the token alone would compute). Every selector here is
   attribute-scoped to [data-density="compact"] plus a real component class
   -- never a bare Tailwind utility -- so it can't fight responsive
   variants (pitfall #20) and wins on specificity regardless of stylesheet
   order, without needing !important except where the base rule already
   forces one (.standard-table). Typography is NOT left alone: the root-scale
   rule below also shrinks every rem-derived font-size app-wide, which is why
   its ratio is a measured legibility floor rather than a rounder number --
   see docs/claude/density-root-scale-plan.md §3 and the comment on
   font-size below.

   Reach is bounded by what's in this file's shared component classes: a
   page built entirely from raw Tailwind utility padding (no .card/.table/
   .standard-table/.form-* class) sees no change unless it carries its own
   scoped override, the way therapists/caseload.html does for its one table.
   That's an intentional, incremental v1 scope -- like nav-rail-collapse and
   topbar-condense before it, this doesn't uniformly touch every page's
   internal layout -- not a claim that every page in the app is covered. */
:root[data-density="compact"] {
  /* Root-scale reach (docs/claude/density-root-scale-plan.md) -- the
     component-class overrides below only touch pages using .card/.btn/
     .table/.form-* etc, which is 61% of substantial templates measured
     as carrying NONE of them (0px height change on 12 of 16 routes
     audited). Tailwind's entire spacing scale is rem, and there is no
     other html{}/:root{} font-size rule in app/static/css/, so scaling
     the root reaches every rem-derived utility on every page in one
     declaration -- no config change, no rebuild, no cross-file var()
     dependency. 93.75% (15px base) is a measured floor, not a rounder
     number picked for convenience: it is the last ratio with zero
     regressions across a 6-route scan (0 new text under 11px, 0 new
     sub-24px controls, 0 new clipping). One step further (87.5%) adds
     39-156 new sub-11px text nodes per route; two steps further (81.25%)
     additionally pushes 17-20 controls per route under the WCAG 2.2
     SC 2.5.8 target-size minimum. Do not tighten this past 93.75%
     without re-running that scan -- see tests/test_density_root_scale.py,
     which floors it. */
  font-size: 93.75%;
  --space-xs: 0.1875rem;
  --space-sm: 0.375rem;
  --space-md: 0.75rem;
  --space-lg: 1.125rem;
  --space-xl: 1.5rem;
  --space-2xl: 2.25rem;
}

:root[data-density="compact"] .card {
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

:root[data-density="compact"] .card-body {
  padding: 0.75rem;
}

:root[data-density="compact"] .card-header,
:root[data-density="compact"] .card-footer {
  padding: 0.5rem 0.875rem;
}

:root[data-density="compact"] .btn {
  padding: 0.375rem 0.75rem;
}

:root[data-density="compact"] .table th,
:root[data-density="compact"] .table td {
  padding: 0.4375rem 0.625rem;
}

:root[data-density="compact"] .form-control,
:root[data-density="compact"] .form-input,
:root[data-density="compact"] .form-select,
:root[data-density="compact"] .form-textarea {
  padding: 0.25rem 0.5rem;
}

:root[data-density="compact"] .form-group {
  margin-bottom: 0.5rem;
}

/* standardization.css's .standard-table th/td force `!important` to beat
   Tailwind Preflight, so the compact override needs it too -- our extra
   attribute selector already wins on specificity, !important here only
   matches the rule it's overriding, not a new escalation.

   Vertical padding ONLY -- never horizontal. Page-tuned subclasses
   (.standard-table.pto-req-table / .pto-balances-table in pto_shared.css)
   deliberately tighten horizontal padding to 8px so their wide columns fit
   without sideways scroll at 1440px; a bare `padding:` shorthand here has
   higher specificity than their `.standard-table.<subclass>` rule even
   though both carry !important, so it would silently override their
   horizontal value too and re-widen those tables past the columns they
   were tuned to fit -- reintroducing the overflow those rules exist to
   prevent. Setting only padding-top/padding-bottom leaves horizontal
   padding entirely to whichever rule already owns it (base or page-tuned),
   the same pattern therapists/caseload.html uses for its own table.

   0.5rem (8px) is also at-or-below every page-tuned .standard-table
   subclass's own vertical padding today (pto-req-table: 10px th / 10px td;
   pto-balances-table: 9px th / 9px td) -- if a future page tunes a
   .standard-table subclass tighter than 8px vertical, this override would
   grow it back up, the same class of bug fixed here for horizontal
   padding. Check any new subclass's vertical padding against this value. */
:root[data-density="compact"] .standard-table th,
:root[data-density="compact"] .standard-table td {
  padding-top: 0.5rem !important;
  padding-bottom: 0.5rem !important;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #334155;
    --border-light: #1e293b;
  }
}

/* ==========================================================================
   BASE COMPONENTS
   ========================================================================== */

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Button Variants */
.btn-primary {
  background-color: var(--primary-600);
  color: white;
  border-color: var(--primary-600);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-700);
  border-color: var(--primary-700);
}

.btn-secondary {
  background-color: white;
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--gray-50);
}

.btn-success {
  background-color: var(--success);
  color: white;
  border-color: var(--success);
}

.btn-danger {
  background-color: var(--error);
  color: white;
  border-color: var(--error);
}

/* Warning variant: used by 25+ templates; was defined only in the scheduler's
   CancellationModal.css before its scoped rewrite removed it. */
.btn-warning {
  background-image: linear-gradient(135deg, #f39c12, #e67e22);
  color: #fff;
  border-color: #e67e22;
}

.btn-warning:hover:not(:disabled) {
  background-image: linear-gradient(135deg, #e67e22, #d35400);
  border-color: #d35400;
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-primary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--gray-100);
}

/* Button Sizes */
.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* FORM ELEMENTS */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-label .required {
  color: var(--error);
  margin-left: 0.25rem;
}

.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-sm);
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--text-primary);
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: 2px solid var(--primary-500);
  outline-offset: -1px;
  border-color: var(--primary-500);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background-color: var(--gray-50);
  cursor: not-allowed;
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--error);
}

.form-hint {
  margin-top: var(--space-xs);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-error {
  margin-top: var(--space-xs);
  font-size: 0.75rem;
  color: var(--error);
}

/* CARDS */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 1px 3px 0 var(--shadow);
}

.card-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  background-color: var(--gray-50);
}

.card-body {
  padding: var(--space-lg);
}

.card-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  background-color: var(--gray-50);
}

/* TABLES */
/* Scoped to the <table> element so the bare ".table" name belongs solely to
   Tailwind's display utility (display:table). Every consumer of this component
   is a real <table class="table">, so this is visually identical — it just
   stops the component from claiming the Tailwind utility name. */
table.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead {
  background-color: var(--gray-50);
  border-bottom: 1px solid var(--border);
}

.table th {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

.table tbody tr:hover {
  background-color: var(--surface-hover);
}

/* MODALS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal-backdrop);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

.modal > .modal-content {
  position: relative;
  background-color: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  z-index: 1;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* TABS */
.tabs {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: var(--space-md);
}

.tab {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-600);
}

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
}

.badge-primary {
  background-color: var(--primary-100);
  color: var(--primary-700);
}

.badge-success {
  background-color: #dcfce7;
  color: #15803d;
}

.badge-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-error {
  background-color: #fee2e2;
  color: #991b1b;
}

/* ALERTS */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid;
  margin-bottom: var(--space-md);
}

.alert-info {
  background-color: #d0f7ec;
  border-color: #6adec3;
  color: #14584f;
}

.alert-success {
  background-color: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

.alert-warning {
  background-color: #fef3c7;
  border-color: #fde047;
  color: #92400e;
}

.alert-error {
  background-color: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

/* LOADING STATES */
.skeleton {
  animation: skeleton-loading 1.5s infinite ease-in-out;
  background: linear-gradient(
    90deg,
    var(--gray-200) 25%,
    var(--gray-100) 50%,
    var(--gray-200) 75%
  );
  background-size: 200% 100%;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
}

.skeleton-title {
  height: 1.5rem;
  width: 50%;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
}

.skeleton-card {
  height: 200px;
  border-radius: var(--radius-lg);
}

/* EMPTY STATES */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
}

.empty-state-icon {
  font-size: 3rem;
  color: var(--gray-400);
  margin-bottom: var(--space-md);
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.empty-state-description {
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

/* TOASTS */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 15px -3px var(--shadow);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  min-width: 300px;
  pointer-events: auto;
  animation: slide-in 0.3s ease-out;
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-error {
  border-left: 4px solid var(--error);
}

.toast-warning {
  border-left: 4px solid var(--warning);
}

.toast-info {
  border-left: 4px solid var(--info);
}

/* UTILITIES */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.focus-visible:focus {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* LAYOUT */
.container {
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* NOTE: a bare ".flex { display:flex }" was removed here — Tailwind already
   provides it, and a global redefinition collides with Tailwind's display
   utilities. See scripts/ci/css_utility_override_guard.py. */

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

/* ==========================================================================
   TYPOGRAPHY UPGRADES — Inter font features & spacing
   ========================================================================== */

/* Tighter letter-spacing on headings for premium feel */
h1, h2, h3,
.text-3xl, .text-2xl, .text-xl, .text-lg {
  letter-spacing: -0.025em;
  font-feature-settings: 'cv01', 'cv02';
}

/* Refined label typography */
.uppercase {
  letter-spacing: 0.08em;
}

/* ==========================================================================
   PREMIUM CARD EFFECTS
   ========================================================================== */

/* Cursor-following glow effect */
.glow-card {
  position: relative;
  overflow: hidden;
  --glow-x: 50%;
  --glow-y: 50%;
  --glow-opacity: 0;
}

.glow-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(320px circle at var(--glow-x) var(--glow-y),
    rgba(30, 171, 144, 0.08) 0%, transparent 100%);
  opacity: var(--glow-opacity);
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 0;
}

/* Hover lift for clickable cards */
a.hub-card,
a.glow-card,
.hover-lift {
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

a.hub-card:hover,
a.glow-card:hover,
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(74, 69, 63, 0.1);
}

/* Gradient accent for hero metrics */
.metric-accent {
  background: linear-gradient(135deg, #148a76 0%, #38c6a8 60%, #e69a3a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==========================================================================
   WARM SHADOWS — replace default cool-gray shadows
   ========================================================================== */

.shadow-warm-sm { box-shadow: 0 1px 2px rgba(74, 69, 63, 0.06); }
.shadow-warm-md { box-shadow: 0 4px 6px -1px rgba(74, 69, 63, 0.08), 0 2px 4px -1px rgba(74, 69, 63, 0.04); }
.shadow-warm-lg { box-shadow: 0 10px 15px -3px rgba(74, 69, 63, 0.08), 0 4px 6px -2px rgba(74, 69, 63, 0.04); }

/* ==========================================================================
   MICRO-INTERACTIONS & MOTION
   ========================================================================== */

/* Scroll reveal — staggered page load animation */
.reveal-on-load {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s cubic-bezier(0, 0, 0.2, 1),
              transform 0.5s cubic-bezier(0, 0, 0.2, 1);
}

.reveal-on-load.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-on-load:nth-child(1) { transition-delay: 0ms; }
.reveal-on-load:nth-child(2) { transition-delay: 60ms; }
.reveal-on-load:nth-child(3) { transition-delay: 120ms; }
.reveal-on-load:nth-child(4) { transition-delay: 180ms; }
.reveal-on-load:nth-child(5) { transition-delay: 240ms; }
.reveal-on-load:nth-child(6) { transition-delay: 300ms; }
.reveal-on-load:nth-child(7) { transition-delay: 360ms; }
.reveal-on-load:nth-child(8) { transition-delay: 420ms; }
.reveal-on-load:nth-child(9) { transition-delay: 480ms; }
.reveal-on-load:nth-child(10) { transition-delay: 540ms; }

/* Toast slide-in with spring easing */
@keyframes toast-in {
  0% { transform: translateX(100%); opacity: 0; }
  60% { transform: translateX(-4px); opacity: 1; }
  100% { transform: translateX(0); opacity: 1; }
}

.toast {
  animation: toast-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Button press feedback */
.btn-primary:active {
  transform: scale(0.97);
}

/* Brand-tinted skeleton loading */
.skeleton-brand {
  background: linear-gradient(90deg, #d0f7ec 25%, #eefcf8 50%, #d0f7ec 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite ease-in-out;
}

/* Reduced motion — disable all premium animations */
@media (prefers-reduced-motion: reduce) {
  .reveal-on-load {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .glow-card::before {
    display: none;
  }
  .skeleton-brand,
  .skeleton {
    animation: none;
  }
  .toast {
    animation: none;
  }
  a.hub-card:hover,
  a.glow-card:hover,
  .hover-lift:hover {
    transform: none;
  }
}

/* ─────────────────────────────────────────────────────────────────────
   Documentation textarea font-size preference

   Per-user preference scoped to clinical documentation textareas. The
   ``data-doc-text-size`` attribute on <body> is server-rendered from
   ``User.documentation_text_size`` (see base.html) and updated client-
   side by the cycler in session_workspace/_header.html. Targets the
   ``data-doc-textarea`` attribute, which tags the primary documentation
   text boxes (SOAP sections, pull-forward review, addendum forms,
   cross-session review, dynamic clinical fields). ``medium`` is the
   default and intentionally omits the attribute so the baseline
   ``text-base`` size applies.

   ``!important`` is required because the workspace density CSS in
   session_workspace/_header.html scopes off ``#unifiedForm textarea``,
   which carries an ID-selector and would otherwise outrank these
   attribute selectors. An explicit user-set text size must always win
   over the WORKSPACE (``data-ws-density``, body-scoped) density default —
   picking "Large" while in "Compact" workspace density should still
   produce larger text than "Compact" would, not the compacted size.

   This guarantee is about ``data-ws-density`` only. It does NOT cover the
   separate, page-wide ``data-density`` toggle on <html> (see the
   ":root[data-density=\"compact\"]" block above,
   docs/claude/density-root-scale-plan.md) — that toggle scales the root
   font-size, and every declaration below is `rem`, which resolves against
   the live root size regardless of which rule wins the specificity/
   `!important` battle. A user on "Large" doc text AND page-wide Compact
   density gets ~93.75% of 1.125rem, not the full 18px "Large" would be at
   the default root. Both are user-chosen reductions layered on top of each
   other (density-root-scale-plan.md §4) — a real interaction, not a bug —
   but it means `!important` here protects against ONE density mechanism,
   not both, and a future reader must not assume otherwise.

   ``xsmall`` (12px) also tightens the box itself: at 12px the default
   ``px-4 py-3`` padding and ``rounded-xl`` corners leave each one-line
   field mostly empty space, so the padding drops to roughly the
   ``px-2.5 py-1.5`` the compact inputs elsewhere in the app use, and the
   workspace-density ``min-height`` floors are dropped so ``rows`` and the
   autogrow height decide. The structured-note inputs and selects that sit
   between those textareas (tempo-field-renderer.js) get the same
   treatment, so a one-line "Chief Complaint" box doesn't stay at 16px
   beside 12px text boxes. Those rules are scoped to the note form
   (``#unifiedForm``): ``data-field-type`` is also set on the HR
   fill-and-sign overlay inputs (hr_fill_sign.js), which are sized to the
   PDF's field boxes and must not get this padding. Inputs match on
   "any renderer field that types text", not on the field type, because
   CPT/ICD pickers and unknown field types render as text inputs with
   their own ``data-field-type`` value.
   ───────────────────────────────────────────────────────────────────── */
body[data-doc-text-size="xsmall"] textarea[data-doc-textarea] {
  font-size: 0.75rem !important;
  line-height: 1.35 !important;
  padding: 0.375rem 0.625rem !important;
  border-radius: 0.5rem !important;
  min-height: 0 !important;
}
body[data-doc-text-size="xsmall"] #unifiedForm input[data-field-type]:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]),
body[data-doc-text-size="xsmall"] #unifiedForm select[data-field-type],
body[data-doc-text-size="xsmall"] #unifiedForm select.tempo-grid-instrument,
body[data-doc-text-size="xsmall"] #unifiedForm .tempo-multiselect > .tempo-ms-trigger {
  font-size: 0.75rem !important;
  line-height: 1.35 !important;
  padding-top: 0.375rem !important;
  padding-bottom: 0.375rem !important;
  padding-left: 0.625rem !important;
  border-radius: 0.5rem !important;
}
/* Selects keep their wider right padding for the dropdown arrow. */
body[data-doc-text-size="xsmall"] #unifiedForm input[data-field-type]:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]),
body[data-doc-text-size="xsmall"] #unifiedForm .tempo-multiselect > .tempo-ms-trigger {
  padding-right: 0.625rem !important;
}
body[data-doc-text-size="small"] textarea[data-doc-textarea] {
  font-size: 0.875rem !important;
  line-height: 1.4 !important;
}
body[data-doc-text-size="large"] textarea[data-doc-textarea] {
  font-size: 1.125rem !important;
  line-height: 1.55 !important;
}
body[data-doc-text-size="xlarge"] textarea[data-doc-textarea] {
  font-size: 1.3125rem !important;
  line-height: 1.6 !important;
}
/* ==========================================================================
   Brand "tempo" color utilities
   --------------------------------------------------------------------------
   `bg-tempo` / `text-tempo` / `border-tempo` are used in templates (fax
   inbox/filed: state pills, "Confirm & file", proposal "Apply") but were
   NEVER generated — "tempo" is not a registered Tailwind color (only `blue`
   is remapped to the brand teal), so these classes resolved to nothing and
   rendered white text on a transparent background → invisible primary
   buttons and selected pills. Define them here (design-system.css is loaded
   globally by base.html) against the existing brand token so the affected
   controls render in Tempo teal as intended. Additive — there was no prior
   `.bg-tempo` rule to override.
   ========================================================================== */
.bg-tempo { background-color: var(--primary-600, #148a76); }
.text-tempo { color: var(--primary-600, #148a76); }
.border-tempo { border-color: var(--primary-600, #148a76); }
/* opacity-modifier form used as `bg-tempo/5` (light tint behind confirm form) */
.bg-tempo\/5 { background-color: color-mix(in srgb, var(--primary-600, #148a76) 5%, transparent); }

/* ==========================================================================
   Project Hub (My Plate) sticky-offset override — laptop chrome-budget
   shell plan step 9
   --------------------------------------------------------------------------
   frontend/src/components/ProjectHub/ProjectHub.css:7397 and :7551 hard-code
   the pre-shell header height (64px full / 60px condensed-media-query, both
   now wrong after step 8's --app-header-h). That file cannot be edited here:
   any frontend/src/** diff forces a 9.1 MB bundle rebuild
   (scripts/ci/frontend_bundle_guard.py:43-70), so this overrides from CSS
   instead and leaves the source-file fix as a follow-up when that bundle
   next rebuilds anyway.

   IMPORTANT — load order, verified empirically, contradicts the naive
   assumption: design-system.css loads at base.html:187 (in <head>), but the
   formbuilder bundle carrying ProjectHub.css loads via
   project_hub/index.html's formbuilder_css link, which sits inside
   {% block extra_js %} — base.html's placeholder for that block is at
   line 1584, deep in <body>. The bundle CSS therefore loads AFTER this
   file, not before, so an equal-specificity rule here would LOSE the
   cascade tie, not win it. Every selector below adds a leading `html` type
   selector solely to raise specificity one notch above the bundle's own
   `body.myplate-active .my-plate--rail > .my-plate-rail` (0,3,1) — making
   this (0,3,2), which wins regardless of stylesheet order.
   ========================================================================== */
@media (min-width: 1280px) {
  html body.myplate-active .my-plate--rail > .my-plate-rail,
  html body.myplate-active .my-plate--rail > .my-plate-focus {
    top: var(--app-header-h);
    max-height: calc(100vh - var(--app-header-h) - 8px);
  }
  html body.myplate-active .my-plate--rail > .my-plate-main {
    min-height: calc(100vh - var(--app-header-h) - 8px);
  }
}

@media (max-width: 1279px) {
  html .my-plate--rail > .my-plate-focus {
    top: var(--app-header-h);
    height: calc(100vh - var(--app-header-h));
  }
}

/* Standardized-assessment entry grid (tempo-field-renderer.js). On a narrow
   container the score columns scroll sideways inside .tempo-grid-body; keep the
   domain name pinned so every score stays attached to its subtest, and move the
   rating badge under the name (the Interpretation column would be off-screen).
   Scoped to the grid's own classes: no Tailwind utility is redefined. */
.tempo-grid-body {
  container-type: inline-size;
  container-name: tempo-grid;
  /* A focused/scrolled-to score cell lands to the right of the pinned name
     column instead of underneath it (tabbing across a row scrolls sideways). */
  scroll-padding-left: 10.5rem;
}
.tempo-grid-body .tempo-grid-label {
  position: sticky;
  left: 0;
  z-index: 1;
  /* Theme token: dark mode remaps it (dark_mode.css); a literal #fff left light
     text on a white strip there. */
  background: var(--tt-bg-elevated, #fff);
}
.tempo-grid-body .tempo-interp-mini {
  display: none;
}
@container tempo-grid (max-width: 640px) {
  .tempo-grid-body .tempo-grid-label {
    min-width: 8.5rem;
    max-width: 10rem;
    box-shadow: 1px 0 0 var(--tt-border, #e5e7eb);
  }
  .tempo-grid-body .tempo-interp-mini {
    display: block;
    margin-top: 2px;
    line-height: 1.6;
  }
  .tempo-grid-body .tempo-interp-mini:empty {
    display: none;
  }
  .tempo-grid-body .tempo-interp-col {
    display: none;
  }
}
