/* ============================================================================
 * LocalLights — the sleigh picker, your marker, and everyone else's.
 *
 * Tokens come from css/style.css. Layout here is self-contained so the picker
 * stands up even if the shared .bsheet rules land later or move.
 * ========================================================================= */

/* ------------------------------------------------------------- picker --- */

.sl-picker {
  position: fixed; inset: 0;
  z-index: 95;                      /* over the dock and the map, under toasts */
  overscroll-behavior: contain;
}
.sl-scrim {
  position: absolute; inset: 0;
  background: var(--scrim);
  opacity: 0;
  transition: opacity .22s ease;
}
.sl-picker.is-open .sl-scrim { opacity: 1; }

/* The shared .bsheet does the panel; this is the modal flavour of it: taller,
   driven in and out through its own --bsheet-y, and the essentials restated so
   the picker still stands if that rule set moves. */
.sl-picker .bsheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-height: min(92dvh, 720px);
  background: var(--night-2);
  color: var(--text);
  transform: translateY(var(--bsheet-y, 0px));
  transition: transform .28s cubic-bezier(.2, .8, .3, 1);
  --bsheet-y: calc(100% + 40px);
}
.sl-picker.is-open .bsheet { --bsheet-y: 0px; }
@media (min-width: 760px) {
  .sl-picker .bsheet {
    left: 50%; right: auto; bottom: 4vh;
    width: min(560px, 94vw);
    border-radius: 22px;
    border-bottom: 1px solid var(--line);
    transform: translate(-50%, var(--bsheet-y, 0px));
  }
}
@media (prefers-reduced-motion: reduce) {
  .sl-picker .bsheet, .sl-scrim { transition: none; }
}
.sl-picker .bsheet-body { padding-top: 2px; }

.sl-title {
  margin: 4px 0 2px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -.01em;
  color: var(--text);
}
.sl-sub {
  margin: 0 0 14px;
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.4;
}
.sl-keeping {
  margin: -6px 0 12px;
  color: var(--text-3);
  font-size: 13.5px;
}
.sl-keeping strong { color: var(--amber); font-weight: 600; }

/* The tiles: big, square-ish, one tap. Three across on a phone. */
.sl-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}
.sl-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  min-height: 112px;
  padding: 12px 6px 10px;
  background: var(--night-3);
  color: var(--text-2);
  border: 2px solid var(--line);
  border-radius: 16px;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.sl-tile .sl-art {
  display: block;
  width: 64px; height: 64px;
  color: var(--amber);
  filter: drop-shadow(0 0 6px var(--glow));
  transition: transform .15s ease;
}
.sl-tile-label {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  color: var(--text-2);
}
.sl-tile:active { transform: scale(.97); }
@media (hover: hover) { .sl-tile:hover { border-color: var(--text-3); } }
.sl-tile:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.sl-tile.is-current {
  border-color: var(--amber);
  background: var(--amber-soft);
  box-shadow: var(--glow-ring);
}
.sl-tile.is-current .sl-tile-label { color: var(--text); }
.sl-tile.is-current .sl-art { transform: scale(1.06); }
.sl-tile.is-secret { border-style: dashed; }
.sl-chip {
  position: absolute; top: 6px; right: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--amber-2);
  color: var(--night);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* The presence switch and its one honest line. */
.sl-toggle {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px;
  padding: 6px 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sl-toggle-text { font-size: 16px; font-weight: 600; color: var(--text); }
.sl-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.sl-switch {
  flex: 0 0 auto;
  position: relative;
  width: 52px; height: 32px;
  border-radius: 16px;
  background: var(--line);
  transition: background .18s ease;
}
.sl-switch::after {
  content: '';
  position: absolute; top: 4px; left: 4px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--text);
  transition: transform .18s ease, background .18s ease;
}
.sl-toggle input:checked + .sl-switch { background: var(--amber); box-shadow: 0 0 12px var(--glow); }
.sl-toggle input:checked + .sl-switch::after { transform: translateX(20px); background: var(--night); }
.sl-toggle input:focus-visible + .sl-switch { outline: 3px solid var(--amber); outline-offset: 2px; }
.sl-honest {
  margin: 0 0 14px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.4;
}
.sl-done { margin-top: 2px; }

/* The map should not scroll under an open picker. */
body.sl-picker-open { overflow: hidden; }

/* ------------------------------------------------------------- marker --- */

/* Leaflet puts its own white box on a divIcon; the sleigh is the whole icon. */
.sl-marker, .sl-other {
  background: transparent;
  border: 0;
  margin: 0;
}
.sl-art { display: block; width: 100%; height: 100%; line-height: 0; }
.sl-art svg { display: block; width: 100%; height: 100%; overflow: visible; color: inherit; }

/* The body turns by --h, a compass heading (0 = north), set on the marker
   element by LL.sleigh.setHeading or by whoever owns the marker. The art in
   the file faces east, so it is turned to north once inside; with no heading
   at all a sleigh just faces east, the way it was drawn. .is-flip (set by
   setHeading past 180) mirrors the art first so a westbound sleigh is not
   upside down. The tour screen may also write rotate(deg) straight onto the
   body; that reads the same way. */
.sl-marker-body {
  width: 36px; height: 36px;
  color: var(--amber);
  filter: drop-shadow(0 0 7px var(--glow)) drop-shadow(0 1px 1px rgba(0, 0, 0, .5));
  transform: rotate(var(--h, 90deg));
  transform-origin: 50% 50%;
  transition: transform .25s ease;
  will-change: transform;
}
.sl-marker-body .sl-art { transform: rotate(-90deg); }
.is-flip .sl-marker-body .sl-art { transform: rotate(90deg) scaleX(-1); }

/* Everyone else: smaller, quieter, no name, no tap. A move glides. */
.sl-other {
  opacity: .7;
  pointer-events: none;
  transition: transform .9s ease-in-out, opacity .3s ease;
}
.sl-other .sl-marker-body {
  width: 24px; height: 24px;
  filter: drop-shadow(0 0 4px var(--glow));
}
/* Leaflet repositions every marker itself during a zoom; do not ease that. */
.leaflet-zoom-anim .sl-other,
.leaflet-touching .sl-other { transition: none; }

@media (prefers-reduced-motion: reduce) {
  .sl-other, .sl-marker-body, .sl-tile, .sl-tile .sl-art, .sl-switch, .sl-switch::after { transition: none; }
}
