/* Base tokens, reset, and shared controls. Imported by /styles.css. */

/*
  ⚠️ ARCHITECTURE NOTE (v3, May 2026)
  ──────────────────────────────────────────────────────────────────
  Core design tokens (--accent*, --ink*, --bg*, --line*, --radius-*,
  --text-*, --space-*, type stacks, --hover*, --transition*) live in
  the :root block BELOW and in the design-system reference
  (colors_and_type.css). ONE declaration each — do NOT redeclare any
  of these tokens in other files.

  If you're about to write `--radius-md: 12px` somewhere else, STOP.
  That value is wrong (v2 is 8px) and duplicating it creates cascade
  drift. Use var(--radius-md) and let this file own the value.
  ────────────────────────────────────────────────────────────────── */

/* ─── Design tokens ──────────────────────────────────────────────────────── */
:root {
  /* Background scale */
  --bg:              #fafaf9;
  --surface-canvas:  #fafaf9;   /* workspace / editor — warm bench */
  --surface-paper:   #ffffff;   /* sidebar / list panels — paper white */
  --bg-soft:         #ffffff;   /* legacy alias → sidebar paper (v2: was #f9f9f9) */
  --bg-strong:    #f3f3f3;
  --bg-hero:      #fef3ea;   /* landing hero only — warm orange tint, bleeds accent into neutral */
  --bg-challenge: #f3f0eb;   /* 365-hooks challenge ribbon background */
  --panel:        rgba(0, 0, 0, 0.02);
  --panel-strong: rgba(0, 0, 0, 0.03);
  --panel-soft:   rgba(0, 0, 0, 0.015);
  --paper:        #eeeeee;

  /* Text */
  --ink:          #1a1a1a;
  --ink-strong:   #0f0f0f;
  --muted:        rgba(0, 0, 0, 0.62);
  --muted-dark:   rgba(0, 0, 0, 0.52);

  /* Borders */
  --line:         rgba(0, 0, 0, 0.07);
  --line-strong:  rgba(0, 0, 0, 0.13);

  /* Accent — remapped to emerald design system (was orange var(--brand-primary)) */
  --accent:       var(--brand-primary);        /* #1a9e6e */
  --accent-hot:   var(--brand-primary-hover);  /* #178a60 */
  --accent-deep:  var(--brand-primary-active); /* #137553 */
  --accent-text:  var(--fg-brand);             /* #137c56 */
  --accent-cool:  #0ea5c0;
  --accent-glow:  var(--bg-brand-soft);        /* rgba(26,158,110,0.10) */
  --accent-soft:  var(--bg-brand-soft);        /* rgba(26,158,110,0.10) */
  --accent-ring:  var(--border-brand);         /* rgba(26,158,110,0.55) */
  --accent-light: #5fd6a3;                      /* bright emerald — for accents on dark surfaces (undo toast) */
  --mint-soft:    rgba(14, 165, 192, 0.08);

  /* Surface aliases — map to new design system */
  --surface:         var(--bg-surface);  /* #ffffff */
  --surface-paper:   var(--bg-surface);
  --surface-canvas:  var(--bg-app);     /* #fbfaf8 */
  --bg:              var(--bg-app);     /* #fbfaf8 */

  /* State */
  --success:      #16a34a;
  --success-soft:   rgba(22, 163, 74, 0.08);
  --success-border: rgba(22, 163, 74, 0.22);
  --danger:       #dc2626;
  --teal:         #0e7c91;   /* scheduled-status only — never action (orange owns action) */
  --teal-soft:    rgba(14, 124, 145, 0.10);
  --amber:        #a07800;
  --amber-bg:     rgba(160, 120, 0, 0.08);

  /* Elevation */
  --shadow:       0 1px 3px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.07);
  --shadow-soft:  0 1px 2px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.06);

  /* Shape — v2 scale (6–12px is the house range; pill is chip-only) */
  --radius-xs:    4px;    /* utility buttons (.btn-accent, .btn-ghost) */
  --radius-sm:    6px;    /* secondary button, nav-pill, small chrome */
  --radius-md:    8px;    /* primary buttons, catalog items, inputs, list rows */
  --radius-lg:    10px;   /* sidebar widgets, dashed-outline CTAs */
  --radius-xl:    12px;   /* platform blocks, floating toolbars */
  --radius-2xl:   14px;   /* large cards, modal sheets */
  --radius-pill:  999px;  /* CHIP indicators only (streak, status). NEVER on action buttons. */

  /* Layout */
  --tab-bar-h:    64px;
  --header-h:     52px;

  /* Fonts */
  --mono:    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans:    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Bricolage Grotesque", Inter, -apple-system, sans-serif;
  --serif:   "Fraunces", Georgia, serif;

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

  /* ── Typography scale ── */
  --text-xs:   0.67rem;   /* 10.7px — labels, badges, uppercase eyebrows   */
  --text-sm:   0.77rem;   /* 12.3px — captions, meta, secondary controls   */
  --text-base: 0.875rem;  /* 14px   — body, textareas, catalog items        */
  --text-md:   1rem;      /* 16px   — section titles, ws-track-title        */
  --text-lg:   1.125rem;  /* 18px   — panel headings                        */

  /* ── Font weights ── */
  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;
  --weight-black:    800;

  /* ── Interaction ── */
  --hover:           rgba(0, 0, 0, 0.04);   /* default hover fill            */
  --hover-strong:    rgba(0, 0, 0, 0.07);   /* pressed / active fill         */
  --transition:      150ms ease-out;         /* standard state feedback       */
  --transition-fast: 100ms ease-out;         /* snappy micro-interactions     */
  --transition-open: 220ms ease-out;         /* deliberate open/close         */
  --ease-out-expo:   cubic-bezier(0.16, 1, 0.3, 1); /* spring-like decel for position/scale moves */
}

/* ─── Dark mode tokens ────────────────────────────────────────────────────── */
[data-theme="dark"] {
  color-scheme: dark;

  /* Surfaces */
  --bg:             #111111;
  --bg-soft:        #181818;
  --bg-strong:      #222222;
  --surface-paper:  #1a1a1a;   /* sidebar / list panels in dark — matches bg-soft tier */
  --surface-canvas: #111111;   /* workspace / editor in dark — same as --bg */
  --bg-hero:        #161310;   /* landing hero — warm-tinted near-black, mirrors light tint */
  --bg-challenge:   #181714;   /* challenge ribbon — slightly warmer than --bg-soft */
  --panel:        rgba(255, 255, 255, 0.025);
  --panel-strong: rgba(255, 255, 255, 0.045);
  --panel-soft:   rgba(255, 255, 255, 0.012);
  --paper:        #2c2c2c;

  /* Text */
  --ink:          #e8e5e0;
  --ink-strong:   #f2ede8;
  --muted:        rgba(255, 255, 255, 0.44);
  --muted-dark:   rgba(255, 255, 255, 0.36);

  /* Borders */
  --line:         rgba(255, 255, 255, 0.08);
  --line-strong:  rgba(255, 255, 255, 0.15);

  /* Accent tints (orange stays the same; accent-ring slightly brighter for dark) */
  --accent-glow:  var(--border-brand);
  --accent-soft:  var(--bg-brand-soft);
  --accent-ring:  rgba(26,158,110,0.30);
  --mint-soft:    rgba(14, 165, 192, 0.12);
  --teal:         #2bb6cf;   /* lifted for dark-mode contrast */
  --teal-soft:    rgba(43, 182, 207, 0.16);

  /* Interaction — dark mode overrides */
  --hover:        rgba(255, 255, 255, 0.06);
  --hover-strong: rgba(255, 255, 255, 0.10);

  /* Elevation */
  --shadow:       0 1px 3px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-soft:  0 1px 2px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* Hardcoded-color overrides that don't pull from tokens */
[data-theme="dark"] .admin-header {
  background: rgba(17, 17, 17, 0.94);
}
[data-theme="dark"] .provider-dot {
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .provider-dot:hover {
  background: rgba(255, 255, 255, 0.1);
}
/* Earned exception: dark mode tooltip needs a near-black surface distinct from page bg; no dark-surface token defined yet */
[data-theme="dark"] .provider-tooltip {
  background: #242424;
}
[data-theme="dark"] .sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .button-secondary,
[data-theme="dark"] .button.button-secondary {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
}
[data-theme="dark"] .button-secondary:hover,
[data-theme="dark"] .button.button-secondary:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.18);
}

/* ── Dark mode: phone frame ── */
[data-theme="dark"] .ae-phone {
  background: var(--bg);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .ae-phone-notch,
[data-theme="dark"] .ae-phone-bar {
  background: var(--line-strong);
}

/* ── Dark mode: platform brand colors — TikTok #111 is invisible on dark ── */
/* Earned exception: TikTok brand colour is #111 which is invisible on dark bg; #e8e5e0 is the minimum contrast override — no token maps to "light-on-dark platform brand text" */
[data-theme="dark"] .pb-brand--tiktok .pb-brand-icon,
[data-theme="dark"] .pb-brand--tiktok .pb-brand-name { color: #e8e5e0; }

/* ── Dark mode: new-hook dashed border ── */
[data-theme="dark"] .btn-new-hook {
  border-color: var(--line-strong);
}
[data-theme="dark"] .btn-new-hook:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.24);
}

/* ── Dark mode: submit bar gradient ── */
[data-theme="dark"] .form-submit-bar {
  background: linear-gradient(to bottom, transparent, rgba(17, 17, 17, 0.97) 28%);
}

/* ── Dark mode: preflight warning text ── */
[data-theme="dark"] .preflight-item {
  color: var(--ink);
}
/* Earned exception: preflight warning icon uses amber in dark mode — --status-warning is yellow-toned which bleeds on dark; #e6a020 is the calibrated dark-mode amber; no dark-aware warning-icon token exists yet */
[data-theme="dark"] .preflight-item svg {
  color: #e6a020;
}

/* ── Dark mode: scheduler amber badge ── */
/* Earned exception: schedule-status badge uses amber in dark mode — same dark-mode amber calibration as preflight; #d4a017 has adequate contrast on dark surfaces; no dark-aware token yet */
[data-theme="dark"] .sched-status {
  color: #d4a017;
}
[data-theme="dark"] .catalog-sched-badge {
  color: #d4a017;
}

/* Theme toggle button */
.theme-toggle {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
  transition: background 120ms, color 120ms;
  margin-left: 4px;
}
.theme-toggle:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
}
[data-theme="dark"] .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}
.logout-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
  transition: background 120ms, color 120ms;
  margin-left: 2px;
}
.logout-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
}
[data-theme="dark"] .logout-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }
[data-theme="dark"] .ae-clip-slider { accent-color: var(--accent); }
[data-theme="dark"] .ae-speed-btn { border-color: rgba(255,255,255,0.12); }
[data-theme="dark"] .ae-speed-btn--active { background: var(--bg-brand-soft); border-color: var(--border-brand); }
[data-theme="dark"] .sheet {
  background: var(--bg-soft);
}

/* ─── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
/* Ensure [hidden] always wins over any display:flex/grid set on a class.
   Without !important the UA rule (specificity 0,0,1,0) loses to any class rule. */
[hidden] { display: none !important; }
html { color-scheme: light; }

body {
  position: relative;
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before, body::after { display: none; }

a {
  color: var(--accent-cool);
  text-decoration-color: rgba(77, 184, 200, 0.3);
  text-underline-offset: 0.18em;
}
a:hover { text-decoration-color: var(--accent-cool); }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { color: var(--ink-strong); }

h2 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

h3 {
  margin-bottom: 4px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

input, textarea, select, button { font: inherit; }

/* ─── Shared card ─────────────────────────────────────────────────────────── */
/* v2 spec: card = flat rectangle with 1px ring on the surface beneath.
   Sidebar/list cards sit on --surface-canvas, so they use white paper.
   Never use --bg-strong here — that's the "selected/active fill" role. */
.card,
.track-card {
  background: var(--surface-paper);   /* white (v2) — was --bg-strong (wrong) */
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);    /* 12px (v2) — was 20px (legacy over-round) */
  padding: 24px;
}

.track-card {
  padding: 28px;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
/*
  Three tiers:
  1. .button              — solid dark, primary CTA (Save, Publish)
  2. .button-secondary    — neutral ghost, secondary action
  3. accent-ghost classes — orange text/border, AI/generative actions only
*/
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;   /* touch target — admin is mobile-first */
  border: 0;
  border-radius: var(--radius-md);   /* 8px (v2 — NOT pill) */
  padding: 10px 20px;
  background: var(--ink-strong);   /* near-black fill (v2 — not accent orange) */
  color: #fff; /* Earned exception: ink-fill button — white text on near-black; --fg-on-brand is for emerald, not ink; no --fg-on-ink token yet */
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  /* v2 shadow rule: subtle inset ring only — no outer lift shadow */
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  transition: background 150ms ease, filter 150ms ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Earned exception: hover on ink button goes to pure black — ink-strong is already near-black; need a slightly darker hover; no --ink-max token exists yet */
.button:hover {
  background: #000;
  /* No box-shadow change on hover — hover never lifts (v2 §"Animation") */
}
.button:active {
  filter: brightness(0.92);
  transform: scale(0.97);   /* only sanctioned transform — press feedback only */
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

/* Alias — .button already provides the dark-pill primary CTA style */
.button-primary { /* inherits all from .button */ }

.button-secondary {
  background: transparent;
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line-strong);
}
.button-secondary:hover {
  background: var(--hover);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.18);
}
.button-secondary:active {
  background: rgba(0, 0, 0, 0.05);
  filter: none;
}

.button-full {
  width: 100%;
}

.button-icon {
  min-width: 44px;
  padding: 0;
  font-size: 1.1rem;
  font-weight: 400;
}

/*
  Accent CTA — orange text, no border. AI/generative actions only.
  Examples: AI Generate, Surprise me, Generate Captions.
  Never use on non-AI actions.
*/
.btn-accent {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 5px 10px;
  background: transparent;
  color: var(--accent);
  border: none; border-radius: 4px;
  font-size: var(--text-sm); font-weight: var(--weight-semibold);
  font-family: var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-accent:hover  { background: var(--accent-soft); }
.btn-accent:active { background: var(--accent-glow); }
.btn-accent:disabled { opacity: 0.45; cursor: not-allowed; }

/*
  Secondary — subtle border, functional but not primary.
  Examples: Post to Platform, Schedule, Browse stock.
  No min-height: 44px, no pill shape.
*/
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 12px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  font-family: var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:hover  { border-color: var(--line-strong); background: var(--hover); }
.btn-secondary:active { background: var(--hover-strong); }
.btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }

/*
  Ghost / text — borderless. Utilities and inline controls.
  Examples: Save as template, load template, Precise crop.
*/
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 4px 8px;
  background: transparent;
  color: var(--muted);
  border: none; border-radius: 4px;
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  font-family: var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-ghost:hover  { color: var(--ink); background: var(--hover); }
.btn-ghost:active { background: var(--hover-strong); }
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }

/* ─── Form inputs ─────────────────────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="number"],
textarea,
select {
  width: 100%;
  min-height: 44px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-strong);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input::placeholder,
textarea::placeholder { color: var(--muted); }

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 0px;
  border-color: var(--border-brand);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--line-strong);
  background: rgba(0, 0, 0, 0.04);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='rgba(0,0,0,0.4)' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Earned exception: native select option needs an explicit bg for cross-browser consistency; var(--bg-surface) is #fafaf9 (warm white) which some browsers ignore; #f5f5f5 is neutral white and accepted everywhere */
select option {
  background: #f5f5f5;
  color: var(--ink);
}

/* ─── Status message ──────────────────────────────────────────────────────── */
.status {
  margin: 10px 0 0;
  min-height: 1.4em;
  color: var(--muted);
  font-size: 0.88rem;
}
.status[data-error="true"] { color: var(--danger); }

.muted { color: var(--muted); }
