/**
 * HAVLO CANONICAL VISUAL SYSTEM
 * Derived from 35 Stitch design references.
 * This file is the single source of truth for all visual appearance in Havlo.
 * The composition engine, Go templates, and islands all reference these tokens.
 *
 * DO NOT override these values in page-specific CSS.
 * DO NOT introduce colors not defined here.
 * DO NOT use hardcoded hex values anywhere in templates — use these variables.
 *
 * File: web/static/css/havlo-canonical.css
 * Load order: first, before all other CSS
 */

/* ============================================================
   SECTION 1: COLOR TOKENS
   Extracted from 35 Stitch designs — 100% consistent across all.
   ============================================================ */

:root {

  /* --- Core Brand --- */
  --hv-primary:              #002046;
  --hv-primary-container:    #1b365d;
  --hv-primary-fixed:        #d6e3ff;
  --hv-primary-fixed-dim:    #aec7f7;
  --hv-on-primary:           #ffffff;
  --hv-on-primary-container: #87a0cd;
  --hv-on-primary-fixed:     #001b3d;

  /* --- Secondary / Slate --- */
  --hv-secondary:            #505f76;
  --hv-secondary-container:  #d0e1fb;
  --hv-secondary-fixed:      #d3e4fe;
  --hv-secondary-fixed-dim:  #b7c8e1;
  --hv-on-secondary:         #ffffff;
  --hv-on-secondary-container: #54647a;
  --hv-on-secondary-fixed:   #0b1c30;

  /* --- Teal / Tertiary (Care & Automation signals) --- */
  --hv-tertiary:             #002522;
  --hv-tertiary-container:   #003d37;
  --hv-tertiary-fixed:       #89f5e7;
  --hv-tertiary-fixed-dim:   #6bd8cb;
  --hv-on-tertiary:          #ffffff;
  --hv-on-tertiary-fixed:    #00201d;
  --hv-on-tertiary-container: #3cafa2;

  /* --- Surface / Background Hierarchy --- */
  --hv-background:                  #fcf9f4;
  --hv-surface:                     #fcf9f4;
  --hv-surface-bright:              #fcf9f4;
  --hv-surface-dim:                 #dcdad5;
  --hv-surface-container-lowest:    #ffffff;
  --hv-surface-container-low:       #f6f3ee;
  --hv-surface-container:           #f0ede9;
  --hv-surface-container-high:      #ebe8e3;
  --hv-surface-container-highest:   #e5e2dd;
  --hv-surface-variant:             #e5e2dd;
  --hv-on-surface:                  #1c1c19;
  --hv-on-surface-variant:          #44474e;
  --hv-inverse-surface:             #31302d;
  --hv-inverse-on-surface:          #f3f0eb;

  /* --- Outline / Border --- */
  --hv-outline:         #74777f;
  --hv-outline-variant: #c4c6cf;

  /* --- Error / Human Required --- */
  --hv-error:              #ba1a1a;
  --hv-error-container:    #ffdad6;
  --hv-on-error:           #ffffff;
  --hv-on-error-container: #93000a;

  /* --- Inverse Primary --- */
  --hv-inverse-primary: #aec7f7;

  /* --- Surface Tint --- */
  --hv-surface-tint: #465f88;

  /* ============================================================
     SECTION 2: SEMANTIC ALIASES
     ============================================================ */

  --hv-auto-bg:       var(--hv-tertiary-fixed);
  --hv-auto-text:     var(--hv-on-tertiary-fixed);
  --hv-assisted-bg:   var(--hv-secondary-fixed);
  --hv-assisted-text: var(--hv-on-secondary-fixed);
  --hv-human-bg:      var(--hv-error-container);
  --hv-human-text:    var(--hv-on-error-container);

  --hv-page-bg:       var(--hv-background);
  --hv-card-bg:       var(--hv-surface-container-lowest);
  --hv-surface-panel-bg:      var(--hv-surface-container-low);
  --hv-grouped-bg:    var(--hv-surface-container-high);

  --hv-text-primary:   var(--hv-on-surface);
  --hv-text-secondary: var(--hv-secondary);
  --hv-text-headline:  var(--hv-primary);
  --hv-text-on-dark:   var(--hv-on-primary);
  --hv-text-muted:     var(--hv-on-primary-container);

  --hv-border:        var(--hv-outline-variant);
  --hv-border-subtle: rgba(196, 198, 207, 0.2);

  /* ============================================================
     SECTION 3: TYPOGRAPHY
     ============================================================ */

  --hv-font-display: 'Instrument Sans', 'Inter', system-ui, sans-serif;
  --hv-font-body:    'Instrument Sans', 'Inter', sans-serif;
  --hv-display-tracking: -0.052em;
  --hv-display-word-spacing: 0.025em;

  --hv-text-xs:   0.625rem;
  --hv-text-sm:   0.75rem;
  --hv-text-base: 0.875rem;
  --hv-text-md:   1rem;
  --hv-text-lg:   1.125rem;
  --hv-text-xl:   1.25rem;
  --hv-text-2xl:  1.5rem;
  --hv-text-3xl:  2rem;
  --hv-text-4xl:  2.5rem;
  --hv-text-hero: 3.5rem;

  /* ============================================================
     SECTION 4: SPACING
     ============================================================ */

  --hv-space-1:  0.25rem;
  --hv-space-2:  0.5rem;
  --hv-space-3:  0.75rem;
  --hv-space-4:  1rem;
  --hv-space-5:  1.25rem;
  --hv-space-6:  1.5rem;
  --hv-space-8:  2rem;
  --hv-space-10: 2.5rem;
  --hv-space-12: 3rem;
  --hv-space-16: 4rem;
  --hv-space-24: 6rem;

  /* ============================================================
     SECTION 5: ELEVATION
     ============================================================ */

  --hv-shadow-card:    0 4px 20px rgba(28, 28, 25, 0.06);
  --hv-shadow-raised:  0 20px 40px rgba(28, 28, 25, 0.06);
  --hv-shadow-nav:     0 20px 40px rgba(28, 28, 25, 0.06);
  --hv-shadow-fab:     0 8px 24px rgba(0, 32, 70, 0.3);
  --hv-shadow-modal:   0 24px 48px rgba(28, 28, 25, 0.12);

  /* ============================================================
     SECTION 6: BORDER RADIUS
     ============================================================ */

  --hv-radius-sm:   0.25rem;
  --hv-radius-md:   0.375rem;
  --hv-radius-lg:   0.75rem;
  --hv-radius-xl:   1rem;
  --hv-radius-full: 9999px;
}

/* ============================================================
   SECTION 7: COMPONENT CLASSES
   ============================================================ */

body {
  font-family: var(--hv-font-body);
  background: var(--hv-page-bg);
  color: var(--hv-text-primary);
  -webkit-font-smoothing: antialiased;
}

.hv-font-display { font-family: var(--hv-font-display); }

/* --- TYPOGRAPHY --- */
.hv-display {
  font-family: var(--hv-font-display);
  font-size: var(--hv-text-hero);
  font-weight: 900;
  color: var(--hv-text-headline);
  line-height: 1;
  letter-spacing: -0.02em;
}

.hv-display--on-dark {
  font-family: var(--hv-font-display);
  font-size: var(--hv-text-hero);
  font-weight: 900;
  color: var(--hv-text-on-dark);
  line-height: 1;
  letter-spacing: -0.02em;
}

.hv-headline {
  font-family: var(--hv-font-display);
  font-size: var(--hv-text-4xl);
  font-weight: 700;
  color: var(--hv-text-headline);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.hv-title {
  font-family: var(--hv-font-display);
  font-size: var(--hv-text-2xl);
  font-weight: 700;
  color: var(--hv-text-headline);
}

.hv-label {
  font-family: var(--hv-font-body);
  font-size: var(--hv-text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hv-body {
  font-size: var(--hv-text-base);
  color: var(--hv-text-secondary);
  line-height: 1.6;
}

.hv-body-lg {
  font-size: var(--hv-text-md);
  color: var(--hv-text-secondary);
  line-height: 1.6;
  max-width: 42rem;
}

/* --- LAYOUT --- */
.hv-container {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 var(--hv-space-8);
}

.hv-grid-12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--hv-space-8);
}

.hv-col-8  { grid-column: span 8; }
.hv-col-4  { grid-column: span 4; }
.hv-col-6  { grid-column: span 6; }
.hv-col-12 { grid-column: span 12; }

/* --- SECTIONS --- */
.hv-section {
  background: var(--hv-page-bg);
  padding: var(--hv-space-16) 0;
}

.hv-section--subtle {
  background: var(--hv-surface-container-low);
  padding: var(--hv-space-16) 0;
}

.hv-section--dark {
  background: linear-gradient(135deg, var(--hv-primary) 0%, var(--hv-primary-container) 100%);
  padding: var(--hv-space-24) 0;
  color: var(--hv-text-on-dark);
}

.hv-hero {
  background: linear-gradient(135deg, var(--hv-primary) 0%, var(--hv-primary-container) 100%);
  padding: var(--hv-space-24) 0;
  color: var(--hv-text-on-dark);
  position: relative;
  overflow: hidden;
}

/* --- CARDS --- */
.hv-card {
  background: var(--hv-card-bg);
  border-radius: var(--hv-radius-lg);
  box-shadow: var(--hv-shadow-card);
  padding: var(--hv-space-6);
}

.hv-card--raised {
  background: var(--hv-card-bg);
  border-radius: var(--hv-radius-lg);
  box-shadow: var(--hv-shadow-raised);
  padding: var(--hv-space-8);
}

.hv-card--dark {
  background: var(--hv-primary);
  border-radius: var(--hv-radius-lg);
  box-shadow: 0 10px 30px rgba(0, 32, 70, 0.2);
  padding: var(--hv-space-8);
  color: var(--hv-text-on-dark);
  position: relative;
  overflow: hidden;
}

.hv-card--accent-teal  { border-left: 4px solid var(--hv-tertiary-fixed-dim); }
.hv-card--accent-red   { border-left: 4px solid var(--hv-error); }
.hv-card--accent-blue  { border-left: 4px solid var(--hv-secondary-fixed); }

.hv-surface.hv-surface--panel {
  background: var(--hv-surface-panel-bg);
  border-radius: var(--hv-radius-lg);
  padding: var(--hv-space-6);
}

.hv-grouped {
  background: var(--hv-grouped-bg);
  border-radius: var(--hv-radius-lg);
  padding: var(--hv-space-1);
  display: flex;
  flex-direction: column;
  gap: var(--hv-space-1);
}

/* --- AUTOMATION PILLS --- */
.hv-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--hv-radius-sm);
  font-size: var(--hv-text-xs);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.hv-pill--auto     { background: var(--hv-auto-bg);     color: var(--hv-auto-text); }
.hv-pill--assisted { background: var(--hv-assisted-bg); color: var(--hv-assisted-text); }
.hv-pill--human    { background: var(--hv-human-bg);    color: var(--hv-human-text); }
.hv-pill--round    { border-radius: var(--hv-radius-full); padding: 4px 12px; }

/* --- DOT INDICATORS --- */
.hv-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.hv-dot--auto     { background: var(--hv-tertiary-fixed); }
.hv-dot--assisted { background: var(--hv-secondary-fixed-dim); }
.hv-dot--human    { background: var(--hv-error); }
.hv-dot--pulse    { animation: hv-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

@keyframes hv-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- BUTTONS --- */
.hv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--hv-font-display);
  font-weight: 600;
  border-radius: var(--hv-radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.hv-btn--primary {
  background: var(--hv-primary);
  color: var(--hv-on-primary);
  padding: var(--hv-space-3) var(--hv-space-6);
  font-size: var(--hv-text-base);
}
.hv-btn--primary:hover { opacity: 0.9; transform: scale(0.98); }

.hv-btn--primary-lg {
  background: var(--hv-primary);
  color: var(--hv-on-primary);
  padding: var(--hv-space-4) var(--hv-space-8);
  font-size: var(--hv-text-base);
  font-weight: 700;
}
.hv-btn--primary-lg:hover { opacity: 0.9; box-shadow: var(--hv-shadow-raised); }

.hv-btn--secondary {
  background: transparent;
  color: var(--hv-primary);
  padding: var(--hv-space-3) var(--hv-space-6);
  font-size: var(--hv-text-base);
  border: 1.5px solid var(--hv-primary);
}
.hv-btn--secondary:hover { background: var(--hv-surface-container-low); }

.hv-btn--sm {
  padding: var(--hv-space-2) var(--hv-space-4);
  font-size: var(--hv-text-sm);
  font-weight: 700;
}

.hv-btn--ghost {
  background: transparent;
  color: var(--hv-secondary);
  padding: var(--hv-space-2) var(--hv-space-3);
  font-size: var(--hv-text-sm);
}
.hv-btn--ghost:hover { color: var(--hv-primary); }

.hv-fab {
  position: fixed;
  bottom: var(--hv-space-8);
  right: var(--hv-space-8);
  width: 3.5rem;
  height: 3.5rem;
  background: var(--hv-primary);
  color: var(--hv-on-primary);
  border-radius: 50%;
  box-shadow: var(--hv-shadow-fab);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: none;
  cursor: pointer;
  z-index: 50;
  transition: transform 0.2s ease;
}
.hv-fab:hover { transform: scale(1.05); }

/* --- PROGRESS BARS --- */
.hv-progress {
  height: 6px;
  background: var(--hv-surface-container);
  border-radius: var(--hv-radius-full);
  overflow: hidden;
}

.hv-progress__fill {
  height: 100%;
  border-radius: var(--hv-radius-full);
  background: var(--hv-tertiary-fixed-dim);
  transition: width 0.4s ease;
}
.hv-progress__fill--error { background: var(--hv-error); }

/* --- NAV --- */
.hv-nav {
  background: rgba(252, 249, 244, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--hv-shadow-nav);
}

.hv-nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--hv-space-3) var(--hv-space-8);
  max-width: 80rem;
  margin: 0 auto;
}

/* --- SIDEBAR (admin) --- */
.hv-sidebar {
  background: var(--hv-surface-container-low);
  width: 16rem;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: var(--hv-space-4);
  gap: var(--hv-space-2);
  z-index: 50;
}

.hv-sidebar__nav-item {
  display: flex;
  align-items: center;
  gap: var(--hv-space-3);
  padding: var(--hv-space-2) var(--hv-space-3);
  border-radius: var(--hv-radius-md);
  font-family: var(--hv-font-display);
  font-size: var(--hv-text-base);
  font-weight: 500;
  color: var(--hv-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
}
.hv-sidebar__nav-item:hover { background: var(--hv-surface-container-highest); }
.hv-sidebar__nav-item--active {
  background: var(--hv-card-bg);
  color: var(--hv-primary);
  font-weight: 700;
  box-shadow: var(--hv-shadow-card);
}

/* --- AUTOMATION STATUS BADGE --- */
.hv-automation-status {
  background: var(--hv-tertiary-fixed);
  border-radius: var(--hv-radius-xl);
  padding: var(--hv-space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hv-automation-status__label {
  font-size: var(--hv-text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hv-on-tertiary-fixed);
}

/* --- ICONS --- */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  line-height: 1;
}
.hv-icon--filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ============================================================
   SECTION 8: COMPOSITION ENGINE COMPONENT CLASSES
   ============================================================ */

.hv-module-hero {
  background: linear-gradient(135deg, var(--hv-primary) 0%, var(--hv-primary-container) 100%);
  padding: var(--hv-space-24) 0;
  color: var(--hv-text-on-dark);
  position: relative;
  overflow: hidden;
}

.hv-module-hero__eyebrow {
  font-size: var(--hv-text-xs);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--hv-on-primary-container);
  margin-bottom: var(--hv-space-4);
  display: block;
}

.hv-module-hero__title {
  font-family: var(--hv-font-display);
  font-size: var(--hv-text-hero);
  font-weight: 900;
  color: var(--hv-text-on-dark);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: var(--hv-space-4);
}

.hv-module-hero__body {
  font-size: var(--hv-text-md);
  color: var(--hv-on-primary-container);
  line-height: 1.6;
  max-width: 36rem;
  margin-bottom: var(--hv-space-8);
}

.hv-module-proof-strip {
  background: var(--hv-surface-container-low);
  padding: var(--hv-space-6) 0;
  border-top: 1px solid var(--hv-border-subtle);
  border-bottom: 1px solid var(--hv-border-subtle);
}

.hv-module-feature-grid {
  padding: var(--hv-space-16) 0;
  background: var(--hv-page-bg);
}

.hv-module-feature-grid__card {
  background: var(--hv-card-bg);
  border-radius: var(--hv-radius-lg);
  box-shadow: var(--hv-shadow-raised);
  padding: var(--hv-space-8);
}

.hv-module-metric {
  background: var(--hv-card-bg);
  border-radius: var(--hv-radius-lg);
  box-shadow: var(--hv-shadow-card);
  padding: var(--hv-space-6);
}

.hv-module-metric__value {
  font-family: var(--hv-font-display);
  font-size: var(--hv-text-4xl);
  font-weight: 700;
  color: var(--hv-text-headline);
}

.hv-module-cta {
  background: var(--hv-surface-container-low);
  padding: var(--hv-space-16) 0;
  text-align: center;
}

.hv-module-timeline {
  padding: var(--hv-space-16) 0;
}

.hv-module-timeline__step {
  display: flex;
  gap: var(--hv-space-6);
  position: relative;
}

.hv-module-decision {
  background: var(--hv-card-bg);
  border-radius: var(--hv-radius-lg);
  padding: var(--hv-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--hv-space-2);
}

/* ============================================================
   SECTION 9: UTILITIES
   ============================================================ */

.hv-text-eyebrow {
  font-size: var(--hv-text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hv-text-secondary);
}

.hv-divider {
  border: none;
  border-top: 1px solid var(--hv-border-subtle);
  margin: var(--hv-space-6) 0;
}

.hv-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- ISLAND MOUNT POINTS --- */
.hv-market-strip-mount {
  background: var(--hv-surface-container-low);
  border-top: 1px solid var(--hv-border-subtle);
  border-bottom: 1px solid var(--hv-border-subtle);
}
