/* Path to Success — shared design system.
   Load after the legacy styles. Existing component hooks and token names stay
   available to the application, translations, tours and native wrappers. */

:root {
  color-scheme: light;

  /* Brand and surfaces */
  --ds-brand: #0E6E5C;
  --ds-brand-hover: #095747;
  --ds-brand-deep: #073E32;
  --ds-mint: #E7F3ED;
  --ds-yellow: #F2B544;
  --ds-yellow-soft: #FFF3D7;
  --ds-canvas: #FAF8F2;
  --ds-surface: #FFFFFF;
  --ds-surface-soft: #F1F4EE;
  --ds-text: #142D25;
  --ds-text-secondary: #354C42;
  --ds-text-muted: #596B61;
  --ds-text-inverse: #FFFFFF;
  --ds-text-inverse-muted: #D4E8DF;
  --ds-border: #DDE5DB;
  --ds-border-strong: #B9C9BC;
  --ds-overlay: rgba(7, 38, 29, .55);

  /* Every status foreground also works as a white-text badge background. */
  --ds-success: #246849;
  --ds-warning: #865A0C;
  --ds-behind: #9A4614;
  --ds-danger: #AD2925;
  --ds-danger-hover: #8D201D;

  /* System fonts stay crisp offline and in the mobile wrappers. */
  --ds-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --ds-text-xs: .75rem;
  --ds-text-sm: .875rem;
  --ds-text-base: 1rem;
  --ds-text-lg: 1.125rem;
  --ds-text-xl: 1.375rem;
  --ds-text-2xl: 1.75rem;
  --ds-text-3xl: 2.25rem;
  --ds-text-display: clamp(2.5rem, 5.5vw, 5rem);
  --ds-leading: 1.5;
  --ds-leading-tight: 1.14;

  --ds-space-1: .25rem;
  --ds-space-2: .5rem;
  --ds-space-3: .75rem;
  --ds-space-4: 1rem;
  --ds-space-5: 1.25rem;
  --ds-space-6: 1.5rem;
  --ds-space-8: 2rem;
  --ds-space-10: 2.5rem;
  --ds-space-12: 3rem;
  --ds-space-16: 4rem;

  --ds-radius-xs: 6px;
  --ds-radius-sm: 12px;
  --ds-radius-md: 18px;
  --ds-radius-lg: 24px;
  --ds-radius-pill: 999px;
  --ds-shadow-sm: 0 2px 6px rgba(20, 45, 37, .04);
  --ds-shadow-md: 0 4px 18px rgba(20, 45, 37, .06);
  --ds-shadow-lg: 0 18px 48px rgba(20, 45, 37, .13);
  --ds-shadow-dialog: 0 24px 80px rgba(7, 38, 29, .24);
  --ds-motion-fast: 120ms;
  --ds-motion-normal: 180ms;
  --ds-motion-slow: 280ms;
  --ds-ease: cubic-bezier(.2, .7, .2, 1);

  /* Compatibility aliases: app modules and older page CSS use these. */
  --bg: var(--ds-canvas);
  --surface: var(--ds-surface);
  --surface-2: var(--ds-surface-soft);
  --ink: var(--ds-text);
  --ink-2: var(--ds-text-secondary);
  --muted: var(--ds-text-muted);
  --line: var(--ds-border);
  --line-2: var(--ds-border-strong);
  --primary: var(--ds-brand);
  --primary-dark: var(--ds-brand-hover);
  --primary-soft: var(--ds-mint);
  --good: var(--ds-success);
  --slipping: var(--ds-warning);
  --behind: var(--ds-behind);
  --critical: var(--ds-danger);
  --radius: var(--ds-radius-md);
  --radius-sm: var(--ds-radius-sm);
  --shadow: var(--ds-shadow-md);
  --shadow-lg: var(--ds-shadow-lg);
  --sans: var(--ds-font);
}

/* Foundations. Page and app layout rules live in their own style sheets. */
*, *::before, *::after { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: var(--ds-leading);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, h4 {
  color: inherit;
  font-family: var(--sans);
  font-weight: 750;
  letter-spacing: -.035em;
}
h1 { font-size: var(--ds-text-2xl); line-height: var(--ds-leading-tight); }
h2 { font-size: var(--ds-text-xl); line-height: 1.22; }
h3 { font-size: var(--ds-text-lg); line-height: 1.3; }
a { color: var(--primary); text-underline-offset: .2em; }
button, input, select, textarea { font-family: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; height: auto; }
button, input, select, textarea { max-width: 100%; }
button { touch-action: manipulation; }
input, select, textarea { accent-color: var(--primary); }
::selection { color: var(--ds-brand-deep); background: #C7E7D7; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}
:where(.ds-inverse, .sa) :where(a, button, input, select, textarea):focus-visible {
  outline-color: var(--ds-yellow);
}
.muted { color: var(--muted); }
.tiny { font-size: var(--ds-text-xs); }
.small { font-size: var(--ds-text-sm); }
.ds-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
.ds-icon-lg { width: 24px; height: 24px; }

/* Public checkmarks are vector decorations; their text stays untouched. */
.v7-ticks li::before, .v3-trust-row span::before {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m5 12 4 4L19 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m5 12 4 4L19 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.v7-ticks li::before { top: .22em; }
.v3-trust-row span::before { margin-inline-end: 6px; vertical-align: -.12em; }

/* Buttons. Existing JS hooks and all button variants are retained. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-2);
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: 650 .9375rem/1.35 var(--sans);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--ds-motion-fast) var(--ds-ease),
    border-color var(--ds-motion-fast) var(--ds-ease),
    box-shadow var(--ds-motion-normal) var(--ds-ease),
    transform var(--ds-motion-fast) var(--ds-ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { color: #fff; background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { color: var(--primary-dark); background: transparent; border-color: transparent; }
.btn-ghost:hover { color: var(--primary-dark); background: var(--primary-soft); border-color: transparent; }
.btn-danger { color: #fff; background: var(--critical); border-color: var(--critical); }
.btn-danger:hover { color: #fff; background: var(--ds-danger-hover); border-color: var(--ds-danger-hover); filter: none; }
.btn-sm { min-height: 36px; padding: 7px 12px; font-size: var(--ds-text-sm); }
.btn-block { display: flex; width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .58; cursor: default; transform: none; }
.btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.qbtn, .ft-opt {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-2);
  border-radius: var(--radius-sm);
  transition: background var(--ds-motion-fast), border-color var(--ds-motion-fast);
}
.qbtn:hover, .ft-opt:hover { border-color: var(--primary); background: var(--primary-soft); }

/* Cards and nested surfaces. No card wrapper is moved or hidden here. */
.card, .ds-card {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.ds-card { padding: var(--ds-space-5); }
.card-flat { box-shadow: none; }
.step { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.step-action, .ft-reward-p, .mailprev, .mp-step { background: var(--surface-2); border-radius: var(--radius-sm); }
.guardrail { background: var(--ds-yellow-soft); color: #67470C; border-color: #E3CB94; border-radius: var(--radius-sm); }
.ft-kidcard, .ft-help { border-radius: var(--radius-sm); border-color: var(--line); }

/* Inputs: auth and dynamically-created fields receive the same treatment. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
select, textarea {
  min-width: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: 400 1rem/1.4 var(--sans);
  padding: 10px 12px;
  transition: border-color var(--ds-motion-fast), box-shadow var(--ds-motion-fast);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--critical); }
.field label { color: var(--ink); font-size: var(--ds-text-sm); font-weight: 650; }
.field .hint, .field-err { font-size: var(--ds-text-xs); line-height: 1.4; }
.field-err { color: var(--critical); }
.choice label { border-radius: var(--radius-sm); border-color: var(--line-2); background: var(--surface); }
.choice label.sel, .choice label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice label:focus-within { outline: 3px solid var(--primary); outline-offset: 3px; }

/* Chips and navigation tabs. Selection is never conveyed by color alone. */
.chip, .ask-chip, .yearpick button {
  border: 1px solid var(--line-2);
  border-radius: var(--ds-radius-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--ds-text-sm);
  font-weight: 600;
  transition: background var(--ds-motion-fast), border-color var(--ds-motion-fast);
}
.chip:hover, .ask-chip:hover, .yearpick button:hover { border-color: var(--primary); background: var(--primary-soft); }
.chip.on, .yearpick button.active { color: #fff; background: var(--primary); border-color: var(--primary); font-weight: 750; }
.stage-chip, .ai-credits { color: var(--primary-dark); background: var(--primary-soft); border-radius: var(--ds-radius-pill); }
.sev { font-weight: 750; border-radius: var(--ds-radius-pill); }
.sev.on_track, .sev.ahead { background: var(--good); }
.sev.slipping { background: var(--slipping); }
.sev.behind { background: var(--behind); }
.sev.critical { background: var(--critical); }
.tab { color: var(--muted); transition: color var(--ds-motion-fast), background var(--ds-motion-fast); }
.tab.active { color: var(--primary-dark); background: var(--primary-soft); border-top-color: var(--primary); font-weight: 750; }
.tab:focus-visible { outline-offset: -4px; border-radius: var(--ds-radius-xs); }
.tab svg { stroke-linecap: round; stroke-linejoin: round; }

/* Native-style dialogs, app tours, language chooser and feature pop-ups. */
.fdlg-ov, .tour-backdrop, .v7-modal-bg, .i18n-sheet-backdrop { background: var(--ds-overlay); }
.fdlg, .tour-card, .v7-modal-card, .i18n-sheet-panel, .tour-pick, .fb-panel {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-dialog);
}
.fdlg-t, .tour-card h3 { color: var(--ink); letter-spacing: -.025em; }
.fdlg-m, .tour-card p { color: var(--ink-2); }
.tour-eyebrow { color: var(--primary); }
.tour-dots span { background: var(--line-2); }
.tour-dots span.on { background: var(--primary); }
.tour-pick { border-radius: var(--radius); }
.tour-pick button { border-radius: var(--radius-sm); }
.tour-pick button:hover { background: var(--primary-soft); }
.v7-modal-x, .i18n-sheet-x, .ai-dock-btn { color: var(--ink-2); border-radius: var(--radius-sm); }

/* Ask: one visual language for both site and app, retaining every chat hook. */
.ai-fab { background: var(--primary); color: #fff; box-shadow: var(--ds-shadow-lg); }
.ai-fab:hover { background: var(--primary-dark); }
.ai-dock { background: var(--bg); border-color: var(--line); border-radius: var(--ds-radius-lg); box-shadow: var(--ds-shadow-dialog); }
.ai-dock.ai-full { border-radius: 0; }
.ask-bot, .ask-ai { color: var(--ink); background: var(--surface); border-radius: var(--radius-sm); border-color: var(--line); }
.ask-user { color: #fff; background: var(--primary); border-radius: var(--radius-sm); }
.ask-msg { overflow-wrap: anywhere; }
.ask-form button { background: var(--primary); color: #fff; border-radius: var(--radius-sm); }
.ask-trust { color: var(--muted); }
.sa { color: #fff; background: var(--ds-brand-deep); border-color: #467D69; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.sa-h small, .sa-fine { color: var(--ds-text-inverse-muted); }
.sa-chips button { color: #fff; border-color: #7CA492; background: rgba(255,255,255,.08); border-radius: var(--ds-radius-pill); }
.sa-chips button:hover { background: rgba(255,255,255,.15); }
.sa-send { color: var(--ink); background: var(--ds-yellow); border-radius: var(--radius-sm); }
.sa-m.ai { background: var(--surface); color: var(--ink); }
.sa-m.me { background: var(--primary); color: #fff; }
.sa-x { color: #fff; }

/* Keep motion brief. Reduced motion also reveals content that legacy entrance
   effects otherwise leave waiting for animation or an observer. */
@media (prefers-reduced-motion: reduce) {
  :root { --ds-motion-fast: 0ms; --ds-motion-normal: 0ms; --ds-motion-slow: 0ms; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0ms !important;
    scroll-behavior: auto !important;
  }
  .v7-reveal, .pa-fuq, .v7-chat .v7-msg.ai, .v7-chat .v7-chips, .v7-chat .v7-card {
    opacity: 1 !important;
    transform: none !important;
  }
  .v7-type { clip-path: none !important; }
  .btn:active, .qbtn:active, .ai-fab:active { transform: none; }
}
