/* Annecy Fly Conditions — mobile-first, glanceable, dark. */

:root {
  --bg: #10151d;
  --card: #1a212c;
  --card-hover: #202938;
  --text: #e8edf4;
  --muted: #8b97a8;
  --line: #2a3442;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --accent: #60a5fa;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- chrome ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(16, 21, 29, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.updated-at { color: var(--muted); font-size: 0.8rem; }

.refresh-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1.15rem;
  width: 38px;
  height: 38px;
  cursor: pointer;
}
.refresh-btn:active { transform: rotate(180deg); transition: transform 0.25s; }

.stale-banner {
  background: #4a3520;
  color: #fcd34d;
  text-align: center;
  padding: 7px 12px;
  font-size: 0.85rem;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer {
  max-width: 760px;
  margin: 8px auto 24px;
  padding: 0 14px;
  color: var(--muted);
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.loading { color: var(--muted); text-align: center; padding: 48px 0; }

/* ---------- cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: block;
}

.card-link { color: inherit; text-decoration: none; }
.card-link:hover, .card-link:active { background: var(--card-hover); }

.card-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.card-sub { color: var(--muted); font-weight: 400; font-size: 0.78rem; margin-left: 4px; }

/* ---------- value colors ---------- */

.ok { color: var(--ok); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.na { color: var(--muted); }
.muted { color: var(--muted); font-size: 0.85rem; }
.pad { padding: 0 14px; }

/* ---------- live wind ---------- */

.live-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.site-switch {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 2px;
  flex: 0 0 auto;
}

.site-btn {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.site-btn.active {
  background: var(--card-hover);
  color: var(--text);
  font-weight: 600;
}

.hero-note {
  color: var(--warn);
  opacity: 0.85;
  font-size: 0.76rem;
  margin-top: 6px;
}

.cross-signal {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.45;
}
.cross-signal.warn { background: rgba(251, 191, 36, 0.1); color: var(--warn); }
.cross-signal.danger { background: rgba(248, 113, 113, 0.1); color: var(--danger); }

.hero-station {
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: 10px;
  padding: 6px 8px;
  margin: -4px -8px 8px;
}
.hero-station:hover { background: var(--card-hover); }

.hero-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.hero-name { font-weight: 600; }
.hero-alt { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }

.hero-numbers {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 4px;
}

.hero-main .big { font-size: 3rem; font-weight: 700; line-height: 1; }
.hero-main .unit { font-size: 0.9rem; margin-left: 4px; color: inherit; opacity: 0.8; }
.hero-gust { font-size: 0.95rem; }
.hero-gust b { font-size: 1.25rem; }

.hero-dir {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.dir-label { font-size: 0.85rem; color: var(--muted); }

.hero-temp { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

.wind-arrow { color: var(--accent); vertical-align: -3px; }
.arrow-na { color: var(--muted); }

.station-rows { display: flex; flex-direction: column; }

.station-row {
  display: grid;
  grid-template-columns: 1fr 64px 44px 44px 76px;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  font-size: 0.92rem;
}
.station-row:hover { background: var(--card-hover); }
.row-name small { color: var(--muted); font-size: 0.72rem; }
.row-dir { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.row-avg, .row-gust { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.row-gust { font-weight: 400; }
.row-age { text-align: right; color: var(--muted); font-size: 0.7rem; }

.offline { opacity: 0.55; }

/* ambient severity cues — steer the eye, no verdicts */
.hero-station, .station-row { border-left: 3px solid transparent; }
.hero-station.sev-ok, .station-row.sev-ok { border-left-color: var(--ok); }
.hero-station.sev-warn, .station-row.sev-warn { border-left-color: var(--warn); }
.hero-station.sev-danger, .station-row.sev-danger {
  border-left-color: var(--danger);
  background: rgba(248, 113, 113, 0.07);
}
.hero-station.sev-danger:hover, .station-row.sev-danger:hover { background: rgba(248, 113, 113, 0.12); }

.hero-spread { font-size: 0.8rem; opacity: 0.9; }

/* compass dial */
.wind-dial { display: block; }
.dial-track { stroke: var(--line); fill: none; }
.dial-good { stroke: var(--ok); fill: none; opacity: 0.8; }
.dial-bad { stroke: var(--danger); fill: none; opacity: 0.8; }
.dial-n { fill: var(--muted); font-size: 7px; }

/* ---------- hour strip ---------- */

.hour-strip {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.hour-cell {
  flex: 1 0 44px;
  text-align: center;
  background: var(--bg);
  border-radius: 8px;
  padding: 6px 2px;
}
.hour-label { color: var(--muted); font-size: 0.72rem; }
.hour-wind { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.hour-gust { font-size: 0.78rem; opacity: 0.85; }
.hour-rain { font-size: 0.7rem; min-height: 1em; }

.strip-legend { color: var(--muted); font-size: 0.72rem; margin-top: 6px; }

/* ---------- pressure ---------- */

.pressure-row { display: flex; align-items: center; gap: 14px; }

.pressure-num { flex: 0 0 auto; }
.pressure-value { font-size: 2.1rem; font-weight: 700; }
.pressure-unit { color: var(--muted); margin-left: 4px; }
.pressure-trend { font-size: 0.85rem; margin-top: 2px; }

.dwd-thumb {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 120px;
  object-fit: cover;
  object-position: 62% 38%; /* crop roughly onto the Alps */
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.dwd-full {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.windy { width: 100%; height: 420px; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- detail views ---------- */

.detail-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.detail-head h2 { margin: 0; font-size: 1.1rem; }
.back { color: var(--accent); text-decoration: none; font-size: 0.9rem; white-space: nowrap; }

.note { color: var(--muted); font-size: 0.85rem; }

.graph { width: 100%; height: auto; display: block; }
.g-grid { stroke: var(--line); stroke-width: 1; }
.g-thresh { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.6; }
.g-tick { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.g-band { fill: var(--accent); opacity: 0.16; }
.g-avg { stroke: var(--accent); stroke-width: 2; fill: none; }
.g-max { stroke: var(--accent); stroke-width: 1; fill: none; opacity: 0.45; }
.g-arrow { fill: var(--muted); }

/* ---------- forecast table ---------- */

.fc-table { display: flex; flex-direction: column; }

.fc-row {
  display: grid;
  grid-template-columns: 26px 1fr 1fr 52px 52px 56px;
  align-items: center;
  gap: 4px;
  padding: 3px 0;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--line);
}
.fc-head { color: var(--muted); font-size: 0.72rem; border-top: none; }
.fc-hour { color: var(--muted); }
.fc-cloud { display: flex; gap: 2px; align-items: flex-end; }
.cb {
  display: inline-block;
  width: 9px;
  height: 14px;
  background: #cbd5e1;
  border-radius: 2px;
}
.fc-cape { font-size: 0.8rem; letter-spacing: 1px; }

.primer { margin: 0; padding-left: 18px; font-size: 0.88rem; display: flex; flex-direction: column; gap: 8px; }

/* ---------- desktop ---------- */

@media (min-width: 768px) {
  main { max-width: 980px; }
  #view:not(.detail) { }
  .windy { height: 540px; }
}

@media (min-width: 900px) {
  main.home-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  main.home-grid #card-live { grid-row: span 2; }
}

/* ---------- meteo pattern card (home) ---------- */

.meteo-summary { display: flex; align-items: center; gap: 14px; }
.meteo-emoji { font-size: 2.4rem; flex: 0 0 auto; line-height: 1; }
.meteo-text { flex: 1; min-width: 0; }
.meteo-label { font-weight: 600; font-size: 1rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meteo-synopsis { font-size: 0.83rem; margin-top: 3px; }

.confidence-badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.confidence-badge.ok { background: rgba(74,222,128,0.15); color: var(--ok); }
.confidence-badge.warn { background: rgba(251,191,36,0.15); color: var(--warn); }

/* ---------- meteo analysis detail view ---------- */

.pattern-header { display: flex; align-items: flex-start; gap: 16px; }
.pattern-emoji-large { font-size: 3rem; line-height: 1; flex: 0 0 auto; margin-top: 2px; }
.pattern-name { font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pattern-sub { color: var(--muted); font-size: 0.88rem; margin-top: 5px; line-height: 1.45; }

.primer-text { font-size: 0.88rem; line-height: 1.55; margin: 0 0 10px 0; color: var(--text); }

.meteo-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 16px;
  font-size: 0.85rem;
  align-items: center;
}
.meteo-grid-label { color: var(--muted); white-space: nowrap; }
.meteo-grid-value { font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 4px; }

/* ---------- secondary flags ---------- */

.flag-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.flag-chip {
  background: rgba(251,191,36,0.1);
  border: 1px solid rgba(251,191,36,0.3);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: var(--warn);
  cursor: pointer;
}
.flag-chip summary { list-style: none; font-weight: 500; }
.flag-chip summary::-webkit-details-marker { display: none; }
.flag-chip[open] { border-radius: 10px; padding: 8px 12px; }
.flag-detail { font-size: 0.78rem; color: var(--text); margin: 6px 0 0 0; line-height: 1.45; }

/* ---------- meteo journal ---------- */

.journal-empty { margin: 4px 0; }
.journal-list { display: flex; flex-direction: column; }
.journal-entry { padding: 10px 0; border-top: 1px solid var(--line); }
.journal-entry:first-child { border-top: none; padding-top: 0; }
.journal-entry-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.journal-date { color: var(--muted); font-size: 0.75rem; font-weight: 400; margin-left: auto; }
.journal-meta { color: var(--muted); font-size: 0.75rem; margin-top: 3px; font-variant-numeric: tabular-nums; }
.journal-note { color: #93c5fd; font-size: 0.8rem; font-style: italic; margin-top: 4px; }
.journal-note-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  padding: 2px 9px;
  cursor: pointer;
  margin-top: 5px;
}
.journal-note-btn:hover { color: var(--text); border-color: var(--muted); }
.journal-clear {
  background: none;
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--danger);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  margin-top: 14px;
  width: 100%;
}
.journal-clear:hover { background: rgba(248,113,113,0.08); }

/* ---------- chat ---------- */

.chat-card { padding: 0; overflow: hidden; }
.mode-tabs { display: flex; border-bottom: 1px solid var(--line); }
.mode-tab {
  flex: 1; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 10px; font: inherit; font-size: 0.85rem; cursor: pointer;
}
.mode-tab.active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.chat-messages {
  overflow-y: auto; padding: 14px; display: flex; flex-direction: column;
  gap: 10px; min-height: 180px; max-height: 52vh;
}
.msg {
  max-width: 85%; padding: 9px 13px; border-radius: 14px; font-size: 0.88rem;
  line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.msg.user { align-self: flex-end; background: var(--accent); color: #0f172a; border-bottom-right-radius: 4px; }
.msg.ai   { align-self: flex-start; background: var(--card-hover); border-bottom-left-radius: 4px; }
.typing-indicator { padding: 6px 14px; display: flex; gap: 5px; align-items: center; }
.typing-indicator span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: tybounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tybounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }
.typing-indicator.hidden { display: none !important; }
.chat-input-row {
  display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line);
  align-items: flex-end;
}
.chat-textarea {
  flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font: inherit; font-size: 0.88rem; padding: 8px 12px;
  resize: none; max-height: 120px;
}
.chat-textarea:focus { outline: none; border-color: var(--accent); }
.send-btn {
  background: var(--accent); color: #0f172a; border: none; border-radius: 10px;
  width: 38px; height: 38px; font-size: 1.1rem; font-weight: 700; cursor: pointer; flex: 0 0 auto;
}
.send-btn:disabled { opacity: 0.4; cursor: default; }
.no-key-notice { padding: 20px 14px; color: var(--warn); font-size: 0.88rem; text-align: center; line-height: 1.6; }
.hidden { display: none !important; }

/* ---------- settings ---------- */

.settings-form { display: flex; flex-direction: column; gap: 14px; }
.settings-label { font-size: 0.85rem; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.settings-input, .settings-select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); font: inherit; font-size: 0.88rem; padding: 8px 12px;
}
.settings-save {
  background: var(--accent); color: #0f172a; border: none; border-radius: 9px;
  font: inherit; font-weight: 600; padding: 9px 20px; cursor: pointer; align-self: flex-start;
}
.api-key-hint { margin: 0; }

/* ---------- action buttons (meteo card + home) ---------- */

.action-row { display: flex; gap: 8px; margin-top: 10px; }
.action-btn {
  background: var(--line); color: var(--text); text-decoration: none;
  border-radius: 8px; padding: 7px 14px; font-size: 0.82rem; flex: 1; text-align: center;
}
.action-btn:hover { background: var(--card-hover); }
.action-link {
  color: var(--accent); font-size: 0.8rem; text-decoration: none;
  border: 1px solid rgba(96,165,250,0.3); border-radius: 8px; padding: 4px 10px;
}
.action-link:hover { background: rgba(96,165,250,0.08); }

/* ---------- topbar settings icon ---------- */

.settings-icon { color: var(--muted); font-size: 1.15rem; text-decoration: none; padding: 4px 6px; border-radius: 8px; }
.settings-icon:hover { color: var(--text); background: var(--card); }

/* ---------- card inner link (meteo home card) ---------- */

.card-inner-link { display: block; color: inherit; text-decoration: none; margin: -14px -14px 0; padding: 14px; }
.card-inner-link:hover { background: var(--card-hover); border-radius: var(--radius) var(--radius) 0 0; }
