/* Safe Route — page-specific styles.
   Reuses the variables, .card, .address-search, .nav-link, and button
   styles from style.css. Only adds what's unique to the safety overlay:
   legend gradient, summary list, tunnel marker. */

/* ── Support / donate card ───────────────────────────────────────────── */
#support-card { padding: 10px 12px; }
.support-row { display: flex; gap: 8px; }
.support-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.support-btn:hover { color: var(--text); background: var(--bg); }
/* Subtle "sister tool" cross-link under the support buttons. */
.also-by-me {
  display: block;
  margin-top: 10px;
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.35;
}
.also-by-me:hover { color: var(--accent); }
.also-by-me strong { font-weight: 600; }

.donate-modal { text-align: center; }
.donate-msg { font-size: 0.84rem; color: var(--text); line-height: 1.5; margin: 0 0 14px; }
.donate-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.donate-link:hover { text-decoration: underline; }

/* ── Top navigation bar ──────────────────────────────────────────────── */
#topnav {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 16px;
  flex: 0 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}
.brand-mark { width: 30px; height: 38px; flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: row; align-items: baseline; gap: 9px; }
.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.brand-sep {
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--border);
}
/* Tagline sits inline next to the title, same size — lighter weight + muted so
   the name still leads. */
.brand-tagline {
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--muted);
}
.topnav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Account trigger + dropdown */
.account { position: relative; }
.account-trigger {
  width: auto;                 /* override the global full-width button */
  padding: 0;
  background: none;
  border: none;
}
/* Logged-out state: a compact "Log in" pill. */
#trigger-login {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
}
.account-trigger:hover #trigger-login { background: var(--accent-dark); }
/* Logged-in state: avatar + email + caret chip. */
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.account-chip:hover { border-color: var(--accent); }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}
.trigger-email {
  font-size: 0.82rem;
  color: var(--text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.caret { font-size: 0.7rem; color: var(--muted); }

.account-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px;
  z-index: 1500;
}
.dropdown-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 0 0 6px;
}
.dropdown-email { font-size: 0.88rem; color: var(--text); margin: 0 0 12px; }
/* Menu-item button inside the profile dropdown (e.g. "Saved routes"). */
.dropdown-link {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 6px;
  border-radius: 7px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 4px;
}
.dropdown-link:hover { background: var(--bg); color: var(--accent); }

/* ── Saved-routes popup ───────────────────────────────────────────────── */
.saved-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 16px;
}
.saved-modal {
  position: relative;
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 38px 20px 18px;
  width: 380px;
  max-width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.saved-list { list-style: none; padding: 0; margin: 6px 0 0; }
.saved-empty { font-size: 0.82rem; color: var(--muted); padding: 8px 0; }
.saved-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.saved-item:first-child { border-top: none; }
/* The clickable name/meta area (view on map). */
.saved-view {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: none;
  border: none;
  padding: 4px 6px;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
}
.saved-view:hover { background: var(--bg); }
.saved-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.saved-meta { font-size: 0.72rem; color: var(--muted); }
.saved-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.saved-actions button {
  width: auto;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--muted);
}
.saved-actions button:hover { background: var(--bg); color: var(--accent); }
.saved-item.editing { gap: 6px; }
.saved-edit-input {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
}
.saved-unlock {
  width: auto;
  border: none;
  background: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  text-decoration: underline;
}

/* ── Passphrase modal ─────────────────────────────────────────────────── */
.pass-modal { text-align: left; }
.pass-msg { font-size: 0.82rem; color: var(--muted); margin: 0 0 12px; line-height: 1.45; }
.pass-input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
}
.pass-input:focus { border-color: var(--accent); }
#pass-submit { margin-top: 6px; }

/* ── Privacy modal ────────────────────────────────────────────────────── */
.privacy-modal { text-align: left; }
.privacy-body p { font-size: 0.83rem; color: var(--text); line-height: 1.5; margin: 0 0 10px; }
.privacy-reset {
  width: 100%;
  margin-top: 8px;
  padding: 9px;
  border-radius: 8px;
  border: 1px solid #d62828;
  background: none;
  color: #d62828;
  font-weight: 600;
  cursor: pointer;
}
.privacy-reset:hover { background: rgba(214, 40, 40, 0.08); }

/* Collapse the brand name / Wind label a little on narrow screens. */
@media (max-width: 560px) {
  .brand-name { font-size: 1rem; }
  .brand-tagline, .brand-sep { display: none; }   /* keep the nav compact on phones */
  .trigger-email { max-width: 90px; }
}

/* ── Stacked address inputs (two .address-search blocks in one card) ── */
.card .address-search + .address-search {
  margin-top: 10px;
}
.address-search label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}

/* ── Legend (yellow → red gradient + tunnel marker explanation) ──────── */
.safe-legend {
  min-width: 180px;
}
/* Pin the night-discomfort legend to the map's lower-left corner (the shared
   #legend rule centres it; the summary now lives below the map, so the bottom
   of the map is free). */
#legend.safe-legend {
  left: 16px;
  bottom: 16px;
  transform: none;
}
.safe-legend .legend-title {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
  /* Fixed dark text: the legend panel is always a light/white card (see
     #legend in style.css), so theme vars would make it unreadable in dark mode. */
  color: #1a2332;
}
.safe-legend #legend-bar {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right, #ffeb3b, #ff9800, #d62828);
  margin-bottom: 4px;
}
.safe-legend #legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #666;
  margin-bottom: 6px;
}
.safe-legend .legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: #333;
  margin-top: 4px;
}
.legend-tunnel,
.legend-underpass {
  color: #1a1a1a;
  font-weight: 700;
  font-size: 1rem;
}
/* Small dashed square matching the coverage-boundary rectangle on the map. */
.legend-coverage {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px dashed #7b3ff2;
  border-radius: 2px;
  flex: 0 0 auto;
}
/* No dark-theme override: the legend panel is always light, so the tunnel /
   underpass symbols stay dark (#1a1a1a) and readable in both themes. */

/* ── Safety verdict headline ─────────────────────────────────────────── */
#summary-text { margin: 0; }
.verdict {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 4px solid var(--verdict-color, var(--accent));
  background: var(--verdict-bg, rgba(31, 111, 235, 0.08));
}
.verdict-emoji { font-size: 1.5rem; line-height: 1; }
.verdict-body { display: flex; flex-direction: column; gap: 2px; }
.verdict-title { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.verdict-sub   { font-size: 0.76rem; color: var(--muted); }
.verdict-dist  { font-variant-numeric: tabular-nums; }
/* One tint per verdict level — greener = calmer, redder = riskier. */
.verdict-calm  { --verdict-color: #22a06b; --verdict-bg: rgba(34, 160, 107, 0.10); }
.verdict-mild  { --verdict-color: #d9a406; --verdict-bg: rgba(217, 164, 6, 0.10); }
.verdict-watch { --verdict-color: #e8590c; --verdict-bg: rgba(232, 89, 12, 0.10); }
.verdict-avoid { --verdict-color: #d62828; --verdict-bg: rgba(214, 40, 40, 0.12); }

/* ── Factor chips (what makes it feel that way) ──────────────────────── */
#summary-components {
  list-style: none;
  padding: 0;
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.factor {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  border: 1px solid var(--border, #e2e8f0);
  cursor: pointer;                    /* tappable — highlights its cells on the map */
  user-select: none;
  transition: box-shadow 0.12s, transform 0.12s;
}
.factor:hover { transform: translateY(-1px); }
/* Pinned chip: a ring in the highlight colour so it's clear which is active. */
.factor.active { box-shadow: 0 0 0 2px #1f6feb; }
.factor::before { content: none; }   /* no list bullet */
.factor-icon  { font-size: 0.9rem; line-height: 1; }
.factor-label { color: var(--text); }
.factor-count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.72rem;
  min-width: 16px;
  text-align: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--chip-badge-bg, rgba(0, 0, 0, 0.06));
  color: var(--muted);
}
/* Concerns read warm; the transit "comfort" chip reads green. */
.factor-concern { --chip-badge-bg: rgba(214, 40, 40, 0.12); background: rgba(214, 40, 40, 0.05); border-color: rgba(214, 40, 40, 0.25); }
.factor-comfort { --chip-badge-bg: rgba(34, 160, 107, 0.14); background: rgba(34, 160, 107, 0.06); border-color: rgba(34, 160, 107, 0.30); }

/* The verdict/chips/hint group, and the action buttons group. Both stack
   vertically in the sidebar/mobile card. */
.summary-main    { display: flex; flex-direction: column; gap: 10px; }
.summary-actions { display: flex; flex-direction: column; gap: 8px; }

/* …laid out as a horizontal bar below the map on desktop. #summary-card is
   moved into #right-col by placeSummary(); that different parent is the hook.
   Left: verdict + chips inline (wide). Right: a narrow column of stacked
   buttons — keeps the bar short so the map keeps most of the height. */
#right-col > #summary-card {
  flex: 0 0 auto;
  flex-direction: row;
  align-items: stretch;
  gap: 16px;
  padding: 12px 16px;
  max-height: 40%;
  overflow-y: auto;
}
#right-col > #summary-card .card-label { display: none; }   /* redundant in the bar */
#right-col > #summary-card .summary-main {
  flex: 1 1 auto;
  min-width: 0;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
#right-col > #summary-card .summary-main #summary-text { flex: 0 1 auto; }
#right-col > #summary-card .summary-main #summary-components { margin-top: 0; flex: 1 1 220px; }
#right-col > #summary-card .summary-actions {
  flex: 0 0 auto;
  width: 190px;
  justify-content: center;
}
#right-col > #summary-card .summary-actions button,
#right-col > #summary-card .share-open-btn {
  width: 100%;
  margin: 0;
  white-space: nowrap;
}

/* ── Tunnel marker on the map (solid black square) ───────────────────── */
.tunnel-marker {
  width: 18px;
  height: 18px;
  background: #1a1a1a;
  border: 2px solid #ffffff;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ── Underpass marker (open arch, distinguishes from tunnel) ────────── */
.underpass-marker {
  width: 18px;
  height: 18px;
  background: #ffffff;
  border: 3px solid #1a1a1a;
  border-bottom: none;        /* gives an arch / 'doorway' silhouette */
  border-radius: 10px 10px 0 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Highlighted tunnel/underpass (from tapping its summary chip): enlarge + glow. */
.tunnel-marker.factor-hit,
.underpass-marker.factor-hit {
  transform: scale(1.5);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.6), 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s;
}

/* ── Avoid-a-stretch reroute ─────────────────────────────────────────── */
/* Tip under the summary telling the rider the route is tappable. */
.avoid-hint {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

/* 🚫 pin dropped at each committed avoided stretch. */
.avoid-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 15px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* Popup that appears when the rider taps the route. */
.avoid-popup .avoid-popup-body p {
  margin: 0 0 8px;
  font-size: 0.82rem;
}
.avoid-popup .avoid-btn {
  width: 100%;
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.avoid-popup .avoid-btn:hover { filter: brightness(1.08); }
/* The two avoid buttons stack with a small gap when a park option is shown. */
.avoid-popup .avoid-btn + .avoid-btn { margin-top: 6px; }
/* "Avoid the whole park" reads green — a calmer, different action. */
.avoid-popup .avoid-btn-park { background: #22a06b; }

/* ── Navigate / Share ─────────────────────────────────────────────────── */
.share-open-btn {
  display: block;
  width: 100%;
  margin: 6px 0 4px;
  padding: 11px 14px;
  border-radius: 9px;
  border: 1px solid #7b3ff2;
  background: #7b3ff2;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}
.share-open-btn:hover { background: #6a2fe0; }

.share-overlay {
  /* Absolute so it covers #map-container (position: relative) — the modal is
     centered over the MAP, not the whole page. */
  position: absolute;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 16px;
}
.share-modal {
  position: relative;
  background: #fff;
  color: #1a2332;
  border-radius: 14px;
  /* Extra top padding so the ✕ close button sits above the title, not on it. */
  padding: 38px 22px 20px;
  width: 320px;
  max-width: 100%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  text-align: center;
}
.share-close {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  border: none;
  background: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #6b7a8d;
}
.share-title { font-weight: 700; margin: 0 0 14px; font-size: 1rem; }
.share-qr {
  display: flex;
  justify-content: center;
  min-height: 200px;
  align-items: center;
}
.share-qr img, .share-qr canvas { border-radius: 6px; }
.share-hint { font-size: 0.8rem; color: #6b7a8d; margin: 12px 0; line-height: 1.4; }
.share-link-row { display: flex; gap: 6px; }
.share-link {
  flex: 1;
  min-width: 0;
  font-size: 0.72rem;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  color: #1a2332;
  background: #f6f8fb;
}
.share-copy {
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid #7b3ff2;
  background: #fff;
  color: #7b3ff2;
  font-weight: 600;
  cursor: pointer;
}
.share-privacy { font-size: 0.72rem; color: #6b7a8d; margin: 12px 0 0; }

/* ── Account / login ──────────────────────────────────────────────────── */
.account-hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  margin: 0 0 8px;
}
/* Match the bordered look of the address inputs (which style.css leaves to the
   browser default) so the email field lines up with the rest of the card. */
#login-email {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
}
#login-email:focus { border-color: var(--accent); background: var(--bg); }
/* Filled accent button, same treatment as #calculate-btn, with a gap above so
   it isn't glued to the email field. */
#login-btn {
  margin-top: 8px;
  background: var(--accent);
  color: #fff;
}
#login-btn:hover:not(:disabled) { background: var(--accent-dark); }
#login-btn:disabled { background: #a8c0e8; cursor: not-allowed; }
.account-status {
  font-size: 0.78rem;
  color: var(--accent);
  margin: 8px 0 0;
  line-height: 1.35;
}
.account-status-error { color: #c0392b; }
/* Email + password fields in the login/register dropdown. */
.auth-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
}
.auth-input:focus { border-color: var(--accent); }
.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}
.linkish {
  width: auto;
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font-size: 0.76rem;
  cursor: pointer;
}
.linkish:hover { text-decoration: underline; }
.account-email {
  font-size: 0.85rem;
  color: var(--text);
  margin: 0 0 10px;
}
#logout-btn.secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
#logout-btn.secondary:hover { background: var(--border); }

/* ── Save to account button (in the summary card) ─────────────────────── */
.save-account-btn {
  display: block;
  width: 100%;
  margin: 2px 0 4px;
  padding: 10px 14px;
  border-radius: 9px;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.save-account-btn:hover:not(:disabled) { background: rgba(58, 123, 213, 0.08); }
.save-account-btn:disabled { opacity: 0.7; cursor: default; }

/* ── Recent / saved route lists ───────────────────────────────────────── */
.myroutes-sub {
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--muted);
}
.myroutes-empty {
  list-style: none;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 4px 0;
}
/* The recent route currently loaded on the map (edits update it in place). */
.myroute-item.current {
  border-left: 3px solid var(--accent);
  padding-left: 8px;
}
#myroutes-list { list-style: none; margin: 6px 0 0; padding: 0; }
.myroute-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--border, #e2e8f0);
}
.myroute-item:first-child { border-top: none; }
.myroute-info { min-width: 0; display: flex; flex-direction: column; }
.myroute-name {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.myroute-meta { font-size: 0.7rem; color: var(--muted); }
.myroute-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.myroute-actions button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 3px 5px;
  border-radius: 6px;
  color: var(--muted);
}
.myroute-actions button:hover { background: rgba(123, 63, 242, 0.12); }
