/* ============================================================
   ReVoyage — theme system
   Four themes. Every token pair measured against WCAG 2.1 AA.

     warm-sand   (default)  light, paper-like
     paper-ink              light, near-neutral
     blush-stone            light, soft/romantic
     dark                   one dark mode, warm

   Applied via <html data-theme="warm-sand">.
   data-theme="system" follows the OS preference: warm-sand by day,
   dark at night.
   ============================================================ */

:root,
[data-theme="warm-sand"] {
  --bg:            #FBF7F0;
  --surface:       #FFFFFF;
  --surface-alt:   #F4EEE4;
  --line:          #E0D6C7;   /* decorative separators only */
  --line-strong:   #8A7C6A;   /* inputs, focus rings, interactive boundaries — 3:1+ */
  --text:          #221E1A;
  --muted:         #6B6259;
  --accent:        #8F4A12;
  --accent-hover:  #7A3E0F;
  --accent-text:   #FFFFFF;
  --accent-soft:   #F5E7DA;   /* tinted fills, never text */
  --danger:        #A32E22;
  --success:       #2F6B45;
  --shadow:        0 2px 10px rgba(34, 30, 26, .07);
  color-scheme: light;
}

[data-theme="paper-ink"] {
  --bg:            #FAF9F7;
  --surface:       #FFFFFF;
  --surface-alt:   #F1EFEB;
  --line:          #DDD9D2;
  --line-strong:   #84807A;
  --text:          #1A1A1A;
  --muted:         #63615C;
  --accent:        #1F5F4B;
  --accent-hover:  #184C3C;
  --accent-text:   #FFFFFF;
  --accent-soft:   #E2EDE8;
  --danger:        #A32E22;
  --success:       #1F5F4B;
  --shadow:        0 2px 10px rgba(26, 26, 26, .07);
  color-scheme: light;
}

[data-theme="blush-stone"] {
  --bg:            #FDF8F5;
  --surface:       #FFFFFF;
  --surface-alt:   #F6EAE4;
  --line:          #E8DBD4;
  --line-strong:   #8C7A72;
  --text:          #2B211D;
  --muted:         #6E5F58;
  --accent:        #A63D40;
  --accent-hover:  #8C3235;
  --accent-text:   #FFFFFF;
  --accent-soft:   #F7E4E2;
  --danger:        #A63D40;
  --success:       #3F6B52;
  --shadow:        0 2px 10px rgba(43, 33, 29, .07);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:            #15120E;
  --surface:       #201B16;
  --surface-alt:   #2A231C;
  --line:          #332C24;
  --line-strong:   #8A7F72;
  --text:          #F2EDE4;
  --muted:         #A79C8E;
  --accent:        #E0A458;
  --accent-hover:  #EDB570;
  --accent-text:   #231705;
  --accent-soft:   #2E2418;
  --danger:        #E88A7A;
  --success:       #7FB08A;
  --shadow:        0 2px 14px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

/* "Match system" — light default, dark when the OS asks for it. */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --bg:            #15120E;
    --surface:       #201B16;
    --surface-alt:   #2A231C;
    --line:          #332C24;
    --line-strong:   #8A7F72;
    --text:          #F2EDE4;
    --muted:         #A79C8E;
    --accent:        #E0A458;
    --accent-hover:  #EDB570;
    --accent-text:   #231705;
    --accent-soft:   #2E2418;
    --danger:        #E88A7A;
    --success:       #7FB08A;
    --shadow:        0 2px 14px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

/* ============================================================
   AGENT BRAND OVERRIDE (white-label)

   An agent may override ONLY the accent tokens. Background, surface,
   text and border stay platform-controlled so an agent can never
   accidentally break contrast or readability.

   The agent's chosen colour is validated server-side against all four
   themes before it is saved. If it fails on any theme, the agent is
   asked for a darker or lighter variant rather than being allowed to
   ship something unreadable to their clients.

   Injected per-tenant as an inline style on <html>:
     style="--accent:#123456; --accent-hover:#0F2C45; --accent-text:#FFF"
   ============================================================ */

/* ============================================================
   Shared primitives — theme-agnostic
   ============================================================ */
* { box-sizing: border-box; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  transition: background-color .2s ease, color .2s ease;
}

.display { font-family: "Fraunces", Georgia, serif; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  cursor: pointer;
  min-height: 44px;              /* touch target minimum */
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  padding: 12px 18px;
  min-height: 44px;
}

input, textarea, select {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--line-strong);   /* never --line: fails 3:1 */
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  width: 100%;
  min-height: 44px;
}

/* Focus is always visible. Never remove without replacing. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Funding progress — conveys state by text and number as well as colour */
.vessel { background: var(--line); border-radius: 999px; overflow: hidden; }
.vessel-fill { background: var(--accent); height: 100%; border-radius: 999px; transition: width .4s ease; }

.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
