/* ============================================================
   School Atlas — styles.css
   Phase 8: larger logo desktop, disclaimer always visible,
   mobile levels fix, legend panel, About modal,
   bolder circle colors (fillOpacity in map.js)
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --bar-height: 72px;
  --bar-bg: #14213d;
  --bar-border: rgba(255,255,255,0.08);
  --bar-shadow: 0 2px 12px rgba(0,0,0,0.28);

  --input-bg: rgba(255,255,255,0.08);
  --input-bg-focus: rgba(255,255,255,0.14);
  --input-border: rgba(255,255,255,0.14);
  --input-border-focus: rgba(255,255,255,0.38);
  --input-text: #f0f4ff;
  --input-placeholder: rgba(255,255,255,0.38);

  --accent: #4a9eff;
  --toggle-on: #4a9eff;

  --disclaimer-bg: rgba(14,20,38,0.92);
  --disclaimer-text: rgba(255,255,255,0.55);

  --font-ui: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono', monospace;

  /* Legend panel */
  --legend-w: 170px;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: var(--font-ui);
  background: #0e1426;
  overflow: hidden;
}

/* ── Top bar ─────────────────────────────────────────────── */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--bar-height);
  z-index: 1100;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--bar-border);
  box-shadow: var(--bar-shadow);
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
}

/* Logo section */
.top-bar-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  height: 100%;
  border-right: 1px solid var(--bar-border);
}

.site-logo-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: 12px;
  padding: 4px 10px;
  height: 54px;               /* mobile default */
  box-shadow: 0 1px 6px rgba(0,0,0,0.22);
}

.site-logo {
  display: block;
  height: 46px;               /* mobile default */
  width: auto;
  object-fit: contain;
}

/* Desktop: larger logo */
@media (min-width: 769px) {
  .site-logo-badge {
    height: 62px;
    border-radius: 14px;
    padding: 4px 12px;
  }
  .site-logo {
    height: 54px;
  }
}

/* Search section — grows to fill available space */
.top-bar-search {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 12px;
  height: 100%;
  display: flex;
  align-items: center;
}

.address-search-wrap {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--input-placeholder);
  pointer-events: none;
  flex-shrink: 0;
}

.address-input {
  width: 100%;
  height: 38px;
  padding: 0 32px 0 34px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  color: var(--input-text);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 400;
  letter-spacing: 0.01em;
  outline: none;
  transition: background 0.15s, border-color 0.15s;
}

.address-input::placeholder {
  color: var(--input-placeholder);
}

.address-input:focus {
  background: var(--input-bg-focus);
  border-color: var(--input-border-focus);
}

.address-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--input-placeholder);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.12s;
}

.address-clear:hover {
  color: var(--input-text);
}

/* Levels section */
.top-bar-levels {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  height: 100%;
  border-left: 1px solid var(--bar-border);
}

.levels-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  flex-shrink: 0;
}

.level-toggles {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
  white-space: nowrap;
}

.toggle-label:hover {
  color: #fff;
}

/* Custom checkbox */
.toggle-label input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.toggle-label input[type="checkbox"]:checked {
  background: var(--toggle-on);
  border-color: var(--toggle-on);
}

.toggle-label input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* About button in top bar */
.top-bar-about {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 14px;
  height: 100%;
  border-left: 1px solid var(--bar-border);
}

.about-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.7);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 5px 13px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.about-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-color: rgba(255,255,255,0.45);
}

/* ── Map ─────────────────────────────────────────────────── */
#map {
  position: fixed;
  top: var(--bar-height);
  left: 0;
  right: 0;
  bottom: 0;          /* footer is layered on top — map fills full height */
  z-index: 1;
}

/* ── Zoom controls at bottom-left ────────────────────────── */
.leaflet-bottom.leaflet-left {
  bottom: 52px;       /* clear the disclaimer footer */
}

/* ── Loading indicator ───────────────────────────────────── */
.loading {
  position: fixed;
  top: calc(var(--bar-height) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  background: var(--bar-bg);
  color: rgba(255,255,255,0.85);
  padding: 9px 22px 9px 16px;
  border-radius: 30px;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--bar-border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* ── Disclaimer footer — always fully visible ─────────────── */
.map-disclaimer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1050;
  background: var(--disclaimer-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  font-size: 10.5px;
  color: var(--disclaimer-text);
  letter-spacing: 0.02em;
  border-top: 1px solid rgba(255,255,255,0.08);
  text-align: center;
  /* no height cap, no overflow:hidden, no text-overflow:ellipsis */
  white-space: normal;
  line-height: 1.5;
  min-height: 32px;
}

/* ── Legend panel ────────────────────────────────────────── */
.legend-panel {
  position: fixed;
  top: calc(var(--bar-height) + 16px);
  left: 12px;
  width: var(--legend-w);
  z-index: 1080;
  background: rgba(14, 20, 38, 0.91);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 14px 12px 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.38);
  transition: transform 0.25s ease, opacity 0.2s ease;
  transform: translateX(0);
  opacity: 1;
}

.legend-panel--collapsed {
  transform: translateX(calc(-1 * var(--legend-w) - 20px));
  opacity: 0;
  pointer-events: none;
}

/* Vertical gradient bar */
.legend-gradient-bar {
  width: 18px;
  height: 120px;
  border-radius: 4px;
  background: linear-gradient(
    to bottom,
    #1a9850 0%,
    #91cf60 25%,
    #ffffbf 50%,
    #fc8d59 75%,
    #d73027 100%
  );
  float: left;
  margin-right: 8px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.legend-labels {
  float: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 120px;
  margin-right: 6px;
}

.legend-labels span {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  line-height: 1;
}

/* Clear float */
.legend-tiers {
  clear: both;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-tier {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: rgba(255,255,255,0.72);
  line-height: 1.2;
}

.lt-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.25);
  flex-shrink: 0;
}

/* Legend tab handle */
.legend-tab {
  position: fixed;
  top: calc(var(--bar-height) + 16px);
  left: calc(var(--legend-w) + 16px);   /* flush right of panel */
  z-index: 1081;
  background: rgba(14, 20, 38, 0.91);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-left: none;
  border-radius: 0 8px 8px 0;
  padding: 8px 8px 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-family: var(--font-ui);
  color: rgba(255,255,255,0.65);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: left 0.25s ease, background 0.15s;
  box-shadow: 2px 0 8px rgba(0,0,0,0.2);
}

.legend-tab:hover {
  background: rgba(30, 42, 74, 0.95);
  color: #fff;
}

.legend-tab--collapsed {
  left: 12px;
  border-radius: 0 8px 8px 0;
}

.legend-tab-icon {
  font-size: 10px;
  line-height: 1;
}

.legend-tab-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  letter-spacing: 0.1em;
}

/* ── About modal ─────────────────────────────────────────── */
.about-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(10, 15, 30, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.about-overlay[hidden] {
  display: none;
}

.about-modal {
  position: relative;
  background: #f8f9fc;
  border-radius: 14px;
  max-width: 580px;
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 36px 36px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.about-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: #6b7a99;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}

.about-close:hover {
  color: #14213d;
  background: rgba(0,0,0,0.07);
}

.about-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.about-logo {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: contain;
}

.about-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: #14213d;
  margin: 0 0 6px;
}

.about-tagline {
  text-align: center;
  color: #6b7a99;
  font-size: 0.92rem;
  margin: 0 0 24px;
}

.about-section {
  margin-bottom: 20px;
}

.about-section h2 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #a0aabf;
  margin: 0 0 6px;
}

.about-section p {
  font-size: 0.875rem;
  color: #3a4a6b;
  line-height: 1.65;
  margin: 0 0 8px;
}

.about-tiers {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.about-tier-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  color: #3a4a6b;
  background: #eef1f8;
  border-radius: 6px;
  padding: 6px 10px;
}

.about-tier-row span:last-child {
  color: #6b7a99;
  font-size: 0.8rem;
}

.about-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e2e6f0;
  text-align: center;
}

.about-footer p {
  font-size: 0.82rem;
  color: #6b7a99;
  margin: 0 0 6px;
}

.about-footer a {
  color: #4a9eff;
  text-decoration: none;
}

.about-footer a:hover {
  text-decoration: underline;
}

.about-disclaimer {
  font-size: 0.75rem !important;
  color: #a0aabf !important;
  font-style: italic;
}

/* ── Address search result pin ───────────────────────────── */
.search-result-pin {
  /* styled via Leaflet divIcon in map.js */
}

/* ── Popup ───────────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  padding: 0;
}

.leaflet-popup-content {
  margin: 0;
  width: auto !important;
}

.school-popup {
  min-width: 240px;
  max-width: 320px;
  padding: 14px 16px 12px;
}

.school-popup h3 {
  margin: 0 0 10px 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  border-bottom: 1px solid #e8ecf4;
  padding-bottom: 8px;
  color: #14213d;
}

.popup-section-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #a0aabf;
  margin: 8px 0 3px 0;
}

.popup-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 2px 0;
  font-size: 12.5px;
}

.popup-row .label {
  color: #6b7a99;
  flex-shrink: 0;
}

.popup-row .value {
  text-align: right;
  font-weight: 500;
  color: #1a2540;
}

.popup-row .value.missing {
  color: #c0c8d8;
  font-weight: 400;
  font-family: var(--font-mono);
  font-size: 12px;
}

.popup-row--missing .label {
  color: #b0baca;
}

.popup-divider {
  height: 1px;
  background: #e8ecf4;
  margin: 6px 0 2px 0;
}

.popup-footer {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid #e8ecf4;
  font-size: 11.5px;
  color: #8a96b0;
  text-align: center;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ── NCES polygon layers (wired in future phase) ─────────── */
.leaflet-interactive.attendance-zone {
  stroke-width: 1.5px;
}

/* ── Mobile breakpoints ──────────────────────────────────── */

/* ≤ 768px: search bar stacks above level toggles */
@media (max-width: 768px) {
  :root { --bar-height: 116px; }

  .top-bar {
    flex-wrap: wrap;
    height: var(--bar-height);
    align-content: flex-start;
  }

  /* Search goes first (full-width top row) */
  .top-bar-search {
    order: 1;
    flex-basis: 100%;
    width: 100%;
    height: 54px;
    border-left: none;
    border-bottom: 1px solid var(--bar-border);
  }

  /* Logo / levels / about share the bottom row */
  .top-bar-logo   { order: 2; height: 62px; }
  .top-bar-levels { order: 3; height: 62px; flex: 1; }
  .top-bar-about  { order: 4; height: 62px; }
}

@media (max-width: 680px) {
  /* Disclaimer wraps naturally — no extra rules needed now */

  /* Zoom controls clear disclaimer */
  .leaflet-bottom.leaflet-left {
    bottom: 56px;
  }

  /* Levels: tighter and smaller so they fit on narrow screens */
  .top-bar-levels {
    padding: 0 6px;
    gap: 4px;
  }

  .levels-label {
    display: none;
  }

  .level-toggles {
    gap: 6px;
  }

  .toggle-label {
    font-size: 11px;
    gap: 3px;
  }

  .toggle-label input[type="checkbox"] {
    width: 13px;
    height: 13px;
  }

  /* About button: icon only on mobile */
  .about-btn {
    font-size: 11px;
    padding: 5px 8px;
    letter-spacing: 0;
  }

  /* Legend panel: slightly narrower */
  :root {
    --legend-w: 150px;
  }

  .address-input {
    font-size: 13px;
  }

  /* About modal: full-width on mobile */
  .about-modal {
    padding: 28px 20px 20px;
    border-radius: 10px;
  }
}

@media (max-width: 480px) {
  .address-input::placeholder {
    font-size: 12px;
    letter-spacing: 0;
  }

  /* Hide About text on very narrow, keep as tiny "?" */
  .about-btn {
    font-size: 0;
    padding: 5px 10px;
  }
  .about-btn::after {
    content: '?';
    font-size: 14px;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
  }
}

/* ── Map clusters (neutral — not score-encoded) ──────────── */
.marker-cluster-neutral div {
  background-color: rgba(74, 158, 255, 0.72);
}

.marker-cluster-neutral div:before {
  background-color: rgba(74, 158, 255, 0.48);
}

.marker-cluster-neutral div span {
  color: #fff;
  font-weight: 700;
}
