/* =========================================================================
   Ntern theme tokens — the ONE place where colours are decided.

   Every colour in the app goes through a token defined here (or in the
   generated theme-extended.css). Components never carry their own colours.
   The theme is chosen by  <html data-theme="light|dark">  (theme.js).
   See THEME.md for the full table (role · light · dark).

   Load order: theme.css, theme-extended.css, style.css, internix.css, …
   ========================================================================= */

/* ── Light values (the default). The same block is re-applied inside the
      "paper" containers below, so what a recruiter will receive is always
      shown on a light page, even in dark mode. ───────────────────────── */
:root,
:root[data-theme="dark"] :is(.email-preview, .email-body, .sim-email, .light-scope) {
  color-scheme: light;

  /* Surfaces */
  --bg-app: #FCFCFD;
  --bg-surface: #FFFFFF;
  --bg-surface-raised: #FFFFFF;      /* popovers, dropdowns, modals */
  --bg-subtle: #F7F8FA;              /* table header, segmented track, disabled */
  --bg-subtle-2: #EEF0F4;
  --bg-hover: #F7F8FA;
  --bg-selected: #EEF0FF;
  --bg-field: #FFFFFF;
  --bg-inverse: #0F1126;             /* batch bar, active chip, avatar */
  --bg-inverse-2: #1A1D3A;
  --bg-glass: rgba(255, 255, 255, .92);
  --bg-glass-strong: rgba(255, 255, 255, .96);

  /* Text */
  --text-primary: #191C2E;
  --text-secondary: #3A3F52;
  --text-muted: #6A7082;
  --text-dim: #9AA0AE;
  --text-strong: #0F1126;            /* hero titles, prices */
  --text-link: #4A56E8;
  --text-on-accent: #FFFFFF;         /* on --accent / --st-* fills */
  --text-on-solid: #FFFFFF;          /* on fills that stay dark in both themes */
  --text-on-inverse: #FFFFFF;
  --text-on-amber: #0F1126;
  --text-on-brand: #FFFFFF;

  /* Borders */
  --border-default: #DFE2E9;
  --border-soft: #ECEEF2;
  --border-strong: #C9CEDA;
  --border-focus: #4A56E8;

  /* Accent (the indigo) */
  --accent: #4A56E8;
  --accent-hover: #3A45CC;
  --accent-subtle: #EEF0FF;

  /* Status: each has bg / border / text */
  --success-bg: #F1FBF3;  --success-border: #C5E9CE;  --success-text: #12602F;
  --warning-bg: #FFF6E0;  --warning-border: #F3DDA6;  --warning-text: #8A5A00;
  --danger-bg: #FFF5F4;   --danger-border: #F6CFCB;   --danger-text: #A8322A;
  --danger-strong: #B42318;
  --info-bg: #EEF0FF;     --info-border: #C9CEF8;     --info-text: #3A40B5;

  /* Pipeline stages (solid colours, used as text, dots, bars and fills) */
  --st-pending: #7A7C90;
  --st-research: #0E8A9C;
  --st-write: #0B7285;
  --st-ready: #4A56E8;
  --st-queued: #8B63E6;
  --st-sending: #7447D6;
  --st-sent: #16803C;
  --st-failed: #D0453A;
  --st-retry: #C2610C;
  --st-bounced: #B42318;
  --st-skipped: #A5A7B8;
  --warn: #A86A06;

  /* Brand */
  --brand-gradient: linear-gradient(180deg, #6B79FE 0%, #3B4ADB 100%);
  --coin: #F4B544;
  --blue: #666EFF;
  --cream: #F5F2E9;

  /* Effects */
  --shadow-sm: 0 1px 1px rgba(25, 28, 46, .05);
  --shadow-md: 0 1px 2px rgba(25, 28, 46, .05);
  --shadow-lg: 0 20px 25px -5px rgba(25, 28, 46, .08), 0 8px 10px -6px rgba(25, 28, 46, .05);
  --overlay: rgba(15, 17, 38, .45);
  --overlay-strong: rgba(15, 17, 38, .55);
  --scrollbar-thumb: #C9CEDA;
  --selection: rgba(102, 110, 255, .26);

  /* Legacy names, kept so existing rules keep working. Aliases only. */
  --bg: var(--bg-app);
  --surface: var(--bg-surface);
  --surface-2: var(--bg-subtle);
  --surface-3: var(--bg-subtle-2);
  --field: var(--bg-field);
  --border: var(--border-default);
  --text: var(--text-primary);
  --text-2: var(--text-secondary);
  --accent-soft: var(--accent-subtle);
  --accent-ink: var(--text-on-accent);
  --grad-brand: var(--brand-gradient);
  --navy: var(--bg-inverse);
  --navy-2: var(--bg-inverse-2);
  --amber: var(--coin);
  --amber-soft: var(--warning-bg);
  --amber-ink: var(--warning-text);
  --shadow: var(--shadow-md);
}

/* ── Dark values. Raised layers are LIGHTER than what is under them:
      page < card < popover (shadows barely show on dark). ──────────────── */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg-app: #0F1115;
  --bg-surface: #171A21;
  --bg-surface-raised: #1F232C;
  --bg-subtle: #1C2029;
  --bg-subtle-2: #232834;
  --bg-hover: #222733;
  --bg-selected: #1D2347;
  --bg-field: #12151B;
  --bg-inverse: #2A3050;
  --bg-inverse-2: #343B63;
  --bg-glass: rgba(23, 26, 33, .92);
  --bg-glass-strong: rgba(23, 26, 33, .96);

  --text-primary: #E6E8EE;
  --text-secondary: #C3C8D4;
  --text-muted: #9AA3B5;
  --text-dim: #8089A0;
  --text-strong: #F1F3F8;
  --text-link: #98A3FF;
  --text-on-accent: #0F1126;
  --text-on-solid: #FFFFFF;
  --text-on-inverse: #FFFFFF;
  --text-on-amber: #0F1126;
  --text-on-brand: #FFFFFF;

  --border-default: #2C3240;
  --border-soft: #232834;
  --border-strong: #3D4558;
  --border-focus: #98A3FF;

  --accent: #8B95FF;
  --accent-hover: #A5ADFF;
  --accent-subtle: #1D2347;

  --success-bg: #11261A;  --success-border: #1F5236;  --success-text: #7EE2A0;
  --warning-bg: #2A2110;  --warning-border: #5A4616;  --warning-text: #F5C566;
  --danger-bg: #2A1517;   --danger-border: #67292D;   --danger-text: #FF9B94;
  --danger-strong: #FF8F85;
  --info-bg: #171C3A;     --info-border: #343D7A;     --info-text: #AEB6FF;

  --st-pending: #9498AE;
  --st-research: #3CC0D4;
  --st-write: #38B2C6;
  --st-ready: #8B95FF;
  --st-queued: #B79BF7;
  --st-sending: #AB8FF5;
  --st-sent: #5FD38A;
  --st-failed: #FF8076;
  --st-retry: #F0A253;
  --st-bounced: #FF8076;
  --st-skipped: #8A8DA0;
  --warn: #F0B04A;

  --blue: #8B95FF;

  --shadow-sm: 0 1px 1px rgba(0, 0, 0, .35);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, .5), 0 8px 10px -6px rgba(0, 0, 0, .4);
  --overlay: rgba(0, 0, 0, .62);
  --overlay-strong: rgba(0, 0, 0, .72);
  --scrollbar-thumb: #3D4558;
  --selection: rgba(139, 149, 255, .35);
}

/* ── Global behaviour of the theme ─────────────────────────────────────── */
html { scrollbar-color: var(--scrollbar-thumb) transparent; }
::selection { background: var(--selection); }

/* A short colour fade when the person switches theme (never on page load,
   never with reduced motion). theme.js adds the class for ~200 ms. */
@media (prefers-reduced-motion: no-preference) {
  html.theme-animating, html.theme-animating *, html.theme-animating *::before, html.theme-animating *::after {
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, fill .15s ease, stroke .15s ease !important;
  }
}

/* The wordmark has a navy ink "tern": dark theme swaps in logo-dark.png (_brand.html). */
.brand-logo--dark { display: none !important; }
:root[data-theme="dark"] .brand-logo--dark { display: block !important; }
:root[data-theme="dark"] .brand-logo--light { display: none !important; }

/* Pictures with transparent backgrounds (company logos, avatars) keep a subtle
   light backing so they never vanish on dark. */
:root[data-theme="dark"] .avatar__img { background: var(--bg-glass-strong); }
