/* theme-pill.1.css - the header theme pill (assets/theme.3.js builds it) and its menu. Linked after /styles.css (and after
   theme-scene.1.css where a page has the footer card). Design note: P:\live-it-up-data\deploy\theme-header-pill-1119\design.md.
   The pill's three layers carry the footer card's classes (.scene-dark, .scene-lights) and follow :root[data-scene], which
   theme-control.1.js sets at t=0 of every change, so the pill and the card move on ONE clock; the same classes keep them out of
   theme-scene.1.css's theme-swap suspension. The layer rules are repeated here, scoped to .tp-scene and with the footer's numbers (a test
   pins them equal), so the pill also works on a page without the card (privacy, terms): there data-scene is never set and the scene follows
   data-theme and the system exactly as the colour tokens do. Only opacity, transform, border-color and box-shadow animate. Never transition: all. */
.tp-wrap { position: relative; display: inline-flex; flex: 0 0 auto; margin: 0 0 0 8px; }
.tp-pill {
  position: relative; display: block; flex: 0 0 auto; box-sizing: border-box;
  width: 88px; height: 36px; margin: 0; padding: 0;
  border: 1px solid var(--border-control); /* 3:1 against the header in both themes: 4.09 dark, 3.35 light */
  border-radius: 999px; background: var(--background-primary); color: var(--text-secondary);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
/* The 44 px hit area without a layout change: an absolutely placed ::after reaches 4 px above and below the 36 px border box. */
.tp-pill::after { content: ""; position: absolute; left: -1px; right: -1px; top: -5px; bottom: -5px; border-radius: 999px; }
.tp-scene { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; }
.tp-scene svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* The layers: day is the base, night fades over it, the lights are a third layer. */
.tp-scene .scene-dark, .tp-scene .scene-lights { opacity: 1; }
:root[data-scene="light"] .tp-scene .scene-dark, :root[data-scene="light"] .tp-scene .scene-lights { opacity: 0; }
/* No data-scene (before the deferred card script has run, or on a page without it): the scene follows the theme as the tokens do. */
:root:not([data-scene])[data-theme="light"] .tp-scene .scene-dark,
:root:not([data-scene])[data-theme="light"] .tp-scene .scene-lights { opacity: 0; }
@media (prefers-color-scheme: light) {
  :root:not([data-scene]):not([data-theme="dark"]) .tp-scene .scene-dark,
  :root:not([data-scene]):not([data-theme="dark"]) .tp-scene .scene-lights { opacity: 0; }
}

/* System mark: a 14 px chip on the pill's top-right corner (over the corner's empty arc, never a lamp) with the half-filled circle the
   old header button showed. Only while System is the choice. */
.tp-sys { position: absolute; top: -5px; right: -5px; display: none; place-items: center; width: 14px; height: 14px; box-sizing: border-box;
  border: 1px solid var(--border-control); border-radius: 50%; background: var(--background-card); color: var(--text-primary); pointer-events: none; }
.tp-pill[data-choice="system"] .tp-sys { display: grid; }
.tp-sys-glyph { width: 8px; height: 8px; box-sizing: border-box; border: 1.5px solid currentColor; border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
@media (hover: hover) { .tp-pill:hover { border-color: var(--text-secondary); } }
/* pressed: the site-wide button:active { opacity: 0.8 } (styles.css) applies; nothing changes size */
.tp-wrap.is-open .tp-pill { border-color: var(--accent-line); box-shadow: 0 0 0 1px var(--accent-line); }
/* keyboard focus only: the shared ring, keeping the pill's shape (the shared rule's border-radius: 4px would square it) */
.tp-pill:focus-visible { outline: 2px solid var(--border-focused); outline-offset: 2px; border-radius: 999px; }
.tp-pill.via-pointer:focus-visible, .tp-item.via-pointer:focus-visible { outline-color: transparent; }

/* The menu: under the pill, right edges aligned, so it never leaves the viewport on a phone. */
.tp-menu { position: absolute; top: calc(100% + 10px); right: 0; z-index: 110; min-width: 188px; box-sizing: border-box; padding: 4px;
  background: var(--background-card); border: 1px solid var(--border-default); border-radius: 12px; box-shadow: 0 12px 32px var(--web-shadowPop);
  opacity: 0; transform: translateY(-4px) scale(0.97); transform-origin: top right; text-align: left; }
.tp-menu[hidden] { display: none; }
.tp-wrap.is-open .tp-menu { opacity: 1; transform: none; }
.tp-wrap.menu-start .tp-menu { right: auto; left: 0; transform-origin: top left; }
.tp-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; margin: 0; padding: 0 12px 0 10px; box-sizing: border-box;
  border: 0; border-radius: 8px; background: transparent; color: var(--text-primary); font-size: 15px; font-weight: 500; line-height: 1.2;
  text-align: left; cursor: pointer; white-space: nowrap; }
@media (max-width: 767px), (pointer: coarse) { .tp-item { min-height: 48px; } }
.tp-item[aria-checked="true"] { font-weight: 700; }
.tp-check { position: relative; width: 16px; height: 16px; flex: 0 0 auto; }
.tp-item[aria-checked="true"] .tp-check::before { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px;
  border: solid var(--accent-light); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.tp-now { margin-left: auto; padding-left: 12px; font-size: 13px; font-weight: 400; color: var(--text-secondary); }
@media (hover: hover) { .tp-item:hover { background: var(--background-cardElevated); } }
.tp-item:active { background: var(--background-secondary); }
.tp-item:focus-visible { outline: 2px solid var(--border-focused); outline-offset: -2px; border-radius: 8px; }

@media (max-width: 479px) {
  .tp-wrap { margin-left: 2px; }
  .tp-pill { width: 56px; } /* the drawing is cut to its middle (xMidYMid slice): the truss, the four lamps, the band */
}
/* Under 360 px the pill is 20 px wider than the old 36 px button: the link before it moves closer, so the header keeps its rows. */
@media (max-width: 359px) {
  .glass-header .nav-links.has-pill { column-gap: 10px; }
  .glass-header .tp-wrap { margin-left: 0; }
  .map-body .glass-header .nav-links.has-pill { column-gap: 4px; } /* /map: wordmark, Get the app and the pill on one row at 320 px */
}

@media (prefers-reduced-motion: no-preference) {
  /* the footer's clock (theme-scene.1.css): night 360 ms in-out at t=0; the lights 140 ms after 360 ms on, 60 ms linear off */
  .tp-scene .scene-dark { transition: opacity 360ms cubic-bezier(0.77, 0, 0.175, 1); }
  .tp-scene .scene-lights { transition: opacity 140ms cubic-bezier(0.22, 1, 0.36, 1) 360ms; }
  :root[data-scene="light"] .tp-scene .scene-lights,
  :root:not([data-scene])[data-theme="light"] .tp-scene .scene-lights { transition: opacity 60ms linear; }
  /* the menu: 160 ms in, 100 ms out, transform and opacity only */
  .tp-menu { transition: opacity 100ms cubic-bezier(0.22, 1, 0.36, 1), transform 100ms cubic-bezier(0.22, 1, 0.36, 1); }
  .tp-wrap.is-open .tp-menu { transition-duration: 160ms; }
  .tp-pill { transition: border-color 150ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 150ms cubic-bezier(0.22, 1, 0.36, 1); }
}
@media (prefers-reduced-motion: no-preference) and (prefers-color-scheme: light) {
  :root:not([data-scene]):not([data-theme="dark"]) .tp-scene .scene-lights { transition: opacity 60ms linear; }
}
