/* wm-base.css — design system tokens + shared components
   v11 — design refresh from Wine Maestro Redesign (2026)
   Backward compatible: keeps all existing variables, adds new ones for richer typography,
   spacing scale, shadow system, and refined dark/light themes.
*/

:root {
  /* ===== Color — dark (default) ===== */
  --bg: #0D0B0E;
  --bg-elevated: #14101A;
  --bg-deep: #08070A;          /* NEW: deeper than --bg, used behind cards */
  --card: #1A1520;             /* slightly more violet than 1A1518 */
  --card-hover: #221C2C;
  --card-elev: #221B2D;        /* NEW: elevated card surface */

  --gold: #C9A96E;
  --gold-light: #D9BD86;
  --gold-dark: #9D8451;
  --gold-soft: rgba(201,169,110,.14);  /* NEW: ambient gold tint */

  --wine: #722F37;
  --wine-light: #8B3F47;
  --wine-deep: #5A2329;        /* NEW */

  --text: #F2EDE4;             /* slightly brighter than E8E0D5 — better contrast */
  --text-muted: #8A8290;
  --text-dim: #5A5363;         /* NEW: tertiary text */

  --border: rgba(201,169,110,.12);     /* gold-tinted instead of pure white */
  --border-strong: rgba(201,169,110,.24);
  --divider: rgba(255,255,255,.06);

  /* Brand connectors */
  --tg: #2AABEE;
  --ya: #FC3F1D;

  /* ===== Type ===== */
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, monospace;

  /* ===== Spacing scale (4px base) ===== */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* ===== Radii ===== */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --radius-card: 12px;     /* legacy alias */
  --radius-pill: 999px;
  --r-pill: 999px;

  /* ===== Shadows ===== */
  --shadow-sm: 0 2px 6px rgba(0,0,0,.25);
  --shadow-md: 0 4px 14px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  --shadow-gold: 0 8px 24px rgba(201,169,110,.18);
  --shadow-card: 0 4px 18px rgba(0,0,0,.4);  /* legacy alias */

  /* ===== Button radius scale (S3 tokens) ===== */
  --btn-radius-sm: 8px;
  --btn-radius-md: 12px;
  --btn-radius-lg: 14px;
  --btn-radius-pill: 999px;

  /* ===== H1 size scale (S3 tokens) ===== */
  --h1-mobile: 26px;
  --h1-tablet: 30px;
  --h1-desktop: 34px;

  /* ===== Z-index scale (S3 tokens) ===== */
  --z-sticky: 50;
  --z-dropdown: 100;
  --z-overlay: 200;
  --z-modal: 1000;
  --z-toast: 1100;
  --z-skip-link: 1200;

  /* Bottom-nav offset for sticky elements (mobile only) */
  --bottomnav-h: 0px;
}

@media (max-width: 768px) {
  :root { --bottomnav-h: 64px; }
}

[data-theme="light"] {
  --bg: #F8F5EE;
  --bg-elevated: #FFFFFF;
  --bg-deep: #F0EBDF;
  --card: #FFFFFF;
  --card-hover: #FAF6EC;
  --card-elev: #FFFFFF;

  --gold: #8B7340;             /* darker for AA contrast on light */
  --gold-light: #A88E55;
  --gold-dark: #6B5728;
  --gold-soft: rgba(139,115,64,.10);

  --wine: #722F37;
  --wine-light: #8B3F47;
  --wine-deep: #5A2329;

  --text: #1A1518;
  --text-muted: #6E6862;
  --text-dim: #9C958C;

  --border: rgba(139,115,64,.18);
  --border-strong: rgba(139,115,64,.32);
  --divider: rgba(0,0,0,.06);

  --shadow-sm: 0 2px 6px rgba(0,0,0,.06);
  --shadow-md: 0 4px 14px rgba(0,0,0,.10);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.14);
  --shadow-gold: 0 8px 24px rgba(139,115,64,.18);
  --shadow-card: 0 4px 18px rgba(0,0,0,.08);
}

/* ===== Reset ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ===== Type scale ===== */
h1, h2, h3, h4, .title {
  font-family: var(--font-display);
  font-weight: 500;
  margin: 0 0 .4em;
  color: var(--gold);
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(28px, 4vw, 44px); line-height: 1.1; }
h2 { font-size: clamp(22px, 3vw, 32px); line-height: 1.15; }
h3 { font-size: clamp(18px, 2.4vw, 24px); line-height: 1.2; }
h4 { font-size: 18px; line-height: 1.3; }

.eyebrow {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--text-muted);
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, color .15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--wine), var(--wine-light));
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover { box-shadow: var(--shadow-lg); }
.btn-primary:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; box-shadow: none; }

.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--bg);
  border-color: transparent;
}
.btn-gold:hover { filter: brightness(1.05); }

.btn-secondary {
  background: transparent;
  color: var(--gold);
  border-color: var(--gold);
}
.btn-secondary:hover { background: var(--gold-soft); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--border-strong); background: var(--card-hover); }

.btn-large { min-height: 56px; font-size: 15px; padding: 14px 24px; }
.btn-small { min-height: 36px; padding: 8px 14px; font-size: 13px; }

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}
.card-elev {
  background: var(--card-elev);
  box-shadow: var(--shadow-md);
}
.card-gold-frame {
  border-color: var(--border-strong);
  background: linear-gradient(180deg, var(--card) 0%, var(--card-hover) 100%);
}

/* ===== Chips & Pills ===== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--gold-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}
.chip-active {
  background: var(--gold);
  color: var(--bg);
  border-color: var(--gold);
}
.chip-gold-pill {
  background: rgba(201,169,110,.18);
  color: var(--gold-light);
  font-weight: 600;
}
.pill {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
}

/* ===== Dividers ===== */
.divider {
  height: 1px;
  background: var(--divider);
  margin: var(--sp-4) 0;
}
.divider-text {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
}
.divider-text::before, .divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--divider);
}

/* ===== Inputs ===== */
.input {
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color .15s ease;
}
.input:focus { outline: none; border-color: var(--gold); }
.input::placeholder { color: var(--text-dim); }

/* ===== Utilities ===== */
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.gold { color: var(--gold); }

button, a.btn, [role="button"] { min-height: 44px; }

@media (max-width: 360px) {
  body { font-size: 14px; }
}


/* ===== Phase 3.11 WCAG 2.2 AA — reinstated after design refresh 2026-04-26 ===== */

/* Variable used by focus-visible — keep token themable */
:root { --gold-a11y: #D4B883; }

/* SC 2.4.7 Focus Visible */
:focus-visible { outline: 2px solid var(--gold-a11y); outline-offset: 2px; border-radius: 2px; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible,
select:focus-visible, [role="button"]:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--gold-a11y); outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* SC 2.4.1 Skip Link */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  padding: 8px 14px; background: var(--bg); color: var(--gold);
  border-radius: 4px; font-weight: 600;
}
.skip-link:focus, .skip-link:focus-visible {
  left: 0; outline: 2px solid #fff; outline-offset: 2px;
}

/* SC 2.3.3 / 2.2.2 Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after {
  animation-duration: 0.01ms !important; transition-duration: 0.01ms !important;
}

/* SC 1.4.6 High Contrast */
@media (prefers-contrast: more) {
  :root { --gold: #FFD580; --bg: #000000; --text: #ffffff; --border: rgba(255,255,255,.4); }
}

/* SC 1.1.1 Screen Reader Only */
.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;
}

/* SC 2.5.8 Target Size — buttons stay >=44 (handoff dropped min-width) */
.btn, button.btn, a.btn, input[type="button"], input[type="submit"] { min-width: 44px; }
.btn-inline, [data-inline-btn] { min-height: 24px; min-width: 24px; }
/* ===== /Phase 3.11 ===== */

/* wm-scrollbar global */
/* page-level scroll only — DON'T target nested overflow:auto elements with gold thumbs */
html::-webkit-scrollbar, body::-webkit-scrollbar{width:8px;height:8px}
html::-webkit-scrollbar-track, body::-webkit-scrollbar-track{background:transparent}
html::-webkit-scrollbar-thumb, body::-webkit-scrollbar-thumb{background:rgba(201,169,110,0.18);border-radius:4px}
html::-webkit-scrollbar-thumb:hover, body::-webkit-scrollbar-thumb:hover{background:rgba(201,169,110,0.4)}
html::-webkit-scrollbar-corner, body::-webkit-scrollbar-corner{background:transparent}
html{scrollbar-color:rgba(201,169,110,0.25) transparent;scrollbar-width:thin}
[data-theme="light"] html::-webkit-scrollbar-thumb,[data-theme="light"] body::-webkit-scrollbar-thumb{background:rgba(139,115,64,0.22)}
[data-theme="light"] html::-webkit-scrollbar-thumb:hover,[data-theme="light"] body::-webkit-scrollbar-thumb:hover{background:rgba(139,115,64,0.45)}
[data-theme="light"] html{scrollbar-color:rgba(139,115,64,0.32) transparent}

/* ===== wm-toasts ===== */
.wm-toast-stack {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
  width: auto;
}
.wm-toast {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  max-width: 380px;
  width: max-content;
  min-width: 220px;
  background: rgba(26, 21, 32, 0.95);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  animation: wmToastIn 260ms cubic-bezier(.22,.61,.36,1) both;
  word-wrap: break-word;
}
.wm-toast.leaving {
  animation: wmToastOut 220ms cubic-bezier(.4,0,.6,1) forwards;
  pointer-events: none;
}
.wm-toast.success { border-left-color: var(--gold); }
.wm-toast.error   { border-left-color: var(--wine-light); }
.wm-toast.info    { border-left-color: var(--gold-light); }

.wm-toast .ic {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  font-weight: 700;
  margin-top: 1px;
}
.wm-toast.success .ic {
  background: rgba(201, 169, 110, 0.18);
  color: var(--gold);
  border: 1px solid rgba(201, 169, 110, 0.35);
}
.wm-toast.error .ic {
  background: rgba(139, 63, 71, 0.22);
  color: #E89AA0;
  border: 1px solid rgba(139, 63, 71, 0.45);
}
.wm-toast.info .ic {
  background: rgba(217, 189, 134, 0.16);
  color: var(--gold-light);
  border: 1px solid rgba(217, 189, 134, 0.32);
}
.wm-toast .msg {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text);
}

@keyframes wmToastIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes wmToastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}

@media (max-width: 768px) {
  .wm-toast-stack {
    right: 12px;
    left: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)); /* above bottom-nav */
    align-items: stretch;
    max-width: none;
  }
  .wm-toast {
    width: auto;
    max-width: none;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wm-toast { animation: none; }
  .wm-toast.leaving { animation: none; opacity: 0; }
}
/* ===== /wm-toasts ===== */


/* === TEST INSTANCE: force sans-serif everywhere (overrides inline Cormorant/Raleway/serif fallbacks) === */
*, *::before, *::after, h1, h2, h3, h4, h5, h6, p, span, div, a, button, input, textarea, select, label { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Inter", "Helvetica Neue", Arial, sans-serif !important; }
code, pre, kbd, samp, .mono, [class*="mono"] { font-family: var(--font-mono) !important; }

/* === TEST INSTANCE: kill all italic === */
*, *::before, *::after, em, i, blockquote, cite, dfn, address, var { font-style: normal !important; }

/* Fresh button — sticky above .rec-actions container (A1) */
.rec-fresh-inline { display: block !important; width: 100% !important; max-width: min(960px, calc(100% - 24px)) !important; margin: 14px auto !important; padding: 14px 26px !important; position: static !important; transform: none !important; align-self: flex-start !important; box-sizing: border-box !important; }

/* === HIGH #4: restore focus-visible outline (WCAG 2.4.7) === */
*:focus-visible { outline: 2px solid var(--gold-a11y, #D4B883) !important; outline-offset: 2px !important; }

