/* ridebetter — dark, map-first, everything floats over the terrain. */

:root {
  --bg:        #070b12;
  --panel:     rgba(11, 17, 27, 0.80);
  --panel-2:   rgba(18, 26, 39, 0.72);
  --line:      rgba(255, 255, 255, 0.09);
  --line-2:    rgba(255, 255, 255, 0.16);
  --text:      #e9eff8;
  --muted:     #8ba0bb;
  --dim:       #5d738f;
  --accent:    #5ad1ff;
  --accent-dk: #0b3a4d;

  --head:  #ff5f52;   /* Gegenwind */
  --cross: #ffb02e;   /* Seitenwind */
  --tail:  #35e08a;   /* Rückenwind */

  --r:   14px;
  --r-s: 9px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --blur: saturate(160%) blur(18px);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#map { position: absolute; inset: 0; }

#wind-canvas {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 2;
}

/* Darkens the corners so the floating panels always have contrast to sit on,
   whatever the map is showing underneath. */
#vignette {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 40%, rgba(4, 7, 12, 0.55) 100%),
    linear-gradient(180deg, rgba(4, 7, 12, 0.75) 0%, transparent 22%, transparent 62%, rgba(4, 7, 12, 0.85) 100%);
}

.maplibregl-ctrl-attrib {
  background: rgba(7, 11, 18, 0.75) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-bottom-right { z-index: 5; }

/* ── shared ─────────────────────────────────────────────────────────── */

.panel, .results, .hud, .topbar {
  position: absolute; z-index: 6;
}

.panel {
  background: var(--panel);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.btn {
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text); background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-2); border-radius: var(--r-s);
  padding: 9px 13px; cursor: pointer;
  transition: background .16s, border-color .16s, transform .12s;
}
.btn:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255,255,255,.28); }
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; font-weight: 500; }
.btn--primary {
  width: 100%; margin-top: 4px; padding: 12px;
  background: linear-gradient(180deg, #6fdcff, #2eb3e6);
  color: #04202c; border-color: transparent; font-size: 14px;
  box-shadow: 0 6px 22px rgba(45, 178, 230, 0.32);
}
.btn--primary:hover { background: linear-gradient(180deg, #8ae6ff, #3ec2f2); }
.btn--primary:disabled { opacity: .5; cursor: progress; }
.btn--ghost.is-on { background: rgba(90, 209, 255, .16); border-color: rgba(90,209,255,.5); }

/* ── top bar ────────────────────────────────────────────────────────── */

/* Tall enough for the wind dial to sit inside it — at 64px the dial's ring
   was being cut off by the viewport edge. */
.topbar {
  top: 0; left: 0; right: 0; height: 104px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 11px; align-self: flex-start; margin-top: 17px; }
.brand__mark { width: 30px; height: 30px; color: var(--accent); flex: none; }
.brand__text { display: flex; flex-direction: column; line-height: 1.25; }
.brand__text b { font-size: 17px; letter-spacing: -0.2px; }
.brand__text span { font-size: 11px; color: var(--muted); letter-spacing: .3px; }

.wind-dial {
  position: relative; width: 92px; height: 92px;
  display: grid; place-items: center;
}
.wind-dial svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.dial__ring { fill: rgba(9, 14, 22, .66); stroke: var(--line-2); stroke-width: 1; }
.dial__gust {
  fill: none; stroke: var(--accent); stroke-width: 2.5; opacity: .5;
  stroke-dasharray: 289; stroke-dashoffset: 289;
  transform: rotate(-90deg); transform-origin: 60px 60px;
  transition: stroke-dashoffset .8s cubic-bezier(.3,.9,.3,1);
}
.dial__ticks line { stroke: var(--line-2); stroke-width: 1; }
.dial__nsew {
  fill: var(--muted); font-size: 9px; font-family: var(--font);
  text-anchor: middle; letter-spacing: .5px;
}
.dial__arrow {
  fill: var(--accent);
  filter: drop-shadow(0 0 6px rgba(90, 209, 255, .55));
  transform-origin: 60px 60px;
  transition: transform 1s cubic-bezier(.3,.9,.3,1);
}
.dial__readout { position: relative; text-align: center; line-height: 1.05; }
.dial__readout b { display: block; font-size: 19px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dial__readout span { font-size: 9px; color: var(--muted); letter-spacing: .4px; }

/* ── planner panel ──────────────────────────────────────────────────── */

.panel--plan {
  top: 88px; left: 18px; width: 306px;
  padding: 18px 18px 16px;
  max-height: calc(100vh - 200px); overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.panel--plan.is-collapsed { max-height: 52px; overflow: hidden; }

.panel__title {
  margin: 0 0 15px; font-size: 13px; font-weight: 700;
  letter-spacing: 1.3px; text-transform: uppercase; color: var(--muted);
}
.panel__toggle {
  position: absolute; top: 12px; right: 12px;
  width: 24px; height: 24px; border-radius: 6px;
  background: transparent; border: 1px solid var(--line);
  color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1;
}
.panel__toggle:hover { color: var(--text); border-color: var(--line-2); }

.field { display: block; margin-bottom: 15px; }
.field__label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; font-weight: 600; letter-spacing: .8px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 7px;
}
.field__label em { font-style: normal; text-transform: none; letter-spacing: 0; color: var(--accent); font-size: 11px; }
.row { display: flex; gap: 7px; }
.row .btn { flex: 1; }

.dist { display: flex; align-items: center; gap: 12px; }
.dist__value { display: flex; align-items: baseline; gap: 3px; }
.dist__value input {
  width: 52px; background: transparent; border: none; color: var(--text);
  font-family: var(--mono); font-size: 25px; font-weight: 600; text-align: right;
  font-variant-numeric: tabular-nums; padding: 0;
}
.dist__value input:focus { outline: none; color: var(--accent); }
.dist__value i { font-style: normal; font-size: 12px; color: var(--muted); }

input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 22px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--line-2); }
input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line-2); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; margin-top: -6px;
  border-radius: 50%; background: var(--accent); cursor: grab;
  box-shadow: 0 0 0 4px rgba(90, 209, 255, .18);
}
input[type=range]::-moz-range-thumb {
  width: 15px; height: 15px; border: none; border-radius: 50%;
  background: var(--accent); cursor: grab; box-shadow: 0 0 0 4px rgba(90, 209, 255, .18);
}

select, .field--inline input {
  width: 100%; font: inherit; font-size: 13px; color: var(--text);
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line-2);
  border-radius: var(--r-s); padding: 9px 10px;
}
select:focus, input:focus-visible { outline: 2px solid rgba(90, 209, 255, .5); outline-offset: 1px; }
select option { background: #0e1622; }

.seg { border: none; padding: 0; margin: 0 0 15px; }
.seg__opts { display: flex; gap: 4px; background: rgba(255,255,255,.05); padding: 3px; border-radius: var(--r-s); border: 1px solid var(--line); }
.seg__opts button {
  flex: 1; font: inherit; font-size: 11px; font-weight: 600; padding: 7px 4px;
  color: var(--muted); background: transparent; border: none; border-radius: 6px; cursor: pointer;
  transition: background .15s, color .15s;
}
.seg__opts button:hover { color: var(--text); }
.seg__opts button.is-on { background: rgba(90, 209, 255, .18); color: var(--accent); }

.hint { margin: 7px 0 0; font-size: 11px; line-height: 1.45; color: var(--muted); }

.adv { margin-bottom: 14px; }
.adv summary {
  font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); cursor: pointer; padding: 6px 0; list-style: none;
}
.adv summary::-webkit-details-marker { display: none; }
.adv summary::before { content: "▸ "; }
.adv[open] summary::before { content: "▾ "; }
.field--inline { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.field--inline span { flex: 1; font-size: 12px; color: var(--muted); }
.field--inline input { width: 74px; flex: none; text-align: right; font-family: var(--mono); }
.field--inline i { font-style: normal; font-size: 11px; color: var(--muted); width: 20px; }

.status { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); min-height: 15px; }
.status.is-err { color: var(--head); }

/* ── results ────────────────────────────────────────────────────────── */

.results {
  left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 0 18px 16px; pointer-events: none;
}
.results__verdict {
  pointer-events: auto;
  max-width: 640px; margin: 0 auto 11px;
  background: var(--panel); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 10px 15px; font-size: 12.5px; line-height: 1.5; color: var(--muted);
  text-align: center; box-shadow: var(--shadow);
}
.results__verdict b { color: var(--text); }
.results__verdict .k { color: var(--accent); font-family: var(--mono); font-weight: 600; }

.cards {
  display: flex; gap: 11px; justify-content: center;
  overflow-x: auto; padding-bottom: 4px; pointer-events: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}

.card {
  flex: 0 0 296px;
  background: var(--panel); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 15px 12px; cursor: pointer; box-shadow: var(--shadow);
  transition: border-color .18s, transform .18s, background .18s;
}
.card:hover { transform: translateY(-2px); border-color: var(--line-2); }
.card.is-on { border-color: var(--accent); background: var(--panel-2); }

/* Distance on its own line, everything else beneath it. Cramming time, speed
   and ascent alongside the big number made the third item wrap. */
.card__top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1px; }
.card__dist { font-family: var(--mono); font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.card__dist i { font-style: normal; font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.card__sub {
  font-size: 11.5px; color: var(--muted); font-family: var(--mono);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-bottom: 9px;
}
.card__rank {
  font-size: 9.5px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase;
  color: var(--accent); background: rgba(90,209,255,.14); border-radius: 4px; padding: 3px 7px;
}

/* head / cross / tail proportions as one bar */
.mix { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin-bottom: 8px; background: rgba(255,255,255,.06); }
.mix i { display: block; height: 100%; }
.mix .h { background: var(--head); }
.mix .c { background: var(--cross); }
.mix .t { background: var(--tail); }

.legend { display: flex; gap: 11px; font-size: 10.5px; color: var(--muted); margin-bottom: 10px; }
.legend span { display: flex; align-items: center; gap: 4px; }
.legend b { color: var(--text); font-family: var(--mono); font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot--h { background: var(--head); } .dot--c { background: var(--cross); } .dot--t { background: var(--tail); }

.spark { width: 100%; height: 34px; display: block; margin-bottom: 9px; }

.card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.card__tax b { color: var(--text); font-family: var(--mono); }
.card__gpx {
  font-size: 11px; font-weight: 600; color: var(--accent); text-decoration: none;
  border: 1px solid rgba(90,209,255,.3); border-radius: 6px; padding: 5px 9px;
}
.card__gpx:hover { background: rgba(90,209,255,.14); }

/* ── flight HUD ─────────────────────────────────────────────────────── */

.hud {
  right: 18px; bottom: 168px; z-index: 6;
  width: 208px; padding: 11px 13px;
  background: var(--panel); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
}
.hud__btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text);
  background: rgba(255,255,255,.06); border: 1px solid var(--line-2);
  border-radius: var(--r-s); padding: 9px 11px; cursor: pointer; margin-bottom: 9px;
}
.hud__btn:hover { background: rgba(255,255,255,.12); }
.hud__btn svg { width: 15px; height: 15px; flex: none; }
.hud__meta { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; color: var(--muted); margin-bottom: 7px; }
.hud__meta b { font-family: var(--mono); font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.hud__bar { height: 3px; border-radius: 2px; background: rgba(255,255,255,.1); overflow: hidden; }
.hud__bar i { display: block; height: 100%; width: 0; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* ── boot ───────────────────────────────────────────────────────────── */

.boot {
  position: absolute; inset: 0; z-index: 20; display: grid; place-content: center;
  gap: 16px; justify-items: center; background: var(--bg);
  transition: opacity .6s ease, visibility .6s;
}
.boot.is-gone { opacity: 0; visibility: hidden; }
.boot p { margin: 0; font-size: 12px; color: var(--muted); letter-spacing: .5px; }
.boot__spin {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--accent);
  animation: spin .85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── responsive ─────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .panel--plan { top: 70px; left: 10px; right: 10px; width: auto; max-height: 40vh; }
  .topbar { padding: 0 12px; height: 58px; }
  .wind-dial { width: 74px; height: 74px; }
  .results { padding: 0 10px 10px; }
  .cards { justify-content: flex-start; }
  .card { flex-basis: 262px; }
  .hud { right: 10px; bottom: auto; top: 70px; width: 168px; }
  .brand__text span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
