/* =============================================================================
   OPENHYBRID BRAND CONSISTENCY
   Programs is the reference for depth, card rhythm and restraint. This final
   stylesheet carries that language through the core loop with a more technical
   palette: midnight navy, gunmetal, cobalt, ice blue and a small burnt-orange
   "today" accent. Green/amber/red remain reserved for real state and feedback.
   Loaded last so component-specific styles consume one final brand decision.
   ============================================================================= */

:root {
  --brand-midnight: #060606;
  --brand-gunmetal: var(--surface-2);
  --brand-raised: var(--surface-3);
  --brand-cobalt: #2563eb;
  --brand-cobalt-strong: #1d4ed8;
  --brand-cobalt-rgb: 37, 99, 235;
  --brand-ice: var(--info);
  --brand-ice-soft: #bfdbfe;
  --brand-steel: var(--text-2);
  --brand-burnt-orange: var(--data-3);
  --brand-gradient: linear-gradient(135deg, var(--brand-cobalt-strong), var(--brand-cobalt));

  --bg-app: var(--bg);
  --bg-card: var(--surface-1);
  --bg-input: var(--brand-gunmetal);
  --bg-input-focus: var(--brand-raised);
  --bg-deep: var(--brand-midnight);
  --color-blue: var(--brand-cobalt);
  --color-indigo: var(--brand-cobalt-strong);
  --color-orange: var(--brand-burnt-orange);
  --accent-blue: var(--brand-cobalt);
  --accent-indigo: var(--brand-cobalt-strong);
}

/* The brand layer loads last, so it re-declares the legacy aliases from the
   semantic tokens. One block covers every dark palette; only the palette's
   semantic values differ, and js/theme/tokens.js mirrors them for canvas. */
html[data-theme="dark"] {
  --brand-midnight: var(--bg);
  --brand-gunmetal: var(--surface-1);
  --brand-raised: var(--surface-3);
  --brand-cobalt: var(--accent);
  --brand-cobalt-strong: var(--accent-pressed);
  --brand-cobalt-rgb: var(--accent-rgb);
  --brand-ice: var(--accent-text);
  --brand-ice-soft: var(--accent-text);
  --brand-steel: var(--text-2);
  --brand-burnt-orange: var(--data-3);
  --brand-gradient: linear-gradient(135deg, var(--accent), var(--accent-pressed));
  --bg-app: var(--bg);
  --bg-card: var(--surface-1);
  --bg-input: var(--surface-3);
  --bg-input-focus: var(--surface-3);
  --bg-deep: var(--bg);
  --color-blue: var(--accent);
  --color-indigo: var(--accent-pressed);
  --color-orange: var(--data-3);
  --accent-blue: var(--accent);
  --accent-indigo: var(--accent-pressed);
}

/* Midnight keeps its pastel-cyan nav ink and the lime "today" accent. */
html[data-theme="dark"][data-palette="midnight"] {
  --brand-ice: #67e8f9;
  --brand-ice-soft: #cffafe;
  --brand-burnt-orange: #a3e635;
  --color-orange: #a3e635;
}

/* Light mode of the same default palette: cobalt has no place in a cyan/teal
   brand, so the brand tokens follow the light semantic accent instead. */
html[data-theme="light"] {
  --brand-midnight: var(--bg);
  --brand-gunmetal: var(--surface-1);
  --brand-raised: var(--surface-3);
  --brand-cobalt: var(--accent);
  --brand-cobalt-strong: var(--accent-pressed);
  --brand-cobalt-rgb: var(--accent-rgb);
  --brand-ice: var(--accent-text);
  --brand-ice-soft: var(--accent-text);
  --brand-steel: var(--text-2);
  --brand-burnt-orange: var(--data-3);
  --brand-gradient: linear-gradient(135deg, var(--accent), var(--accent-pressed));
  --bg-app: var(--bg);
  --bg-card: var(--surface-1);
  --bg-input: var(--surface-3);
  --bg-input-focus: var(--surface-3);
  --bg-deep: var(--surface-2);
  --color-blue: var(--accent);
  --color-indigo: var(--accent-pressed);
  --color-orange: var(--data-3);
  --accent-blue: var(--accent);
  --accent-indigo: var(--accent-pressed);
}

/* Cyan is bright: use dark ink, not white, for the primary CTA and selected
   pills so the icon palette keeps accessible contrast. */
html[data-theme="dark"] #homePrimaryCta.btn-green,
html[data-theme="dark"] #startWorkoutBtn.btn-green,
html[data-theme="dark"] .ob-cta,
html[data-theme="dark"] .day-pill.active,
html[data-theme="dark"] .set-load-choice__btn.active,
html[data-theme="dark"] .an-tab--active,
html[data-theme="dark"] .detail-cta-btn:not(.detail-cta-btn--active):not(.detail-cta-btn--completed) {
  color: var(--on-accent) !important;
  box-shadow: 0 6px 22px color-mix(in srgb, var(--accent) 22%, transparent) !important;
}

body { background-image: none; }
#view-home.active { background-image: var(--bg-image); }

/* One surface vocabulary across Home, Workout, Insights and Profile. Cards use
   the semantic surface/divider/elevation tokens; no per-card tint or glow.

   The base card is BORDERLESS on purpose. Separation comes from the surface
   ladder (card/page is 1.17-1.18:1 in every dark palette, and light mode keeps
   its own step); a 1px hairline competing with body text was doing the job a
   luminance step should do. `--divider` still rules INNER rows, where a
   boundary is genuinely needed. A near-black shadow is invisible on these
   surfaces, so it is not painted either. */
.card-dark,
.glance-card,
.profile-stat-card,
.profile-active-program,
.an-chart,
.an-insights {
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.card-dark:hover {
  background: var(--surface-2);
}

/* Programs-style type hierarchy: compact, sentence-case and confident. */
#view-home h2.section-header,
#view-workout h2.section-header,
#view-profile h2.section-header,
.profile-section-title,
.profile-subsection-title {
  text-transform: none;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

#view-home h2.section-header,
#view-workout h2.section-header,
#view-profile h2.section-header { font-size: 0.88rem; }
.profile-section-title { font-size: 0.8rem; }
.profile-subsection-title { font-size: 0.72rem; color: var(--brand-steel); }

/* Primary brand interaction. Completion and warnings keep semantic colours. */
#homePrimaryCta.btn-green,
#startWorkoutBtn.btn-green,
.ob-cta,
.day-pill.active,
.set-load-choice__btn.active,
.an-tab--active,
.detail-cta-btn:not(.detail-cta-btn--active):not(.detail-cta-btn--completed) {
  background: var(--brand-gradient) !important;
  border-color: transparent !important;
  color: #fff !important;
  box-shadow: 0 6px 22px rgba(var(--brand-cobalt-rgb), 0.28) !important;
}

.bottom-nav {
  background: color-mix(in srgb, var(--surface-1) 95%, transparent) !important;
  border-color: var(--divider) !important;
  box-shadow: var(--elevation-2) !important;
}
.nav-item.active { color: var(--brand-ice-soft) !important; }
.nav-item.active::before { background: rgba(var(--brand-cobalt-rgb), 0.14) !important; }
.nav-item::after { background: var(--brand-cobalt) !important; }

.home-avatar:not(.home-avatar--img),
.profile-avatar-btn,
.profile-hero-avatar {
  background: var(--brand-gradient) !important;
  border-color: rgba(var(--brand-cobalt-rgb), 0.72) !important;
  box-shadow: 0 4px 16px rgba(var(--brand-cobalt-rgb), 0.28) !important;
}
.home-phase-label { color: var(--brand-ice); }
.home-week-progress__fill,
.hs-confidence__fill { background: var(--brand-gradient); }

/* Burnt orange is deliberately rare: it answers "which day is today?" only. */
.day-pill--today:not(.active) { border-color: var(--brand-burnt-orange) !important; }
.day-pill--today::before { background: var(--brand-burnt-orange) !important; }

.cockpit-exercise:not(.collapsed) {
  border-color: rgba(var(--brand-cobalt-rgb), 0.23) !important;
  box-shadow: 0 12px 32px rgba(0,0,0,0.48),
              0 0 0 1px rgba(var(--brand-cobalt-rgb), 0.06) !important;
}
.cockpit-exercise:not(.collapsed) .cockpit-header {
  background: rgba(var(--brand-cobalt-rgb), 0.045) !important;
}

.subview-back-btn,
.week-nav-arrow:not(:disabled) {
  color: var(--brand-ice-soft) !important;
  background: rgba(var(--brand-cobalt-rgb), 0.10) !important;
  border-color: rgba(var(--brand-cobalt-rgb), 0.28) !important;
}

.hs-hero {
  border-radius: 18px;
  border-color: rgba(var(--brand-cobalt-rgb), 0.20);
  box-shadow: 0 12px 38px rgba(0,0,0,0.38);
}
.hs-level {
  color: var(--brand-ice-soft);
  background: rgba(var(--brand-cobalt-rgb), 0.12);
  border: 1px solid rgba(var(--brand-cobalt-rgb), 0.22);
}
.mbrief {
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(16,27,42,0.98), rgba(7,17,31,0.98));
  border-color: color-mix(in srgb, var(--info) 10%, transparent);
}
.mbrief__mission {
  background: rgba(var(--brand-cobalt-rgb), 0.10);
  border-color: rgba(var(--brand-cobalt-rgb), 0.28);
}
.mbrief__mission-k { color: var(--brand-ice); }

input[type="number"]:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  border-color: rgba(var(--brand-cobalt-rgb), 0.58) !important;
  box-shadow: 0 0 0 3px rgba(var(--brand-cobalt-rgb), 0.11);
}

:focus-visible { outline-color: rgba(var(--brand-cobalt-rgb), 0.78); }

/* Program chrome keeps its successful layout but joins the approved palette. */
.plan-row { background: var(--surface-1); }
.prog-card--small .prog-card-info,
.prog-card--large .prog-card-info { background: var(--surface-1); }

html[data-theme="light"] body { background-image: none; }

html[data-theme="light"] .card-dark,
html[data-theme="light"] .profile-stat-card,
html[data-theme="light"] .profile-active-program,
html[data-theme="light"] .an-chart,
html[data-theme="light"] .an-insights {
  background: var(--surface-1);
  border-color: var(--divider);
  box-shadow: var(--elevation-1);
}

html[data-theme="light"] .bottom-nav {
  background: color-mix(in srgb, var(--surface-1) 96%, transparent) !important;
  border-color: rgba(var(--brand-cobalt-rgb), 0.30) !important;
  box-shadow: 0 10px 36px rgba(var(--brand-cobalt-rgb), 0.12) !important;
}

html[data-theme="light"] .nav-item.active { color: var(--brand-cobalt-strong) !important; }
html[data-theme="light"] .mbrief { background: linear-gradient(160deg, #ffffff, #f4f7fb); }

@media (prefers-reduced-motion: reduce) {
  .card-dark,
  .cockpit-exercise,
  .day-pill { transition: none !important; }
}
