/*
 * The one visual foundation behind the signed-in product: the sign-in pages,
 * the merchant dashboard and the operator console all load this first.
 *
 * It holds what makes the three read as one product (palette, type, radii,
 * depth and the handful of element defaults every page needs) and nothing
 * about layout. Each area's own sheet (auth.css, dashboard.css, platform.css)
 * builds its components from these tokens and never re-declares a colour, so
 * a change here lands in all three at once. Before this file each of them
 * carried its own copy of the palette, and the copies had drifted: the
 * dashboard was Tailwind's zinc grey while the sign-in page and the landing
 * page were the brand's blue-black.
 *
 * The rules, stated once:
 *
 *   Colour   A blue-black ground taken from the landing page, neutrals with a
 *            faint cool bias so they sit with the violet instead of against
 *            it, and one accent: the logo's violet. The accent marks what you
 *            can act on and where you are (primary buttons, the current page,
 *            links, focus). It is never a gradient, a glow or decoration.
 *            good / warn / bad / info are status colours, kept apart from it.
 *   Shape    Controls (buttons, fields, menus) --radius-sm, 8px. Containers
 *            (panels, tables, dialogs) --radius, 12px. Status tags
 *            --radius-tag, 6px: squared, so a status never looks like a
 *            button. Full round only for avatars and the language switch.
 *   Type     The platform's own UI face (Segoe UI Variable on Windows, SF on
 *            a Mac): nothing to download, and it is what the operating system
 *            already renders forms in. Sentence case everywhere; figures are
 *            tabular wherever they line up.
 *   Depth    A border, not a shadow. Shadows only on what floats over the
 *            page: menus, dialogs, toasts, the mobile drawer.
 *
 * Themes. The dashboard, the console and the sign-in pages are light, like
 * the landing page: their shells stamp data-theme="light" whatever the theme
 * cookie says (the sign-in pages in _auth_layout.html). Dark stays the base
 * block below; the unstamped "system" state still follows the media query.
 */

:root {
  color-scheme: dark;

  /* Ground and surfaces, darkest to lightest. */
  --bg: #0a0a0f;
  --bg-elev: #14151d;
  --surface: #101118;
  --surface-2: #161721;
  --surface-hover: #1c1e29;
  /* A field sits a step *below* the panel it is on, so it reads as a place to
     type rather than as one more card. */
  --field: #0c0d13;

  --border: #1f2130;
  --border-strong: #2f3244;

  --ink: #ececf2;
  --ink-soft: #a7a8ba;
  /* 4.9:1 on --surface; only ever set at 12-13px, so this is the floor. */
  --ink-faint: #83849b;

  /* The mark's violet. White on it clears 5.7:1, hover included.
     --accent-ink is its readable form for text and icons on the dark ground
     (10:1), where the button violet itself would not be (3.9:1). */
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-ink: #c4b5fd;
  --accent-soft: #1b1530;
  --ring: rgba(139, 92, 246, 0.34);

  --good: #34d399;
  --good-soft: #0b2820;
  --warn: #fbbf24;
  --warn-soft: #2a210b;
  --bad: #f87171;
  --bad-soft: #2c1216;
  --info: #7cb4f8;
  --info-soft: #0f2136;

  --code-bg: #07070b;
  --code-ink: #e3e3ea;
  --scrim: rgba(5, 5, 9, 0.66);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-tag: 6px;

  --font: "Segoe UI Variable Text", "Segoe UI Variable", ui-sans-serif, system-ui,
    -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI Variable", ui-sans-serif,
    system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 44px -10px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* The light palette: the landing page's own values (landing.css), so the
   dashboard and the console read as the same site a merchant signed up on.
   Re-picked rather than inverted: the status hues that read on near-black are
   unreadable on white, and the violet is the landing's deeper #5828d9 (white
   on it 7.7:1, it on the page 7.2:1). Shadows are tinted toward the violet,
   never plain black on a light page. */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f7f7f9;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f2f6;
  --surface-hover: #efeff4;
  --field: #ffffff;

  --border: #e4e4eb;
  --border-strong: #d2d2dc;

  --ink: #121217;
  --ink-soft: #4f4f5c;
  --ink-faint: #666674;

  --accent: #5828d9;
  --accent-hover: #4a21b6;
  --accent-ink: #4a21b6;
  --accent-soft: #efecfd;
  --ring: rgba(88, 40, 217, 0.22);

  --good: #047857;
  --good-soft: #e5f5ee;
  --warn: #9a5b00;
  --warn-soft: #fcf2df;
  --bad: #b42323;
  --bad-soft: #fcebeb;
  --info: #1d5fae;
  --info-soft: #e8f1fc;

  --code-bg: #14141b;
  --code-ink: #e3e3ea;
  --scrim: rgba(18, 18, 23, 0.4);

  --shadow: 0 1px 2px rgba(32, 24, 76, 0.06);
  --shadow-lg: 0 18px 44px -12px rgba(32, 24, 76, 0.2), 0 2px 6px rgba(32, 24, 76, 0.06);
}

/* "System": no stamp, so the operating system decides. The same values as
   above; kept in step by tests/test_foundation.py. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;

    --bg: #f7f7f9;
    --bg-elev: #ffffff;
    --surface: #ffffff;
    --surface-2: #f2f2f6;
    --surface-hover: #efeff4;
    --field: #ffffff;

    --border: #e4e4eb;
    --border-strong: #d2d2dc;

    --ink: #121217;
    --ink-soft: #4f4f5c;
    --ink-faint: #666674;

    --accent: #5828d9;
    --accent-hover: #4a21b6;
    --accent-ink: #4a21b6;
    --accent-soft: #efecfd;
    --ring: rgba(88, 40, 217, 0.22);

    --good: #047857;
    --good-soft: #e5f5ee;
    --warn: #9a5b00;
    --warn-soft: #fcf2df;
    --bad: #b42323;
    --bad-soft: #fcebeb;
    --info: #1d5fae;
    --info-soft: #e8f1fc;

    --code-bg: #14141b;
    --code-ink: #e3e3ea;
    --scrim: rgba(18, 18, 23, 0.4);

    --shadow: 0 1px 2px rgba(32, 24, 76, 0.06);
    --shadow-lg: 0 18px 44px -12px rgba(32, 24, 76, 0.2), 0 2px 6px rgba(32, 24, 76, 0.06);
  }
}

/* --- Element defaults ------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; }

::selection { background: color-mix(in srgb, var(--accent) 38%, transparent); }

:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tabular { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
