/* 
  CIVIC DESIGN LANGUAGE (CDL)
  Core styling system for Civitas One.
  Inspired by GOV.UK (clarity), Estonia (digital innovation), Apple (simplicity), 
  Monocle (editorial restraint), and Google Maps (wayfinding clarity).
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Lora:ital,wght@0,400;0,500;0,600;1,400&display=swap');

/* --- DESIGN SYSTEM TOKENS --- */
:root {
  /* Color System */
  --bg-primary: #FAF9F6;         /* Soft White */
  --bg-secondary: #F2F0EA;       /* Light Stone */
  --bg-surface: #FFFFFF;         /* Cloud White */
  --text-primary: #1A222E;       /* Deep Slate (never pure black) */
  --text-secondary: #5C646E;     /* Warm Gray */
  --accent-primary: #0F4C81;     /* Civic Blue (represents trust) */
  --accent-secondary: #1E4620;   /* Forest Green (represents public service) */
  
  /* Status Colors */
  --status-success: #10B981;     /* Emerald */
  --status-warning: #F59E0B;     /* Amber */
  --status-error: #B91C1C;       /* Brick Red */

  /* Borders & Dividers */
  --border-color: #E2DFD8;       /* Hairline divider, warm gray */
  --border-focus: #0F4C81;
  --border-width: 1px;

  /* Typography Scale */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Lora', Georgia, serif;

  --fs-xs: 0.75rem;     /* 12px */
  --fs-sm: 0.875rem;    /* 14px */
  --fs-base: 1rem;      /* 16px */
  --fs-lg: 1.125rem;    /* 18px */
  --fs-xl: 1.25rem;     /* 20px */
  --fs-2xl: 1.5rem;     /* 24px */
  --fs-3xl: 1.875rem;   /* 30px */
  --fs-4xl: 2.25rem;    /* 36px */
  --fs-5xl: 3rem;       /* 48px */
  --fs-6xl: 3.75rem;    /* 60px */

  --lh-tight: 1.2;
  --lh-snug: 1.35;
  --lh-base: 1.5;
  --lh-relaxed: 1.625;

  /* Spacing Scale (Base unit 8px) */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
  --space-6: 64px;
  --space-7: 96px;
  --space-8: 128px;
  --space-9: 192px;
  --space-10: 256px;
  --space-11: 384px;

  /* Corner Radius */
  --radius-btn: 10px;
  --radius-card: 14px;
  --radius-dialog: 18px;
  --radius-input: 10px;

  /* Shadows (Ambient, soft elevation) */
  --shadow-sm: 0 1px 3px rgba(26, 34, 46, 0.05);
  --shadow-md: 0 4px 12px rgba(26, 34, 46, 0.05);
  --shadow-lg: 0 8px 24px rgba(26, 34, 46, 0.06);

  /* Animation Timings */
  --t-micro: 200ms;
  --t-standard: 350ms;
  --t-major: 650ms;
}

/* --- ACCESSIBILITY OVERRIDES --- */
/* High Contrast Mode */
body.high-contrast {
  --bg-primary: #FFFFFF;
  --bg-secondary: #F0F0F0;
  --bg-surface: #FFFFFF;
  --text-primary: #000000;
  --text-secondary: #222222;
  --accent-primary: #0000FF;
  --accent-secondary: #006600;
  --border-color: #000000;
  --border-width: 2px;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
}

/* Large Font Mode */
body.large-text {
  font-size: 1.25rem; /* Scales base size to 20px */
  --fs-xs: 0.95rem;
  --fs-sm: 1.1rem;
  --fs-base: 1.25rem;
  --fs-lg: 1.35rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.1rem;
  --fs-4xl: 2.5rem;
  --fs-5xl: 3.25rem;
  --fs-6xl: 4.25rem;
}

/* Reduced Motion Mode */
body.reduced-motion *,
body.reduced-motion *:before,
body.reduced-motion *:after {
  animation-duration: 0s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0s !important;
  scroll-behavior: auto !important;
}

/* --- RESET & BASIC STYLES --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: var(--lh-base);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--t-standard), color var(--t-standard);
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--t-micro);
}

a:hover {
  text-decoration: underline;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

img {
  max-width: 100%;
  height: auto;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: var(--lh-tight);
}

.serif-text {
  font-family: var(--font-serif);
}

/* --- GRID & LAYOUT --- */
.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

@media (max-width: 1024px) {
  .container {
    padding: 0 var(--space-3);
  }
}

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

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

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

/* Responsive grid helper classes */
.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }

@media (max-width: 900px) {
  .col-8, .col-6, .col-4, .col-3 {
    grid-column: span 12;
  }
}

/* --- LOADING EXPERIENCE --- */
#loading-screen {
  position: fixed;
  inset: 0;
  background-color: #FAF9F6; /* Always soft white initially */
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity var(--t-major) ease;
}

.loading-line-container {
  width: 280px;
  height: 2px;
  background-color: var(--border-color);
  overflow: hidden;
  margin-bottom: var(--space-3);
  position: relative;
}

.loading-line {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background-color: var(--accent-primary);
  animation: drawLine 2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.loading-logo {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-2xl);
  letter-spacing: -0.02em;
  opacity: 0;
  color: var(--text-primary);
  animation: fadeInLogo 1s ease 1s forwards;
}

@keyframes drawLine {
  to { width: 100%; }
}

@keyframes fadeInLogo {
  to { opacity: 1; }
}

/* Natural Daylight Illumination Effect */
.daylight-bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.8) 0%, rgba(250, 249, 246, 0) 80%);
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity var(--t-major) cubic-bezier(0.16, 1, 0.3, 1);
}

.daylight-bg.active {
  opacity: 1;
}

/* --- UNIVERSAL HEADER --- */
header.universal-header {
  border-bottom: var(--border-width) solid var(--border-color);
  background-color: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color var(--t-standard), border-color var(--t-standard);
}

.header-container {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.logo-icon {
  width: 24px;
  height: 24px;
  background-color: var(--accent-primary);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-surface);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.logo-text {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav-link {
  color: var(--text-primary);
  font-weight: 500;
  font-size: var(--fs-sm);
  padding: var(--space-1) var(--space-2);
  border-radius: 6px;
  transition: background-color var(--t-micro);
}

.nav-link:hover {
  background-color: var(--bg-secondary);
  text-decoration: none;
}

/* Universal Search Control */
.search-container {
  position: relative;
  width: 260px;
}

@media (max-width: 768px) {
  .search-container {
    display: none; /* Hide or collapse on mobile header */
  }
}

.search-input {
  width: 100%;
  padding: var(--space-1) var(--space-2) var(--space-1) 36px;
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-input);
  background-color: var(--bg-secondary);
  font-size: var(--fs-sm);
  transition: background-color var(--t-micro), border-color var(--t-micro);
}

.search-input:focus {
  background-color: var(--bg-surface);
  border-color: var(--border-focus);
  outline: none;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
  font-size: var(--fs-sm);
}

/* Accessibility & Language Selectors */
.controls-group {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.btn-icon-dropdown {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: var(--space-1) var(--space-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-surface);
  transition: all var(--t-micro);
}

.btn-icon-dropdown:hover {
  background-color: var(--bg-secondary);
}

/* Dropdown Menu */
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background-color: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-dialog);
  padding: var(--space-2);
  width: 260px;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
}

.dropdown-menu.active {
  display: flex;
}

.dropdown-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dropdown-section-title {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}

.dropdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Toggle Switch Styling */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-secondary);
  transition: .4s;
  border-radius: 24px;
  border: 1px solid var(--border-color);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: var(--bg-surface);
}

.font-size-controls {
  display: flex;
  gap: 4px;
}

.btn-size-toggle {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: var(--fs-xs);
  cursor: pointer;
}

.btn-size-toggle.active {
  background-color: var(--accent-primary);
  color: var(--bg-surface);
  border-color: var(--accent-primary);
}

/* --- HERO EXPERIENCE --- */
.hero-section {
  position: relative;
  background-color: var(--bg-surface);
  padding: var(--space-6) 0 var(--space-8) 0;
  border-bottom: var(--border-width) solid var(--border-color);
  overflow: hidden;
  transition: background-color var(--t-standard), border-color var(--t-standard);
  z-index: 2;
}

.hero-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--space-5);
  align-items: center;
}

@media (max-width: 992px) {
  .hero-layout {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}

.hero-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.hero-tag {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-primary);
  font-weight: 700;
}

.hero-title {
  font-size: var(--fs-5xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: var(--lh-tight);
}

.hero-subtext {
  font-size: var(--fs-lg);
  color: var(--text-secondary);
  max-width: 580px;
  line-height: var(--lh-relaxed);
}

.hero-ctas {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

@media (max-width: 576px) {
  .hero-ctas {
    flex-direction: column;
  }
}

/* Button UI Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-weight: 500;
  font-size: var(--fs-sm);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: all var(--t-micro) ease;
  border: var(--border-width) solid transparent;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: var(--bg-surface);
}

.btn-primary:hover {
  background-color: #0b375d;
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-secondary);
}

.btn-text {
  background: none;
  color: var(--text-secondary);
  padding: 12px 16px;
}

.btn-text:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

/* Hero Photographic Carousel (Simulated CSS Illustrations) */
.hero-visual {
  position: relative;
  height: 380px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-card);
  overflow: hidden;
  border: var(--border-width) solid var(--border-color);
}

.visual-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  transition: opacity var(--t-standard) ease-in-out;
}

.visual-slide.active {
  opacity: 1;
}

/* Premium CSS-based Visual Scenes */
.scene {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 10px;
  overflow: hidden;
}

.scene-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(26,34,46,0) 30%, rgba(26,34,46,0.85) 100%);
  z-index: 2;
}

.scene-img-sim {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: transform 10s ease;
}

.visual-slide.active .scene-img-sim {
  transform: scale(1.05);
}

.scene-caption {
  position: relative;
  z-index: 3;
  color: #FFFFFF;
  padding: var(--space-3);
}

.scene-caption h4 {
  font-size: var(--fs-md);
  margin-bottom: 4px;
}

.scene-caption p {
  font-size: var(--fs-xs);
  opacity: 0.85;
}

/* Carousel Indicators */
.carousel-indicators {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10;
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.4);
  border: none;
  cursor: pointer;
  padding: 0;
}

.indicator-dot.active {
  background-color: #FFFFFF;
  width: 18px;
  border-radius: 8px;
  transition: all var(--t-micro);
}

/* --- FIRST SCROLL (QUICK GATEWAY) --- */
.quick-gateway {
  padding: var(--space-5) 0;
  background-color: var(--bg-primary);
  border-bottom: var(--border-width) solid var(--border-color);
}

.gateway-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.gateway-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background-color: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-card);
  flex: 1 1 200px;
  cursor: pointer;
  transition: all var(--t-micro) ease;
}

.gateway-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.gateway-item .icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background-color: var(--bg-secondary);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-lg);
  flex-shrink: 0;
}

.gateway-item-text h3 {
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: 2px;
}

.gateway-item-text p {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

/* --- INTRO SECTION --- */
.intro-section {
  padding: var(--space-5) 0;
  background-color: var(--bg-surface);
  border-bottom: var(--border-width) solid var(--border-color);
}

.intro-container {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.intro-text {
  font-family: var(--font-serif);
  font-size: var(--fs-2xl);
  color: var(--text-primary);
  line-height: var(--lh-relaxed);
  font-style: italic;
}

/* --- LIFE EVENTS INTERACTIVE CHECKSURVEY --- */
.life-events-section {
  padding: var(--space-6) 0;
  background-color: var(--bg-secondary);
  border-bottom: var(--border-width) solid var(--border-color);
}

.section-header {
  margin-bottom: var(--space-4);
  max-width: 600px;
}

.section-title {
  font-size: var(--fs-3xl);
  margin-bottom: 8px;
  color: var(--text-primary);
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: var(--fs-base);
}

.life-events-picker {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  padding: 4px 4px 12px 4px;
  margin-bottom: var(--space-3);
  scrollbar-width: thin;
}

.life-events-picker::-webkit-scrollbar {
  height: 6px;
}

.life-events-picker::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 3px;
}

.picker-tab {
  flex: 0 0 auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--t-micro) ease;
  min-height: 44px;
  box-shadow: var(--shadow-sm);
}

.picker-tab:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.picker-tab.active {
  background-color: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
  box-shadow: 0 4px 12px rgba(15, 98, 254, 0.25);
}

.life-events-details {
  background-color: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-dialog);
  padding: var(--space-4);
  box-shadow: var(--shadow-md);
  transition: all var(--t-standard) ease;
}

.checklist-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

@media (max-width: 768px) {
  .checklist-container {
    grid-template-columns: 1fr;
  }
}

.checklist-column h4 {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  background-color: var(--bg-primary);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--t-micro);
  margin-bottom: 8px;
}

.checklist-item:hover {
  background-color: var(--bg-surface);
  border-color: var(--accent-primary);
}

.checklist-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
  margin-top: 2px;
}

.checklist-item-text {
  display: flex;
  flex-direction: column;
}

.checklist-item-title {
  font-size: var(--fs-sm);
  font-weight: 600;
}

.checklist-item-desc {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

/* --- SERVICES CATEGORY DIRECTORY --- */
.services-directory {
  padding: var(--space-6) 0;
  background-color: var(--bg-surface);
  border-bottom: var(--border-width) solid var(--border-color);
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
}

.service-card {
  background-color: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-card);
  padding: var(--space-3);
  transition: all var(--t-micro) ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.service-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.service-card-top h3 {
  font-size: var(--fs-md);
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.service-card-top p {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.service-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.meta-pill {
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: 12px;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
}

.meta-pill.accent {
  background-color: rgba(15, 76, 129, 0.1);
  color: var(--accent-primary);
}

/* --- DETAILED SERVICE MODAL / DETAIL VIEW --- */
.service-details-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(26, 34, 46, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-3);
}

.service-details-overlay.active {
  display: flex;
}

.service-details-modal {
  background-color: var(--bg-surface);
  border-radius: var(--radius-dialog);
  border: var(--border-width) solid var(--border-color);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn var(--t-standard) cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-width) solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background-color: var(--bg-surface);
  z-index: 10;
}

.modal-body {
  padding: var(--space-4);
}

.close-btn {
  background: none;
  border: none;
  font-size: var(--fs-2xl);
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-primary);
}

.service-detail-section {
  margin-bottom: var(--space-3);
}

.service-detail-section h4 {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.service-step-list {
  list-style: none;
}

.service-step-item {
  display: flex;
  gap: 16px;
  margin-bottom: var(--space-2);
  position: relative;
}

.service-step-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 12px;
  top: 24px;
  bottom: -16px;
  width: 2px;
  background-color: var(--border-color);
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  color: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  flex-shrink: 0;
}

.step-content-text h5 {
  font-size: var(--fs-base);
  margin-bottom: 2px;
}

.step-content-text p {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

/* --- CITIZEN DASHBOARD (LOGGED IN STATE) --- */
.dashboard-section {
  padding: var(--space-5) 0;
  display: none; /* Controlled by routing */
}

.dashboard-section.active {
  display: block;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-2);
}

.citizen-profile-summary {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--fs-lg);
  border: var(--border-width) solid var(--border-color);
}

.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-nav-btn {
  background: none;
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius-btn);
  text-align: left;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all var(--t-micro);
  width: 100%;
}

.sidebar-nav-btn.active {
  background-color: var(--accent-primary);
  color: var(--bg-surface);
}

.sidebar-nav-btn:not(.active):hover {
  background-color: var(--bg-secondary);
}

/* Application Tracking Timeline */
.timeline-card {
  background-color: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-card);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  align-items: center;
}

.timeline-tracker {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin: var(--space-3) 0 var(--space-1) 0;
}

.timeline-tracker::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--border-color);
  z-index: 1;
}

.timeline-progress-bar {
  position: absolute;
  top: 10px;
  left: 0;
  height: 2px;
  background-color: var(--status-success);
  z-index: 1;
  transition: width var(--t-major) ease;
}

.timeline-step {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 25%;
}

.timeline-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-secondary);
  transition: all var(--t-micro);
}

.timeline-step.completed .timeline-dot {
  background-color: var(--status-success);
  border-color: var(--status-success);
  color: #FFFFFF;
}

.timeline-step.active .timeline-dot {
  background-color: var(--bg-surface);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(15, 76, 129, 0.15);
}

.timeline-label {
  font-size: var(--fs-xs);
  font-weight: 500;
  margin-top: 8px;
  color: var(--text-secondary);
  text-align: center;
}

.timeline-step.active .timeline-label {
  color: var(--accent-primary);
  font-weight: 600;
}

/* Document Wallet Cards */
.document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-3);
}

.document-wallet-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: var(--space-3);
  position: relative;
  overflow: hidden;
  transition: all var(--t-micro);
  border-top: 4px solid var(--accent-primary);
}

.document-wallet-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.doc-status-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
}

.doc-status-badge.verified {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--status-success);
}

.doc-status-badge.expiring {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--status-warning);
}

.document-wallet-card h4 {
  font-size: var(--fs-base);
  margin-bottom: var(--space-1);
  margin-right: 70px;
}

.document-wallet-card p.doc-number {
  font-family: monospace;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.doc-meta {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-1);
  margin-top: var(--space-1);
}

.doc-actions {
  display: flex;
  gap: 12px;
  margin-top: var(--space-2);
}

.doc-action-link {
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
}

/* --- TAX & PAYMENTS SIMULATOR --- */
.tax-container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-3);
}

@media (max-width: 768px) {
  .tax-container {
    grid-template-columns: 1fr;
  }
}

.tax-card {
  background-color: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-card);
  padding: var(--space-3);
}

.tax-summary-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding: var(--space-1) 0;
}

/* --- HELP CENTER & SIMULATED CHAT ASSISTANT --- */
.help-section {
  padding: var(--space-6) 0;
  background-color: var(--bg-primary);
  border-bottom: var(--border-width) solid var(--border-color);
}

.help-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--space-4);
}

@media (max-width: 900px) {
  .help-grid {
    grid-template-columns: 1fr;
  }
}

.chat-assistant-card {
  background-color: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-dialog);
  display: flex;
  flex-direction: column;
  height: 480px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.chat-header {
  background-color: var(--accent-primary);
  color: var(--bg-surface);
  padding: var(--space-2) var(--space-3);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.chat-messages {
  flex-grow: 1;
  padding: var(--space-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.chat-message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius-card);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
}

.chat-message.assistant {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.chat-message.user {
  background-color: var(--accent-primary);
  color: #FFFFFF;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: var(--space-1) var(--space-3);
}

.chat-option-btn {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  padding: 6px 12px;
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: all var(--t-micro);
}

.chat-option-btn:hover {
  background-color: var(--accent-primary);
  color: var(--bg-surface);
  border-color: var(--accent-primary);
}

.chat-input-area {
  border-top: var(--border-width) solid var(--border-color);
  padding: var(--space-2);
  display: flex;
  gap: 8px;
}

.chat-input {
  flex-grow: 1;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-input);
  padding: var(--space-1) var(--space-2);
  font-size: var(--fs-sm);
  background-color: var(--bg-secondary);
}

.chat-input:focus {
  background-color: var(--bg-surface);
  outline: none;
  border-color: var(--accent-primary);
}

/* --- OPEN DATA SECTION --- */
.open-data-section {
  padding: var(--space-6) 0;
  background-color: var(--bg-surface);
  border-bottom: var(--border-width) solid var(--border-color);
}

.chart-card {
  background-color: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-card);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  position: relative;
}

.chart-container {
  height: 240px;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: var(--space-3);
  border-bottom: 2px solid var(--border-color);
}

.chart-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 60%;
  background-color: var(--accent-primary);
  border-radius: 4px 4px 0 0;
  position: relative;
  transition: height var(--t-major) cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 10px;
}

.chart-bar.forest {
  background-color: var(--accent-secondary);
}

.chart-bar:hover {
  filter: brightness(0.85);
}

.chart-bar-value {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-label {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin-top: 8px;
  text-align: center;
}

/* --- INTERACTIVE SERVICE MAP --- */
.map-section {
  padding: var(--space-6) 0;
  background-color: var(--bg-secondary);
  border-bottom: var(--border-width) solid var(--border-color);
}

.map-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: var(--space-4);
}

@media (max-width: 900px) {
  .map-layout {
    grid-template-columns: 1fr;
  }
}

.map-canvas-container {
  background-color: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-card);
  height: 380px;
  overflow: hidden;
  position: relative;
}

.map-sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
}

.map-location-card {
  background-color: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 12px;
  cursor: pointer;
  transition: all var(--t-micro);
}

.map-location-card:hover, .map-location-card.active {
  border-color: var(--accent-primary);
  background-color: var(--bg-primary);
}

/* Map Pin Styling on SVG Map */
.map-svg {
  width: 100%;
  height: 100%;
}

.map-pin {
  cursor: pointer;
  transition: transform var(--t-micro);
}

.map-pin:hover, .map-pin.active {
  transform: scale(1.3) translateY(-4px);
}

.map-pin-circle {
  fill: var(--accent-primary);
  stroke: #FFFFFF;
  stroke-width: 2px;
}

.map-pin.hospital .map-pin-circle {
  fill: var(--status-error);
}

.map-pin.library .map-pin-circle {
  fill: var(--accent-secondary);
}

/* --- EMERGENCY OVERRIDE MODE --- */
body.emergency-override {
  --bg-primary: #111827;        /* Dark Slate */
  --bg-secondary: #1F2937;      /* Dark gray */
  --bg-surface: #1F2937;        /* Dark gray card surface */
  --text-primary: #F9FAFB;      /* Light gray */
  --text-secondary: #D1D5DB;    /* Medium light gray */
  --accent-primary: #EF4444;    /* Red alert */
  --border-color: #374151;      /* Dark border */
  --border-focus: #EF4444;
}

.emergency-alert-banner {
  background-color: #EF4444;
  color: #FFFFFF;
  padding: var(--space-2) 0;
  text-align: center;
  font-weight: 700;
  font-size: var(--fs-base);
  z-index: 101;
  position: relative;
  display: none;
}

body.emergency-override .emergency-alert-banner {
  display: block;
}

.btn-emergency-toggle {
  background-color: var(--status-error);
  color: #FFFFFF;
  border: none;
  font-weight: 700;
}

.btn-emergency-toggle:hover {
  background-color: #991b1b;
}

/* --- FINAL INVITATION & FOOTER --- */
.final-invitation {
  padding: var(--space-8) 0;
  background-color: var(--bg-surface);
  border-bottom: var(--border-width) solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.footer {
  background-color: var(--bg-surface);
  border-top: var(--border-width) solid var(--border-color);
  padding: var(--space-6) 0 var(--space-4) 0;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  transition: background-color var(--t-standard), border-color var(--t-standard);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.footer-column h4 {
  font-size: var(--fs-sm);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-column ul {
  list-style: none;
}

.footer-column ul li {
  margin-bottom: 8px;
}

.footer-column ul li a {
  color: var(--text-secondary);
}

.footer-column ul li a:hover {
  color: var(--accent-primary);
}

.footer-bottom {
  border-top: var(--border-width) solid var(--border-color);
  padding-top: var(--space-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: 700;
  color: var(--text-primary);
}

/* --- DYNAMIC TRANSITIONS --- */
.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
  animation: fadeInView var(--t-standard) ease-out;
}

@keyframes fadeInView {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Form inputs & interactive widgets styling */
.form-group {
  margin-bottom: var(--space-3);
}

.form-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-input);
  font-size: var(--fs-sm);
  background-color: var(--bg-surface);
  transition: all var(--t-micro);
}

.form-input:focus {
  border-color: var(--border-focus);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.15);
}

/* Secure Identity Verification Backdrop */
.auth-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(26, 34, 46, 0.6);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-3);
}

.auth-overlay.active {
  display: flex;
}

.auth-modal {
  background-color: var(--bg-surface);
  border-radius: var(--radius-dialog);
  border: var(--border-width) solid var(--border-color);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  text-align: center;
}

.auth-lock-icon {
  font-size: 32px;
  color: var(--accent-primary);
  margin-bottom: var(--space-2);
}

/* ============================================================
   MOBILE OPTIMIZATION
   ============================================================ */
@media (pointer: coarse) {
  .btn, .nav-link, .header-action-btn, .tab-btn, a, button {
    min-height: 44px;
    min-width: 44px;
    -webkit-tap-highlight-color: transparent;
  }
  .btn { padding: 14px 24px; font-size: 0.9rem; }
  .nav-link { padding: 12px 8px; }
  body { cursor: auto; -webkit-text-size-adjust: 100%; }
  html, body { overflow-x: hidden; overscroll-behavior-x: none; }
}

@media (max-width: 480px) {
  .hero-headline { font-size: 1.8rem; line-height: 1.15; }
  .hero-desc { font-size: 0.95rem; }
  .hero-layout { gap: 24px; }
  .hero-ctas { flex-direction: column; width: 100%; }
  .hero-ctas .btn { width: 100%; justify-content: center; }
  .grid-12, .grid-8, .grid-4 { grid-template-columns: 1fr !important; }
  .footer-grid { grid-template-columns: 1fr; }
  .container { padding-left: 16px; padding-right: 16px; }
  .section-header { margin-bottom: 24px; }
  .page-section { padding-top: 32px; padding-bottom: 32px; }
  .auth-modal { width: 95vw; max-width: 95vw; padding: 20px; }
  .tab-btn { padding: 10px 14px; font-size: 0.8rem; }
}

