/* Haringey 2026 Local Election & Deprivation Swipe Map Stylesheet */

/* --- Custom Theme System --- */
:root {
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Color Palette - Editorial & Clean */
  --bg-cream: #faf9f6;          /* FT-style warm paper */
  --bg-white: #ffffff;
  --text-dark: #111111;         /* High contrast dark text */
  --text-muted: #555555;
  --border-light: #e2e8f0;
  --border-dark: #1a202c;
  
  /* Political Parties */
  --color-green: #008075;       /* Green Party Green */
  --color-green-light: #e6f4f2;
  --color-labour: #E4003B;      /* Labour Rose Red */
  --color-labour-light: #fdf2f4;
  --color-libdem: #FAA61A;      /* Liberal Democrat Orange/Yellow */
  --color-libdem-light: #fffcf4;
  --color-split: #7f8c8d;       /* Patterned/Gray split */
  
  /* Shadows & Glassmorphism */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --glass-bg: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(226, 232, 240, 0.8);
}

/* --- Global Resets & Layout --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-cream);
  color: var(--text-dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* --- Editorial Header (FT/Guardian style) --- */
.editorial-header {
  background-color: var(--bg-cream);
  border-bottom: 1px solid var(--border-light);
  border-top: 5px solid var(--text-dark); /* Thick editorial line */
  padding: 16px 24px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-content {
  max-width: 1600px;
  margin: 0 auto;
}

.publication-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.publication-meta .category {
  color: var(--color-green);
  border-bottom: 2px solid var(--color-green);
  padding-bottom: 1px;
}

.editorial-header h1 {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.editorial-header .tagline {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 1000px;
  font-weight: 400;
}

/* --- Main Layout --- */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* --- Side Control & Info Panel --- */
.side-panel {
  width: 400px;
  min-width: 380px;
  background-color: var(--bg-white);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 2px 0 10px rgba(0,0,0,0.02);
}

/* Panel Sections */
.panel-section {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.panel-section:last-child {
  border-bottom: none;
}

.panel-section h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.panel-section h3 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.panel-section p {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Election Seat Bar Graphic */
.seat-bar {
  display: flex;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.seat-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.seat-segment.green { background-color: var(--color-green); }
.seat-segment.labour { background-color: var(--color-labour); }
.seat-segment.libdem { background-color: var(--color-libdem); }

.seat-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dark);
}

.seat-legend span {
  display: flex;
  align-items: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  display: inline-block;
}

.green-dot { background-color: var(--color-green); }
.labour-dot { background-color: var(--color-labour); }
.libdem-dot { background-color: var(--color-libdem); }

/* Form Controls */
.control-group {
  margin-bottom: 8px;
}

.control-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-dark);
}

.select-wrapper {
  position: relative;
}

select {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dark);
  background-color: var(--bg-cream);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}

select:hover {
  background-color: #f1efe9;
  border-color: #cbd5e1;
}

select:focus {
  border-color: var(--text-dark);
  background-color: var(--bg-white);
}

/* Custom Dropdown Arrow */
.select-wrapper::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--text-dark);
  pointer-events: none;
}

/* --- Legend Layouts --- */
.legends-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.legend-box {
  background-color: var(--bg-cream);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 12px 14px;
}

.legend-box h4 {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 2px;
}

.legend-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.legend-scale {
  margin: 8px 0;
}

.legend-color-strip {
  height: 12px;
  border-radius: 3px;
  margin-bottom: 4px;
  border: 1px solid rgba(0,0,0,0.05);
}

/* IMD Sequential Color Strip */
.imd-strip {
  background: linear-gradient(to right,
    #3f007d 0%, #67001f 11%, #980043 22%, #dd1c77 33%,
    #df65b0 44%, #c994c7 55%, #d4b9da 66%, #e7e1ef 77%,
    #f7f4f9 88%, #ffffd4 100%
  );
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.legend-help {
  font-size: 11px !important;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 0 !important;
  line-height: 1.3;
}

/* Dynamic Right Legend (Grid Items) */
.legend-grid-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-dark);
}

.legend-color-box {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  margin-right: 8px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* Hatch Pattern for Split Ward Legend */
.legend-color-box.split-pattern {
  background: repeating-linear-gradient(
    45deg,
    #7f8c8d,
    #7f8c8d 3px,
    #ffffff 3px,
    #ffffff 6px
  );
}

/* --- Info Card (Hover Details) --- */
.info-card {
  background-color: var(--bg-cream);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  min-height: 120px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.info-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
}

.info-placeholder svg {
  margin-bottom: 8px;
  stroke: var(--text-muted);
  opacity: 0.6;
}

.info-placeholder p {
  font-size: 12px;
  margin-bottom: 0;
  line-height: 1.4;
}

.info-card h4 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 2px;
  border-bottom: 1.5px solid var(--text-dark);
  padding-bottom: 4px;
}

.info-meta {
  display: flex;
  justify-content: space-between;
  margin: 8px 0;
  font-size: 12px;
  font-weight: 600;
}

.info-meta-item {
  display: flex;
  flex-direction: column;
}

.info-meta-item .value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dark);
  margin-top: 2px;
}

/* Vote Share Bars inside Info Card */
.info-votes-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 10px;
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.vote-share-row {
  margin-bottom: 8px;
}

.vote-share-row:last-child {
  margin-bottom: 0;
}

.vote-share-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 2px;
}

.vote-share-bar-bg {
  height: 8px;
  background-color: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}

.vote-share-bar-fill {
  height: 100%;
  border-radius: 4px;
}

.vote-share-bar-fill.green { background-color: var(--color-green); }
.vote-share-bar-fill.labour { background-color: var(--color-labour); }
.vote-share-bar-fill.libdem { background-color: var(--color-libdem); }

/* --- Map Wrapper & Swipe Controls --- */
.map-wrapper {
  flex: 1;
  position: relative;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
}

/* Mobile Tabs (hidden on desktop) */
.mobile-tabs {
  display: none;
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  padding: 4px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 420px;
}

.tab-btn {
  flex: 1;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.tab-btn.active {
  background-color: var(--text-dark);
  color: var(--bg-white);
}

/* Draggable Slider Handle styling */
.slider-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  margin-left: -20px;
  z-index: 999;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.slider-line {
  width: 2px;
  height: 100%;
  background: var(--text-dark);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}

.slider-button {
  width: 38px;
  height: 38px;
  background: var(--bg-white);
  border: 2px solid var(--text-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
}

.slider-handle:hover .slider-button {
  background-color: var(--bg-cream);
  transform: translateY(-50%) scale(1.05);
}

.slider-button svg {
  stroke: var(--text-dark);
}

/* Overlay Layer Labels */
.layer-label {
  position: absolute;
  top: 16px;
  padding: 6px 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dark);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

.left-label {
  left: 16px;
}

.right-label {
  right: 16px;
}

/* Leaflet Customization overrides */
.leaflet-container {
  font-family: var(--font-sans) !important;
}

.leaflet-pane {
  transition: clip-path 0.05s ease-out; /* Slight smoothing for high frequency clip updates */
}

/* Custom leaflet tooltip */
.custom-tooltip {
  background: var(--text-dark) !important;
  color: white !important;
  border: none !important;
  border-radius: 4px !important;
  font-weight: 600 !important;
  font-size: 11px !important;
  box-shadow: var(--shadow-md) !important;
}

/* Map info control overlay */
.map-note {
  position: absolute;
  bottom: 24px;
  right: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(4px);
  border: 1px solid var(--glass-border);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 9.5px;
  color: var(--text-muted);
  z-index: 800;
}

/* --- Responsive Media Queries (Mobile & Tablet) --- */
@media (max-width: 900px) {
  .editorial-header h1 {
    font-size: 22px;
  }
  .editorial-header .tagline {
    font-size: 12.5px;
  }
}

@media (max-width: 768px) {
  body {
    overflow-y: auto;
  }

  .app-container {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }

  .editorial-header {
    padding: 12px 16px;
  }

  .editorial-header h1 {
    font-size: 18px;
  }

  .editorial-header .tagline {
    display: none; /* Hide tagline to save vertical space on mobile */
  }

  .main-content {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .map-wrapper {
    height: 420px !important;
    width: 100% !important;
    order: 1; /* Map on top of side panel details */
  }

  #map {
    height: 420px !important;
    width: 100% !important;
  }

  .side-panel {
    width: 100%;
    min-width: 100%;
    border-right: none;
    border-top: 1px solid var(--border-light);
    height: auto;
    overflow-y: visible;
    order: 2;
  }

  .panel-section {
    padding: 16px;
  }

  .legends-grid {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
  }

  .legend-box {
    flex: 1 1 calc(50% - 6px);
    min-width: 150px;
  }

  /* Keep Swipe controls on mobile and scale labels */
  .slider-handle {
    display: flex !important;
  }

  .layer-label {
    display: block !important;
    top: 8px !important;
    font-size: 8.5px !important;
    padding: 4px 8px !important;
  }

  .left-label {
    left: 8px !important;
  }

  .right-label {
    right: 8px !important;
  }
}

/* CSS Utilities */
.hidden {
  display: none !important;
}

/* SVG Patterns for canvas */
.split-hatch-pattern {
  fill: url(#split-hatch);
}
