/* ============================================================
   Auniq v2 - Design Tokens
   Single source of truth for CSS custom properties.

   Strategy: DARK is the :root default. LIGHT is opt-in via
   [data-theme="light"]. This guarantees the page renders dark
   even if theme-init.js fails to set the attr (defense-in-depth).
   ============================================================ */

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

/* ------- Default theme = DARK (cream-on-deep-ink, bronze-gold accent) ------- */
:root,
[data-theme="dark"] {
  --bg-app: #04040D;
  --bg-surface: #04040F;
  --bg-elev: #15151E;
  --border: #22222C;

  --text: #F5EFE0;
  --text-muted: #B8B0A0;

  --accent: #D0BA77;
  --accent-hover: #DAC684;
  --success: #6FCF97;
  --warning: #F2C94C;
  --danger: #EB5757;

  color-scheme: dark;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);

  /* Radii */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;

  /* Spacing (4px scale) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Typography sizes */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;
  --text-3xl: 36px;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 320ms;
}

/* ------- Light theme overrides (deep ink accent on warm off-white) ------- */
[data-theme="light"] {
  --bg-app: #FAFAF7;
  --bg-surface: #FFFFFF;
  --bg-elev: #F3F0EA;
  --border: #E5E0D5;

  --text: #1F1B16;
  --text-muted: #6B6258;

  --accent: #04040D;
  --accent-hover: #17172A;
  --success: #2F855A;
  --warning: #B7791F;
  --danger: #C53030;

  color-scheme: light;

  /* Softer shadows on light */
  --shadow-sm: 0 1px 2px rgba(31, 27, 22, 0.06);
  --shadow-md: 0 4px 12px rgba(31, 27, 22, 0.08);
  --shadow-lg: 0 12px 32px rgba(31, 27, 22, 0.12);
}

/* ------- Base body styles (forced fallback so theme always renders) ------- */
html {
  background: var(--bg-app, #04040D);
  /* Always reserve scrollbar space so the viewport width is stable. Without
     this, a vertical scrollbar appearing/disappearing shifts every element ~15px
     left, which on the home page silently re-clamps right-edge widgets during
     autosave and cascades them down. Modern Chromium/Firefox/Safari only - older
     browsers fall back to the default (scrollbar overlays content). */
  scrollbar-gutter: stable;
}
body {
  background: var(--bg-app, #04040D);
  color: var(--text, #F5EFE0);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  font-size: var(--text-base, 14px);
  transition:
    background-color 200ms var(--ease),
    color 200ms var(--ease);
}

/* Make theme transitions smooth on common surfaces too */
.sidebar,
.topbar,
.card,
.data-table {
  transition:
    background-color 200ms var(--ease),
    border-color 200ms var(--ease),
    color 200ms var(--ease);
}

/* Vertical rhythm. Used as the page-content container on master admin
   pages so meta-pill / description / cards stack with consistent gap. */
.stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.stack--tight { gap: 12px; }
.stack--loose { gap: 28px; }

/* Meta pill: friendly "Updated X ago" chip, rendered above the first
   card on master admin pages. */
.meta-pill-row {
  display: flex;
  justify-content: flex-end;
}
.meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  letter-spacing: 0.01em;
}

/* Card section heading: used inside a card to introduce a region.
   Replaces the older tiny all-caps muted variant. */
.card-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0;
  margin: 0 0 14px 0;
}
.card-section-title__sub {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ------- Brand logos -------
   Two-variant pattern: emit BOTH the cream and the blue SVG in the markup,
   show only the one that matches the current theme. Avoids JS swap on
   theme toggle. SVGs live under /v2/assets/brand/.
*/
.brand-logo {
  display: inline-block;
  line-height: 0;            /* kill img baseline gap */
}
.brand-logo > img {
  display: block;
  height: 100%;
  width: auto;
}
.brand-logo > img[data-variant="dark"]  { display: none; }
.brand-logo > img[data-variant="light"] { display: none; }
[data-theme="dark"]  .brand-logo > img[data-variant="dark"]  { display: block; }
[data-theme="light"] .brand-logo > img[data-variant="light"] { display: block; }

/* Default-render the dark variant before [data-theme] applies, so the FOUC
   moment shows the brand on the deep-ink background instead of empty space. */
:root .brand-logo > img[data-variant="dark"] { display: block; }
[data-theme="light"] .brand-logo > img[data-variant="dark"] { display: none; }

/* Size presets - set on the outer .brand-logo container. Heights reflect
   ACTUAL rendered logo height (viewBox is tight-cropped to the artwork,
   no surrounding whitespace). */
.brand-logo--wordmark-sm { height: 20px; }
.brand-logo--wordmark-md { height: 28px; }
.brand-logo--wordmark-lg { height: 36px; }
.brand-logo--a-sm        { height: 20px; }
.brand-logo--a-md        { height: 26px; }
.brand-logo--a-lg        { height: 28px; }

/* Sidebar brand area: keep the default 64px height from tailwind.input.css.
   The lg logo presets (36px wordmark / 32px A-mark) fit comfortably inside
   the default 14px padding (36px content area), with the wordmark filling
   the available height and the A-mark leaving a touch of breathing room
   when collapsed. Bumped left padding so the wordmark's leftmost trailing
   dot doesn't kiss the sidebar edge. */
.sidebar:not(.sidebar--collapsed) .sidebar__brand { padding-left: 64px; }

/* Sidebar width - slimmer than the 260px default for a tighter chrome.
   Collapsed widened from the 72px default so the A-mark has breathing
   room and doesn't kiss the left/right edges. Selectors bumped to
   `aside.sidebar` (element + class) so they outweigh the base rule in
   tailwind.output.css which loads after tokens.css. */
aside.sidebar { width: 200px; }
aside.sidebar.sidebar--collapsed { width: 84px; }

/* ------- Reduced motion ------- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur: 0ms;
    --dur-slow: 0ms;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0ms !important;
    scroll-behavior: auto !important;
  }
}
