/* Outdoor Tracker web UI. Values come from tokens.css (generated from design/tokens). */

@font-face {
  font-family: 'InterVariable';
  src: url('/static/fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* CSS display rules must never resurrect [hidden] elements. */
[hidden] { display: none !important; }
body {
  min-height: 100dvh;
  background: var(--color-bg-base);
  color: var(--color-text-primary);
  font-family: 'InterVariable', var(--type-family-ui);
  font-size: var(--type-size-md);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.page-live { overflow: hidden; }
a { color: inherit; }
button { font: inherit; }
code { font-family: var(--type-family-mono); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--color-text-muted); }
:focus-visible { outline: 2px solid var(--color-accent-outdoor); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(88, 179, 104, 0.35); }

/* Per-activity accent hook: sets both color and the --acc custom property. */
.accent-hike    { --acc: var(--color-accent-hike);    color: var(--acc); }
.accent-walk    { --acc: var(--color-accent-walk);    color: var(--acc); }
.accent-run     { --acc: var(--color-accent-run);     color: var(--acc); }
.accent-ride    { --acc: var(--color-accent-ride);    color: var(--acc); }
.accent-drive   { --acc: var(--color-accent-drive);   color: var(--acc); }
.accent-outdoor { --acc: var(--color-accent-outdoor); color: var(--acc); }

/* ---- top bar ---------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--space-4) var(--space-3);
  background: var(--color-bg-raised);
  border-bottom: 1px solid var(--color-line-subtle);
  position: sticky; top: 0; z-index: 30;
}
.topbar--overlay {
  position: fixed; inset: 0 0 auto 0;
  background: color-mix(in srgb, var(--color-bg-base) 78%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--color-line-subtle) 60%, transparent);
}
.brand { display: flex; align-items: center; gap: var(--space-2); text-decoration: none; }
.brand__mark { width: 26px; height: 26px; }
.brand__name {
  font-size: var(--type-size-sm); font-weight: 680;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.navlinks { display: flex; align-items: center; gap: var(--space-4); }
.navlinks a {
  text-decoration: none; color: var(--color-text-secondary);
  font-size: var(--type-size-sm); font-weight: 560;
}
.navlinks a:hover { color: var(--color-text-primary); }
.navlinks a.is-active { color: var(--color-text-primary); font-weight: 680; }
.linkbtn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--color-text-muted); font-size: var(--type-size-sm);
}
.linkbtn:hover { color: var(--color-text-secondary); }

/* ---- map -------------------------------------------------------------- */
/* Double class: maplibre-gl.css loads after app.css and sets
   .maplibregl-map { position: relative } — we must out-rank it. */
.map.map--full { position: fixed; inset: 0; z-index: 0; background: #10161B; }
.mapwrap { position: relative; }
.map--detail {
  height: min(46vh, 420px);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-line-subtle);
  background: #10161B;
}
.maplibregl-ctrl-attrib {
  background: rgba(12, 16, 19, 0.65) !important;
  color: var(--color-text-muted);
  font-size: 10px;
}
.maplibregl-ctrl-attrib a { color: var(--color-text-secondary); }

.map-notice {
  position: fixed;
  top: calc(66px + env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100vw - 32px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--color-state-stale) 16%, var(--color-bg-raised));
  color: var(--color-state-stale);
  border: 1px solid color-mix(in srgb, var(--color-state-stale) 40%, transparent);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--type-size-xs); font-weight: 620; letter-spacing: 0.03em;
}
.map-notice--inmap { position: absolute; top: var(--space-3); }

/* position marker (MapLibre custom element) */
.mk {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--mk-accent, var(--color-accent-outdoor));
  border: 3px solid #fff;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
  position: relative;
}
.mk--stale { filter: saturate(0.35) brightness(0.85); }
.mk--idle { border-color: rgba(255, 255, 255, 0.85); }
.mk--live::after {
  content: '';
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--mk-accent, var(--color-accent-outdoor));
  animation: mkpulse 2.2s ease-out infinite;
}
@keyframes mkpulse {
  0% { transform: scale(1); opacity: 0.9; }
  70% { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* ---- live stats bar ----------------------------------------------------- */
.statsbar {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  width: min(560px, calc(100vw - 2 * var(--space-4)));
  z-index: 25;
  background: color-mix(in srgb, var(--color-bg-raised) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-line-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.statsbar__head { display: flex; align-items: center; gap: var(--space-3); min-height: 30px; }
.typebadge {
  display: inline-flex; align-items: center; gap: 7px;
  font-weight: 660; text-transform: capitalize;
}
.typebadge__icon { display: inline-flex; width: 20px; height: 20px; }
.typebadge__icon svg { width: 100%; height: 100%; }
.typebadge--lg { font-size: var(--type-size-lg); }
.typebadge--lg .typebadge__icon { width: 24px; height: 24px; }
.elapsed { margin-left: auto; font-size: var(--type-size-xl); font-weight: 660; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 740; letter-spacing: 0.08em;
  padding: 3px 10px; border-radius: var(--radius-pill);
  white-space: nowrap;
}
.chip--live  { color: var(--color-state-live);  background: color-mix(in srgb, var(--color-state-live) 14%, transparent); }
.chip--stale { color: var(--color-state-stale); background: color-mix(in srgb, var(--color-state-stale) 14%, transparent); }
.chip--idle  {
  color: var(--color-text-secondary); background: var(--color-bg-overlay);
  font-weight: 600; letter-spacing: 0.04em;
}
.chip--sm { font-size: 9.5px; padding: 2px 7px; }
.chip__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: chipblink 2s ease-in-out infinite; }
.chip--stale .chip__dot { animation: none; }
@keyframes chipblink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.stalenote { margin-top: var(--space-2); font-size: var(--type-size-sm); color: var(--color-state-stale); }

.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); margin-top: var(--space-3); }
.statgrid--detail {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  background: var(--color-bg-raised);
  border: 1px solid var(--color-line-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-top: var(--space-4);
}
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat__label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--color-text-muted);
}
.stat__value { font-size: var(--type-size-lg); font-weight: 660; white-space: nowrap; }
.stat__sub { font-size: var(--type-size-xs); color: var(--color-text-muted); white-space: nowrap; }

/* ---- floating bits ------------------------------------------------------ */
.recenter {
  position: fixed;
  right: var(--space-4);
  bottom: calc(168px + env(safe-area-inset-bottom));
  z-index: 25;
  background: color-mix(in srgb, var(--color-bg-raised) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--color-text-primary);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-size: var(--type-size-sm); font-weight: 640;
  cursor: pointer;
}
.conn {
  position: fixed;
  top: calc(66px + env(safe-area-inset-top));
  right: var(--space-4);
  z-index: 20;
  font-size: var(--type-size-xs);
  color: var(--color-text-muted);
  background: var(--color-bg-overlay);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

/* ---- empty state (live) ------------------------------------------------- */
.empty { position: fixed; inset: 0; display: grid; place-items: center; z-index: 5; }
.empty__inner { text-align: center; color: var(--color-text-secondary); padding: var(--space-5); }
.empty__inner svg { width: 56px; height: 56px; margin-bottom: var(--space-3); }
.empty__inner h2 { margin: 0 0 var(--space-2); font-size: var(--type-size-xl); font-weight: 680; color: var(--color-text-primary); }
.empty__inner p { margin: 0; font-size: var(--type-size-sm); }

/* ---- auth pages ---------------------------------------------------------- */
.page-auth {
  display: grid; place-items: center;
  min-height: 100dvh;
  padding: var(--space-4);
  background: radial-gradient(1100px 700px at 72% -12%, #15212B 0%, var(--color-bg-base) 58%);
}
.auth { width: 100%; display: grid; place-items: center; }
.auth__card {
  width: min(400px, 100%);
  background: var(--color-bg-raised);
  border: 1px solid var(--color-line-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-3);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}
.auth__mark { width: 56px; height: 56px; margin: 0 auto var(--space-1); }
.auth__title { margin: 0; text-align: center; font-size: var(--type-size-xl); font-weight: 720; letter-spacing: 0.01em; }
.auth__sub { margin: 0 0 var(--space-2); text-align: center; color: var(--color-text-secondary); font-size: var(--type-size-sm); }
.auth__error { margin: 0; color: var(--color-state-danger); font-size: var(--type-size-sm); text-align: center; }
.auth__foot { margin: var(--space-2) 0 0; text-align: center; color: var(--color-text-muted); font-size: var(--type-size-xs); }
.auth__foot a { color: var(--color-text-secondary); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: var(--type-size-xs); font-weight: 660; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--color-text-secondary);
}
.field__hint { text-transform: none; letter-spacing: 0; color: var(--color-text-muted); font-weight: 500; }
.field__input {
  background: var(--color-bg-base);
  color: var(--color-text-primary);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: var(--type-size-md);
  width: 100%;
}
.field__input::placeholder { color: var(--color-text-muted); }
.field__input:focus {
  outline: none;
  border-color: var(--color-accent-outdoor);
  box-shadow: 0 0 0 3px rgba(88, 179, 104, 0.18);
}

.btn {
  border: none; cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-weight: 660; font-size: var(--type-size-sm);
  background: var(--color-bg-overlay);
  color: var(--color-text-primary);
  white-space: nowrap;
}
.btn--primary { background: var(--color-accent-outdoor); color: #08110B; }
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; border: 1px solid var(--color-line-strong); }
.btn--ghost:hover { border-color: var(--color-text-muted); }
.btn--danger { background: transparent; border: 1px solid transparent; color: var(--color-state-danger); }
.btn--danger:hover { border-color: color-mix(in srgb, var(--color-state-danger) 45%, transparent); }
.btn--full { width: 100%; padding: 12px; }
.btn--sm { padding: 5px 10px; font-size: var(--type-size-xs); }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ---- scrolling pages ------------------------------------------------------ */
.page { max-width: 680px; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-7); }
.page__title { font-size: var(--type-size-xxl); font-weight: 720; letter-spacing: -0.01em; margin: var(--space-3) 0 var(--space-4); }
.backlink { margin: 0 0 var(--space-2); }
.backlink a { color: var(--color-text-muted); text-decoration: none; font-size: var(--type-size-sm); }
.backlink a:hover { color: var(--color-text-secondary); }
.pageempty { color: var(--color-text-muted); text-align: center; padding: var(--space-6) 0; }
.prose p { color: var(--color-text-secondary); line-height: 1.6; margin: 0 0 var(--space-4); }
.prose strong { color: var(--color-text-primary); }

/* ---- history cards --------------------------------------------------------- */
.cards { display: flex; flex-direction: column; gap: var(--space-3); }
.card {
  display: flex; align-items: center; gap: var(--space-4);
  background: var(--color-bg-raised);
  border: 1px solid var(--color-line-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-decoration: none; color: inherit;
  transition: border-color 0.15s ease;
}
.card:hover { border-color: var(--color-line-strong); }
.card__icon {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 12px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--acc, var(--color-accent-outdoor)) 14%, transparent);
  color: var(--acc, var(--color-accent-outdoor));
}
.card__icon svg { width: 22px; height: 22px; }
.card__main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card__title { font-weight: 660; color: var(--color-text-primary); display: flex; gap: 8px; align-items: center; }
.card__stats {
  color: var(--color-text-secondary); font-size: var(--type-size-sm);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card__chev { margin-left: auto; color: var(--color-text-muted); font-size: 22px; line-height: 1; }
.card--skeleton {
  height: 76px;
  border: 1px solid var(--color-line-subtle);
  background: linear-gradient(100deg, var(--color-bg-raised) 40%, var(--color-bg-overlay) 50%, var(--color-bg-raised) 60%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
}
@keyframes skel { 0% { background-position: 120% 0; } 100% { background-position: -80% 0; } }

/* ---- detail ----------------------------------------------------------------- */
.detailhead { margin-bottom: var(--space-4); }
.detailhead .page__title { margin: var(--space-2) 0 2px; }
.detailhead__sub { margin: 0; color: var(--color-text-secondary); font-size: var(--type-size-sm); }
.detailhead__sub a { color: var(--color-state-live); text-decoration: none; }

/* ---- admin -------------------------------------------------------------------- */
.adminsec { margin: var(--space-6) 0; }
.adminsec__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-3); flex-wrap: wrap;
}
.adminsec__head h2 { font-size: var(--type-size-lg); font-weight: 680; margin: 0; }
.inlineform { display: flex; gap: var(--space-2); }
.inlineform .field__input { width: 180px; }
.rows {
  display: flex; flex-direction: column;
  border: 1px solid var(--color-line-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.rows:empty { display: none; }
.row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-raised);
  font-size: var(--type-size-sm);
}
.row + .row { border-top: 1px solid var(--color-line-subtle); }
.row__main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__meta { margin-left: auto; color: var(--color-text-muted); font-size: var(--type-size-xs); white-space: nowrap; }
.rowchip {
  font-size: 10px; font-weight: 720; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: var(--radius-pill);
  background: var(--color-bg-overlay); color: var(--color-text-secondary);
}
.rowchip--ok { color: var(--color-state-live); background: color-mix(in srgb, var(--color-state-live) 12%, transparent); }
.rowchip--dead { color: var(--color-state-danger); background: color-mix(in srgb, var(--color-state-danger) 12%, transparent); }
.rowchip--used { color: var(--color-text-muted); }
.freshbox {
  background: color-mix(in srgb, var(--color-state-live) 8%, var(--color-bg-raised));
  border: 1px solid color-mix(in srgb, var(--color-state-live) 32%, transparent);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
}
.freshbox--warn {
  background: color-mix(in srgb, var(--color-state-stale) 9%, var(--color-bg-raised));
  border-color: color-mix(in srgb, var(--color-state-stale) 36%, transparent);
}
.freshbox__label { margin: 0 0 6px; font-size: var(--type-size-xs); color: var(--color-text-secondary); }
.freshbox__row { display: flex; gap: var(--space-2); align-items: center; }
.freshbox__code {
  font-size: 12px;
  background: var(--color-bg-base);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  overflow-x: auto; white-space: nowrap;
  flex: 1;
}

/* ---- responsive / motion -------------------------------------------------------- */
@media (max-width: 430px) {
  .brand__name { display: none; }
  .navlinks { gap: var(--space-3); }
  .elapsed { font-size: var(--type-size-lg); }
  .stat__value { font-size: var(--type-size-md); }
  .inlineform { width: 100%; }
  .inlineform .field__input { flex: 1; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .mk--live::after, .chip__dot, .card--skeleton { animation: none; }
}
