:root {
  --fg: #fff;
  --card: rgba(255, 255, 255, 0.14);
  --card-border: rgba(255, 255, 255, 0.12);
  --soft: rgba(255, 255, 255, 0.8);
  --faint: rgba(255, 255, 255, 0.6);
  --grid: rgba(255, 255, 255, 0.15);
  --rain: #8cd9ff;
  --warm: #ffb84d;
  --bg-top: #0d1433;
  --bg-bottom: #242e5c;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--bg-top); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom)) fixed;
  -webkit-font-smoothing: antialiased;
  transition: background 0.6s;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { margin: 0; font-size: 1.5rem; font-weight: 600; }
.temp { font-size: 5.5rem; font-weight: 200; line-height: 1.1; padding-left: 0.3em; font-variant-numeric: tabular-nums; }
.cond { font-size: 1.25rem; font-weight: 500; min-height: 1.5em; }
.hilo { font-weight: 600; opacity: 0.9; display: flex; gap: 12px; justify-content: center; min-height: 1.4em; }
.measured { font-size: 0.75rem; opacity: 0.75; margin-top: 6px; }
.stale { color: #ffd84d; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 16px;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0.7;
}
.ico { margin-right: 6px; }
hr { border: 0; border-top: 1px solid rgba(255, 255, 255, 0.3); margin: 10px 0; }
.caption { font-size: 0.75rem; opacity: 0.75; }
.faint { opacity: 0.6; margin-top: 4px; }
.strong { font-weight: 600; }
.soft { opacity: 0.85; }
p { margin: 0 0 8px; }

/* Wind */
.wind { display: flex; gap: 20px; align-items: center; }
.compass { width: 120px; height: 120px; flex: none; }
.compass .ring { fill: none; stroke: rgba(255, 255, 255, 0.35); stroke-width: 1.5; }
.compass .tick { stroke: rgba(255, 255, 255, 0.35); stroke-width: 1.2; }
.compass .tick.major { stroke: rgba(255, 255, 255, 0.9); }
.compass .cardinal { fill: #fff; font-size: 10px; font-weight: 700; text-anchor: middle; }
#arrow { transition: transform 0.8s; }
#arrow path { fill: var(--warm); }
#arrow.calm path { fill: rgba(255, 255, 255, 0.35); }
.wind-text { flex: 1; min-width: 0; font-size: 0.95rem; line-height: 1.45; }
.big { font-size: 2.5rem; font-weight: 600; line-height: 1; margin-bottom: 4px; }
.big small { font-size: 1rem; opacity: 0.8; font-weight: 600; }
.wind-fc { display: grid; grid-template-columns: repeat(6, 1fr); text-align: center; font-size: 0.75rem; gap: 2px; }
.wind-fc .h { opacity: 0.75; }
.wind-fc .s { font-weight: 600; }
.wind-fc .g { opacity: 0.65; }
.dir-arrow { width: 0.85em; height: 0.85em; vertical-align: -0.08em; }

/* Stündlich */
.hourly {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.hourly::-webkit-scrollbar { display: none; }
.hour { flex: none; min-width: 44px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hour .t { font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.hour .icon { font-size: 1.6rem; line-height: 30px; height: 30px; }
.hour .temp-h { font-weight: 600; }
.hour .pop { font-size: 0.7rem; font-weight: 600; color: var(--rain); }
.hour .pop.low { opacity: 0.45; }
.hour .w { font-size: 0.7rem; opacity: 0.8; white-space: nowrap; }

/* Diagramme */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: rgba(255, 255, 255, 0.7); font-size: 10px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.seg { display: flex; background: rgba(255, 255, 255, 0.12); border-radius: 9px; padding: 2px; margin-bottom: 12px; }
.seg button {
  flex: 1; border: 0; background: none; color: #fff; font: inherit; font-size: 0.85rem; font-weight: 600;
  padding: 6px; border-radius: 7px; cursor: pointer;
}
.seg button.active { background: rgba(255, 255, 255, 0.28); }
.legend { display: flex; gap: 14px; font-size: 0.7rem; opacity: 0.8; margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* Details */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  background: var(--card); border: 1px solid var(--card-border); border-radius: 20px;
  padding: 14px; min-height: 110px; min-width: 0;
}
.tile h3 { margin: 0 0 6px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; opacity: 0.7; letter-spacing: 0.03em; }
.tile .v { font-size: 1.5rem; font-weight: 600; white-space: nowrap; }
.tile .n { font-size: 0.75rem; opacity: 0.8; margin-top: 4px; }

/* Sonne */
#sun-arc { width: 100%; height: auto; display: block; }
.sun-row { display: flex; justify-content: space-between; align-items: flex-end; margin: 8px 0; gap: 8px; }
.sun-row .center { text-align: center; }
.sun-row .right { text-align: right; }
.sun-time { font-size: 1.25rem; font-weight: 600; white-space: nowrap; }

/* 7 Tage */
.day { padding: 8px 0; border-top: 1px solid rgba(255, 255, 255, 0.2); }
.day:first-child { border-top: 0; }
.day-main { display: grid; grid-template-columns: 64px 30px 38px 32px 1fr 32px; align-items: center; gap: 8px; }
.day .name { font-weight: 600; font-size: 1.05rem; }
.day .icon { font-size: 1.3rem; text-align: center; }
.day .pop { color: var(--rain); font-size: 0.75rem; font-weight: 600; }
.day .min { opacity: 0.7; text-align: right; }
.day .max { font-weight: 600; text-align: right; }
.bar { position: relative; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.2); }
.bar span { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, var(--rain), var(--warm)); }
.day .sub { font-size: 0.7rem; opacity: 0.7; padding-left: 72px; margin-top: 3px; }

.error { border-color: rgba(255, 200, 80, 0.5); }

footer { text-align: center; font-size: 0.7rem; opacity: 0.7; line-height: 1.7; padding-top: 8px; }
footer a { color: #fff; }

@media (max-width: 360px) {
  .temp { font-size: 4.5rem; }
  .compass { width: 100px; height: 100px; }
  .big { font-size: 2rem; }
  .day-main { grid-template-columns: 56px 26px 34px 28px 1fr 28px; gap: 6px; }
  .day .sub { padding-left: 62px; }
}

/* Vergleich der Windquellen */
.compare { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 4px; }
.cmp { background: rgba(255, 255, 255, 0.08); border-radius: 12px; padding: 8px; min-width: 0; }
.cmp-name { font-size: 0.7rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-kind { font-size: 0.62rem; opacity: 0.6; margin-bottom: 4px; }
.cmp-val { font-size: 1.1rem; font-weight: 600; white-space: nowrap; }
.cmp-val small { font-size: 0.65rem; opacity: 0.8; }
.cmp-sub { font-size: 0.68rem; opacity: 0.8; white-space: nowrap; }
.hour .w.g { opacity: 0.6; margin-top: -4px; }

/* ---------- Layout: Mobil = eine Spalte, Kacheln untereinander ---------- */
@media (max-width: 899px) {
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .tile {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "h v" "n v";
    align-items: center;
    column-gap: 12px;
    padding: 12px 14px;
  }
  .tile h3 { grid-area: h; margin: 0; }
  .tile .v { grid-area: v; font-size: 1.35rem; text-align: right; }
  .tile .n { grid-area: n; margin-top: 2px; }

  .compare { grid-template-columns: 1fr; gap: 6px; }
  .cmp {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "name val" "kind sub";
    align-items: center;
    column-gap: 10px;
    padding: 8px 12px;
  }
  .cmp-name { grid-area: name; font-size: 0.8rem; }
  .cmp-kind { grid-area: kind; margin: 0; }
  .cmp-val { grid-area: val; text-align: right; }
  .cmp-sub { grid-area: sub; text-align: right; }
}

/* ---------- Layout: größere Bildschirme = Kacheln nebeneinander ---------- */
@media (min-width: 900px) {
  main {
    max-width: 1100px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "hero    hero"
      "errors  errors"
      "wind    hourly"
      "wind    rain"
      "details details"
      "trend   daily"
      "sun     daily"
      "foot    foot";
    grid-template-rows: auto auto auto 1fr auto auto 1fr auto;
    align-items: start;
    column-gap: 16px;
    row-gap: 16px;
    padding-left: 24px;
    padding-right: 24px;
  }
  .hero { grid-area: hero; }
  #errors { grid-area: errors; }
  #wind-card { grid-area: wind; }
  #hourly-card { grid-area: hourly; min-width: 0; }
  #rain-card { grid-area: rain; }
  #details { grid-area: details; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  #trend-card { grid-area: trend; }
  #sun-card { grid-area: sun; }
  #daily-card { grid-area: daily; }
  footer { grid-area: foot; }
  .temp { font-size: 6.5rem; }
}

/* ---------- Impressum / Datenschutz ---------- */
main.legal { display: flex; flex-direction: column; max-width: 720px; padding-top: calc(16px + env(safe-area-inset-top)); line-height: 1.55; }
.legal h1 { font-size: 1.4rem; margin: 0 0 10px; }
.legal h2 { font-size: 0.8rem; }
.legal h3 { font-size: 0.95rem; margin: 16px 0 4px; }
.legal p, .legal li { font-size: 0.92rem; }
.legal ul { padding-left: 20px; margin: 0 0 8px; }
.legal a { color: #fff; }

/* ---------- Segelyacht neben der Temperatur: krängt je nach Windstärke ---------- */
.temp-row { display: flex; justify-content: center; align-items: center; gap: 0.12em; font-size: 5.5rem; }
.temp-row .temp { font-size: 1em; padding-left: 0; }
.boat { height: 1.15em; width: 1.03em; flex: none; pointer-events: none; }
.boat svg { width: 100%; height: 100%; overflow: visible; display: block; }
.boat-body {
  transform-box: view-box;
  transform-origin: 50px 90px;        /* Drehpunkt an der Wasserlinie */
  transform: rotate(var(--heel, 0deg));
  animation: boat-rock var(--rock-speed, 4s) ease-in-out infinite;
}
@keyframes boat-rock {
  0%, 100% { transform: rotate(calc(var(--heel, 0deg) - var(--rock, 1deg))) translateY(0); }
  50%      { transform: rotate(calc(var(--heel, 0deg) + var(--rock, 1deg))) translateY(var(--bob, 1px)); }
}
.boat .sail { stroke: rgba(255, 255, 255, 0.55); stroke-width: 0.6; stroke-linejoin: round; }
.boat .battens line { stroke: rgba(120, 130, 160, 0.35); stroke-width: 0.5; }
.boat .mast { stroke: #e9eef7; stroke-width: 1.6; stroke-linecap: round; }
.boat .boom { stroke: #e9eef7; stroke-width: 1.4; stroke-linecap: round; }
.boat .cabin { fill: #dfe7f3; }
.boat .stripe { fill: none; stroke: var(--warm); stroke-width: 1.4; stroke-linecap: round; }
.boat .reflection { opacity: 0.18; filter: blur(0.6px); }
.boat .reflection path { fill: #fff; }
.boat .wave { fill: none; stroke-linecap: round; }
.boat .wave.back { stroke: rgba(140, 217, 255, 0.45); stroke-width: 1.6; animation: wave-move var(--wave-speed, 6s) linear infinite reverse; }
.boat .wave.front { stroke: rgba(140, 217, 255, 0.9); stroke-width: 2; animation: wave-move calc(var(--wave-speed, 6s) * 0.8) linear infinite; }
@keyframes wave-move { from { transform: translateX(0); } to { transform: translateX(-24px); } }

@media (min-width: 900px) { .temp-row { font-size: 6.5rem; } }
@media (max-width: 360px) { .temp-row { font-size: 4.5rem; } }
@media (prefers-reduced-motion: reduce) { .boat-body, .boat .wave { animation: none; } }

/* ---------- Animierter Himmel ---------- */
#sky { position: fixed; top: 0; left: 0; pointer-events: none; z-index: 0; }
main { position: relative; z-index: 1; }

/* Lesbarkeit über hellem Himmel (Wolken, Nebel, Schnee) */
body { text-shadow: 0 1px 2px rgba(0, 20, 50, 0.28); }
.card, .tile { background-color: rgba(20, 35, 70, 0.16); background-image: linear-gradient(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.12)); }
