/* Travel Tracker styles. Colors are set once at the top, with a second set for dark mode. */
/* Layout: one-screen app shell. Title bar, one screen at a time (map full-bleed, others scroll), tab bar pinned to the bottom. */
:root {
  --ink: #16242b;
  --ink-soft: #52656e;
  --paper: #f3f6f5;
  --panel: #ffffff;
  --line: #d5dfdd;
  --ocean: #bcd9df;
  --land: #e9eee7;
  --border: #9fb2ad;
  --visited: #e08a2e;
  --visited-edge: #a85d12;
  --focus: #1d6f86;
  --route: #1d6f86;
  --gold: #c99412;
  --track: #e3eae8;
  --danger: #b3261e;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e7eef0; --ink-soft: #9fb1b8; --paper: #0f181c; --panel: #172328; --line: #2a3a40;
    --ocean: #0d2a33; --land: #24343a; --border: #47606a; --visited: #f0a14a; --visited-edge: #ffd29c;
    --focus: #6cc3db; --route: #7fd6ee; --gold: #e8b93a; --track: #24343a; --danger: #ff8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e7eef0; --ink-soft: #9fb1b8; --paper: #0f181c; --panel: #172328; --line: #2a3a40;
  --ocean: #0d2a33; --land: #24343a; --border: #47606a; --visited: #f0a14a; --visited-edge: #ffd29c;
  --focus: #6cc3db; --route: #7fd6ee; --gold: #e8b93a; --track: #24343a; --danger: #ff8a80;
  color-scheme: dark;
}

[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  overflow: hidden;
}
.app { height: 100%; display: flex; flex-direction: column; position: relative; }

header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.35rem; letter-spacing: -0.01em; text-wrap: balance; }
.tag {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px;
}

.map-wrap { position: relative; flex: 1; min-height: 0; background: var(--ocean); }
#map { position: absolute; inset: 0; }

/* Minimal styles MapLibre needs (its own stylesheet can't load here) */
.maplibregl-map { position: relative; overflow: hidden; -webkit-tap-highlight-color: transparent; }
.maplibregl-canvas { position: absolute; left: 0; top: 0; }
.maplibregl-canvas-container.maplibregl-interactive { cursor: grab; touch-action: none; }
.maplibregl-canvas-container.maplibregl-interactive:active { cursor: grabbing; }
.maplibregl-ctrl-attrib, .maplibregl-ctrl-logo { display: none; }
.maplibregl-marker { position: absolute; top: 0; left: 0; will-change: transform; }

.controls {
  position: absolute;
  top: 12px;
  right: max(12px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 8px;
}
.controls button {
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-family: var(--display); font-size: 1.35rem; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
}
.controls button.small { font-size: 0.72rem; font-family: var(--body); font-weight: 700; }
button:focus-visible, .btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.status {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px;
  text-align: center; color: var(--ink-soft); pointer-events: none;
}
.map-pop {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font: 14px var(--body); box-shadow: 0 4px 14px rgb(0 0 0 / .18); white-space: nowrap;
}
.map-pop span { color: var(--ink-soft); }

footer {
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap;
}
.stat { display: flex; align-items: baseline; gap: 6px; }
.stat b { font-family: var(--display); font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-soft); }
.key { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 0.85rem; min-width: 0; }
.swatch { width: 14px; height: 14px; border-radius: 3px; background: var(--visited); border: 1px solid var(--visited-edge); flex: none; }
footer .btn { margin-left: auto; }
@media (max-width: 520px) { footer .btn { margin-left: 0; width: 100%; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: 10px; cursor: pointer;
  font: 700 0.9rem var(--body); border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
.btn.primary { background: var(--focus); border-color: var(--focus); color: var(--panel); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: var(--panel); }
.btn svg { width: 18px; height: 18px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Screens */
main { position: relative; flex: 1; min-height: 0; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
.screen[hidden] { display: none !important; }
.scroll {
  overflow-y: auto; height: 100%;
  padding-block: 20px 28px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.stack { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.note { margin: 0; color: var(--ink-soft); font-size: 0.85rem; }
.banner { background: var(--track); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner p { margin: 0; min-width: 0; flex: 1 1 220px; }
h2 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
h3 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 0.95rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.bar { height: 10px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--visited); border-radius: inherit; }
.level-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.level-row b { font-family: var(--display); font-size: 1.6rem; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.stats b { font-family: var(--display); font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stats span { color: var(--ink-soft); font-size: 0.85rem; }
.rows { display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 0; list-style: none; }
.rows li { display: flex; flex-direction: column; gap: 6px; }
.rows .top { display: flex; justify-content: space-between; gap: 12px; }
.rows .top span:last-child { color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.trips { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.trips li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.trips li:first-child { border-top: 0; padding-top: 0; }
.trips .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trips .name { font-weight: 700; overflow-wrap: anywhere; }
.trips .meta { color: var(--ink-soft); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.chip { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; color: var(--ink-soft); white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-soft); cursor: pointer; display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 18px; height: 18px; }
.empty { color: var(--ink-soft); font-size: 0.9rem; margin: 0; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.badge { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.badge .medal { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--track); color: var(--ink-soft); }
.badge .medal svg { width: 22px; height: 22px; }
.badge.unlocked .medal { background: var(--gold); color: #fff; }
.badge strong { font-family: var(--display); font-weight: 600; }
.badge p { margin: 0; color: var(--ink-soft); font-size: 0.85rem; }
.badge .state { font-size: 0.8rem; color: var(--ink-soft); }
.badge.unlocked .state { color: var(--ink); font-weight: 700; }
.badge .progress { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.badge .progress .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.badge .pct { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; }
.badge .bar { height: 8px; }
.badge.unlocked .bar > span { background: var(--gold); }

.profile { display: flex; flex-direction: row; align-items: center; gap: 14px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--track); display: grid; place-items: center; color: var(--ink-soft); flex: none; }
.avatar svg { width: 26px; height: 26px; }
.settings { margin: 0; padding: 0; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.settings li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); }
.settings li:first-child { border-top: 0; }
.settings li span:last-child { color: var(--ink-soft); font-size: 0.85rem; text-align: right; }
.later { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; color: var(--ink-soft); white-space: nowrap; }

/* Toast and drop overlay */
.toast {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 5;
  max-width: min(92%, 520px); background: var(--ink); color: var(--panel);
  padding: 10px 16px; border-radius: 12px; font-size: 0.9rem; box-shadow: 0 6px 20px rgb(0 0 0 / .25);
}
.drop {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--paper) 85%, transparent);
  border: 3px dashed var(--focus); font: 700 1.3rem var(--display); color: var(--ink); text-align: center;
}

/* Tab bar */
nav.tabs {
  background: var(--panel); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
nav.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px 10px; color: var(--ink-soft); text-decoration: none; font-size: 0.75rem; font-weight: 700;
  border-top: 3px solid transparent;
}
nav.tabs a[aria-current="page"] { color: var(--ink); border-top-color: var(--visited); }
nav.tabs a:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
nav.tabs svg { width: 24px; height: 24px; }
