/* /wth visual styling — playful/branded palette (coral accent), one of
   a few directions considered; kept as named custom properties (not raw
   hex in selectors) specifically so swapping direction later, if this
   one doesn't read well once live, is a values-only change here rather
   than a rewrite. Also styles web/src/auth.py's login page and the
   wth-loading-spinner (see pages/wth.py's dcc.Loading) — both are
   served from this same file, not a separate stylesheet, since it's one
   small app with one visual identity. */

:root {
  --bg: #faf7f5;
  --surface: #ffffff;
  --ink: #241a15;
  --ink-secondary: #6b5c54;
  --muted: #9c8f88;
  --border: rgba(36, 26, 21, 0.12);
  --accent: #ff6b4a;
  --accent-ink: #241a15;
  /* Status colors are fixed, never themed (light == dark) — a
     safety-validated pair from the dataviz skill's palette, not a
     brand choice, so they don't move with the palette direction above. */
  --warning: #fab219;
  --warning-bg: rgba(250, 178, 25, 0.16);
  --critical: #d03b3b;
  --critical-bg: rgba(208, 59, 59, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171210;
    --surface: #211a17;
    --ink: #f5ede8;
    --ink-secondary: #cbb9b0;
    --muted: #8f7d74;
    --border: rgba(245, 237, 232, 0.14);
    --accent: #ff8a6a;
    --accent-ink: #171210;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- /wth page ---------- */

.wth-page {
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}

@media (min-width: 480px) {
  .wth-page {
    max-width: 560px;
  }
}

@media (min-width: 768px) {
  .wth-page {
    max-width: 720px;
    padding: 32px 24px;
  }
}

.wth-loading-spinner {
  display: block;
  width: 56px;
  height: 56px;
  margin: 24px auto;
}

/* ---------- Header ---------- */

.wth-header-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.wth-header-icon {
  /* height only, width auto — the source SVG is cropped to the
     helicopter's own natural (wide, not square) aspect ratio, so a
     forced square box would either distort it or waste space the way
     the old square icon-192.png asset did here. */
  height: 40px;
  width: auto;
}

.wth-header-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
}

/* ---------- Banner ---------- */

.wth-banner {
  margin-bottom: 12px;
}

.wth-banner-message {
  padding: 10px 14px;
  border-radius: 10px;
  border-left: 4px solid var(--muted);
  background: var(--surface);
  color: var(--ink-secondary);
  font-size: 0.9rem;
}

.wth-banner-message--stale {
  border-left-color: var(--warning);
  background: var(--warning-bg);
}

.wth-banner-message--unreachable {
  border-left-color: var(--critical);
  background: var(--critical-bg);
}

/* ---------- Hero card ---------- */

.wth-hero-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wth-hero-section {
  flex: 1;
  min-width: 0;
  min-height: 180px;
  display: flex;
  align-items: stretch;
}

.wth-nav-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.wth-nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.wth-card,
.wth-empty-state {
  flex: 1;
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 1px 3px var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wth-empty-state {
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink-secondary);
  font-size: 1.05rem;
  min-height: 180px;
}

.wth-empty-state-unavailable {
  border: 1px solid var(--critical);
  background: var(--critical-bg);
  color: var(--ink);
}

/* Distance stays visually dominant — current_sightings() sorts cards by
   distance_nm (closest first), so the headline number matches what
   actually decides card order, rather than a different one. */
.wth-card-distance {
  font-size: clamp(2rem, 9vw, 2.75rem);
  font-weight: 700;
  color: var(--ink);
}

.wth-card-identity {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.wth-card-identity:hover {
  text-decoration: underline;
}

.wth-card-recency {
  font-size: 0.95rem;
  color: var(--ink-secondary);
}

/* ---------- Map ---------- */

.wth-map-section {
  position: relative;
  margin-top: 16px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  min-height: 220px;
}

/* Deliberately visible, not just functional: an unstyled placeholder
   ("Tap to view map & trail") previously read as "no map at all,"
   rather than "tap here." */
.wth-map-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(36, 26, 21, 0.45);
  color: #fff;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  text-align: center;
  padding: 16px;
}

.wth-map-collapse-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1;
  min-width: 44px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  border: none;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 4px var(--border);
}

.wth-map-recenter-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  min-width: 44px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  border: none;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 4px var(--border);
}

.wth-map-graph-container {
  min-height: 220px;
}

.wth-map-graph {
  height: 320px;
  width: 100%;
}

@media (min-width: 768px) {
  .wth-map-graph {
    height: 420px;
  }
}

.wth-map-no-position {
  padding: 24px;
  text-align: center;
  color: var(--ink-secondary);
}

/* ---------- Timeline ---------- */

.wth-timeline-section {
  margin-top: 24px;
}

/* Bounded height + internal scroll, not an ever-growing page — at real
   content volume (a busy day can log dozens of visits) an unconstrained
   list would make the page absurdly long. */
.wth-timeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 40vh;
  overflow-y: auto;
  border-radius: 10px;
  background: var(--border);
}

.wth-timeline-list li {
  background: var(--surface);
}

.wth-timeline-list li:first-child {
  border-radius: 10px 10px 0 0;
}

.wth-timeline-list li:last-child {
  border-radius: 0 0 10px 10px;
}

.wth-timeline-list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 14px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1.6;
}

.wth-timeline-list a:hover {
  color: var(--accent);
}

.wth-timeline-active {
  /* Live aircraft - normal opacity */
}

.wth-timeline-ended {
  /* Ended visit - subtle visual distinction */
  opacity: 0.7;
}

.wth-timeline-flight {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wth-timeline-middle {
  flex: 1;
  text-align: center;
  color: var(--ink-secondary);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.wth-timeline-time {
  flex-shrink: 0;
  width: 100px;
  min-width: 100px;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.wth-timeline-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 8px 4px;
}

/* ---------- Completed-visit detail page (pages/visit.py, SPEC-4) ---------- */
/* Rough first pass — deliberately not polished further than the rest of
   this stylesheet's own first-draft state (see this file's own opening
   comment), pending a real-browser look. */

.wth-visit-back {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--ink-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.wth-visit-back:hover {
  color: var(--accent);
}

.wth-visit-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 1px 3px var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.wth-visit-identity {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
}

/* Duration + time range is the headline stat here (see
   digest.visit_headline) — same visual weight .wth-card-distance gives
   the live hero card's own headline number, so the two views read as
   siblings despite showing different content. */
.wth-visit-headline {
  font-size: clamp(1.6rem, 7vw, 2.1rem);
  font-weight: 700;
  color: var(--ink);
}

.wth-visit-closest {
  font-size: 0.95rem;
  color: var(--ink-secondary);
}

.wth-visit-map {
  height: 320px;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .wth-visit-map {
    height: 420px;
  }
}

.wth-visit-flightaware {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.wth-visit-flightaware:hover {
  text-decoration: underline;
}

.wth-visit-message {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  color: var(--ink-secondary);
}

/* ---------- Login page (web/src/auth.py's _LOGIN_PAGE) ---------- */

.login-page {
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 2px 8px var(--border);
  text-align: center;
}

.login-title {
  margin: 0 0 20px;
  font-size: 1.4rem;
}

.login-password-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.login-input {
  width: 100%;
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  /* 16px minimum keeps iOS Safari from auto-zooming on focus. */
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
}

.login-toggle {
  padding: 0 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.login-button {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

.login-error {
  border-left: 4px solid var(--critical);
  background: var(--critical-bg);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  text-align: left;
}

/* ---------- Desktop layout override (/wth) ---------- */

/* A real two-column desktop layout, not just a wider version of the
   mobile stack: hero card + map on the left, the timeline list as a
   scrollable side panel on the right, rather than a static narrow
   column floating in empty space at desktop widths. Deliberately placed
   at the end of the file: its
   selectors have the same specificity as the base rules they override
   (e.g. .wth-timeline-list's max-height), so it has to win on source
   order — placing it earlier in the file (as a first attempt did) meant
   the later base rules silently won regardless of viewport width, only
   caught by actually screenshotting a real desktop-width render.

   The timeline column is deliberately NOT stretched to match the left
   column's exact height (e.g. via flex:1/align-items:stretch) — a first
   attempt tried that and CSS Grid's auto-row-sizing fed the list's own
   unbounded content height back into the row size, making the row (and
   the empty space under the left column) enormous, only visible once
   actually screenshotted. A fixed, generous max-height with its own
   scrollbar (align-self: start keeps it pinned to the row's top rather
   than stretched) sidesteps that circular sizing problem entirely. */
@media (min-width: 1024px) {
  .wth-page {
    max-width: 980px;
    padding: 40px 32px;
    display: grid;
    grid-template-columns: minmax(0, 460px) minmax(320px, 1fr);
    grid-template-areas:
      "header header"
      "banner banner"
      "primary timeline";
    column-gap: 32px;
    row-gap: 16px;
  }

  .wth-header-bar {
    grid-area: header;
  }

  .wth-banner {
    grid-area: banner;
    margin-bottom: 0;
  }

  .wth-primary-column {
    grid-area: primary;
  }

  .wth-map-section {
    margin-top: 16px;
  }

  .wth-timeline-section {
    grid-area: timeline;
    margin-top: 0;
    align-self: start;
  }

  .wth-timeline-list {
    max-height: 70vh;
  }
}
