/* Roofing Source shared web theme tokens + light-mode surface overrides.
   Dark = existing appearance. Light = warm paper surfaces, slate ink.
   Brand: teal primary, orange accent. Semantic colours are darkened in light
   mode for AA contrast. Photos, charts and canvases are never filtered. */

:root {
  --rs-teal: #0d9488;
  --rs-teal-strong: #0f766e;
  --rs-orange: #f97316;
  --rs-orange-strong: #c2410c;
  --rs-brand-grad: linear-gradient(135deg, #0d9488 0%, #14b8a6 55%, #f97316 130%);
}

html[data-rs-theme="dark"] {
  --rs-bg: #0a1628; --rs-surface: #111f35; --rs-surface-2: #1a2d45; --rs-card: #152236;
  --rs-line: #1e3a5280; --rs-ink: #f1f5f9; --rs-ink-2: #94a3b8; --rs-ink-3: #64748b;
  --rs-success: #22c55e; --rs-warning: #f59e0b; --rs-error: #ef4444;
  color-scheme: dark;
}

html[data-rs-theme="light"] {
  --rs-bg: #f6f3ee; --rs-surface: #fffdf9; --rs-surface-2: #efeae2; --rs-card: #fffdf9;
  --rs-line: #d9d2c5; --rs-ink: #1b2430; --rs-ink-2: #4a5566; --rs-ink-3: #6b7383;
  --rs-success: #15803d; --rs-warning: #b45309; --rs-error: #b91c1c;
  color-scheme: light;

  /* Role dashboards (operative / subcontractor / hirer) + building regs use these vars */
  --dark: var(--rs-bg); --dark2: var(--rs-surface); --dark3: var(--rs-surface-2);
  --card: var(--rs-card); --border: var(--rs-line);
  --text: var(--rs-ink); --text-sub: var(--rs-ink-2); --text-muted: var(--rs-ink-3);
  --green: var(--rs-success); --gold: var(--rs-warning); --red: var(--rs-error);
  --teal-glow: #0d948822; --teal: #0f766e; --teal-light: #0f766e;
  --bg: var(--rs-bg); --header-bg: rgba(255, 253, 249, .9);
}

/* Brand gradient: teal -> orange accent, both themes */
html[data-rs-theme] { --grad: linear-gradient(135deg, #0d9488, #14b8a6 60%, #f97316); }

/* Brand navigation/actions remain teal in both themes, not legacy purple. */
html[data-rs-theme] .adm-logo span { color: #2dd4bf !important; }
html[data-rs-theme="light"] .adm-logo span { color: #0f766e !important; }
html[data-rs-theme] .adm-badge,
html[data-rs-theme] .card-btn { background: #0f766e !important; color: #fff !important; }
html[data-rs-theme][data-rs-page] .adm-nav-item.active {
  background: #123b3b !important;
  color: #5eead4 !important;
  border-left-color: #14b8a6 !important;
}
html[data-rs-theme="light"][data-rs-page] .adm-nav-item.active {
  background: #e0f2ef !important;
  color: #115e59 !important;
  border-left-color: #0f766e !important;
}
html[data-rs-theme] .adm-nav-item:focus-visible,
html[data-rs-theme] .adm-nav-toggle:focus-visible { outline-color: #14b8a6 !important; }

/* ---------- Light: generic role dashboards ---------- */
html[data-rs-theme="light"] body { background: var(--rs-bg); color: var(--rs-ink); }
html[data-rs-theme="light"] input,
html[data-rs-theme="light"] select,
html[data-rs-theme="light"] textarea { color: var(--rs-ink); }
html[data-rs-theme="light"] .op-nav,
html[data-rs-theme="light"] .sb-nav,
html[data-rs-theme="light"] .hr-nav { backdrop-filter: none; box-shadow: 0 1px 0 var(--rs-line); }

/* Admin, public and page-specific hard-coded colours are remapped by the
   generated /css/rs-theme-light.css (scripts/src/generate-rs-theme-light.mjs),
   which never recolours text on semantic/brand-filled buttons. */

/* Never recolour media */
html[data-rs-theme] img,
html[data-rs-theme] video,
html[data-rs-theme] canvas,
html[data-rs-theme] svg image { filter: none; }

/* ---------- Toggle ---------- */
.rs-theme-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 6px 12px 6px 8px;
  border-radius: 999px; border: 1px solid rgba(148, 163, 184, .35);
  background: rgba(17, 31, 53, .92); color: #f1f5f9;
  font: 600 12px/1 system-ui, -apple-system, 'Segoe UI', sans-serif; letter-spacing: .04em;
  cursor: pointer;
}
html[data-rs-theme="light"] .rs-theme-toggle { background: rgba(255, 253, 249, .96); color: var(--rs-ink); border-color: var(--rs-line); }
.rs-theme-toggle:focus-visible { outline: 3px solid var(--rs-orange); outline-offset: 2px; }
.rs-theme-toggle__track {
  position: relative; width: 34px; height: 20px; border-radius: 999px;
  background: #cbd5e1; flex-shrink: 0;
}
.rs-theme-toggle[aria-pressed="true"] .rs-theme-toggle__track { background: var(--rs-teal); }
.rs-theme-toggle__thumb {
  position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--rs-orange); transition: transform .18s ease;
}
.rs-theme-toggle[aria-pressed="true"] .rs-theme-toggle__thumb { transform: translateX(14px); background: #fffdf9; }
.rs-theme-toggle--floating {
  position: fixed; z-index: 8700; left: 12px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 6px 18px rgba(10, 22, 40, .22);
}
.rs-theme-toggle--inline { min-height: 36px; }
@media (min-width: 900px) { .rs-theme-toggle--floating { left: auto; right: 16px; bottom: 80px; } }
@media (max-width: 640px) { .rs-theme-toggle--inline .rs-theme-toggle__label { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .rs-theme-toggle__thumb { transition: none; }
}
@media print { .rs-theme-toggle { display: none; } }

/* ---------- Stabilisation polish (docs/stabilisation-ui.md) ---------- */
/* Floating toggle: respect notch safe areas. */
.rs-theme-toggle { white-space: nowrap; }
.rs-theme-toggle--floating { left: calc(12px + env(safe-area-inset-left, 0px)); }
@media (min-width: 900px) { .rs-theme-toggle--floating { left: auto; right: calc(16px + env(safe-area-inset-right, 0px)); } }

/* Dark-mode contrast fixes found by check-rs-theme-contrast-browser (all < 3:1 before). */
html[data-rs-theme="dark"] { --text-muted: #8a9ab0; }
html[data-rs-theme="dark"] footer p,
html[data-rs-theme="dark"] .crumb { color: #8a9ab0; }
html[data-rs-theme="dark"] .crumb a { color: #a8b5c7; }
html[data-rs-theme="dark"] .cta-btn:not(.alt) { background: var(--rs-orange-strong); color: #fffdf9; }
