/* Catppuccin Mocha palette mapped to Material 3 system tokens.
   Defaults: Mocha flavour, Lavender accent (per the project's standing theme
   convention). Screens paint with --ctp-accent, never the palette name, so
   lib/theme.ts can re-point every colour at runtime when the user picks
   another flavour/accent on the Settings screen — this file keeps the app
   styled before that module runs. Shared by every screen; loaded once from
   index.html. */
:root {
  /* Catppuccin Mocha core */
  --ctp-base:     #1e1e2e;
  --ctp-mantle:   #181825;
  --ctp-crust:    #11111b;
  --ctp-text:     #cdd6f4;
  --ctp-subtext1: #bac2de;
  --ctp-subtext0: #a6adc8;
  --ctp-surface0: #313244;
  --ctp-surface1: #45475a;
  --ctp-surface2: #585b70;
  --ctp-overlay0: #6c7086;
  --ctp-overlay1: #7f849c;

  /* Accents */
  --ctp-lavender: #b4befe;
  --ctp-mauve:    #cba6f7;
  --ctp-green:    #a6e3a1;  /* success/status */
  --ctp-peach:    #fab387;  /* warning / highlight */
  --ctp-red:      #f38ba8;  /* error */
  --ctp-yellow:   #f9e2af;

  /* Themeable accent (Material 3 primary / active tab): what every screen
     paints with. Defaults to the flavour's lavender; lib/theme.ts overwrites
     it when the user picks another accent. */
  --ctp-accent: var(--ctp-lavender);

  /* Basemap tints consumed by map-glue.js when it recolours openfreemap. */
  --ctp-water: #1b1d2e;
  --ctp-park:  #1c2826;

  /* MapLibre control icons are dark SVGs: inverted on the dark flavours,
     untouched on Latte (set by lib/theme.ts). */
  --map-invert: invert(0.85);

  /* Material 3 system tokens mapped to Mocha */
  --md-sys-color-background:    var(--ctp-base);
  --md-sys-color-on-background: var(--ctp-text);
  --md-sys-color-surface:        var(--ctp-surface0);
  --md-sys-color-surface-variant: var(--ctp-surface1);
  --md-sys-color-on-surface:     var(--ctp-text);
  --md-sys-color-on-surface-variant: var(--ctp-subtext0);
  --md-sys-color-primary:        var(--ctp-accent);
  --md-sys-color-on-primary:     var(--ctp-crust);
  --md-sys-color-secondary:      var(--ctp-mauve);
  --md-sys-color-on-secondary:   var(--ctp-crust);
  --md-sys-color-tertiary:       var(--ctp-peach);
  --md-sys-color-on-tertiary:    var(--ctp-crust);
  --md-sys-color-error:          var(--ctp-red);
  --md-sys-color-on-error:       var(--ctp-crust);
  --md-sys-color-outline:        var(--ctp-surface2);
  --md-sys-color-outline-variant: var(--ctp-surface1);
  --md-sys-color-shadow:         #000000;

  --radius: 14px;
  --radius-sm: 12px;
  --radius-lg: 16px;

  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Safe-area insets. The app runs edge-to-edge on Android (targetSdk 36, and
     MainActivity calls enableEdgeToEdge), so the WebView paints under the
     status and navigation bars and forwards their sizes through the CSS env
     vars (WebView 136+). Every positional rule reads these two variables, so
     overriding them (or CDP Emulation.setSafeAreaInsetsOverride) simulates a
     device. Both are 0px on desktop, and when nothing overlaps. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

button { font-family: inherit; }

/* Very little text, generous whitespace, rounded cards, no heavy shadows. */
.card {
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.05rem;
}

/* Bottom tab bar. The translucent surfaces below keep a plain rgba()
   fallback (the Mocha value) first: where color-mix is unavailable the
   theme simply stays Mocha-tinted instead of going transparent. */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 72px;
  display: flex; align-items: center; justify-content: space-around;
  background: rgba(30, 30, 46, 0.92);
  background: color-mix(in srgb, var(--ctp-base) 92%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-top: 1px solid var(--ctp-surface1);
  padding-bottom: var(--safe-bottom);
  z-index: 100;
}
.bottom-nav a, .bottom-nav button.tab {
  color: var(--ctp-subtext0);
  text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.01em;
  background: none; border: none; cursor: pointer; padding: 0;
}
.bottom-nav a.active, .bottom-nav button.tab.active { color: var(--ctp-accent); }

/* Input tokens */
input, textarea, select {
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  font-family: inherit; font-size: 0.95rem;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--ctp-accent); }
input::placeholder { color: var(--ctp-overlay0); }

/* Map: MapLibre controls, user dot and restaurant pins, in the active theme. */
.maplibregl-ctrl-group {
  background: rgba(30, 30, 46, 0.9) !important;
  background: color-mix(in srgb, var(--ctp-base) 90%, transparent) !important;
  border: 1px solid var(--ctp-surface1);
  border-radius: var(--radius-sm) !important;
  box-shadow: none !important;
  overflow: hidden;
}
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--ctp-surface1) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: var(--map-invert); }
.maplibregl-ctrl-attrib {
  background: rgba(30, 30, 46, 0.8) !important;
  background: color-mix(in srgb, var(--ctp-base) 80%, transparent) !important;
  color: var(--ctp-overlay1);
  font-size: 0.65rem;
}
.maplibregl-ctrl-attrib a { color: var(--ctp-subtext0) !important; }
.maplibregl-ctrl-attrib-button { filter: var(--map-invert); }

.winnie-me { position: relative; width: 18px; height: 18px; }
.winnie-me-dot {
  position: absolute; inset: 3px;
  background: var(--ctp-accent);
  border: 2px solid var(--ctp-base);
  border-radius: 50%;
}
.winnie-me-pulse {
  position: absolute; inset: -8px;
  border-radius: 50%;
  background: rgba(180, 190, 254, 0.25);
  background: color-mix(in srgb, var(--ctp-accent) 25%, transparent);
  animation: winnie-pulse 2.4s ease-out infinite;
}
@keyframes winnie-pulse {
  from { transform: scale(0.4); opacity: 1; }
  to   { transform: scale(1.4); opacity: 0; }
}

.winnie-pin {
  position: relative;
  width: 14px; height: 14px;
  padding: 0;
  background: var(--ctp-peach);
  border: 2px solid var(--ctp-base);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(250, 179, 135, 0.25);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ctp-peach) 25%, transparent);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.winnie-pin:hover { transform: scale(1.35); }
/* Opening state returned by GET /nearby: green = confirmed open, grey =
   confirmed closed (only visible with the "Open now" filter off). */
.winnie-pin.is-open { background: var(--ctp-green); box-shadow: 0 0 0 3px rgba(166, 227, 161, 0.28); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ctp-green) 28%, transparent); }
.winnie-pin.is-closed { background: var(--ctp-overlay0); box-shadow: 0 0 0 3px rgba(108, 112, 134, 0.22); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ctp-overlay0) 22%, transparent); }
/* Selected pin (a restaurant tapped on the Map tab, applied through
   window.mapGlue.setSelected): the accent colour whatever the opening state,
   the biggest dot, with a pulsing halo. Must stay after .is-open/.is-closed —
   same specificity, so source order decides. */
.winnie-pin.is-selected,
.winnie-pin.is-selected.is-open,
.winnie-pin.is-selected.is-closed {
  background: var(--ctp-accent);
  box-shadow: 0 0 0 4px rgba(180, 190, 254, 0.35);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ctp-accent) 35%, transparent);
  transform: scale(1.5);
  z-index: 4;
}
.winnie-pin.is-selected::after {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 2px solid rgba(180, 190, 254, 0.55);
  border: 2px solid color-mix(in srgb, var(--ctp-accent) 55%, transparent);
  animation: winnie-pulse 1.8s ease-out infinite;
  pointer-events: none;
}

/* "Open now" filter chip of the Map screen */
.open-filter {
  position: absolute; top: 0.8rem; left: 0.6rem;
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.75rem; font-weight: 600;
  color: var(--ctp-subtext1);
  background: rgba(17, 17, 27, 0.85);
  background: color-mix(in srgb, var(--ctp-crust) 85%, transparent);
  border: 1px solid var(--ctp-surface1);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}
.open-filter.is-on { color: var(--ctp-green); border-color: rgba(166, 227, 161, 0.35); border-color: color-mix(in srgb, var(--ctp-green) 35%, transparent); }
.open-filter-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ctp-overlay0); }
.open-filter.is-on .open-filter-dot { background: var(--ctp-green); }

/* Hours line of the map bottom sheet */
.hours-line {
  margin: 0.45rem 0 0; font-size: 0.78rem; color: var(--ctp-subtext0);
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem;
}
.hours-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.hours-dot.is-open { background: var(--ctp-green); }
.hours-dot.is-closed { background: var(--ctp-red); }
.hours-dot.is-unknown { background: var(--ctp-overlay0); }
.hours-raw { color: var(--ctp-overlay1); }
.winnie-pin-label {
  position: absolute;
  left: 50%; bottom: calc(100% + 5px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.68rem; font-weight: 600;
  color: var(--ctp-text);
  background: rgba(30, 30, 46, 0.88);
  background: color-mix(in srgb, var(--ctp-base) 88%, transparent);
  border: 1px solid var(--ctp-surface1);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  pointer-events: none;
}

/* Order tracking (Map tab): the restaurant origin and the courier that
   map-glue.js (window.mapGlue.showTracking) animates along the route. The
   courier keeps a pulsing halo while it waits at the restaurant (prep phase),
   loses it while riding, and gets it back nowhere once delivered. */
.winnie-route-origin {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1;
  background: var(--ctp-base);
  border: 2px solid var(--ctp-green);
  border-radius: 50%;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

.winnie-courier {
  position: relative;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
  background: var(--ctp-base);
  border: 2px solid var(--ctp-accent);
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  z-index: 5;
}
.winnie-courier:not(.is-riding):not(.is-done)::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(180, 190, 254, 0.55);
  border: 2px solid color-mix(in srgb, var(--ctp-accent) 55%, transparent);
  animation: winnie-pulse 1.8s ease-out infinite;
  pointer-events: none;
}

/* Small error banner */
.error-banner {
  background: rgba(243, 139, 168, 0.12);
  background: color-mix(in srgb, var(--ctp-red) 12%, transparent);
  color: var(--ctp-red);
  border: 1px solid rgba(243, 139, 168, 0.25);
  border: 1px solid color-mix(in srgb, var(--ctp-red) 25%, transparent);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.82rem;
  margin: 0.6rem 1rem 0;
}
