/* ==========================================================================
   Lakefront Splash & Dash — styles
   Palette: lake blue, sky wash, sand, teal, coral. Rounded + playful, never dark mode.
   ========================================================================== */

:root {
  --lake: #1E7FA6;
  --lake-dark: #145F80;
  --lake-tint: #DCF0F8;
  --sky: #EAF6FA;
  --foam: #FFFFFF;
  --sand: #F2C879;
  --sand-dark: #DE9F35;
  --coral: #FF6B5F;
  --coral-tint: #FFE3E0;
  --teal: #2BB3A3;
  --teal-tint: #DBF3EF;
  --brown: #8D6E4C;
  --brown-tint: #EFE4D6;
  --ink: #16333F;
  --ink-soft: #4C6572;
  --line: #D8ECF2;

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-soft: 0 10px 28px rgba(22, 51, 63, 0.12);
  --shadow-pop: 0 6px 18px rgba(22, 51, 63, 0.20);

  --font-display: 'Fredoka', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --topbar-h: 68px;
  --sidebar-w: 400px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--sky);
  overflow: hidden; /* app is a fixed-viewport shell */
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 6px;
  line-height: 1.15;
}

p { margin: 0 0 10px; line-height: 1.5; }

button { font-family: var(--font-body); }

a { color: var(--lake-dark); }

.hidden { display: none !important; }

.mobile-only { display: none; }
.desktop-only { display: revert; }

/* ==========================================================================
   App shell
   ========================================================================== */

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--sky);
  position: relative;
}

#top-bar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--foam);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.brand-icon {
  font-size: 28px;
  line-height: 1;
}

.brand-text h1 {
  font-size: 19px;
  color: var(--lake-dark);
  white-space: nowrap;
}

.tagline {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 0;
}

.credit {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
  margin: 0;
}

.icon-btn {
  border: none;
  background: var(--sky);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 17px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { background: var(--lake-tint); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:focus-visible { outline: 3px solid var(--sand-dark); outline-offset: 2px; }

/* ==========================================================================
   Layout: split-screen on desktop
   ========================================================================== */

#app-layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  position: relative;
}

#map {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  background: var(--sky);
}

#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 auto;
  background: var(--foam);
  position: relative;
  overflow-y: auto;
  box-shadow: var(--shadow-soft);
  z-index: 10;
}

/* Signature "waterline" — a wavy seam where the sidebar meets the map */
#sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  right: -19px;
  width: 20px;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 40'%3E%3Cpath d='M10,0 Q2,10 10,20 T10,40 L0,40 L0,0 Z' fill='%23FFFFFF'/%3E%3C/svg%3E");
  background-repeat: repeat-y;
  background-size: 20px 40px;
  pointer-events: none;
}

#sheet-handle { display: none; }
#sheet-backdrop { display: none; }

#sidebar-content {
  padding: 22px 22px 32px;
}

/* ==========================================================================
   Welcome / legend panel
   ========================================================================== */

.welcome-panel h2 { color: var(--lake-dark); }

.legend-list {
  list-style: none;
  margin: 6px 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
}

.legend-swatch {
  --c: var(--lake);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  box-shadow: var(--shadow-pop);
  flex: 0 0 auto;
}

.welcome-note {
  background: var(--sky);
  border: 1px dashed var(--lake);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink-soft);
}

/* ==========================================================================
   Panels (form / details) shared chrome
   ========================================================================== */

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.panel-header h2 {
  color: var(--lake-dark);
  font-size: 21px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.coords-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--sky);
  color: var(--lake-dark);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}

/* ==========================================================================
   Forms
   ========================================================================== */

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 18px;
}

legend {
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 8px;
  padding: 0;
  color: var(--ink);
}

.type-fieldset {
  display: block;
}

.type-option {
  display: block;
  margin-bottom: 8px;
  cursor: pointer;
}

.type-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.type-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 14.5px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.type-emoji {
  font-size: 20px;
}

.type-option input:checked + .type-card {
  border-color: var(--lake);
  background: var(--lake-tint);
}

.type-option input:focus-visible + .type-card {
  outline: 3px solid var(--sand-dark);
  outline-offset: 2px;
}

.type-option:hover .type-card {
  transform: translateY(-1px);
}

.radio-inline, .checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 14.5px;
  margin-right: 18px;
  cursor: pointer;
}

.radio-inline input, .checkbox-inline input {
  width: 18px;
  height: 18px;
  accent-color: var(--lake);
  cursor: pointer;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 6px;
}

textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14.5px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  resize: vertical;
  color: var(--ink);
  background: var(--foam);
}

textarea:focus-visible, textarea:focus {
  outline: none;
  border-color: var(--lake);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14.5px;
  border-radius: 999px;
  padding: 11px 20px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.btn:active { transform: scale(0.96); }
.btn:focus-visible { outline: 3px solid var(--sand-dark); outline-offset: 2px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: var(--lake);
  color: #fff;
  box-shadow: var(--shadow-pop);
}
.btn-primary:hover { background: var(--lake-dark); }

.btn-ghost {
  background: var(--foam);
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--lake); }

.form-note {
  background: var(--sky);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

/* Delete zone at the bottom of the edit form */
.delete-zone {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.btn-delete-link {
  background: none;
  border: none;
  padding: 4px 0;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--coral);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-delete-link:hover { color: #D94A3F; }
.btn-delete-link:focus-visible { outline: 3px solid var(--sand-dark); outline-offset: 2px; border-radius: 4px; }

.delete-warning {
  background: var(--coral-tint);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: #7A241C;
}

.btn-danger {
  background: var(--coral);
  color: #fff;
  box-shadow: var(--shadow-pop);
}
.btn-danger:hover { background: #E85448; }

/* ==========================================================================
   Facility details view
   ========================================================================== */

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.badge {
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--sky);
  color: var(--lake-dark);
}
.badge-seasonal { background: var(--sand); color: #5B3E0A; }
.badge-year_round { background: var(--teal-tint); color: #0E6459; }
.badge-info { background: var(--lake-tint); color: var(--lake-dark); }

.detail-block {
  margin-bottom: 16px;
}
.detail-block h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.detail-block p {
  font-size: 15px;
  margin-bottom: 0;
}

.meta-line {
  font-size: 12.5px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  margin-top: 4px;
  margin-bottom: 0;
}

/* ==========================================================================
   Leaflet marker & popup theming
   ========================================================================== */

.leaflet-div-icon { background: transparent; border: none; }

.marker-badge {
  --badge-color: var(--lake);
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 50% 4px;
  background: var(--badge-color);
  border: 3px solid var(--foam);
  box-shadow: var(--shadow-pop);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(45deg);
  animation: drop-in 0.35s ease;
}
.marker-badge span {
  transform: rotate(-45deg);
  font-size: 16px;
}

.temp-badge {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 4px;
  background: var(--coral);
  border: 3px solid var(--foam);
  box-shadow: var(--shadow-pop);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(45deg);
  animation: pulse-drop 1.6s ease-in-out infinite;
}
.temp-badge span {
  transform: rotate(-45deg);
  font-size: 15px;
}

@keyframes drop-in {
  0% { transform: rotate(45deg) translateY(-14px) scale(0.5); opacity: 0; }
  100% { transform: rotate(45deg) translateY(0) scale(1); opacity: 1; }
}

@keyframes pulse-drop {
  0%, 100% { box-shadow: var(--shadow-pop); }
  50% { box-shadow: 0 6px 18px rgba(255, 107, 95, 0.55); }
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}
.leaflet-popup-content { font-family: var(--font-body); margin: 14px 16px; }
.leaflet-popup-tip { box-shadow: none; }

.temp-popup p {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 14px;
}

/* ==========================================================================
   Toasts
   ========================================================================== */

#toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  width: min(92vw, 420px);
  align-items: center;
}

.toast {
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--coral); }
.toast-success { background: var(--teal); color: #06322C; }

/* ==========================================================================
   Config banner (shown when firebase-config.js still has placeholders)
   ========================================================================== */

#config-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--sand);
  color: #4A3106;
  font-weight: 700;
  font-size: 13.5px;
  text-align: center;
  padding: 10px 16px;
  z-index: 1000;
}
#config-banner code {
  background: rgba(255,255,255,0.5);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ==========================================================================
   Mobile: full-bleed map + swipeable bottom sheet
   ========================================================================== */

@media (max-width: 860px) {

  .mobile-only { display: inline-flex; }
  .desktop-only { display: none; }

  #app { overflow: hidden; }

  #top-bar {
    position: absolute;
    top: 12px;
    left: 12px;
    right: auto;
    height: auto;
    width: auto;
    max-width: calc(100% - 24px);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 999px;
    border: none;
    box-shadow: var(--shadow-soft);
    padding: 8px 10px 8px 16px;
    z-index: 500;
  }

  .brand-icon { font-size: 22px; }
  .brand-text h1 { font-size: 15px; }

  #app-layout {
    position: absolute;
    inset: 0;
    display: block;
  }

  #map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  #sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 78vh;
    max-height: 78dvh;
    border-radius: 26px 26px 0 0;
    box-shadow: 0 -8px 28px rgba(22, 51, 63, 0.22);
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 600;
    padding-top: 14px;
  }

  #sidebar::before {
    /* horizontal waterline along the top edge of the sheet instead */
    top: -19px;
    right: 0;
    left: 0;
    width: 100%;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 20'%3E%3Cpath d='M0,10 Q10,2 20,10 T40,10 L40,20 L0,20 Z' fill='%23FFFFFF'/%3E%3C/svg%3E");
    background-repeat: repeat-x;
    background-size: 40px 20px;
  }

  #sidebar.sheet-open {
    transform: translateY(0);
  }

  #sheet-handle {
    display: flex;
    justify-content: center;
    padding: 2px 0 8px;
    touch-action: none;
    cursor: grab;
  }
  .handle-bar {
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: var(--line);
  }

  #sidebar-content {
    padding: 4px 20px 28px;
    overflow-y: auto;
    max-height: calc(78vh - 40px);
    max-height: calc(78dvh - 40px);
  }

  #sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(22, 51, 63, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.32s ease;
    z-index: 550;
  }
  #sheet-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ==========================================================================
   "Find me" button + user location dot
   ========================================================================== */

.locate-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--foam);
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-pop);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.12s ease;
}
.locate-btn:hover { background: var(--lake-tint); }
.locate-btn:active { transform: scale(0.92); }
.locate-btn:focus-visible { outline: 3px solid var(--sand-dark); outline-offset: 2px; }
.locate-btn.locating { animation: locating-spin 1s linear infinite; }

@keyframes locating-spin {
  to { transform: rotate(360deg); }
}

.user-loc-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--lake);
  border: 3px solid var(--foam);
  box-shadow: 0 0 0 0 rgba(30, 127, 166, 0.45);
  animation: loc-pulse 2s ease-out infinite;
}

@keyframes loc-pulse {
  0% { box-shadow: 0 0 0 0 rgba(30, 127, 166, 0.45); }
  70% { box-shadow: 0 0 0 16px rgba(30, 127, 166, 0); }
  100% { box-shadow: 0 0 0 0 rgba(30, 127, 166, 0); }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .marker-badge, .temp-badge, #sidebar, .toast, .icon-btn, .btn, .type-option:hover .type-card,
  .locate-btn, .locate-btn.locating, .user-loc-dot {
    animation: none !important;
    transition: none !important;
  }
}
