/*
 * GeoSnow Beta — layout & theme (aligned with alpha palette)
 * Breakpoint: 768px — desktop vs mobile shell
 */

/* -------------------------------------------------------------------------- */
/* Design tokens (alpha: #0072ce header gradient, dark slate sidebar)         */
/* -------------------------------------------------------------------------- */

:root {
  --color-primary: #0072ce;
  --color-primary-dark: #005a9e;
  --color-ink: #0b1120;
  --color-ink-deep: #020617;
  --color-surface: #ffffff;
  --color-muted: #64748b;
  --color-text: #0f172a;
  --color-text-inverse: #e5e7eb;
  --color-accent-soft: #e5f0ff;
  --color-border: rgba(148, 163, 184, 0.45);
  --color-border-strong: rgba(148, 163, 184, 0.65);
  --header-gradient: linear-gradient(135deg, #0072ce 0%, #0b1120 100%);
  --sidebar-gradient: linear-gradient(
    180deg,
    var(--color-ink) 0%,
    var(--color-ink-deep) 55%,
    #000000 100%
  );
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-soft: 0 8px 30px rgba(15, 23, 42, 0.12);
  --shadow-nav: 0 4px 24px rgba(15, 23, 42, 0.18);
  --header-h: 56px;
  --sidebar-w: 240px;
  --panel-w: 320px;
  --sheet-peek: 148px;
  --sheet-expanded: min(72vh, 560px);
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

/* -------------------------------------------------------------------------- */
/* Reset & base                                                                */
/* -------------------------------------------------------------------------- */

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

html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-ink);
  -webkit-font-smoothing: antialiased;
}

/* Shiny root */
.container-fluid {
  padding: 0;
  margin: 0;
  max-width: none;
  height: 100%;
}

/* -------------------------------------------------------------------------- */
/* App shell                                                                   */
/* -------------------------------------------------------------------------- */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-surface);
}

/* -------------------------------------------------------------------------- */
/* Header                                                                      */
/* -------------------------------------------------------------------------- */

.app-header {
  flex: 0 0 var(--header-h);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: var(--header-gradient);
  color: var(--color-text-inverse);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-logo {
  display: block;
  height: 32px;
  width: auto;
  border-radius: 6px;
}

.brand-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-placeholder {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(229, 240, 255, 0.55);
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
}

.style-switcher {
  appearance: none;
  background-color: rgba(15, 23, 42, 0.72);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23e5f0ff'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 8px 5px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: var(--radius-sm);
  color: #e5f0ff;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 1.8rem 0.35rem 0.7rem;
  cursor: pointer;
  height: 36px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.style-switcher:hover {
  background-color: rgba(15, 23, 42, 0.9);
  border-color: rgba(148, 163, 184, 0.7);
}

.style-switcher option {
  background: #0b1120;
  color: #e5f0ff;
}

.menu-btn {
  display: none;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.menu-icon {
  font-size: 1.25rem;
}

/* -------------------------------------------------------------------------- */
/* Main layout — desktop: 3 columns                                            */
/* -------------------------------------------------------------------------- */

.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
  grid-template-rows: 1fr;
  min-height: calc(100dvh - var(--header-h));
}

/* -------------------------------------------------------------------------- */
/* Left sidebar (desktop)                                                      */
/* -------------------------------------------------------------------------- */

.sidebar-left {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: var(--sidebar-gradient);
  color: var(--color-text-inverse);
  border-right: 1px solid rgba(148, 163, 184, 0.2);
  min-height: 0;
}

.mode-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mode-btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.5);
  color: #cbd5f5;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.mode-btn:hover {
  background: rgba(0, 114, 206, 0.25);
  border-color: rgba(0, 114, 206, 0.55);
  color: #fff;
}

.mode-btn.active {
  background: linear-gradient(135deg, rgba(0, 114, 206, 0.85), rgba(11, 17, 32, 0.95));
  border-color: rgba(0, 114, 206, 0.9);
  color: #fff;
  box-shadow: 0 2px 12px rgba(0, 114, 206, 0.35);
}

/* Sidebar: only full labels for split buttons */
.sidebar-left .label-mobile {
  display: none;
}

.sidebar-left .label-desktop {
  display: inline;
}

.mode-status {
  margin: 0;
  font-size: 0.8rem;
  color: #cbd5f5;
  line-height: 1.45;
}

.mode-controls-placeholder {
  flex: 1;
  min-height: 120px;
  margin-top: auto;
  padding: 0.85rem;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-input {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(2, 6, 23, 0.55);
  color: #e5f0ff;
  padding: 0.55rem 0.65rem;
  font-size: 0.85rem;
  outline: none;
}

.search-input::placeholder {
  color: rgba(203, 213, 245, 0.65);
}

.search-input:focus {
  border-color: rgba(0, 114, 206, 0.75);
  box-shadow: 0 0 0 3px rgba(0, 114, 206, 0.18);
}

.search-results {
  display: none;
  max-height: 260px;
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(2, 6, 23, 0.82);
}

.search-box--mobile {
  margin-bottom: 0.75rem;
  margin-top: 0.75rem;
}

.search-results.is-open {
  display: block;
}

.search-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: #e5f0ff;
  padding: 0.6rem 0.7rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.search-item:hover {
  background: rgba(0, 114, 206, 0.18);
}

.search-item-title {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.25;
}

.search-item-meta {
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: rgba(203, 213, 245, 0.72);
  line-height: 1.25;
}

.search-empty {
  padding: 0.65rem 0.7rem;
  font-size: 0.8rem;
  color: rgba(203, 213, 245, 0.75);
}

.mode-controls-label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(229, 240, 255, 0.75);
}

.mode-controls-hint {
  margin: 0;
  font-size: 0.78rem;
  color: #94a3b8;
  line-height: 1.45;
}

.btn-simulate {
  margin-top: auto;
  align-self: stretch;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  color: #e5f0ff;
}

.btn-simulate:hover {
  background: rgba(0, 114, 206, 0.45);
  border-color: rgba(0, 114, 206, 0.8);
}

/* -------------------------------------------------------------------------- */
/* Map region                                                                  */
/* -------------------------------------------------------------------------- */

.map-region {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #e8eef5;
}

/* Mapbox mounts its canvas as position:absolute inside #map */
.map-container {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  background: linear-gradient(160deg, #dfe9f3 0%, #cfd9e8 45%, #b8c9dc 100%);
  overflow: hidden;
}

/* Placeholder grid — shown before Mapbox loads */
.map-container::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  opacity: 0.55;
  transition: opacity 0.4s ease;
}

/* Once Mapbox fires 'load', JS adds .map-loaded — remove the placeholder */
.map-container.map-loaded::before {
  opacity: 0;
  pointer-events: none;
}

/* Bottom nav — hidden on desktop */
.bottom-nav {
  display: none;
}

.mode-status-mobile {
  display: none;
}

.btn-simulate-float {
  display: none;
}

/* -------------------------------------------------------------------------- */
/* Right panel (desktop)                                                       */
/* -------------------------------------------------------------------------- */

.panel-right {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem;
  gap: 0.75rem;
  background: #f8fafc;
  border-left: 1px solid rgba(148, 163, 184, 0.35);
  overflow: auto;
}

.card-surface {
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

.panel-empty {
  padding: 1.5rem 1.25rem;
  text-align: left;
}

.panel-empty-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

.panel-empty-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-muted);
  line-height: 1.5;
}

.panel-filled-heading,
.sheet-filled-heading {
  margin: 0 0 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted);
}

.panel-cards,
.sheet-cards {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.info-card {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.info-card-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
}

.info-card-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-muted);
  line-height: 1.45;
}

.is-hidden {
  display: none !important;
}

/* -------------------------------------------------------------------------- */
/* Bottom sheet (mobile) — default closed                                      */
/* -------------------------------------------------------------------------- */

.bottom-sheet {
  display: none;
}

.sheet-backdrop {
  display: none;
}

/* -------------------------------------------------------------------------- */
/* Mobile layout (<768px)                                                      */
/* -------------------------------------------------------------------------- */

@media (max-width: 767px) {
  .app-shell {
    position: fixed;
    inset: 0;
    height: 100%;
    height: 100dvh;
  }

  .app-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    flex: none;
    height: var(--header-h);
    background: linear-gradient(
      180deg,
      rgba(11, 17, 32, 0.92) 0%,
      rgba(11, 17, 32, 0.55) 70%,
      transparent 100%
    );
    box-shadow: none;
    pointer-events: none;
  }

  .app-header .brand,
  .app-header .header-right {
    pointer-events: auto;
  }

  .header-placeholder {
    display: none;
  }

  .menu-btn {
    display: inline-flex;
  }

  .app-main {
    display: block;
    flex: 1;
    min-height: 0;
    height: 100%;
    position: relative;
  }

  .sidebar-left {
    display: none;
  }

  .map-region {
    position: absolute;
    inset: 0;
    height: 100%;
  }

  .map-container {
    flex: 1;
    height: 100%;
    min-height: 100%;
  }

  .panel-right {
    display: none;
  }

  /* Bottom pill navigation */
  .bottom-nav {
    display: flex;
    position: absolute;
    left: 50%;
    bottom: max(1rem, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 15;
    gap: 0.35rem;
    padding: 0.35rem 0.45rem;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow-nav);
    border: 1px solid rgba(148, 163, 184, 0.35);
    max-width: calc(100% - 1.5rem);
    flex-wrap: wrap;
    justify-content: center;
    pointer-events: auto;
  }

  .bottom-nav-btn {
    border: none;
    background: transparent;
    color: var(--color-text);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.45rem 0.55rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    white-space: nowrap;
  }

  .bottom-nav-btn .label-desktop {
    display: none;
  }

  .bottom-nav-btn .label-mobile {
    display: inline;
  }

  .bottom-nav-btn.mode-btn.active {
    background: linear-gradient(135deg, #0072ce, #0b1120);
    color: #fff;
  }

  .bottom-nav-btn.mode-btn:not(.active):hover {
    background: rgba(0, 114, 206, 0.1);
  }

  /* Mode line without desktop “Current mode” block */
  .mode-status-mobile {
    display: block;
    position: absolute;
    top: calc(var(--header-h) + 0.35rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
    margin: 0;
    padding: 0.35rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-ink);
    background: rgba(255, 255, 255, 0.92);
    border-radius: var(--radius-pill);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.12);
    max-width: 90vw;
    text-align: center;
    pointer-events: none;
  }

  /* Bottom sheet */
  .bottom-sheet {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    pointer-events: none;
  }

  .bottom-sheet.is-open {
    /* Keep the map clickable even when sheet is open */
    pointer-events: none;
  }

  .sheet-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    /* No dimming overlay; allow direct map interaction */
    background: transparent;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
  }

  .bottom-sheet.is-open .sheet-backdrop {
    opacity: 0;
  }

  .sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    max-height: var(--sheet-expanded);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 0 0 max(0.75rem, env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition:
      transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
      max-height 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 -8px 40px rgba(15, 23, 42, 0.2);
    pointer-events: auto;
  }

  .bottom-sheet.is-open .sheet-panel {
    transform: translateY(0);
  }

  /* Peek vs expanded height */
  .bottom-sheet.is-open:not(.is-expanded) .sheet-panel {
    max-height: var(--sheet-peek);
  }

  .bottom-sheet.is-open.is-expanded .sheet-panel {
    max-height: var(--sheet-expanded);
  }

  .sheet-handle {
    flex: 0 0 auto;
    width: 100%;
    border: none;
    background: transparent;
    padding: 0.65rem 0 0.35rem;
    cursor: pointer;
  }

  .sheet-handle-bar {
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto;
    border-radius: var(--radius-pill);
    background: rgba(148, 163, 184, 0.55);
  }

  .sheet-body {
    flex: 1;
    overflow: auto;
    padding: 0 1rem 0.5rem;
    min-height: 0;
  }

  .sheet-empty {
    padding: 0.25rem 0 0.5rem;
  }

  .sheet-placeholder-title {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
  }

  .sheet-placeholder-hint {
    margin: 0;
    font-size: 0.82rem;
    color: var(--color-muted);
    line-height: 1.45;
  }

  /* Floating simulate — visible on small screens; same action as desktop sidebar button */
  .btn-simulate-float {
    display: block;
    position: absolute;
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: calc(
      max(1rem, env(safe-area-inset-bottom)) + 5.5rem
    );
    z-index: 14;
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(0, 114, 206, 0.45);
    background: rgba(255, 255, 255, 0.96);
    color: var(--color-primary-dark);
    box-shadow: var(--shadow-nav);
    cursor: pointer;
  }

  .btn-simulate-float:hover {
    background: #fff;
    border-color: var(--color-primary);
  }
}

/* -------------------------------------------------------------------------- */
/* Mapbox hover popup                                                          */
/* -------------------------------------------------------------------------- */

.gs-hover-popup .mapboxgl-popup-content {
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--color-text);
  box-shadow: var(--shadow-soft);
  pointer-events: none;
}

.gs-hover-popup .mapboxgl-popup-tip {
  display: none;
}

/* -------------------------------------------------------------------------- */
/* Info card: label/value rows (used for ski area group info)                 */
/* -------------------------------------------------------------------------- */

.info-card--ski .info-card-meta-block {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.info-card-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.info-card-label {
  flex: 0 0 5.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-muted);
}

.info-card-value {
  color: var(--color-text);
  font-weight: 500;
  line-height: 1.35;
}

/* Badge: "X related areas highlighted" */
.info-badge {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.info-badge--related {
  background: rgba(229, 160, 0, 0.14);
  color: #7a5000;
  border: 1px solid rgba(229, 160, 0, 0.45);
}

