/* Gotthard Stau — quiet alpine dashboard.
 *
 * Design tokens follow the dataviz skill's validated reference palette:
 * direction colors are categorical slots 1+2 (north blue / south orange —
 * colorblind-safe, validated in both modes), heat levels use the fixed
 * status scale (always paired with a text label, never color alone).
 * Dark mode restates the same hues stepped for the dark surface. */

:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);

  --south: #eb6834;
  --north: #2a78d6;
  --south-wash: rgba(235, 104, 52, 0.12);
  --north-wash: rgba(42, 120, 214, 0.12);

  --heat-0: #0ca30c;
  --heat-1: #fab219;
  --heat-2: #ec835a;
  --heat-3: #d03b3b;

  --good-text: #006300;
  --bad-text: #b3362f;
  --warn-bg: rgba(250, 178, 25, 0.16);
  --warn-border: rgba(197, 137, 0, 0.5);

  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);

    --south: #d95926;
    --north: #3987e5;
    --south-wash: rgba(217, 89, 38, 0.18);
    --north-wash: rgba(57, 135, 229, 0.18);

    --good-text: #0ca30c;
    --bad-text: #e66767;
    --warn-bg: rgba(250, 178, 25, 0.12);
    --warn-border: rgba(250, 178, 25, 0.45);

    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

/* ── Header / tabs ─────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 16px 6px;
  max-width: 1080px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.brand strong {
  font-weight: 700;
  color: var(--south);
}
.brand-mark {
  font-size: 22px;
}
.brand-sub {
  color: var(--muted);
  font-size: 12.5px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 10px 12px;
  max-width: 1080px;
  margin: 0 auto;
  background: color-mix(in srgb, var(--page) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tabs a {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tabs a.active {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow);
}
.tabs a:hover {
  color: var(--ink);
}

/* ── Layout ────────────────────────────────────────────────────────────── */

.view {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
}
.card h3 {
  margin: 14px 0 6px;
  font-size: 14px;
  font-weight: 700;
}
.card-sub {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0 0 10px;
}

.grid-2 {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Direction cards (Heute) ───────────────────────────────────────────── */

.dir-card {
  position: relative;
  overflow: hidden;
  padding-top: 19px;
}
.dir-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
}
.dir-card.south::before {
  background: var(--south);
}
.dir-card.north::before {
  background: var(--north);
}

.dir-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dir-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.dir-dot.south {
  background: var(--south);
}
.dir-dot.north {
  background: var(--north);
}
.dir-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}
.dir-route {
  color: var(--ink-2);
  font-size: 13px;
  margin: 1px 0 12px;
}

.dir-hero {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.hero-value {
  font-size: 46px;
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: -0.5px;
}
.hero-unit {
  font-size: 20px;
  font-weight: 500;
  color: var(--ink-2);
}
.dir-wait {
  font-size: 15px;
  color: var(--ink-2);
  margin: 6px 0 0;
}
.dir-wait strong {
  color: var(--ink);
  font-weight: 650;
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 650;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
}
.trend.up {
  color: var(--bad-text);
}
.trend.down {
  color: var(--good-text);
}
.trend.flat {
  color: var(--muted);
}

.dir-meta {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* ── Banners, errors, skeletons ────────────────────────────────────────── */

.banner-stale {
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13.5px;
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.error-box {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--ink-2);
  font-size: 14px;
}

.skeleton {
  display: grid;
  gap: 14px;
}
.sk-block {
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface) 40%, var(--surface-2) 50%, var(--surface) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border: 1px solid var(--border);
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .sk-block {
    animation: none;
  }
}

/* ── Segmented controls / toggle buttons ───────────────────────────────── */

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  border-color: var(--border);
}
.seg button:focus-visible {
  outline: 2px solid var(--north);
  outline-offset: 1px;
}

.btn-quiet {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.btn-quiet[aria-pressed="true"] {
  background: var(--north-wash);
  border-color: var(--north);
  color: var(--ink);
}
.btn-quiet:focus-visible {
  outline: 2px solid var(--north);
  outline-offset: 1px;
}

/* ── Charts ────────────────────────────────────────────────────────────── */

.chart-box {
  position: relative;
  height: 240px;
  margin-top: 8px;
}
.chart-box.tall {
  height: 280px;
}
@media (max-width: 480px) {
  .chart-box {
    height: 210px;
  }
  .chart-box.tall {
    height: 240px;
  }
}

/* ── Table view (accessible twin of every chart) ───────────────────────── */

.tview {
  margin-top: 10px;
  font-size: 13px;
}
.tview summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}
.tview summary:hover {
  color: var(--ink-2);
}
.tscroll {
  overflow-x: auto;
  margin-top: 8px;
}
.tview table {
  border-collapse: collapse;
  width: 100%;
  min-width: 420px;
}
.tview th,
.tview td {
  text-align: right;
  padding: 4px 10px;
  border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tview th:first-child,
.tview td:first-child {
  text-align: left;
}
.tview th {
  color: var(--muted);
  font-weight: 600;
}

/* ── Heat (levels 0–3) ─────────────────────────────────────────────────── */

.heat-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.heat-bg-0 {
  background: var(--heat-0);
}
.heat-bg-1 {
  background: var(--heat-1);
}
.heat-bg-2 {
  background: var(--heat-2);
}
.heat-bg-3 {
  background: var(--heat-3);
}

.heat-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--ink-2);
  font-size: 12.5px;
  margin-top: 10px;
}
.heat-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.heat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 650;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}

/* ── Hourly heatmap strip ──────────────────────────────────────────────── */

.hm-wrap {
  margin: 6px 0 2px;
}
.hm-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 650;
  margin: 10px 0 6px;
}
.hm-label small {
  color: var(--muted);
  font-weight: 500;
}
.hm-strip {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
}
.hm-cell {
  height: 30px;
  border-radius: 4px;
  cursor: default;
}
.hm-cell:hover,
.hm-cell:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
  z-index: 1;
}
.hm-hours {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
  color: var(--muted);
  font-size: 10.5px;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.hm-hours span {
  text-align: left;
}

/* ── Calendar month grid ───────────────────────────────────────────────── */

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.cal-title {
  font-size: 15px;
  font-weight: 700;
  text-transform: capitalize;
}
.cal-nav {
  display: flex;
  gap: 6px;
}
.cal-nav button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  cursor: pointer;
}
.cal-nav button:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dow {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  padding: 2px 0 6px;
}
.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 46px;
  border-radius: 9px;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid var(--border);
  background: var(--surface);
}
.cal-cell:hover {
  outline: 2px solid var(--ink-2);
  outline-offset: -1px;
}
.cal-cell.empty {
  border: 0;
  background: transparent;
  pointer-events: none;
}
.cal-cell.today {
  outline: 2px solid var(--ink);
  outline-offset: -1px;
}
.cal-cell.past {
  opacity: 0.45;
}
.cal-cell .bar {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 4px;
  height: 4px;
  border-radius: 2px;
}
.cal-cell.h1 {
  background: color-mix(in srgb, var(--heat-1) 14%, var(--surface));
}
.cal-cell.h2 {
  background: color-mix(in srgb, var(--heat-2) 16%, var(--surface));
}
.cal-cell.h3 {
  background: color-mix(in srgb, var(--heat-3) 18%, var(--surface));
}
.cal-ev {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 9px;
  line-height: 1;
}
.cal-holi {
  display: flex;
  gap: 2px;
  height: 3px;
}
.cal-holi i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--muted);
}

/* ── Day list (next 31 days) ───────────────────────────────────────────── */

.day-list {
  display: grid;
  gap: 2px;
  max-height: 420px;
  overflow-y: auto;
  margin-top: 6px;
}
.day-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 13.5px;
}
.day-row:hover {
  background: var(--surface-2);
}
.day-row .d-date {
  flex: 0 0 92px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.day-row .d-event {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.day-row .d-spacer {
  flex: 1;
}
.day-row .d-flags {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

/* ── Window cards (Beste Zeitfenster) ──────────────────────────────────── */

.win-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  margin-top: 8px;
}
@media (min-width: 640px) {
  .win-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}
.win-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface);
}
.win-card.best {
  border-color: var(--heat-0);
  background: color-mix(in srgb, var(--heat-0) 7%, var(--surface));
}
.win-time {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.win-meta {
  color: var(--ink-2);
  font-size: 13px;
  margin-top: 2px;
}
.win-verdict {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 650;
  color: var(--good-text);
}

.worst-box {
  margin-top: 10px;
  border: 1px solid color-mix(in srgb, var(--heat-3) 45%, transparent);
  background: color-mix(in srgb, var(--heat-3) 8%, var(--surface));
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
}

/* ── Chips & stats ─────────────────────────────────────────────────────── */

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--border);
}

.stat-row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-top: 8px;
}
.stat {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.stat .s-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.stat .s-value {
  font-size: 22px;
  font-weight: 650;
  margin-top: 2px;
}
.stat .s-sub {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 1px;
}

/* ── Ausweich card ─────────────────────────────────────────────────────── */

.advice-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid var(--grid);
  font-size: 14px;
  flex-wrap: wrap;
}
.advice-row:first-of-type {
  border-top: 0;
}
.advice-row .a-dir {
  flex: 0 0 auto;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.advice-row .a-text {
  color: var(--ink-2);
}
.rule-note {
  color: var(--muted);
  font-size: 12px;
  margin: 10px 0 0;
}

/* ── Methodik / prose ──────────────────────────────────────────────────── */

.prose {
  max-width: 720px;
}
.prose h2 {
  font-size: 17px;
  margin: 0 0 6px;
}
.prose p,
.prose li {
  color: var(--ink-2);
  font-size: 14px;
}
.prose ul {
  padding-left: 20px;
  margin: 6px 0;
}
.prose strong {
  color: var(--ink);
}

.src-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}

.back-link {
  display: inline-block;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 2px;
}
.back-link:hover {
  color: var(--ink);
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.page-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 2px 0 0;
}

/* ── Historie ──────────────────────────────────────────────────────────── */

.date-input {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  padding: 6px 12px;
  border-radius: 9px;
}

/* ── Utilities ─────────────────────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Footer ────────────────────────────────────────────────────────────── */

.footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px 16px 40px;
  color: var(--muted);
  font-size: 12.5px;
}
.footer a {
  color: var(--ink-2);
}
