/* ============================================
   Alpe60 — Zwift-inspired dark theme
   ============================================ */

:root {
  --bg: #0b0e14;
  --bg-raise: #121722;
  --panel: #161c28;
  --panel-line: #232b3b;
  --ink: #f3f5f9;
  --ink-2: #b6bdcc;
  --ink-3: #7d869a;
  --accent: #fc6719;
  --accent-ink: #ff8a4c;
  --grid: #222a39;

  /* Power zones (Zwift order) */
  --z1: #8c8c8c;
  --z2: #338cff;
  --z3: #59bf59;
  --z4: #f2be22;
  --z5: #ff6639;
  --z6: #e8261c;

  --radius: 12px;
  --gutter: 16px;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Barlow', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 12px max(var(--gutter), calc((100% - 1100px) / 2));
  background: rgba(11, 14, 20, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--panel-line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.brand span {
  font-family: var(--display); font-style: italic; font-weight: 800;
  font-size: 24px; letter-spacing: 0.5px; color: var(--ink);
}
.brand b { color: var(--accent); font-weight: 800; }
.topbar nav { display: flex; gap: 18px; flex: 1; }
.topbar nav a {
  color: var(--ink-2); font-family: var(--display); font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px; font-size: 15px;
}
.topbar nav a:hover { color: var(--ink); text-decoration: none; }
.day-chip {
  font-family: var(--display); font-weight: 700; font-style: italic;
  background: var(--accent); color: #fff; padding: 2px 12px; border-radius: 999px;
  white-space: nowrap;
}

main { max-width: 1100px; margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Hero / climb ---------- */
.hero { padding: 40px 0 8px; }
.eyebrow {
  color: var(--ink-3); font-family: var(--display); font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.5px; font-size: 14px;
}
h1 {
  font-family: var(--display); font-style: italic; font-weight: 800;
  font-size: clamp(40px, 7vw, 72px); line-height: 1; margin: 6px 0 24px;
  text-transform: uppercase;
}
h2 {
  font-family: var(--display); font-style: italic; font-weight: 800;
  font-size: 28px; text-transform: uppercase; letter-spacing: 0.5px;
}
h3 { font-family: var(--display); font-weight: 700; font-size: 20px; }

.climb {
  background: linear-gradient(180deg, var(--panel), var(--bg-raise));
  border: 1px solid var(--panel-line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
}
.climb-top { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.climb-time .label { color: var(--ink-3); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.climb-time .value {
  font-family: var(--display); font-style: italic; font-weight: 800;
  font-size: 56px; line-height: 1;
}
.climb-time .value small { font-size: 22px; color: var(--ink-3); font-style: normal; font-weight: 600; }
.climb-goal { text-align: right; }
.climb-goal .value { color: var(--accent); }
.climb svg { display: block; width: 100%; height: auto; margin-top: 12px; }
.climb-caption { color: var(--ink-3); font-size: 13px; margin-top: 8px; }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile {
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: var(--radius); padding: 16px;
}
.tile {
  position: relative; display: block; width: 100%; text-align: left; font: inherit; color: inherit;
  cursor: pointer; transition: border-color 0.15s, transform 0.15s;
}
.tile:hover, .tile:focus-visible { border-color: var(--accent); outline: none; }
.tile:hover .tile-more, .tile:focus-visible .tile-more { color: var(--accent-ink); }
.tile-more { position: absolute; top: 14px; right: 14px; font-size: 12px; color: var(--ink-3); }
.tile .label { color: var(--ink-3); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.tile .value {
  font-family: var(--display); font-weight: 700; font-size: 40px; line-height: 1.1;
}
.tile .value small { font-size: 18px; color: var(--ink-2); font-weight: 600; }
.tile .sub { color: var(--ink-2); font-size: 14px; }
.tile .bar { height: 6px; background: var(--grid); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.tile .bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.delta-good { color: #6fdc8c; }
.delta-bad { color: #ff8a7a; }

/* ---------- Panels ---------- */
.panel { padding: 32px 0 8px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-note { color: var(--ink-3); font-size: 14px; }
.stack { display: grid; gap: 14px; }
.empty {
  color: var(--ink-3); background: var(--panel); border: 1px dashed var(--panel-line);
  border-radius: var(--radius); padding: 20px; text-align: center;
}

.card {
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: var(--radius); padding: 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card-date { color: var(--ink-3); font-size: 14px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 10px 0 14px; }
.stat .k { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.stat .v { font-family: var(--display); font-weight: 700; font-size: 22px; }
.stat .v small { font-size: 14px; color: var(--ink-2); font-weight: 600; }

/* ---------- Charts ---------- */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--body); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .ftp-line { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 4 3; }
.chart .ftp-label { fill: var(--ink-2); font-size: 11px; }
.chart .target { stroke: #fff; stroke-width: 2; opacity: 0.85; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.chart .goal-line { stroke: #6fdc8c; stroke-width: 1.5; stroke-dasharray: 6 4; }
.chart .goal-label { fill: #6fdc8c; font-size: 11px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; color: var(--ink-3); font-size: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend .target-key { width: 14px; height: 2px; background: #fff; border-radius: 0; vertical-align: 3px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; color: var(--ink-3); font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: 1px; padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--panel-line);
}
td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--grid); color: var(--ink-2); }
td:first-child { color: var(--ink); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
.zone-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.up { color: #6fdc8c; font-weight: 600; }

/* ---------- Start -> Now ---------- */
.compare { display: grid; gap: 4px; padding: 10px 18px; }
.cmp-row {
  display: grid; grid-template-columns: 130px 80px 1fr 80px 90px; align-items: center; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid var(--grid);
}
.cmp-row:last-child { border-bottom: none; }
.cmp-label { font-family: var(--display); font-weight: 700; font-size: 17px; text-transform: uppercase; letter-spacing: 0.5px; }
.cmp-val { font-family: var(--display); font-weight: 700; font-size: 22px; line-height: 1.1; }
.cmp-val small { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.cmp-val span { display: block; font-family: var(--body); font-weight: 500; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 1px; }
.cmp-start { color: var(--ink-2); }
.cmp-now { text-align: right; }
.cmp-delta { text-align: right; font-weight: 600; font-size: 15px; color: var(--ink-3); }
.cmp-delta.delta-good { color: #6fdc8c; }
.cmp-delta.delta-bad { color: #ff8a7a; }
.cmp-track { position: relative; height: 34px; }
.cmp-rail { position: absolute; left: 0; right: 0; top: 16px; height: 2px; background: var(--grid); }
.cmp-span { position: absolute; top: 15px; height: 4px; background: var(--accent); border-radius: 2px; opacity: 0.55; }
.cmp-dot { position: absolute; top: 9px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; cursor: default; }
.cmp-dot-start { background: var(--bg); border: 3px solid var(--ink-3); }
.cmp-dot-now { background: var(--accent); border: 3px solid var(--panel); box-shadow: 0 0 0 1px var(--accent); }
.cmp-goal { position: absolute; top: 4px; width: 2px; height: 26px; margin-left: -1px; background: #6fdc8c; }
.cmp-goal span {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 11px; color: #6fdc8c;
}
.cmp-goal-left span { left: 0; transform: none; }
.cmp-goal-right span { left: auto; right: 0; transform: none; }

.cmp-click { cursor: pointer; border-radius: 8px; transition: background 0.15s; }
.cmp-click:hover, .cmp-click:focus-visible { background: var(--bg-raise); outline: none; }

/* ---------- Drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.drawer.open { pointer-events: auto; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); opacity: 0; transition: opacity 0.2s; }
.drawer.open .drawer-backdrop { opacity: 1; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--panel); border-left: 1px solid var(--panel-line);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.25s ease;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.4);
}
.drawer.open .drawer-panel { transform: none; }
.drawer-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 20px 22px 14px; border-bottom: 1px solid var(--panel-line);
}
.drawer-title { color: var(--accent); }
.drawer-subtitle { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.drawer-close {
  background: none; border: 1px solid var(--panel-line); color: var(--ink-2); border-radius: 8px;
  width: 36px; height: 36px; font-size: 22px; line-height: 1; cursor: pointer; flex: none;
}
.drawer-close:hover, .drawer-close:focus-visible { color: var(--ink); border-color: var(--accent); outline: none; }
.drawer-body { padding: 18px 22px 28px; overflow-y: auto; display: grid; gap: 18px; align-content: start; }
.drawer-body td b { color: var(--ink); font-weight: 600; }
body.drawer-open { overflow: hidden; }
.tooltip { z-index: 40; }

/* ---------- Day timeline ---------- */
.day { position: relative; padding: 4px 0 28px 26px; border-left: 2px solid var(--panel-line); margin-left: 8px; }
.day::before {
  content: ''; position: absolute; left: -9px; top: 10px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--bg); border: 3px solid var(--accent);
}
.day:last-child { border-left-color: transparent; }
.day-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.day-head h2 { font-size: 34px; color: var(--accent); }
.day-date { font-family: var(--display); font-weight: 600; font-size: 20px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  background: var(--bg-raise); border: 1px solid var(--panel-line); border-radius: 999px;
  padding: 3px 12px; font-size: 14px; color: var(--ink-2);
}
.chip b { color: var(--ink); font-weight: 600; }
.journal {
  background: var(--bg-raise); border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px; margin-bottom: 14px; color: var(--ink-2);
}
.journal h3 { color: var(--ink); font-style: italic; font-size: 22px; margin-bottom: 6px; }
.journal p + p, .journal p + ul, .journal ul + p { margin-top: 10px; }
.journal ul { padding-left: 20px; }
.journal strong { color: var(--ink); }
.journal-empty { border-left-color: var(--panel-line); color: var(--ink-3); font-style: italic; }
.tag {
  display: inline-block; font-family: var(--body); font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; padding: 2px 8px; border-radius: 4px; margin-right: 10px; vertical-align: 3px;
}
.tag-ride { background: rgba(252, 103, 25, 0.16); color: var(--accent-ink); }
.tag-lift { background: rgba(51, 140, 255, 0.16); color: #7db4ff; }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  background: #0b0e14; border: 1px solid var(--panel-line); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; color: var(--ink); line-height: 1.4;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45); white-space: nowrap;
}
.tooltip b { font-family: var(--display); font-size: 16px; }
.tooltip .muted { color: var(--ink-3); }

/* ---------- Footer ---------- */
.footer {
  max-width: 1100px; margin: 40px auto 0; padding: 20px var(--gutter) 32px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--ink-3); font-size: 13px; border-top: 1px solid var(--panel-line);
}

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .topbar { gap: 12px; }
  .topbar nav { gap: 12px; overflow-x: auto; }
  .topbar nav a { font-size: 14px; }
  .day-chip { display: none; }
  .climb-time .value { font-size: 44px; }
  .tile .value { font-size: 32px; }
  .day { padding-left: 18px; margin-left: 6px; }
  .drawer-panel {
    top: auto; left: 0; width: 100%; max-height: 85vh; border-left: none;
    border-top: 1px solid var(--panel-line); border-radius: 16px 16px 0 0; transform: translateY(100%);
  }
  .drawer-header, .drawer-body { padding-left: 16px; padding-right: 16px; }
  .cmp-row { grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .cmp-label { grid-column: 1 / 2; }
  .cmp-delta { grid-column: 2 / 3; grid-row: 1; }
  .cmp-start { grid-column: 1 / 2; }
  .cmp-now { grid-column: 2 / 3; }
  .cmp-track { grid-column: 1 / -1; grid-row: 3; margin: 6px 8px 0; }
  .day-head h2 { font-size: 28px; }
}
@media (max-width: 420px) {
  .brand span { display: none; }
}
