/* ── Variables ── */
:root {
  --bg:           #f2f1ec;
  --surface:      #ffffff;
  --surface-2:    #edecea;
  --border:       #d6d5cf;
  --border-strong:#b0afa8;
  --text:         #18181a;
  --text-2:       #52524e;
  --text-3:       #8a8a85;
  --accent:       #c94f00;
  --accent-hover: #a33f00;
  --nav-bg:       #111111;
  --nav-text:     #f5f5f5;
  --nav-text-dim: #888884;
  --low-bg:   #d4edda; --low-text:  #155724;
  --med-bg:   #fff3cd; --med-text:  #856404;
  --high-bg:  #f8d7da; --high-text: #721c24;
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* overflow-x: clip (not hidden) prevents any sideways page scroll without
   establishing a scroll container, so the sticky navbar/sidebar keep working.
   overscroll-behavior-y: none stops iOS's rubber-band bounce: on the map page,
   dragging the big Leaflet map lets the document overscroll and bounce down
   under the fixed navbar/bottom-nav, making those bars look like they drift. */
html { height: 100%; height: 100dvh; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: clip; overscroll-behavior-y: none; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  /* Use the dynamic viewport (dvh) as the height reference, NOT
     -webkit-fill-available: on iOS the latter resolves to a stale height that
     lags the Safari toolbar, so on the one page whose content fits the viewport
     exactly and can't scroll (the map — .map-page-body { height: 100% }), the
     fixed bottom-nav anchored to it floated ~18px up and exposed a strip of body
     background below it. dvh tracks the live visible area, so bottom: 0 lands on
     the true visual-viewport bottom. Scrollable pages never showed this because
     Safari pins fixed elements to the visual viewport once a page can scroll. */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  overscroll-behavior-y: none;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

main {
  flex: 1;
  padding: 28px 24px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 600px) {
  main { padding: 20px 16px; }
}

/* ── Navbar (always dark) ── */
.navbar {
  background: var(--nav-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  height: 62px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid #1e1e1e;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.logo:hover { text-decoration: none; }

.logo-mark {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  padding: 2px 5px;
  border-radius: 3px;
  line-height: 1.4;
}

.logo-word {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--nav-text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: #b2b2aa;
  padding: 6px 10px;
  border-radius: 4px;
  text-decoration: none;
  transition: color 0.15s;
}
.nav-link:hover { color: var(--nav-text); text-decoration: none; }
.nav-link-admin { color: var(--accent) !important; }
.nav-link-admin:hover { color: #ff7a3a !important; }

.nav-signout {
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: #b2b2aa;
  padding: 6px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}
.nav-signout:hover { color: #e07070; }

/* ── Navbar dropdown ── */
.nav-dropdown {
  position: relative;
}
.nav-dropdown-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--nav-text-dim);
  padding: 6px 12px;
  border-radius: 4px;
  transition: color 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-dropdown-btn:hover { color: var(--nav-text); }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #1a1a1a;
  border: 1px solid #2e2e2e;
  border-radius: 4px;
  min-width: 230px;
  z-index: 200;
  padding: 4px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu { display: block; }
.nav-dropdown-group {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #555;
  padding: 8px 14px 3px;
}
.nav-dropdown-item {
  display: block;
  padding: 7px 14px;
  font-size: 13px;
  color: #aaa;
  text-decoration: none;
  white-space: nowrap;
}
.nav-dropdown-item:hover { color: #f0f0ee; background: #242424; text-decoration: none; }
.nav-dropdown-sep {
  height: 1px;
  background: #2e2e2e;
  margin: 4px 0;
}

/* ── Footer ── */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 24px;
  margin-top: auto;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-logo { text-decoration: none; }
.footer-logo:hover { text-decoration: none; }
.footer-logo .logo-word { color: var(--text-2); font-size: 14px; }

.footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-3);
  flex-wrap: wrap;
}
.footer-links a { color: var(--text-3); }
.footer-links a:hover { color: var(--text); }
.footer-sep { color: var(--border-strong); }
.footer-admin-link { color: var(--border-strong) !important; font-size: 11px; }
.footer-admin-link:hover { color: var(--text-3) !important; }
.footer-cubevo-link { color: var(--text-2) !important; text-decoration: underline; }
.footer-cubevo-link:hover { color: var(--text) !important; }
.footer-feedback-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-3);
  padding: 0;
  font-family: inherit;
}
.footer-feedback-btn:hover { color: var(--text); }

/* ── Feedback type chips ── */
.feedback-type-row { display: flex; gap: 8px; flex-wrap: wrap; }
.feedback-type-chip { display: flex; align-items: center; cursor: pointer; }
.feedback-type-chip input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.feedback-type-chip span {
  display: inline-block;
  padding: 5px 13px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-2);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.feedback-type-chip input[type="radio"]:checked + span {
  border-color: var(--accent);
  color: var(--accent);
  background: #fff6f3;
}

/* ── Propose crossing button (navbar) ── */
.nav-propose-btn {
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: 1px solid #404040;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #b2b2aa;
  padding: 0 12px;
  height: 30px;
  transition: color 0.15s, border-color 0.15s;
}
.nav-propose-btn:hover { color: var(--nav-text); border-color: #606060; }

/* ── Propose crossing modal ── */
.propose-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 400;
  overflow-y: auto;
  padding: 40px 24px;
}
.propose-overlay.is-open {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.propose-overlay[hidden] { display: none !important; }
.propose-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 100%;
  max-width: 520px;
  margin: auto;
}
.propose-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.propose-modal-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text);
}
.propose-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-3);
  cursor: pointer;
  padding: 0 2px;
}
.propose-modal-close:hover { color: var(--text); }
.propose-modal-body { padding: 20px; }
.propose-tagline {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 18px;
  line-height: 1.5;
}
.propose-fields { display: flex; flex-direction: column; gap: 14px; }
.propose-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.propose-field { display: flex; flex-direction: column; gap: 5px; }
.propose-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.propose-required { color: var(--accent); }
.propose-input,
.propose-textarea {
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
.propose-input:focus,
.propose-textarea:focus { border-color: var(--border-strong); }
.propose-textarea { resize: vertical; min-height: 72px; }
.propose-footer { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.propose-actions { display: flex; justify-content: flex-end; gap: 8px; }
.propose-btn-ghost {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  cursor: pointer;
}
.propose-btn-ghost:hover { border-color: var(--border-strong); color: var(--text); }
.propose-btn-primary {
  height: 34px;
  padding: 0 16px;
  background: var(--accent);
  border: none;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}
.propose-btn-primary:hover { background: var(--accent-hover); }
.propose-btn-primary:disabled { opacity: 0.6; cursor: default; }
.propose-feedback { font-size: 13px; min-height: 18px; }
.propose-feedback-ok    { color: #2d7a3a; }
.propose-feedback-error { color: #b91c1c; }
@media (max-width: 480px) {
  .propose-field-row { grid-template-columns: 1fr; }
}

/* ── Language switcher ── */
.lang-select {
  -webkit-appearance: none;
  appearance: none;
  margin-left: 4px;
  padding: 0 10px 0 6px;
  border: 1px solid #404040;
  border-radius: 4px;
  background: transparent;
  color: #b2b2aa;
  font-size: 13px;
  font-weight: 500;
  height: 30px;
  cursor: pointer;
  outline: none;
}
.lang-select:hover { border-color: #606060; color: var(--nav-text); }
.lang-select option { background: #222; color: var(--nav-text); }

/* ── PWA install banner ── */
.pwa-banner {
  background: #1a1a1a;
  border-bottom: 1px solid #2e2e2e;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.pwa-banner[hidden] { display: none !important; }
.pwa-banner-msg { font-size: 13px; color: #ddd; flex: 1; min-width: 180px; }
.pwa-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
.pwa-install-btn {
  height: 32px;
  padding: 0 14px;
  background: var(--accent);
  border: none;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}
.pwa-install-btn:hover { background: var(--accent-hover); }
.pwa-dismiss-btn {
  height: 32px;
  padding: 0 10px;
  background: none;
  border: 1px solid #404040;
  border-radius: 3px;
  font-size: 12px;
  color: #b2b2aa;
  cursor: pointer;
}
.pwa-dismiss-btn:hover { color: #ddd; border-color: #666; }

/* ── Hamburger button ── */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: 2px;
  color: var(--nav-text-dim);
  border-radius: 4px;
  line-height: 0;
  transition: color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.nav-hamburger:hover,
.nav-hamburger.is-open { color: var(--nav-text); }

/* ── Mobile slide-down menu ── */
.nav-mobile-menu {
  display: none;
  flex-direction: column;
  position: fixed;
  top: 62px;
  left: 0;
  right: 0;
  background: #181818;
  border-bottom: 1px solid #2a2a2a;
  z-index: 150;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.nav-mobile-menu.is-open { display: flex; }

.nav-mobile-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  color: #c8c8c4;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
  line-height: 1.3;
  width: 100%;
  box-sizing: border-box;
}
.nav-mobile-item:hover,
.nav-mobile-item:active { background: #232323; color: #fff; text-decoration: none; }
.nav-mobile-sep {
  height: 1px;
  background: #2a2a2a;
  margin: 2px 0;
}

/* ── Bottom navigation (mobile only) ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 58px;
  background: var(--nav-bg);
  border-top: 1px solid #252525;
  z-index: 200;
  flex-direction: row;
  align-items: stretch;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--nav-text-dim);
  font-size: 10px;
  font-weight: 500;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
  padding: 6px 0 4px;
  letter-spacing: 0.2px;
}
.bottom-nav-item:hover, .bottom-nav-item.active { color: var(--nav-text); text-decoration: none; }
.bottom-nav-item.active svg { stroke: var(--accent); }
.bottom-nav-report-btn { color: var(--accent); }
.bottom-nav-report-btn svg { stroke: var(--accent); }

/* ── Copy-link toast (shown when a share button copies the URL on desktop) ── */
.cw-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  max-width: calc(100vw - 32px);
  background: var(--nav-bg);
  color: var(--nav-text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.28);
  opacity: 0;
  pointer-events: none;
  z-index: 500;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.cw-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 700px) {
  .bottom-nav { display: flex; }
  main { padding-bottom: calc(58px + 20px); }
  .footer { padding-bottom: calc(58px + 20px); }
}

/* ── Mobile: larger touch targets for links and buttons ── */
@media (max-width: 700px) {
  /* Hide top-nav links — bottom-nav handles page navigation; propose moves to hamburger */
  .nav-link { display: none; }
  .nav-signout { display: none; }
  .nav-propose-btn { display: none; }

  /* Pin the navbar reliably. `position: sticky` is unreliable on mobile
     Safari here: the body's `overflow-x: clip` makes it a scroll container,
     so the sticky navbar sticks to a box that never scrolls and detaches on
     momentum scroll (while the fixed dropdown/bottom-nav stay put). Fixed is
     rock-solid on iOS, so the navbar, its dropdown and the bottom-nav all
     stay locked together. Body gets top padding to offset the out-of-flow bar. */
  .navbar { position: fixed; top: 0; left: 0; right: 0; }
  body { padding-top: 62px; }

  /* Show hamburger */
  .nav-hamburger { display: flex; align-items: center; }

  /* Make buttons easier to tap */
  .submit-btn, .propose-btn-primary, .propose-btn-ghost,
  .pwa-install-btn { min-height: 44px; }

  /* Compact nav items that stay visible */
  .lang-select { height: 34px; font-size: 13px; padding: 0 8px 0 6px; }

  /* Larger footer links */
  .footer-links { font-size: 14px; }
  .footer-feedback-btn { font-size: 14px; }

  /* Larger modal buttons */
  .propose-btn-primary, .propose-btn-ghost { height: 44px; font-size: 15px; }
  .propose-modal-close { font-size: 26px; padding: 4px 8px; }

  /* Fix iOS Safari auto-zoom on modal inputs (triggers when font-size < 16px) */
  .propose-input,
  .propose-textarea { font-size: 16px; }

  /* Lift the "Copied!" toast above the bottom nav */
  .cw-toast { bottom: calc(58px + 16px); }
}
