/*
 * Lyvion Hub — the single source of all design values (CLAUDE.md §10, skill ui-design D2).
 * Derived from the legacy shell (index.php, includes/theme-colors.php) and measured on the
 * live system (docs/migration/ui-inventory.md). No colour, spacing or radius value may
 * appear anywhere else; module CSS and templates only use these variables.
 * Admin theme settings (later) override only the brand and surface colours per mode.
 */
:root {
  color-scheme: dark;

  /* Brand (admin-configurable, legacy theme_primary / theme_secondary) */
  --primary: #10b981;
  --secondary: #059669;
  --primary-bg: color-mix(in srgb, var(--primary) 10%, transparent);
  --primary-bg-strong: color-mix(in srgb, var(--primary) 15%, transparent);
  --bg-gradient: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  --text-on-primary: #ffffff;

  /* Status (fixed) */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --success-bg: color-mix(in srgb, var(--success) 12%, transparent);
  --warning-bg: color-mix(in srgb, var(--warning) 12%, transparent);
  --danger-bg: color-mix(in srgb, var(--danger) 12%, transparent);
  --info-bg: color-mix(in srgb, var(--info) 12%, transparent);
  --text-on-danger: #ffffff;

  /* Typography (legacy: system font stack, body 16px, UI text 14px) */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-2xs: 10px;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-md: 13px;
  --text-base: 14px;
  --text-body: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 1.5rem;
  --leading: 1.4;
  --leading-body: 1.5;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --tracking-caps: 1px;

  /* Spacing (4/8 grid) */
  --space-0: 0;
  --space-px: 1px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-15: 60px;

  /* Radius (E52: 8 default, 12 cards, 16 modals) */
  --radius: 8px;
  --radius-card: 12px;
  --radius-modal: 16px;
  --radius-pill: 999px;
  --radius-round: 50%;

  /* Borders */
  --border-width: 1px;
  --border-width-accent: 3px;

  /* Shadows */
  --shadow-sm: 0 4px 12px rgb(0 0 0 / .10);
  --shadow-md: 0 6px 20px rgb(0 0 0 / .12);
  --shadow-lg: 0 10px 40px rgb(0 0 0 / .30);
  --focus-ring: 0 0 0 3px var(--primary-bg-strong);
  --focus-ring-danger: 0 0 0 3px var(--danger-bg);
  --focus-outline: 2px solid var(--primary);

  /* Motion (modernised; legacy 0.15–0.3s). Zero under prefers-reduced-motion. */
  --motion-fast: 150ms;
  --motion: 250ms;
  --motion-spin: 800ms;
  --ease: cubic-bezier(.2, 0, 0, 1);
  --lift: -2px;

  /* Layout (legacy shell) */
  --header-height: 60px;
  --sidebar-width: 60px;
  --sidebar-width-open: 240px;
  --content-padding: var(--space-6);
  --content-max-width: 1400px;
  --modal-width: 60vw;          /* skill D3: >= 60vw (legacy: 90% / max 600px) */
  --modal-width-mobile: 92vw;
  --modal-max-height: 90vh;
  --modal-height: min(80vh, 720px);  /* skill D3.1: fixed height, scrolling body */
  --control-height: 42px;
  --control-height-sm: 32px;
  --control-height-header: 34px;  /* legacy .nav-btn: 8px 16px padding, 14px text */
  --control-height-icon: 40px;
  --nav-item-height: 44px;
  --nav-icon-size: 36px;
  --brand-icon-size: 40px;
  --avatar-size: 36px;  /* legacy .sidebar-user avatar */
  --sidebar-user-height: 60px;
  --auth-card-width: 420px;      /* sign-in card (components/login.css) */
  --icon-size: 1.25em;
  --icon-size-lg: 64px;
  --icon-size-md: 32px;       /* symbol of a compact empty state (components/state.css) */
  --spinner-size: 48px;
  --spinner-size-sm: 14px;
  --spinner-stroke: 4px;
  --spinner-stroke-sm: 2px;
  --textarea-min-height: 96px;
  --toast-width: 360px;
  --progress-height: 3px;        /* Turbo page-load bar */
  --flag-width: 20px;            /* flag icons, 4:3 */
  --dropdown-min-width: 200px;
  --dropdown-offset: var(--space-1);
  --dropdown-viewport-margin: var(--space-2);  /* menus keep this distance to the viewport edge */
  --filter-field-min-width: 180px;   /* filter bar grid (components/filter-bar.css) */
  --table-detail-max-width: 480px;   /* expanded cell content (<twig:DataTable>) */
  --settings-card-min: 420px;    /* settings cards before they move to the next row (pages/settings.css) */
  --settings-rail-width: 240px;  /* left rail of the settings page (pages/settings.css) */
  --table-detail-max-height: 240px;
  --entity-card-min: 340px;      /* card grid of roles and groups, legacy minmax(340px, 1fr) (components/entity-card.css) */
  --module-field-min: 200px;     /* small form fields inside a module or category row before they wrap (pages/modules.css) */
  --group-card-min: 420px;       /* group cards carry four buttons (pages/groups.css) */
  --user-right-text-min: 260px;  /* text column of an exception row before the choices wrap below (pages/users.css) */
  --invite-link-min: 280px;      /* link field of a new invitation before the copy button wraps below (components/invitation.css) */
  --invite-pair-min: 180px;      /* lifetime and uses side by side down to this width (components/invitation.css) */
  --my-groups-rail-width: 168px;  /* group list left of the open group (pages/my-groups.css) */
  --my-group-team-width: 180px;  /* team choice in the member toolbar (pages/my-groups.css) */
  --my-group-picker-width: 300px;  /* member picker in the member toolbar (pages/my-groups.css) */
  --my-group-field-min: 170px;   /* fields of the invitation form side by side down to this width (pages/my-groups.css) */
  --picker-list-max-height: 240px;  /* result list of <twig:UserPicker> (components/user-picker.css) */
  --emoji-cell-size: 40px;       /* symbol grid of <twig:EmojiPicker>, legacy 40px (components/emoji-picker.css) */
  --emoji-grid-columns: 10;      /* symbols per row at most, legacy 10 columns */
  --icon-tile-size: 80px;        /* preview tile of <twig:EmojiPicker>, legacy 80px */
  --icon-tile-symbol-size: 40px; /* symbol inside that tile */
  --preset-min: 150px;           /* colour preset buttons of the appearance page (pages/settings.css) */
  --preset-chip-size: 22px;      /* colour chips inside a preset button */
  --preview-gradient-height: 6px;  /* accent bar of the live preview card */
  --dash-stat-min: 160px;        /* dashboard stat tiles and quick-action tiles (pages/dashboard.css) */
  --dash-quick-min: 130px;
  --select-arrow-size: 5px;      /* the two triangles of the select arrow (field.css) */

  /* Layers: the only z-index values in the system (skill D3.4). Dialogs, the
     confirm dialog and toasts use the browser top layer and need none. */
  --layer-content: 1;
  --layer-sidebar: 90;
  --layer-header: 100;
  --layer-drawer-backdrop: 110;
  --layer-drawer: 120;
  --layer-dropdown: 200;

  /* Overlay opacity */
  --overlay-bg: rgb(0 0 0 / .5);
  --muted-opacity: .3;
  --disabled-opacity: .7;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fast: 0ms;
    --motion: 0ms;
    --lift: 0px;
  }
}

/* Dark is the legacy default */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --body-bg: #101820;
  --card-bg: #1a2530;
  --sidebar-bg: #0c1218;
  --border-color: #2a3a4a;
  --input-bg: #2d3748;
  --hover-bg: #1d2a37;          /* legacy adjustBrightness(card-bg, 15), measured */
  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
}

[data-theme="light"] {
  color-scheme: light;
  --body-bg: #f8fafc;
  --card-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --border-color: #e2e8f0;
  --input-bg: #f1f5f9;
  --hover-bg: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
}
