/*==============================================*\
|| TerraLoc – the shared UI kit                   ||
|| css/tl-ui.css                                  ||
\*==============================================*/

/*
 * ONE VOCABULARY, FROM THE MOCKUP.
 *
 * Every artboard in the design canvas ships the same handful of classes in its
 * <helmet>: card, lbl, pbtn, react, rail, ctl, seg, fchip, ftab, lrow, pulse.
 * The activity page, live tracking, challenges and leagues are drawn from that
 * one set, and each page reinventing it is how four pages drift into four
 * products.
 *
 * The mockup's literals are the theme's own tokens, which is the useful part:
 *
 *   #F3F2EC paper      #FAF9F4 panel     #DFDCCB hairline
 *   #23281F ink        #5C6253 muted     #8B8F80 dim
 *   #46603C accent     #A8512E cta-hover #C9C5B2 a heavier hairline
 *
 * So nothing here hard-codes a colour: it all resolves through
 * terraloc-theme.css, and the night face comes free.
 */

/* ------------------------------------------------------------------
   Type
   ------------------------------------------------------------------ */

.tl-display {
  font-family: var(--tl-font-display, 'Bricolage Grotesque', system-ui, sans-serif);
}

.tl-mono {
  font-family: var(--tl-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}

/* The kicker above a block. Mono, wide, quiet: it names the thing under it
   and must never compete with it. */
.tl-lbl {
  font-family: var(--tl-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tl-dim, #8B8F80);
}

/* ------------------------------------------------------------------
   Surfaces
   ------------------------------------------------------------------ */

.tl-card {
  background: var(--tl-panel, #FAF9F4);
  border: 1px solid var(--tl-hairline, #DFDCCB);
  border-radius: 10px;
}

/* Nothing to show yet. One component for every list on the site: it was
   three private copies (activities, routes, the athlete archive) and two
   SkyTrackPro ones nothing styled, so an empty club page and an empty
   competition list looked like two products. */
.tl-empty-state {
  padding: 2.5rem 1.5rem;
  border: 1px solid var(--tl-hairline, #DFDCCB);
  border-radius: var(--tl-radius-lg, 12px);
  background: var(--tl-panel, #FAF9F4);
  text-align: center;
}

.tl-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: .9rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tl-accent, #46603C) 12%, transparent);
  color: var(--tl-accent, #46603C);
  font-size: 1.25rem;
}

.tl-empty-title {
  margin: 0 0 .4rem;
  font-family: var(--tl-font-display, 'Bricolage Grotesque', system-ui, sans-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--tl-ink, #23281F);
}

.tl-empty-copy {
  max-width: 34rem;
  margin: 0 auto;
  color: var(--tl-muted, #5C6253);
}

/* The heading over a list: an orange kicker, a title, and an action opposite.
   Activities, Routes and the athlete archive draw it, and so do the blocks
   that put a short list on another page. Pages that tune it scope their
   own rule under their root. */
.tl-results-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: .75rem;
}

.tl-results-kicker {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--tl-cta, #C86B3F);
}

.tl-results-title {
  font-size: clamp(1.2rem, 1.8vw, 1.75rem);
  font-weight: 800;
  color: var(--tl-ink, #23281F);
}

@media (max-width: 991.98px) {
  .tl-results-head {
    flex-direction: column;
    align-items: start;
  }
}

@media (max-width: 575.98px) {
  .tl-results-kicker {
    font-size: .66rem;
    letter-spacing: .14em;
  }

  .tl-results-title {
    font-size: clamp(1.08rem, 7vw, 1.35rem);
    line-height: 1.15;
  }
}

/* ------------------------------------------------------------------
   Buttons and pills
   ------------------------------------------------------------------ */

.tl-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--tl-hairline-strong, #C9C5B2);
  background: var(--tl-panel, #FAF9F4);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tl-ink, #3B4034);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tl-btn:hover,
.tl-btn:focus-visible {
  border-color: var(--tl-accent, #46603C);
  color: var(--tl-accent, #46603C);
  outline: none;
}

/* The pressed state is ink, not a tint: on paper a filled dark chip is the
   only thing that reads as "this one" at a glance. */
.tl-btn.is-on,
.tl-btn[aria-pressed="true"] {
  background: var(--tl-ink, #23281F);
  border-color: var(--tl-ink, #23281F);
  color: var(--tl-paper, #F3F2EC);
}

.tl-btn.is-on:hover,
.tl-btn[aria-pressed="true"]:hover {
  color: var(--tl-paper, #F3F2EC);
}

/* The one filled action on a screen: the accent, not the ink. .is-on above is
   a state ("this one is selected"); this is a verb. tleagues had its own
   .tleagues-btn-primary saying exactly this, which is how one product ends up
   with two primary buttons. */
.tl-btn-accent {
  background: var(--tl-accent, #46603C);
  border-color: var(--tl-accent, #46603C);
  color: var(--tl-accent-ink, #F3F2EC);
}

.tl-btn-accent:hover,
.tl-btn-accent:focus-visible {
  background: var(--tl-accent-hover, #2E4228);
  border-color: var(--tl-accent-hover, #2E4228);
  color: var(--tl-accent-ink, #F3F2EC);
}

/* A reaction, or any small countable chip. */
.tl-react {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--tl-hairline, #DFDCCB);
  background: var(--tl-panel, #FAF9F4);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--tl-ink, #3B4034);
  cursor: pointer;
  white-space: nowrap;
}

.tl-react[aria-pressed="true"] {
  border-color: var(--tl-accent, #46603C);
  color: var(--tl-accent, #46603C);
}

.tl-react .tl-react-count {
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  color: var(--tl-dim, #8B8F80);
}

.tl-react[aria-pressed="true"] .tl-react-count {
  color: inherit;
}

/* A filter chip: the same pill at label size, for a row of choices. */
.tl-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--tl-hairline, #DFDCCB);
  background: var(--tl-panel, #FAF9F4);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--tl-muted, #5C6253);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.tl-chip.is-on,
.tl-chip[aria-pressed="true"] {
  background: var(--tl-ink, #23281F);
  border-color: var(--tl-ink, #23281F);
  color: var(--tl-paper, #F3F2EC);
}

/* ------------------------------------------------------------------
   Segmented control

   One row, one live option. Used for the basemap picker, where a <select>
   hides three of the four choices behind a click for no reason.
   ------------------------------------------------------------------ */

.tl-seg {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  gap: 2px;
  border-radius: 9px;
  border: 1px solid var(--tl-hairline, #DFDCCB);
  background: var(--tl-panel, #FAF9F4);
}

.tl-seg-item {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--tl-muted, #5C6253);
  cursor: pointer;
  white-space: nowrap;
}

.tl-seg-item.is-on,
.tl-seg-item[aria-pressed="true"] {
  background: var(--tl-ink, #23281F);
  color: var(--tl-paper, #F3F2EC);
}

/* ------------------------------------------------------------------
   The left rail

   An icon over a mono micro-label. The labels are the point: six unlabelled
   circles is a memory test, and the panels behind them are not guessable
   from a glyph.
   ------------------------------------------------------------------ */

.tl-rail {
  width: var(--tl-rail-w, 64px);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 0;
  background: var(--tl-panel, #FAF9F4);
  border-right: 1px solid var(--tl-hairline, #DFDCCB);
}

.tl-rail-btn {
  width: 52px;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 2px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--tl-muted, #5C6253);
  cursor: pointer;
  position: relative;
}

.tl-rail-btn:hover,
.tl-rail-btn:focus-visible {
  background: var(--tl-paper-deep, #EFEDE2);
  color: var(--tl-ink, #23281F);
  outline: none;
}

.tl-rail-btn.is-on {
  background: var(--tl-paper-deep, #EFEDE2);
  color: var(--tl-ink, #23281F);
}

/*
  THE ACTIVE ITEM CARRIES A FILLED CHIP, which is what the mockups draw.

  A slightly darker background behind the whole button was the only thing
  saying which rail item was open, and on paper against paper-deep that is a
  difference of four percent lightness: on a phone in daylight it said
  nothing. The icon sits in a chip instead, and the chip fills with the accent
  when the item is on, which reads at a glance and at arm's length.

  Styled on the <i> rather than on a wrapper, so both rails get it without
  either page changing its markup.
*/
.tl-rail-btn i {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 0.9rem;
  transition: background-color .12s ease, color .12s ease;
}

.tl-rail-btn.is-on i {
  background: var(--tl-accent, #46603C);
  color: var(--tl-white, #fff);
}

/*
  A RAIL ITEM WITH NOTHING TO SHOW.

  Not hidden: the item still says what the planner can do, and an icon that
  comes and goes as waypoints are added is a rail that moves under the
  reader's thumb. Dimmed and unpressable instead.
*/
.tl-rail-btn:disabled,
.tl-rail-btn.is-off {
  opacity: 0.38;
  cursor: default;
}

.tl-rail-btn:disabled:hover,
.tl-rail-btn.is-off:hover {
  background: none;
  color: var(--tl-muted, #5C6253);
}

/* The one rail item that undoes things says so in its own colour. */
.tl-rail-btn.is-danger { color: var(--tl-cta, #C86B3F); }
.tl-rail-btn.is-danger.is-on i { background: var(--tl-cta, #C86B3F); }

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

.tl-rail-label {
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 8.5px;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  /*
    Two words, two lines. "Other ways" and "My routes" already wanted it and
    were being squeezed onto one 52px line; TerraVita is two words and reads
    as one long one when they are run together.
  */
  text-wrap: balance;
}

/* ------------------------------------------------------------------
   A stage: the rail and the thing it belongs to.

   ONE LAYOUT, SO A SECOND PAGE DOES NOT INVENT A SECOND ONE. The track page
   had the only rail on the site and the only rule for what a rail does on a
   phone, written into track.css against its own stage. The planner needs the
   same behaviour, and copying it would have made two places to fix it. A page
   adds .tl-stage next to its own sizing class and gets the arrangement; what
   it keeps for itself is how tall the stage is.
   ------------------------------------------------------------------ */

/*
 * How much of the left edge the rail owns.
 *
 * On :root rather than on .tl-stage because the things that have to start
 * clear of the rail are not all inside it: the track page's panels are modals
 * at the end of the document, and they had the 64 written into them by hand.
 * It goes to zero on a phone, where the rail is along the bottom instead.
 */
:root {
  --tl-rail-w: 64px;

  /*
   * And how the panel the rail opens is shaped, so the planner and the track
   * page cannot drift apart. They had a 344px card 11px from the rail with a
   * 14px radius on one page and a 412px panel 20px away with a 12px radius on
   * the other, which is two answers to one question. The width stays with each
   * page, because the track panel's two-column metric rows genuinely need more
   * of it, but everything about how it sits is settled here.
   */
  --tl-card-gap: 0.85rem;
  --tl-card-radius: 14px;

  /* How far up a phone the sheet comes. */
  /*
    The shadow under a card that floats over a map. Was declared in track.css
    and used by the activity page's dock; the planner's terrain profile is the
    same card doing the same thing and had to guess at it.
  */
  /*
    How tall the altitude dock is when its chart is the 44px strip. Anything
    floating over the bottom of a map has to clear it, and the number was
    written into the planner's sheet as a guess at a panel height.
  */
  --tl-alt-dock-h: 92px;
  /*
    How tall the chart opens to. Belongs with the dock rather than in one
    page's sheet: the planner has the same component and could only guess.
  */
  --tl-track-chart-h: clamp(160px, 24vh, 220px);

  --tl-card-shadow: 0 20px 48px rgba(15, 23, 42, 0.18);
  --tl-sheet-h: 58svh;
}

.tl-stage {
  display: flex;
  overflow: hidden;
}

/* The content beside the rail. Both minimums matter: without them a grid or a
   map inside refuses to shrink and pushes the rail off the edge. */
.tl-stage > :not(.tl-rail) {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

/* Down the side it fills the stage and scrolls if the buttons need more room
   than the window has. This was written against the track page's own stage,
   which is how it came to set a height the phone layout then had to fight. */
.tl-stage > .tl-rail {
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
}

.tl-stage > .tl-rail::-webkit-scrollbar {
  display: none;
}

/* A count on a rail button, for comments and photos. */
.tl-rail-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--tl-cta, #C86B3F);
  color: var(--tl-cta-ink, #fff);
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 9px;
  line-height: 15px;
  text-align: center;
}

/* ------------------------------------------------------------------
   The rail on a phone: along the bottom, not down the side.

   A PHONE HAS NO WIDTH TO SPARE AND A MAP WANTS ALL OF IT. Down the side the
   rail took 54 of 390 px, a seventh of the screen, and the map it sits beside
   got 336: on the activity page that was enough to push the playback dock
   over its own right edge and clip the clock. Along the bottom the map gets
   the lot, and the bar lands where a thumb already is.

   Order 99 rather than a rule on the stage, because the rail is first in the
   markup and belongs last on the screen, and the page should not have to
   remember that.
   ------------------------------------------------------------------ */

@media (max-width: 767.98px) {
  :root {
    --tl-rail-w: 0px;
    /* What the bar comes to, for anything that has to stop above it. The rail
       is held to this rather than left to its content, so the number and the
       bar cannot disagree. */
    --tl-rail-h: 55px;
  }

  .tl-stage {
    flex-direction: column;
  }

  .tl-rail {
    order: 99;
    width: auto;
    flex-direction: row;
    justify-content: space-around;
    gap: 2px;
    padding: 4px 2px;
    /* Clear of the home indicator on a phone that has one. */
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    border-top: 1px solid var(--tl-hairline, #DFDCCB);
  }

  /* Share the width out evenly. Six is what the activity page can show at
     once, and six across 390 px is 65 px each, which still fits the icon and
     its word. */
  .tl-rail {
    height: calc(var(--tl-rail-h, 55px) + env(safe-area-inset-bottom, 0px));
  }

  .tl-rail-btn {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    min-height: 46px;
  }

  .tl-rail-label {
    font-size: 8px;
  }

  /* And it is a bar now, so it stops filling the stage and stops scrolling. */
  .tl-stage > .tl-rail {
    height: auto;
    overflow: visible;
  }
}

/* ------------------------------------------------------------------
   Live

   Amber means live and nothing else, on both faces. The dot pulses; the
   word does not, because a blinking label is unreadable.
   ------------------------------------------------------------------ */

.tl-pulse {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--tl-live, #C86B3F);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--tl-live, #C86B3F) 60%, transparent);
  animation: tl-pulse 2s ease-out infinite;
}

@keyframes tl-pulse {
  70%  { box-shadow: 0 0 0 7px color-mix(in srgb, var(--tl-live, #C86B3F) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tl-live, #C86B3F) 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .tl-pulse { animation: none; }
}

/* ------------------------------------------------------------------
   The page header and its four figures

   Every one of the list pages opens the same way: a kicker, a title, a
   sentence saying what the list is, the current scope with a way out of
   it, and four numbers describing the whole set before you read any of
   it. Activities, Rankings, Clubs and Competitions each had their own
   version of that, which is how four pages of one product end up looking
   like four products.
   ------------------------------------------------------------------ */

.tl-pagehead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
}

.tl-pagehead-copy {
  min-width: 0;
}

.tl-pagehead-kicker {
  display: block;
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tl-cta, #C86B3F);
}

.tl-pagehead-title {
  margin: 0.35rem 0 0;
  font-family: var(--tl-font-display, 'Bricolage Grotesque', system-ui, sans-serif);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--tl-ink, #23281F);
}

.tl-pagehead-sub {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  color: var(--tl-muted, #5C6253);
  max-width: 60ch;
}

/* What the list is currently showing, and the way back to everything. */
.tl-scope {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tl-scope-copy {
  text-align: right;
}

.tl-scope-label {
  display: block;
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tl-dim, #8B8F80);
}

.tl-scope-value {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.8rem;
  color: var(--tl-ink, #23281F);
}

/* ------------------------------------------------------------------
   The four figures
   ------------------------------------------------------------------ */

/* Flex rather than grid, so the last row always fills.
   auto-fit left an empty track whenever the count did not divide by the
   column count, and on a phone that is two columns for three figures: a grey
   hole in the strip, because the hairline is the gap colour showing through.
   Flex items grow into the space instead, and there is never a cell with
   nothing in it. */
.tl-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  margin-top: 1.25rem;
  border: 1px solid var(--tl-hairline, #DFDCCB);
  border-radius: 10px;
  background: var(--tl-hairline, #DFDCCB);
  overflow: hidden;
}

/* One hairline between them rather than four separate cards: they are one
   reading of one set, not four unrelated facts. */
.tl-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem 1.1rem;
  background: var(--tl-paper-deep, #EFEDE2);
  flex: 1 1 11rem;
  min-width: 0;
}

.tl-kpi-label {
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tl-dim, #8B8F80);
}

.tl-kpi-value {
  font-family: var(--tl-font-display, 'Bricolage Grotesque', system-ui, sans-serif);
  font-size: clamp(1.3rem, 2.6vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--tl-ink, #23281F);
  font-variant-numeric: tabular-nums;
}

.tl-kpi-value small {
  font-size: 0.5em;
  font-weight: 700;
  margin-left: 0.2em;
  color: var(--tl-muted, #5C6253);
}

/* What the number covers. A bare "18 640 km" leaves the question open. */
.tl-kpi-note {
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tl-dim, #8B8F80);
}

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

   A row of controls in a card of its own, so the page reads header,
   filters, results rather than one continuous wall.
   ------------------------------------------------------------------ */

.tl-filterbar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--tl-hairline, #DFDCCB);
  border-radius: 10px;
  background: var(--tl-panel, #FAF9F4);
}

.tl-filterbar-spacer {
  flex: 1 1 auto;
}

.tl-filterbar-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

/* A search box wants more room than a select, not the whole row: at 1440 an
   uncapped one came out 1250px wide for a phrase of three words. */
.tl-filterbar-field-grow {
  flex: 1 1 16rem;
  max-width: 26rem;
}

.tl-filterbar-label {
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tl-dim, #8B8F80);
}

/* The panel dresses its own controls. Activities styled its selects from
   tracks.css and Competitions from public-competitions.css, so the same
   filter row came out white and rounded on one page and grey and square on
   the next. A page that adopts .tl-filterbar now gets the fields with it. */
.tl-filterbar .form-select,
.tl-filterbar .form-control {
  height: 34px;
  padding: 0 2rem 0 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--tl-hairline-strong, #C9C5B2);
  background-color: var(--tl-white, #FFFFFF);
  color: var(--tl-ink, #23281F);
  font-size: 0.85rem;
  line-height: 32px;
}

.tl-filterbar .form-control {
  padding-right: 0.7rem;
}

.tl-filterbar .form-select:focus,
.tl-filterbar .form-control:focus {
  border-color: var(--tl-accent, #46603C);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tl-accent, #46603C) 18%, transparent);
  outline: none;
}

/* ------------------------------------------------------------------
   A leaderboard row

   Rank, who, and the number. The rank is display-face and large because it
   is what the eye scans; the number is mono so the column aligns.
   ------------------------------------------------------------------ */

.tl-lrow {
  display: grid;
  grid-template-columns: 3.6rem 1fr auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--tl-hairline, #DFDCCB);
}

.tl-lrow:last-child {
  border-bottom: 0;
}

.tl-lrow-head {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  background: var(--tl-paper-deep, #EFEDE2);
}

.tl-lrow-rank {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  font-family: var(--tl-font-display, 'Bricolage Grotesque', system-ui, sans-serif);
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Movement since the last standing. Up is the accent, down is quiet: a
   drop should be legible, not scolding. */
.tl-lrow-move {
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.62rem;
  color: var(--tl-dim, #8B8F80);
}

.tl-lrow-move.is-up { color: var(--tl-accent, #46603C); }
.tl-lrow-move.is-down { color: var(--tl-muted, #5C6253); }

.tl-lrow-name {
  font-weight: 600;
  min-width: 0;
}

.tl-lrow-meta {
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tl-dim, #8B8F80);
}

.tl-lrow-value {
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* The viewer's own row, marked without shouting. */
.tl-lrow.is-you {
  background: color-mix(in srgb, var(--tl-accent, #46603C) 7%, transparent);
}

/* ------------------------------------------------------------------
   A progress bar, for a challenge's share of its goal
   ------------------------------------------------------------------ */

.tl-meter {
  height: 8px;
  border-radius: 999px;
  background: var(--tl-paper-deep, #EFEDE2);
  overflow: hidden;
}

.tl-meter-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--tl-accent, #46603C);
}


/* ------------------------------------------------------------------
   What the ground is, as a list

   A swatch, a name, a bar and a share. The activity page shows it for a day
   that happened and the planner for a line not yet ridden, and they are the
   same three answers from the same SurfaceMatcher and the same
   --tl-surface-* tokens, so they are one component rather than two that
   happen to look alike.
   ------------------------------------------------------------------ */
.tl-surface-list {
  display: grid;
  gap: 0.35rem;
}

.tl-surface-row {
  display: grid;
  grid-template-columns: 0.7rem minmax(5.5rem, auto) minmax(0, 1fr) 2.6rem;
  align-items: center;
  gap: 0.55rem;
}

.tl-surface-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
}

.tl-surface-name {
  font-size: 0.82rem;
  color: var(--tl-ink, #23281F);
  white-space: nowrap;
}

.tl-surface-bar {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: var(--tl-paper-deep, #EFEDE2);
  overflow: hidden;
}

.tl-surface-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

/* Said quietly, under the list: the percentages above are of the ground the
   engine could follow, and this is how much of the day that was. */
.tl-surface-note {
  margin: 0.55rem 0 0;
  font-size: 0.72rem;
  color: var(--tl-dim, #8B8F80);
}

.tl-surface-pct {
  font-size: 0.78rem;
  text-align: right;
  color: var(--tl-muted, #5C6253);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------
   The ground through a lens: where it gets rough

   Under a lens section's grades (can you skate it), the stretches that are
   not smooth, in order along the way: where, how long and how bad on the
   left, what the ground and the way were on the right.
   ------------------------------------------------------------------ */
.tl-lens-spots-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
  margin: 1rem 0 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--tl-ink, #23281F);
}

.tl-lens-spots-head .tl-mono {
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tl-dim, #8B8F80);
}

.tl-lens-spots {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tl-lens-spot {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--tl-hairline, #DFDCCB);
}

.tl-lens-at {
  font-size: 0.74rem;
  color: var(--tl-ink, #23281F);
  font-variant-numeric: tabular-nums;
}

.tl-lens-at > span {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tl-dim, #8B8F80);
}

.tl-lens-what {
  min-width: 0;
  font-size: 0.85rem;
  color: var(--tl-ink, #23281F);
}

.tl-lens-what > span {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: var(--tl-muted, #5C6253);
}

/* ------------------------------------------------------------------
   A panel of numbers

   A section with a kicker, a title and an accent icon, holding a grid of
   tiles: one mono label over one figure. The activity page shows a day that
   happened and the planner a line not yet ridden, and they ask the same kind
   of question, so they are one component.

   It lived in track.css as .tl-track-* and the planner had a second one of
   its own under .tleagues-metric-*. Two tile designs for the same fact, which
   is how a route and the ride of it came to look like different products.

   The accent is currentColor, set inline by whoever renders the section, so a
   sport colours its own block without a rule per sport. track.css still tunes
   these inside .tl-track-panel, which is a narrower place saying something
   narrower.
   ------------------------------------------------------------------ */

.tl-stat-sections {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

/* A section is a quiet enclosure, not a card stacked on a card: the panel it
   sits in is already raised, and a second shadow inside it reads as clutter. */
.tl-stat-section {
  padding: 1rem;
  border-radius: 1rem;
  background: var(--tl-paper, #f6f6f2);
  border: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.08));
  /* currentColor here is the sport's, set inline by the renderer. Only the
     accents read it; every piece of text sets its own colour below, so the
     section does not turn into green prose. */
}

.tl-stat-section-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.tl-stat-section-icon {
  width: 2.4rem;
  height: 2.4rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 0.8rem;
  /* currentColor is the sport's, set inline; the wash follows it. */
  color: var(--tl-accent, #46603C);
  background: color-mix(in srgb, currentColor 12%, transparent);
}

/* The kicker is mono and small, the way every kicker on the site is. */
.tl-stat-kicker {
  font-family: var(--tl-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tl-dim, #8B8F80);
}

.tl-stat-section-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--tl-ink, inherit);
}

.tl-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.6rem;
}

.tl-stat-grid-core {
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

/* ---- one tile ---- */

.tl-stat-tile {
  position: relative;
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 0.85rem 0.7rem 1rem;
  border-radius: 0.85rem;
  background: var(--tl-white, #fff);
  border: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.08));
  overflow: hidden;
}

/* One hairline of the section's own colour down the left edge, inherited
   rather than assigned by position. */
.tl-stat-tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.2rem;
  background: currentColor;
  opacity: 0.55;
}

.tl-stat-tile-icon {
  display: none;
}

.tl-stat-label {
  font-family: var(--tl-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tl-dim, #8B8F80);
}

.tl-stat-tile-value {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--tl-ink, inherit);
  font-variant-numeric: tabular-nums;
}

.tl-stat-tile-value small,
.tl-stat-unit {
  font-size: 0.62em;
  font-weight: 600;
  color: var(--tl-muted, #5C6253);
  margin-left: 0.15em;
}

/* The three that lead the panel get the room to be read across a table. */
.tl-stat-tile-hero {
  padding: 0.9rem 1rem 0.9rem 1.15rem;
}

.tl-stat-tile-hero .tl-stat-tile-value {
  font-size: 1.65rem;
}

.tl-stat-tile-wide {
  grid-column: 1 / -1;
}

[data-bs-theme="dark"] .tl-stat-tile {
  background: var(--tl-white, #24241C);
  border-color: var(--tl-hairline, #2F2F26);
}

/* ------------------------------------------------------------------
   The same numbers in a narrow column

   Tiles need about 150px each to be read as tiles. A panel 300px wide gives
   two of them, which puts "Avg speed" on three lines next to "21.5 km/h",
   and the fix is not a smaller font: it is to stop being a tile. Here the
   pair is a row, label left and figure right, hairline top and bottom.

   Ask for it with .tl-stat-rows on the grid. It was written as
   ".tl-track-panel .tl-stat-grid", which said "on the activity page" when
   what it meant was "when the column is narrow", and so could not be reached
   from the planner sidebar, which is 370px and has exactly the same problem.
   ------------------------------------------------------------------ */

.tl-stat-rows {
  grid-template-columns: minmax(0, 1fr);
  gap: 0.1rem 0.9rem;
  padding: 0.4rem 0;
  border-top: 1px solid var(--tl-hairline, #DFDCCB);
  border-bottom: 1px solid var(--tl-hairline, #DFDCCB);
}

.tl-stat-rows .tl-stat-tile {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border: 0;
  border-radius: 0;
  background: none;
  overflow: visible;
}

.tl-stat-rows .tl-stat-tile::before {
  display: none;
}

.tl-stat-rows .tl-stat-tile-body {
  display: contents;
}

.tl-stat-rows .tl-stat-tile-value {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* In a row the label is sentence case at reading size, not a mono kicker:
   a column of eight shouted micro-labels is unreadable. */
.tl-stat-rows .tl-stat-label {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--tl-muted, #5C6253);
  white-space: nowrap;
}

.tl-stat-rows .tl-stat-tile-value {
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.74rem;
  font-weight: 500;
  white-space: nowrap;
}

.tl-stat-rows .tl-stat-tile-value small {
  font-size: 1em;
  font-weight: 500;
}

/* ------------------------------------------------------------------
   How hard the athlete found it

   Five pips and a word. The pips are the meter: at a glance you read the
   count, and the word says what the count means so two athletes agree
   roughly what a 4 is. Not a grade of the ground, so it never appears
   without the athlete having said it.

   The scale lives in Track/Difficulty; this only knows that there are
   pips and that more of them is harder.
   ------------------------------------------------------------------ */

.tl-difficulty {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tl-difficulty-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.12));
  background: var(--tl-white, #fff);
  color: var(--tl-muted, #5C6253);
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
}

/* The radio itself is the accessible control and the label is the target,
   so it is here and out of sight rather than display:none, which would take
   it out of the tab order. */
.tl-difficulty-choice input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.tl-difficulty-choice:has(input:checked) {
  border-color: color-mix(in srgb, var(--tl-terra, #A9743E) 55%, transparent);
  background: color-mix(in srgb, var(--tl-terra, #A9743E) 12%, var(--tl-white, #fff));
  color: var(--tl-ink, #23281F);
  font-weight: 600;
}

.tl-difficulty-choice:has(input:focus-visible) {
  outline: 2px solid var(--tl-accent, #46603C);
  outline-offset: 2px;
}

/* ---- the dots ----

   THE LIT AND UNLIT STATES BELONG TO THE PIP, NOT TO WHAT SURROUNDS IT.
   The unlit rule used to be written as ".tl-difficulty-meter ... .is-off",
   so the moment the same markup appeared on an activity card all five dots
   came out ochre and a 2 read as a 5. A pip knows whether it is lit; the
   places it appears only choose how big it is.
*/

.tl-difficulty-pips {
  display: inline-flex;
  gap: 2px;
}

.tl-difficulty-pips i {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  /* Ochre, which is the colour of effort on this site. Amber means live and
     nothing else, and green is the accent. */
  background: var(--tl-terra, #A9743E);
}

.tl-difficulty-pips i.is-off {
  background: var(--tl-hairline, #DFDCCB);
}

/* In the picker each choice shows only its own count, with no unlit dots to
   read it against, so the whole row dims until it is the chosen one. */
.tl-difficulty-choice .tl-difficulty-pips i {
  opacity: 0.55;
}

.tl-difficulty-choice:has(input:checked) .tl-difficulty-pips i {
  opacity: 1;
}

/* The sport as a fact rather than a filled pill: the icon and the name in the
   sport's own colour, which is how the sport is drawn everywhere else here.
   currentColor is set inline from the registry, so a new sport needs no rule. */
.tl-activity-sport {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--tl-ink, #23281F);
  white-space: nowrap;
}

.tl-activity-sport svg,
.tl-activity-sport img {
  flex: 0 0 auto;
}

/* In a card's detail row, under its own label, beside where and how far.
   Sized to sit level with the figures next to it rather than with the meta
   line it used to be in. Same pips as everywhere else. */
.tl-activity-difficulty {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--tl-ink, #23281F);
  white-space: nowrap;
}

/* THE DOTS ARE THE READING, THE WORD IS THE GLOSS.

   A card column is about 96px on a phone and five dots plus "Demanding" want
   114, so the word overflowed into the figure beside it. Below this width the
   dots carry the level on their own: the column heading already says
   DIFFICULTY, and the word stays on the wrapper's title and for a screen
   reader. */
@media (max-width: 575.98px) {
  .tl-activity-difficulty .tl-difficulty-word {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* An unrated day still fills its cell, or the six columns stop lining up
   from one card to the next. */
.tl-activity-difficulty.is-unrated {
  color: var(--tl-muted, #5C6253);
  font-weight: 400;
}

/* The read-only version, on the activity page: the same pips, with the
   unlit ones drawn so the count reads against a scale of five. */
.tl-difficulty-meter {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.tl-difficulty-meter .tl-difficulty-pips i {
  width: 6px;
  height: 6px;
}

[data-bs-theme="dark"] .tl-difficulty-choice {
  background: var(--tl-panel, #1B1B14);
  border-color: var(--tl-hairline, #2F2F26);
  color: var(--tl-muted, #A8A99C);
}

[data-bs-theme="dark"] .tl-difficulty-choice:has(input:checked) {
  background: color-mix(in srgb, var(--tl-terra, #A9743E) 22%, var(--tl-panel, #1B1B14));
  color: var(--tl-ink, #E8E6DA);
}

/* ==================================================================
   THE ALTITUDE DOCK: a card over a map with a height profile in it.

   Lifted verbatim out of track.css, where it was the activity page's own.
   The route planner draws the same chart in the same card with the same
   three colour axes and the same open toggle, and a component described in
   one page's stylesheet is a component the other page has to copy. Same
   class names, so nothing on the activity page changes and nothing here is
   a second look for one thing.

   What stays in track.css: the replay transport, the open-state reflow, and
   the phone overrides that answer to that page's own dock row.
   ================================================================== */

.tl-track-dock {
  position: absolute;
  left: 1.25rem;
  right: 1.25rem;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--tl-hairline, #DFDCCB);
  background: color-mix(in srgb, var(--tl-panel, #FAF9F4) 97%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--tl-track-shadow-md);
}

.tl-track-dock-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.tl-track-profile {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  height: 44px;
  transition: height 0.22s ease;
}

.tl-track-chart-canvas {
  position: absolute;
  inset: 0;
  min-height: 0;
}

/* Both canvases, by class: the rule was keyed to the activity page's id. */
.tl-alt-canvas,
#altChart {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.tl-track-profile:focus-within {
  outline: 2px solid var(--tl-accent, #46603C);
  outline-offset: 2px;
  border-radius: 6px;
}

.tl-track-clock {
  flex: 0 0 auto;
  min-width: 5.1rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--tl-ink, #23281F);
}

.tl-track-alt {
  flex: 0 0 auto;
  font-size: 0.86rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--tl-muted, #5C6253);
}

.tl-track-dock .tl-btn {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 10px;
}

.tl-track-chart-toggle.tl-chart-open {
  background: var(--tl-ink, #23281F);
  border-color: var(--tl-ink, #23281F);
  color: var(--tl-paper, #F3F2EC);
}

.tl-track-colour-modes .tl-seg-item {
  min-width: 0;
  padding: 0 0.5rem;
}

.tl-track-colour-modes .tl-seg-item i {
  font-size: 0.82rem;
  pointer-events: none;
}

/* ------------------------------------------------------------------
   The profile's legend

   One line under the chart naming the colours it is drawn in, for slope and
   surface: sport is the default and the sport is named in the facts line
   above on both pages.

   Here rather than in track.css because the planner renders the same legend
   for the same chart, and without these rules it came out as a stack of bare
   words with no swatches, which is what it looked like.
   ------------------------------------------------------------------ */
.tl-track-legend {
  flex: 1 1 100%;
  order: -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 0.1rem 0 0.2rem;
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.66rem;
  color: var(--tl-muted, #5C6253);
}

.tl-track-legend-set {
  display: contents;
}

.tl-track-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.tl-track-legend-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 2px;
  flex: 0 0 auto;
}

/* The line under the chart: where it starts, how long it is, where it ends.
   With the dock, because the planner says the same three things about a route
   that the activity page says about a ride. */
.tl-track-dock-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.68rem;
  color: var(--tl-muted, #5C6253);
}

.tl-track-dock-when {
  flex: 1 1 auto;
  text-align: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-track-dock-edge {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}
