/* uphill.fit - tokens and app shell.
   Dark is the default; :root[data-mode="light"] is the only override layer.
   Cards, tables and controls live in components.css. */

/* Outfit, self-hosted: the two woff2 subsets Google Fonts serves to a modern
   browser, with their unicode-ranges unchanged. See static/vendor/MANIFEST.md.
   One variable face covers 400-700, so no second file per weight. */
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/vendor/fonts/outfit-v15-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/vendor/fonts/outfit-v15-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --canvas: #141517;
  --base: #1b1d22;
  --tint: #24272d;
  --hairline: #2a2d34;
  --line: #33373f;
  --text: #f9f9f9;
  --strong: #ffffff;
  --subtle: #9ba0a8;
  --brand: oklch(54% 0.11 255);
  --on-brand: #fff;
  --lime: #b7f272;
  --success: #b7f272;
  --danger: #ff6b5e;
  --control: #24272d;

  /* Chart palette: the blue accent and its warm muted-orange counterpart. The
     chart layer names these same tokens and app.js resolves them at mount, so
     ECharts and the SVG widgets read one palette. Every derived token sits here
     with --brand itself, because custom properties inherit by computed value: a
     --brand override on another element would leave these mixes at the default. */
  --warm: oklch(78% 0.1 55);
  --warm-soft: oklch(74% 0.06 55);

  /* years by recency: this year = accent, last year = warm, older = receding neutrals */
  --year-now: var(--brand);
  --year-1: var(--warm);
  --year-2: var(--warm-soft);
  --year-3: #767b83;
  --year-4: #5b5f66;
  --year-5: #45494f;

  /* categorical: sports */
  --cat-ride: var(--brand);
  --cat-run: var(--warm);
  --cat-ski: oklch(80% 0.05 250);
  --cat-hike: oklch(72% 0.1 140);
  --cat-water: oklch(72% 0.09 195);
  --cat-other: #9ba0a8;

  /* sequential intensity ramp: quiet grey, warm, accent */
  --int1: #55595f;
  --int2: var(--warm-soft);
  --int3: var(--warm);
  --int4: var(--brand);

  /* Every accent gradient rises from bottom-left to top-right, lighter at the start. */
  --accent: linear-gradient(
    to top right,
    color-mix(in oklch, var(--brand), white 22%),
    var(--brand)
  );
  --hero: linear-gradient(
    to top right,
    color-mix(in oklch, var(--brand), white 16%),
    var(--brand) 64%
  );
  --tip-bg: #f9f9f9;
  --tip-text: #1b1d22;
  --popover-shadow: 0 16px 48px rgb(0 0 0 / 0.4);

  --page: 1300px;
  --gutter: 28px;
  --gap: 16px;
  --radius-card: 24px;
  --radius-mini: 20px;
  --radius-popover: 18px;
  --round: 999px;
  --rail-top: 74px;
  --tap: 42px;

  --font: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --speed: 130ms;
}

:root[data-mode="light"] {
  --canvas: #e9ebe6;
  --base: #f9f9f9;
  --tint: #eff1ec;
  --hairline: #dfe2db;
  --line: #cccfc8;
  --text: #1b1d22;
  --strong: #141517;
  --subtle: #6a6f76;
  --success: #4c8a1f;
  --danger: #c93a2e;
  --control: #ffffff;
  --popover-shadow: 0 16px 48px rgb(20 21 23 / 0.14);
  --warm: oklch(62% 0.12 50);
  --warm-soft: oklch(67% 0.07 50);
  --year-3: #8f948c;
  --year-4: #a5a99f;
  --year-5: #babeb3;
  --cat-ski: oklch(58% 0.07 250);
  --cat-hike: oklch(52% 0.1 140);
  --cat-water: oklch(52% 0.09 195);
  --cat-other: #6a6f76;
  --int1: #b0b4ab;
  --tip-bg: #1b1d22;
  --tip-text: #f9f9f9;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--brand);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only,
.skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip:focus {
  position: fixed;
  inset: 12px auto auto 12px;
  z-index: 60;
  background: var(--base);
  border: 1px solid var(--hairline);
  border-radius: var(--round);
  padding: 8px 16px;
}

/* ---------------------------------------------------------------- header */

.masthead-inner,
.filterbar-inner,
.frame,
.footer {
  max-width: var(--page);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.masthead-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding-block: 18px 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand:hover {
  color: inherit;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-brand);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
}

.brand-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--strong);
}

.masthead-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* A setting, not a filter: the units live in the header next to the theme. */
.units-select {
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--base);
  border: 1px solid var(--hairline);
  border-radius: var(--round);
  padding: 7px 10px;
  cursor: pointer;
}

.units-select:hover {
  border-color: var(--subtle);
}

.sync {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--subtle);
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
}

.sync--busy .sync-dot {
  background: color-mix(in oklch, var(--brand), white 22%);
}

.sync--failed .sync-dot {
  background: var(--danger);
}

.switch {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--base);
  border: 1px solid var(--hairline);
  border-radius: var(--round);
  padding: 5px;
}

.switch-half {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--subtle);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--speed) ease;
}

.switch-half.is-on {
  background: var(--text);
  color: var(--canvas);
}

/* The spec pins the light-mode active circle to #141517 with a white glyph. */
:root[data-mode="light"] .switch-half.is-on {
  background: var(--strong);
  color: #fff;
}

/* ----------------------------------------------------------- filter bar */

.filterbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in oklch, var(--canvas) 85%, transparent);
  backdrop-filter: blur(12px);
}

.filterbar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-block: 12px;
}

.filterbar-state {
  display: contents;
}

.filter-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--subtle);
}

.chip-summary {
  font-size: 12px;
  color: var(--subtle);
  background: var(--base);
  border: 1px dashed var(--line);
  border-radius: var(--round);
  padding: 5px 12px;
}

.reset-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  padding: 5px 4px;
}

.reset-link:hover {
  text-decoration: underline;
}

/* The pages a filter does not reach say so, in the same dashed voice as the summary chip. */
.filter-note {
  margin: -6px 0 0;
  font-size: 12.5px;
  color: var(--subtle);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 8px 14px;
  width: fit-content;
}

.filterbar-end {
  margin-left: auto;
}

/* ---------------------------------------------------------------- frame */

.frame {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding-block: 10px 56px;
}

.rail {
  position: sticky;
  top: var(--rail-top);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--base);
  border: 1px solid var(--hairline);
  border-radius: var(--round);
  padding: 8px;
  flex: none;
}

.rail-link {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--subtle);
  transition: color var(--speed) ease;
}

.rail-link:hover {
  color: var(--strong);
}

.rail-link.is-on {
  background: var(--accent);
  color: var(--on-brand);
}

.rail-link svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

main#content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.page-title {
  margin: 2px 0 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--strong);
}

/* A view parameter, so it sits by the title of the pages it drives. */
.metric-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-picker .segment span {
  font-size: 12px;
  padding: 5px 13px;
}

/* --------------------------------------------------------------- footer */

.footer {
  display: flex;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
  padding-block: 0 20px;
  font-size: 12px;
  color: var(--subtle);
}

.footer-end {
  display: flex;
  align-items: center;
  gap: 14px;
}

.strava {
  font-weight: 600;
  color: var(--brand);
}

.link-button {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--subtle);
  cursor: pointer;
}

.link-button:hover {
  color: var(--strong);
}

/* ----------------------------------------------------------- login gate */

.gate-page {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 32px;
  padding-inline: var(--gutter);
  padding-block: 48px;
}

.gate {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.gate-title {
  margin: 0;
  font-size: 34px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--strong);
}

.gate-lede {
  margin: 0;
  max-width: 62ch;
  color: var(--subtle);
}

.connect {
  align-self: flex-start;
  background: var(--accent);
  color: var(--on-brand);
  border-radius: var(--round);
  padding: 10px 22px;
  font-weight: 600;
}

.connect:hover {
  color: var(--on-brand);
}

.fineprint {
  margin: 0;
  padding-left: 18px;
  color: var(--subtle);
  font-size: 12.5px;
}

/* -------------------------------------------------------------- tooltip */

/* One floating label for every [data-tip] element; app.js moves it under the pointer. */
.tip {
  position: fixed;
  z-index: 70;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  background: var(--tip-bg);
  color: var(--tip-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 9px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
  opacity: 0;
  transition: opacity var(--speed) ease;
}

.tip.is-on {
  opacity: 1;
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 720px) {
  :root {
    --gutter: 16px;
  }

  .frame {
    flex-direction: column;
    gap: 12px;
  }

  .rail {
    position: static;
    flex-direction: row;
    align-self: stretch;
    overflow-x: auto;
    justify-content: space-between;
  }

  main#content {
    align-self: stretch;
    width: 100%;
  }

  .gate-title {
    font-size: 27px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
