/* Ski Map — Apple-style frosted glass over a full-screen map (D2). Colours, type and timing come from design/tokens.css */

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--page);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { font-family: var(--font-display); }

#map { position: absolute; inset: 0; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

/* Search */
.search {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: var(--gutter);
  width: min(380px, calc(100% - 2 * 16px - 56px));
  display: flex; align-items: center;
  z-index: 3;
}
.search-home {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  color: var(--navy);
}
.search-home svg { width: 22px; height: 22px; }
.search input {
  flex: 1; min-width: 0;
  height: 44px;
  border: 0; background: transparent;
  font: inherit; font-size: 16px;
  color: var(--text);
  padding: 0 14px 0 0;
  outline: none;
}
.search input::placeholder { color: var(--muted); }
.search:focus-within { box-shadow: var(--shadow), 0 0 0 3px rgb(var(--accent-rgb) / .35); }
.search, .control-group, .sos-button { transition: box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-out); }

.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  margin: 0; padding: 6px; list-style: none;
  background: var(--glass-solid);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: drop var(--dur-fast) var(--ease-out);
}
.search-results li {
  display: flex; flex-direction: column;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.search-results li strong { font-weight: 600; font-size: 15px; }
.search-results li span { font-size: 13px; color: var(--muted); }
.search-results li[aria-selected="true"], .search-results li[role=option]:hover { background: rgb(var(--accent-rgb) / .1); }
.search-results .search-empty { color: var(--muted); cursor: default; font-size: 14px; }

@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }

/* Controls */
.controls {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex; flex-direction: column; gap: 10px;
  z-index: 2;
}
.control-group { display: flex; flex-direction: column; overflow: hidden; }
.control {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.control + .control { border-top: 1px solid rgb(var(--navy-rgb) / .1); }
.control:hover { background: rgba(255, 255, 255, .6); }
.control:active { background: var(--separator); }
.control:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -3px; }
.control svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#compass-needle { transition: transform .15s linear; }
#compass-needle .needle-n { fill: var(--badge); stroke: none; }
#compass-needle .needle-s { fill: var(--lift-closed); stroke: none; }

#locate .arrow { fill: none; stroke: var(--accent); }
#locate[data-state="on"] .arrow { fill: var(--accent); }
#locate[data-state="follow"] { background: var(--accent); }
#locate[data-state="follow"] .arrow { fill: #fff; stroke: #fff; }
#locate[data-state="locating"] svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* User location */
.user-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .3);
}
.user-dot::after {
  content: ""; position: absolute; inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: ring 2s ease-out infinite;
}
@keyframes ring { from { transform: scale(1); opacity: .7; } to { transform: scale(2.6); opacity: 0; } }

/* Chips, toast, legend */
.chips {
  position: absolute;
  top: calc(max(16px, env(safe-area-inset-top)) + 54px);
  left: var(--gutter);
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  z-index: 1;
}
.chip {
  padding: 6px 12px;
  font-size: 13px; font-weight: 500;
  border-radius: 999px;
  z-index: 1;
}
.chip.poor { color: var(--caution-strong); }
.chip { transition: opacity var(--dur-fast) var(--ease); }

.toast {
  position: absolute;
  left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 56px);
  width: min(440px, calc(100% - 32px));
  padding: 12px 16px;
  font-size: 14px; line-height: 1.4;
  transform: translate(-50%, 12px);
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
  z-index: 4;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.legends {
  position: absolute;
  left: var(--gutter);
  bottom: max(16px, env(safe-area-inset-bottom));
  max-width: calc(100% - 32px - 40px);
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  z-index: 1;
}
.legend {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  padding: 8px 14px;
  font-size: 12px; font-weight: 500;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; }
.legend .line { width: 16px; height: 0; border-top: 2px solid var(--lift); }
.dot.novice { background: var(--piste-green); }
.dot.easy { background: var(--piste-blue); }
.dot.intermediate { background: var(--piste-red); }
.dot.advanced { background: var(--piste-black); }
.legend .pin { width: 9px; height: 9px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); margin: 0 1px 2px; }   /* a map pin (parks.js) */
.pin.park { background: var(--poi-park); }
.pin.kids { background: var(--poi-kids); }
/* A piste junction (junctions.js): the white disc with a ring, like the marker on the map */
.legend .junction { width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 1.5px solid var(--poi-junction); }

/* Info card for a selected piste, lift or resort (A3). Buttons reuse .btn and .sheet-icon from friends.css.
   Phones: a frosted bottom sheet that slides up from the bottom edge and can be swiped down (sheets.js).
   Wider screens: a floating card at the bottom centre. */
.place-card {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: calc(100% - max(16px, env(safe-area-inset-top)) - 60px);   /* stays below the search bar */
  overflow-y: auto; overscroll-behavior: contain;
  padding: 10px var(--space-5) calc(var(--space-5) + env(safe-area-inset-bottom));
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--blur-thick);
  backdrop-filter: var(--blur-thick);
  border: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-sheet);
  z-index: 3;
  transform: translateY(100%);
  transition: transform var(--dur-slow) var(--ease-sheet);
}
.place-card.open { transform: none; }
.place-card:not(.open) { pointer-events: none; }
/* The grabber that says "swipe me" */
.place-card::before, .sheet::before {
  content: ""; display: block; flex: none;
  width: 36px; height: 5px; margin: 0 auto 10px;
  border-radius: 3px; background: var(--grabber);
}
.sheet::before { margin: 7px auto 0; }
@media (min-width: 700px) {
  .place-card {
    left: 50%; right: auto; bottom: max(16px, env(safe-area-inset-bottom)); width: 380px; margin-left: -190px;
    max-height: calc(100% - max(16px, env(safe-area-inset-top)) - 60px - max(16px, env(safe-area-inset-bottom)));
    padding: var(--space-4) var(--space-4) var(--space-4) var(--space-5);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transform: translateY(24px) scale(.98); opacity: 0;
    transition: transform var(--dur) var(--ease-sheet), opacity var(--dur) var(--ease);
  }
  .place-card.open { opacity: 1; }
  .place-card::before, .sheet::before { display: none; }
  /* With the friends panel open on the left, sit next to it */
  body:has(#sheet.open) .place-card { left: calc(var(--gutter) + 396px); margin-left: 0; }
}
/* The card's heights (select.js): a resort's short "preview", the "full" card, and lowered to its name bar ("peek")
   so the map is in view. A tap anywhere on the bar raises it again; the chevron turns to point up. */
.place-card[data-detent="peek"] > :not(.place-head) { display: none; }
.place-card[data-detent="peek"] { cursor: pointer; }
.place-head .sheet-icon + .sheet-icon { margin-left: -4px; }   /* star, chevron and close sit a little closer */
.place-lower svg { transition: transform var(--dur) var(--ease); }
.place-card[data-detent="peek"] .place-lower svg { transform: rotate(180deg); }
/* The preview keeps each warning to its title; "Details" shows the rest */
.place-card[data-detent="preview"] .cond-alert { padding: 7px 0; align-items: center; }
.place-card[data-detent="preview"] .cond-alert div > span { display: none; }

/* Switching to another piste, lift or resort, or to another tab: the new content settles in */
.place-card.swap-item > :not(.place-head), .place-card.swap-tab .place-tabs ~ * { animation: content-in var(--dur) var(--ease-out) both; }
.place-card.swap-item .place-head { animation: fade var(--dur-fast) var(--ease) both; }
@keyframes content-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade { from { opacity: 0; } }

/* The card covers the legends unless the screen is wide enough for both */
@media (max-width: 1239px) {
  .legends { transition: opacity var(--dur-fast) var(--ease); }
  body.place-open .legends { opacity: 0; visibility: hidden; }
}

.place-head { display: flex; align-items: flex-start; gap: 12px; }
.place-titles { flex: 1; min-width: 0; padding-top: 2px; }
.place-head h2 { margin: 0; font-size: var(--text-title); font-weight: 700; line-height: 1.2; letter-spacing: var(--tracking-title); overflow-wrap: anywhere; }
.place-sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.place-badge {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
}
.place-badge.piste { background: var(--c); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--stroke); }
.place-badge.lift { background: var(--lift); color: #fff; }
.place-badge.resort { background: var(--navy); color: #fff; }
.place-badge.junction { background: #fff; color: var(--poi-junction); border: 2px solid var(--poi-junction); }

/* A junction's card (junctions.js): the pistes that meet there, as coloured dots, and what the place is for */
.place-pistes { display: flex; flex-direction: column; gap: 6px; margin: var(--space-4) 0 0; padding: 0; list-style: none; }
.place-pistes li { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.place-pistes li i { flex: none; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px var(--stroke); }
.place-pistes li small { font-weight: 500; color: var(--muted); }
.place-hint { margin: var(--space-3) 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.place-badge svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.place-stats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: var(--space-2);
  margin: var(--space-4) 0 0;
}
.place-stats div { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--fill); }
.place-stats dt { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.place-stats dd { margin: 1px 0 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.place-mix { margin-top: 12px; }
.mix-bar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; }
.mix-bar i { min-width: 3px; }
.mix-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mix-legend span { display: inline-flex; align-items: center; gap: 5px; }
.mix-legend i { width: 8px; height: 8px; border-radius: 50%; }

.place-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.place-tags li { padding: 3px 9px; border-radius: 999px; background: var(--fill-2); font-size: 12px; font-weight: 600; }
.place-tags li.warn { background: rgba(178, 80, 0, .12); color: #8a3d00; }
.place-note { margin: 12px 0 0; font-size: 13px; color: var(--muted); }

.place-actions { display: flex; gap: var(--space-2); margin-top: var(--space-4); }
.place-actions .btn { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border-radius: 12px; }
.place-actions .btn { white-space: nowrap; }
.place-actions .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-actions .btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* MapLibre attribution, tucked into the glass look */
.maplibregl-ctrl-bottom-right {
  margin: 0 max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) 0;
  transition: transform var(--dur-slow) var(--ease-sheet), opacity var(--dur-fast) var(--ease), visibility var(--dur-fast);
}
/* On phones the (i) rides on top of an open bottom sheet, so the map credits stay reachable (--sheet-h from sheets.js).
   It moves to the left there, clear of the map controls, and opens to the right like MapLibre's bottom-left layout. */
@media (max-width: 699px) {
  .place-head, .sheet-header { touch-action: none; }   /* drag handles for sheets.js, not scroll areas */
  body.sheet-up .maplibregl-ctrl-bottom-right {
    right: auto; left: 0;
    margin-left: var(--gutter);
    transform: translateY(calc(max(16px, env(safe-area-inset-bottom)) - var(--sheet-h, 0px) - 8px));
  }
  body.sheet-up .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib-button { left: 0; right: auto; }
  body.sheet-tall .maplibregl-ctrl-bottom-right { opacity: 0; visibility: hidden; }
  body.sheet-up .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact-show { padding: 2px 8px 2px 28px; }
  body.sheet-up .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact::after { left: 0; right: auto; }
}
.maplibregl-ctrl-bottom-right .maplibregl-ctrl { margin: 0; }
.maplibregl-ctrl-attrib.maplibregl-compact {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
}

@media (max-width: 600px) {
  .place-stats dd { font-size: 14px; }
  .legend { font-size: 11px; gap: 2px 10px; padding: 7px 12px; }
}

/* Reduce motion (D2): nothing slides, zooms or bounces. Panels, cards and messages fade in place instead, and looping
   animations stop. The SOS press-and-hold fill is kept (sos.css) because it shows progress. The map camera jumps
   instead of flying (map.js). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .place-card, .sheet { transform: none !important; transition: opacity var(--dur-fast) linear !important; }
  .place-card:not(.open), .sheet:not(.open) { opacity: 0; }
  .toast { transform: translate(-50%, 0) !important; transition: opacity var(--dur-fast) linear !important; }
  .legends, .maplibregl-ctrl-bottom-right { transition: opacity var(--dur-fast) linear !important; }
  .place-card.swap-item > *, .place-card.swap-tab .place-tabs ~ *, .sheet-body.view-in > *, .dialog[open], .search-results {
    animation: fade var(--dur-fast) linear both !important;
  }
}

/* Favourite star in the resort card's header, and the "I'm here" row (A9, map-links.js) */
.place-star { color: var(--muted); }
.place-star svg { fill: none; stroke-width: 1.8; }
.place-star[aria-pressed="true"] { color: var(--caution); }
.place-star[aria-pressed="true"] svg { fill: currentColor; }
.myresort-row.saved .browse-icon { background: var(--navy); color: #fff; }
.myresort-row + .offline-row { margin-top: var(--space-2); }
