/* Tokens: DS v5 de Rosa Agustina. */
:root {
  --navy: #001B2E;
  --deep: #062B73;
  --sea: #1FA0BB;
  --gold: #D4A95C;
  --gold-soft: #E8D3A7;
  --surface: #FBF9F4;
  --surface-2: #F5F1EA;
  --line: #E6DECF;
  --text: #1C232E;
  --muted: #5B6270;
  --shadow: 0 18px 50px -18px rgba(0, 27, 46, 0.45), 0 2px 8px rgba(0, 27, 46, 0.08);
  --radius-panel: 22px;
  --radius-ctrl: 12px;
  --font-ui: 'Outfit', system-ui, sans-serif;
  --font-display: 'Josefin Slab', Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #0A2335;
    --surface-2: #0F2C42;
    --line: #1E3D55;
    --text: #F2EDE3;
    --muted: #A9B4BF;
    --shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --surface: #0A2335;
  --surface-2: #0F2C42;
  --line: #1E3D55;
  --text: #F2EDE3;
  --muted: #A9B4BF;
  --shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--font-ui);
  color: var(--text);
  background: #EADFC8;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#stage:active { cursor: grabbing; }

/* Pines */
.pins { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pin {
  position: absolute; left: 0; top: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 0; border: 0; background: none; cursor: pointer;
  pointer-events: auto; will-change: transform;
  margin: -42px 0 0 -16px;
}
.pin::after {
  content: ''; position: absolute; left: 15px; top: 30px;
  width: 2px; height: 12px; background: var(--pin); border-radius: 1px;
}
.pin-badge {
  display: grid; place-items: center;
  min-width: 32px; height: 32px; padding: 0 7px;
  border-radius: 16px; background: var(--pin); color: #fff;
  border: 2.5px solid #fff;
  font: 600 13px/1 var(--font-ui); letter-spacing: 0.01em;
  box-shadow: 0 6px 14px -4px rgba(0, 27, 46, 0.55);
  transform: scale(0); transform-origin: 50% 130%;
  transition: transform 420ms cubic-bezier(.34, 1.56, .64, 1) var(--delay, 0ms);
}
.pin.is-in .pin-badge { transform: scale(1); }
.pin-label {
  padding: 5px 10px; border-radius: 9px;
  background: rgba(251, 249, 244, 0.96); color: #1C232E;
  font: 500 13px/1.2 var(--font-ui); white-space: nowrap;
  box-shadow: 0 6px 16px -6px rgba(0, 27, 46, 0.45);
  opacity: 0; transform: translateX(-4px); pointer-events: none;
  transition: opacity 160ms, transform 160ms;
}
.pin:hover .pin-label, .pin:focus-visible .pin-label, .pin.is-selected .pin-label,
.pin.is-near.is-in .pin-label { opacity: 1; transform: none; }
.pin:hover, .pin:focus-visible, .pin.is-selected { z-index: 200000 !important; }
.pin.is-selected .pin-badge { transform: scale(1.22); box-shadow: 0 0 0 4px rgba(212, 169, 92, 0.55), 0 8px 18px -4px rgba(0, 27, 46, 0.6); }
.pin.is-dim { opacity: 0.18; pointer-events: none; }
.pin.is-dim .pin-label { display: none; }
.pin.is-off { display: none; }

.gps-dot {
  position: absolute; left: 0; top: 0; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border-radius: 50%; background: #2F7DF6; border: 3px solid #fff;
  box-shadow: 0 0 0 0 rgba(47, 125, 246, 0.5);
  animation: gps 2s infinite;
}
@keyframes gps { to { box-shadow: 0 0 0 18px rgba(47, 125, 246, 0); } }

/* Panel */
.panel {
  position: fixed; top: 16px; left: 16px; bottom: 16px; width: 360px;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius-panel);
  box-shadow: var(--shadow); overflow: hidden; z-index: 300000;
}
.sheet-handle { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 14px; }
.logo { height: 40px; width: auto; }
.logo-wrap { display: contents; }
.panel-sub { margin: 0; font: 500 13px/1.2 var(--font-ui); color: var(--muted); text-align: right; max-width: 9em; }

.resorts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 16px; }
.resort-tab {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 12px; border-radius: var(--radius-ctrl);
  border: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left;
  transition: background 160ms, border-color 160ms;
}
.resort-tab:hover { border-color: var(--gold); }
.resort-tab[aria-selected="true"] { background: var(--deep); border-color: var(--deep); color: #fff; }
.resort-name { font: 600 15px/1.1 var(--font-ui); }
.resort-place { font: 400 12px/1.1 var(--font-ui); opacity: 0.78; }
.resort-tab[aria-selected="true"] .resort-place { opacity: 1; color: #DCE6F7; }

.resort-intro { padding: 18px 22px 6px; }
.resort-title { margin: 0; font: 600 30px/1.02 var(--font-display); letter-spacing: -0.005em; color: var(--text); }
.resort-address { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

.search {
  display: flex; align-items: center; gap: 10px; margin: 14px 16px 10px; padding: 0 14px;
  height: 44px; border-radius: var(--radius-ctrl); background: var(--surface-2); color: var(--muted);
  border: 1px solid transparent;
}
.search:focus-within { border-color: var(--gold); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font: 400 15px var(--font-ui); color: var(--text); }
.search input::placeholder { color: var(--muted); }

.chips { display: flex; gap: 6px; padding: 0 16px 12px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 34px; padding: 0 12px; border-radius: 17px;
  border: 1px solid var(--line); background: transparent; cursor: pointer;
  font-size: 13px; white-space: nowrap; color: var(--text);
}
.chip svg { color: var(--pin, currentColor); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip[aria-pressed="true"] svg { color: inherit; }

.list { list-style: none; margin: 0; padding: 4px 8px 12px; overflow-y: auto; flex: 1; border-top: 1px solid var(--line); }
.list ul { list-style: none; margin: 0; padding: 0; }
.group + .group { margin-top: 6px; }
.group-title {
  display: flex; align-items: center; gap: 8px; margin: 14px 12px 6px;
  font: 600 13px/1 var(--font-ui); color: var(--muted);
}
.group-title svg { color: var(--pin); }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 12px; background: none; cursor: pointer; text-align: left;
}
.item:hover { background: var(--surface-2); }
.item.is-active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--pin); }
.item-badge {
  display: grid; place-items: center; flex: none; min-width: 30px; height: 30px; padding: 0 6px;
  border-radius: 15px; background: var(--pin); color: #fff; font: 600 12px/1 var(--font-ui);
}
.item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-name { font: 500 15px/1.25 var(--font-ui); }
.item-en { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 24px 14px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.panel-foot { padding: 10px 22px 14px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }

/* Ficha */
.detail {
  position: fixed; top: 16px; right: 84px; width: 372px; max-height: calc(100% - 32px);
  display: flex; flex-direction: column; overflow: hidden auto;
  background: var(--surface); border-radius: var(--radius-panel); box-shadow: var(--shadow);
  z-index: 300001;
}
.detail[hidden] { display: none; }
.detail.is-open { animation: card-in 280ms cubic-bezier(.2, .8, .2, 1); }
@keyframes card-in { from { transform: translateY(14px); } }
.detail-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgba(251, 249, 244, 0.92); color: #1C232E; cursor: pointer;
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.35);
}
.detail-media { margin: 0; aspect-ratio: 16 / 10; background: var(--surface-2); overflow: hidden; flex: none; }
.detail-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-body { padding: 18px 22px 22px; }
.detail-head { display: flex; align-items: center; gap: 10px; }
.detail-badge {
  display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 17px;
  background: var(--pin); color: #fff; font: 600 14px/1 var(--font-ui);
}
.detail-cat { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--muted); }
.detail-cat svg { color: var(--pin); }
.detail-name { margin: 12px 0 2px; font: 600 28px/1.05 var(--font-display); }
.detail-en { margin: 0; font-size: 13px; color: var(--muted); }
.detail-desc { margin: 14px 0 0; font-size: 15px; line-height: 1.55; max-width: 60ch; }
.detail-items { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.detail-items li { position: relative; padding-left: 16px; font-size: 14px; line-height: 1.35; }
.detail-items li::before { content: ''; position: absolute; left: 2px; top: 0.5em; width: 6px; height: 6px; border-radius: 50%; background: var(--pin); }
.detail-tags { margin: 14px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.detail-tags li { padding: 5px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; }
.detail-share {
  margin-top: 18px; height: 40px; padding: 0 16px; border-radius: var(--radius-ctrl);
  border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 14px;
}
.detail-share:hover { border-color: var(--gold); }

/* Herramientas */
.tools {
  position: fixed; right: 16px; bottom: 16px; z-index: 300000;
  display: flex; flex-direction: column; gap: 4px; padding: 6px;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow);
}
.tool {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; cursor: pointer; position: relative;
}
.tool svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { background: var(--surface-2); }
.tool[aria-pressed="true"] { background: var(--deep); color: #fff; }
.tool[aria-busy="true"] { opacity: 0.5; }
.tool-label {
  position: absolute; right: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  padding: 6px 10px; border-radius: 8px; background: var(--navy); color: #fff;
  font-size: 13px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 140ms;
}
.tool:hover .tool-label, .tool:focus-visible .tool-label { opacity: 1; }
.tool-sep { height: 1px; margin: 3px 8px; background: var(--line); }

.compass {
  position: fixed; top: 16px; right: 16px; z-index: 300000;
  width: 52px; height: 52px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.compass-needle { width: 34px; height: 34px; position: relative; display: grid; place-items: start center; }
.compass-needle::before {
  content: ''; position: absolute; left: 50%; top: 13px; width: 0; height: 0; transform: translateX(-50%);
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 12px solid #DB2133;
}
.compass-needle span { font: 700 11px/1 var(--font-ui); color: var(--text); }

/* Carga y avisos */
.loader {
  position: fixed; inset: 0; z-index: 400000; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: radial-gradient(120% 90% at 50% 40%, #FBF9F4 0%, #EADFC8 100%);
  opacity: 0; pointer-events: none; transition: opacity 280ms;
}
.loader.is-on { opacity: 1; pointer-events: auto; }
.loader-name { margin: 0; font: 600 26px/1 var(--font-display); color: #062B73; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 400001; max-width: min(520px, calc(100% - 32px));
  padding: 12px 18px; border-radius: 14px; background: var(--navy); color: #fff; font-size: 14px; line-height: 1.4;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity 200ms, transform 200ms;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.noscript { position: fixed; inset: auto 16px 16px; padding: 16px; background: #fff; border-radius: 12px; }

/* Móvil: hoja inferior */
@media (max-width: 760px) {
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 78dvh;
    border-radius: 22px 22px 0 0;
    transform: translateY(calc(78dvh - 236px)); transition: transform 320ms cubic-bezier(.2, .8, .2, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.is-open { transform: none; }
  .sheet-handle {
    display: block; width: 100%; height: 22px; border: 0; background: none; cursor: pointer; flex: none; position: relative;
  }
  .sheet-handle::before { content: ''; position: absolute; left: 50%; top: 9px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line); }
  .panel-head { padding: 2px 16px 10px; }
  .logo { height: 32px; }
  .resorts { padding: 0 16px; }
  .resort-intro { display: none; }
  .search { margin: 12px 16px 8px; }
  .panel-foot { display: none; }
  .detail {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 72dvh;
    border-radius: 22px 22px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .detail-media { aspect-ratio: 16 / 8; }
  .tools { top: 12px; bottom: auto; right: 70px; flex-direction: row; padding: 4px; border-radius: 16px; }
  .tool { width: 40px; height: 40px; }
  .tool-label { display: none; }
  .compass { top: 12px; right: 12px; width: 48px; height: 48px; }
  .pin-badge { min-width: 28px; height: 28px; font-size: 12px; }
  .pin { margin: -38px 0 0 -14px; }
  .pin::after { left: 13px; top: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation: none !important; }
  .pin-badge { transition-delay: 0ms !important; }
}
.chips { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 32px; }
@media (max-width: 760px) {
  .tool[data-tool="zoom-in"], .tool[data-tool="zoom-out"], .tool[data-tool="north"], .tool-sep { display: none; }
}
