/*
 * All colours come from the theme variables generated in themes.css
 * (see src/web/themes.ts). Nothing here names a colour directly.
 *
 * Type has two voices:
 *   Archivo, narrow, heavy and slanted like race timing: titles and headline numbers.
 *   JetBrains Mono: labels, table figures and the command palette.
 * Sentences are set in Archivo at its normal width.
 *
 * Colour has two accents: --accent for links, active states and the chart,
 * and --accent-2 for numbers.
 */
@layer reset, base, layout, parts, data, palette, live;

@font-face {
  font-family: "Archivo";
  src: url("/assets/fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Archivo";
  src: url("/assets/fonts/archivo-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, p, ul, ol, dl, dd, figure, table { margin: 0; }
  ul, ol { padding: 0; list-style: none; }
  button, input { font: inherit; color: inherit; }
  /* "hidden" always wins, whatever display a component sets for itself. */
  [hidden] { display: none !important; }
}

@layer base {
  :root {
    --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --page: 68rem;
    --gutter: clamp(1rem, 4vw, 2.5rem);
    --radius: 6px;
  }
  html { background: var(--bg); color: var(--text); }
  body {
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }
  ::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

  /* The timing voice: titles and headline numbers. */
  h1, h2, .display {
    font-family: var(--font);
    font-style: italic;
    font-stretch: 70%;
    font-weight: 800;
    letter-spacing: 0;
  }
  h1 { font-size: clamp(2.5rem, 1.5rem + 4vw, 4.25rem); line-height: 0.95; text-wrap: balance; }
  h2 { font-size: 1.625rem; line-height: 1.1; margin-bottom: 1rem; }
  h3 { font-family: var(--mono); font-size: 0.75rem; font-weight: 500; color: var(--text-2); margin: 1.25rem 0 0.5rem; }

  /* Figures: monospaced so columns line up, in the theme's number colour. */
  .num {
    font-family: var(--mono);
    font-size: 0.9375em;
    font-weight: 500;
    font-variant-numeric: tabular-nums lining-nums;
    letter-spacing: -0.01em;
    color: var(--accent-2);
  }
  .num.display { font-family: var(--font); font-size: inherit; font-weight: 800; letter-spacing: 0; }
  .strong { font-weight: 700; }

  /* The label voice: small monospaced captions. */
  .label, kbd, code, table.plain td time,
  .stat-row dt, table.plain th, table.plain td.muted, table.plain .sub, .kicker, .wall-label, .wall-head span,
  .bar-note, .inspector-date, .chart-readout span {
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0;
  }
  .label, .stat-row dt, table.plain th, table.plain .sub, .kicker, .wall-label, .wall-head span,
  .bar-note, .inspector-date, .chart-readout span { color: var(--text-2); }

  a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
  a:hover { text-decoration-thickness: 2px; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
  code { font-size: 0.875em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
  kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0.05rem 0.35rem; color: var(--text-2); }
  .muted { color: var(--text-2); }
  .right { text-align: right; }
  .nowrap { white-space: nowrap; }
  .fine { font-size: 0.8125rem; color: var(--text-2); margin-top: 0.875rem; max-width: 70ch; }
  .lede { font-size: 1.125rem; color: var(--text-2); max-width: 60ch; margin-top: 1rem; }
  .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .skip { position: absolute; left: -999rem; }
  .skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: 0.5rem 0.75rem; z-index: 10; }
}

@layer layout {
  .site-header, main, .site-footer {
    width: 100%;
    max-width: calc(var(--page) + 2 * var(--gutter));
    margin-inline: auto;
    padding-inline: var(--gutter);
  }
  /* One row: the mark, the pages, the tools. The line under it carries a slanted marker for the page you are on. */
  .site-header {
    display: flex; align-items: stretch; gap: 0 2.25rem; flex-wrap: wrap;
    border-bottom: 1px solid var(--line);
  }
  .brand { display: flex; align-items: center; padding-block: 1.125rem; color: var(--text); }
  .brand svg { display: block; height: 1.5rem; width: auto; fill: currentColor; }
  .brand .mark-2 { fill: var(--author); }
  .site-header nav { display: flex; gap: 1.75rem; }
  .site-header nav a {
    position: relative; display: flex; align-items: center; gap: 0.45rem;
    font-style: italic; font-stretch: 75%; font-weight: 700; font-size: 1.125rem; line-height: 1.2;
    text-decoration: none; white-space: nowrap; color: var(--text-2);
  }
  .site-header nav a::after {
    content: ""; position: absolute; inset: auto 0 -1px; height: 3px; border-radius: 1px;
    transform: skewX(-12deg);
  }
  .site-header nav a:hover { color: var(--text); }
  .site-header nav a:hover::after { background: var(--text-2); }
  .site-header nav a[aria-current="page"] { color: var(--text); }
  .site-header nav a[aria-current="page"]::after { background: var(--accent); }
  /* Too narrow for one row: the pages move to a row of their own under the mark and the tools. */
  @media (max-width: 44rem) {
    .brand { padding-block: 0.875rem 0.5rem; }
    .site-header nav { order: 3; flex-basis: 100%; gap: clamp(1rem, 5vw, 1.5rem); }
    .site-header nav a { padding-block: 0.375rem 0.75rem; }
  }
  .header-tools { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }
  /* These need the script; without it they stay out of the way. */
  :root:not([data-scheme]) :is(.header-tools, .inspector) { display: none; }

  main { flex: 1; padding-block: 3rem 4rem; }
  .block { margin-bottom: 3.5rem; }
  .block.narrow { max-width: 40rem; }
  .block.narrow p { margin-top: 1rem; }
  .split { display: grid; gap: 0 3.5rem; }
  @media (min-width: 56rem) { .split { grid-template-columns: 1fr 1fr; } }

  .site-footer { border-top: 1px solid var(--line); padding-block: 1.5rem 2.5rem; color: var(--text-2); font-size: 0.8125rem; }
  .site-footer p { max-width: 70ch; }
}

@layer parts {
  .palette-open, .theme-toggle {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    height: 2.25rem; cursor: pointer;
  }
  .palette-open:hover, .theme-toggle:hover { background: var(--surface-2); border-color: var(--accent); }
  .palette-open {
    display: flex; align-items: center; gap: 0.625rem; padding: 0 0.5rem 0 0.625rem;
    font-family: var(--mono); font-size: 0.75rem; color: var(--text-2);
  }
  .palette-open svg, .theme-toggle svg { width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .palette-open span { margin-right: 0.75rem; }
  /* As the row tightens the button sheds its words, then its shortcut; a touch screen has no use for the shortcut either. */
  @media (max-width: 56rem) { .palette-open span { display: none; } }
  @media (hover: none) { .palette-open kbd { display: none; } }
  @media (max-width: 44rem), (hover: none) and (max-width: 56rem) {
    .palette-open kbd { display: none; }
    .palette-open { width: 2.25rem; padding: 0; justify-content: center; }
  }
  .theme-toggle { width: 2.25rem; display: grid; place-items: center; padding: 0; }
  :root[data-scheme="dark"] .icon-sun, :root[data-scheme="light"] .icon-moon { display: none; }

  .stat-row { display: flex; flex-wrap: wrap; gap: 1rem 2.5rem; margin: 0 0 1.25rem; }
  .stat-row dd { font-size: 1.5rem; line-height: 1.15; }

  table.plain { width: 100%; border-collapse: collapse; }
  table.plain th { text-align: left; padding: 0 0.75rem 0.5rem 0; }
  table.plain th.right { text-align: right; padding-right: 0; padding-left: 0.75rem; }
  table.plain td { padding: 0.55rem 0.75rem 0.55rem 0; border-top: 1px solid var(--line); vertical-align: baseline; }
  table.plain td.right { padding-right: 1.5rem; padding-left: 0.75rem; }
  table.plain th.right:not(:last-child) { padding-right: 1.5rem; }
  table.plain td.right:last-child { padding-right: 0; }
  table.plain .sub { display: block; }
  .table-scroll { overflow-x: auto; }
  table.replays td { vertical-align: middle; }
  .download {
    position: relative; /* keeps its hidden label inside the scrolling table on narrow screens */
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.7rem;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
    font-size: 0.875rem; font-weight: 600; color: var(--text); text-decoration: none; white-space: nowrap;
  }
  .download:hover { background: var(--surface-2); border-color: var(--accent); color: var(--accent); }

  .chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-block: 1.75rem 1.5rem; }
  .chip {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: transparent; border: 1px solid var(--line); border-radius: 999px;
    padding: 0.35rem 0.8rem 0.35rem 0.55rem; cursor: pointer;
    font-family: var(--mono); font-size: 0.75rem; font-weight: 500; color: var(--text);
  }
  .chip .sw { margin-right: 0; }
  .chip .medal { width: 1.66375rem; height: 1.66375rem; margin: -0.275rem 0; vertical-align: 0; }
  .chip[aria-pressed="true"] svg.medal.none { stroke: currentColor; }
  .chip:hover { border-color: var(--accent); }
  .chip[aria-pressed="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); }
  .chip[aria-pressed="true"] .num { color: inherit; }

  .icon { width: 1.2em; height: 1.2em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .icon.solid { fill: currentColor; stroke: none; }
  .day-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.5rem; margin: -0.75rem -0.6rem 2.25rem; }
  .day-nav a {
    display: inline-flex; align-items: center; gap: 0.4rem; justify-self: start;
    padding: 0.4rem 0.6rem; border-radius: var(--radius); text-decoration: none;
    font-family: var(--mono); font-size: 0.8125rem; font-weight: 500; color: var(--text-2);
  }
  .day-nav a:hover { background: var(--surface-2); color: var(--accent); }
  .day-nav > :last-child { justify-self: end; }
  @media (max-width: 30rem) { .day-nav a[rel] span { display: none; } }

  .kicker { margin-bottom: 0.6rem; font-size: 0.8125rem; }
  .notice { margin-top: 1.25rem; padding: 0.75rem 1rem; border-left: 3px solid var(--accent-2); background: var(--surface); max-width: 62ch; }
  .result { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.75rem; margin-top: 2rem; }
  .result-time { font-size: clamp(2.75rem, 1.5rem + 5vw, 4.5rem); line-height: 0.95; }
  .result-none { font-size: 1.25rem; color: var(--text-2); }
  .result-gap { color: var(--text-2); }
  .result-gap .num { font-size: 1.125rem; font-weight: 700; }
  /* The author medal count against all there is to hunt: both figures large, then the whole hunt as a strip. */
  .hunt-count { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.25rem 0.9rem; }
  .hunt-count > .display { font-size: clamp(3rem, 2rem + 3vw, 4rem); line-height: 1; }
  .hunt-of { color: var(--text-2); font-size: 1.125rem; }
  .hunt-of .display { font-size: clamp(1.75rem, 1.25rem + 1.5vw, 2.25rem); line-height: 1; color: var(--text); margin-left: 0.2rem; }
  .hunt-strip { display: block; width: 100%; height: 0.875rem; margin-top: 1.25rem; border-radius: 3px; background: var(--unplayed); }
  .hunt-strip .m4 { fill: var(--author); }
  .hunt-strip .m3 { fill: var(--gold); }
  .hunt-strip .m2 { fill: var(--silver); }
  .hunt-strip .m1 { fill: var(--bronze); }
  .hunt-strip .m0 { fill: var(--text-2); }
  .hunt-strip .un { fill: var(--unplayed); }
  .hunt-key { display: flex; flex-wrap: wrap; gap: 0.35rem 1.5rem; margin: 0.9rem 0 0; padding: 0; list-style: none; font-size: 0.9375rem; color: var(--text-2); }
  .hunt-key li { display: flex; align-items: center; white-space: nowrap; }
  .hunt-key .num { margin-left: 0.4rem; color: var(--text); }
  .map-head { display: grid; gap: 2rem; align-items: start; }
  @media (min-width: 48rem) { .map-head { grid-template-columns: minmax(0, 1fr) minmax(12rem, 20rem); } }
  .map-thumb { width: 100%; max-width: 20rem; height: auto; border-radius: 8px; border: 1px solid var(--line); display: block; }
  .links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 2rem; }
  .links a {
    display: inline-flex; align-items: center; gap: 0.6rem; height: 2.5rem; padding: 0 0.9rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    font-size: 0.9375rem; font-weight: 600; color: var(--text); text-decoration: none;
  }
  .links a:hover { background: var(--surface-2); border-color: var(--accent); }
  /* The Trackmania mark is a mask filled with the text colour, so it follows the theme. */
  .logo-tm {
    display: inline-block; width: 2.9em; height: 0.69em; background: currentColor;
    -webkit-mask: url("/assets/logos/trackmania.png") center / contain no-repeat;
    mask: url("/assets/logos/trackmania.png") center / contain no-repeat;
  }
  .logo-tmx, .logo-tmio { width: 1.5em; height: 1.5em; display: block; }

}

@layer data {
  /* Medal marks: the wall's cells and the swatches beside text. */
  .c, .sw { background: var(--unplayed); transform: skewX(-12deg); border-radius: 2px; position: relative; }
  .sw { display: inline-block; width: 0.75em; height: 0.75em; margin-right: 0.5em; flex: none; }
  .m1 { background: var(--bronze); }
  .m2 { background: var(--silver); }
  .m3 { background: var(--gold); }
  .m4 { background: var(--author); }
  /* Finished without a medal: an empty outline rather than another colour. */
  .m0 { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-2); }
  .sw.un { box-shadow: inset 0 0 0 1px var(--line); }
  /* The author medal also carries a centre mark, so it never depends on colour alone. */
  .m4::after { content: ""; position: absolute; inset: 31%; border-radius: 50%; background: var(--bg); }
  /* Pale medals need an edge to stand off a light background. */
  :root[data-scheme="light"] :is(.m1, .m2, .m3, .m4) { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 38%, transparent); }
  .c.x { background-image: linear-gradient(to top right, transparent 43%, var(--text-2) 43% 57%, transparent 57%); }
  /* Medal images (map pages). "No medal" is an outline drawn in the text colour. */
  .medal { width: 1.936em; height: 1.936em; vertical-align: -0.58em; margin-right: 0.4em; flex: none; }
  svg.medal.none { fill: none; stroke: var(--text-2); stroke-width: 1.4; stroke-linejoin: round; overflow: visible; }
  .result-medal { display: inline-flex; align-items: center; }
  .result-medal .medal { width: 3.3275rem; height: 3.3275rem; }

  /* The wall, with the details of one day beside it. */
  .hunt { display: grid; gap: 2rem 2.5rem; align-items: start; }
  @media (min-width: 64rem) { .hunt { grid-template-columns: minmax(0, 1fr) 15.5rem; } }
  .wall { max-width: 50rem; }
  .wall-row { display: grid; grid-template-columns: 5rem repeat(31, minmax(0, 1fr)); gap: 3px; margin-bottom: 3px; align-items: center; }
  .wall-row.year-start { margin-top: 0.875rem; }
  .wall-label { white-space: nowrap; }
  .wall-label b { color: var(--accent-2); font-weight: 700; }
  .wall-head span { font-size: 0.625rem; text-align: center; }
  .c { display: block; aspect-ratio: 1; }
  .c:hover, .c:focus-visible, .c.is-shown { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 1; }
  .wall[data-filter="m4"] .c:not(.m4), .wall[data-filter="m3"] .c:not(.m3), .wall[data-filter="m2"] .c:not(.m2),
  .wall[data-filter="m1"] .c:not(.m1), .wall[data-filter="m0"] .c:not(.m0), .wall[data-filter="un"] .c:not(.un) { opacity: 0.14; }
  @media (max-width: 40rem) {
    .wall-row { grid-template-columns: 3.75rem repeat(31, minmax(0, 1fr)); gap: 2px; margin-bottom: 2px; }
    .wall-label { font-size: 0.625rem; }
  }

  .inspector { display: none; position: sticky; top: 1.5rem; }
  @media (min-width: 64rem) { .inspector { display: block; } }
  .inspector-thumb { width: 100%; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); object-fit: cover; display: block; }
  .inspector-date { margin-top: 1rem; }
  .inspector-name { font-size: 1.5rem; line-height: 1.1; margin-top: 0.3rem; overflow-wrap: anywhere; }
  .inspector-time { font-size: 2.5rem; line-height: 1; margin-top: 1rem; }
  .inspector-line { margin-top: 0.5rem; font-size: 0.9375rem; }
  .inspector-line.quiet { color: var(--text-2); }

  .tip {
    position: fixed; z-index: 20; pointer-events: none; max-width: 18rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 0.5rem 0.7rem; font-size: 0.875rem; line-height: 1.4;
    box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
  }
  .tip img { display: block; width: 10rem; height: 10rem; object-fit: cover; border-radius: 4px; margin: 0 auto 0.45rem; background: var(--surface-2); }
  .tip b { display: block; }
  .tip > span { display: block; font-family: var(--mono); font-size: 0.75rem; color: var(--text-2); }

  .chart-frame { position: relative; overflow-x: auto; }
  .trophy-chart { display: block; width: 100%; min-width: 36rem; height: auto; touch-action: pan-y; }
  .trophy-chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
  .trophy-chart .tick { stroke: var(--text-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
  .trophy-chart .axis { fill: var(--text-2); font-family: var(--mono); font-size: 12px; }
  .trophy-chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
  .trophy-chart .area { fill: var(--accent); fill-opacity: 0.1; }
  .trophy-chart .end-label { fill: var(--accent-2); font-size: 26px; }
  .trophy-chart .cross { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
  .trophy-chart .dot { fill: var(--bg); stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
  .chart-readout {
    position: absolute; top: 0; pointer-events: none; width: max-content; max-width: 17rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 0.45rem 0.7rem; line-height: 1.4;
  }
  .chart-readout b { display: block; font-size: 1.375rem; line-height: 1.1; }
  .chart-readout span { display: block; }

  .bars li { display: grid; grid-template-columns: minmax(9rem, 12rem) 1fr 3.5rem; gap: 0.1rem 0.875rem; align-items: center; padding-block: 0.55rem; border-top: 1px solid var(--line); }
  .bar { width: 100%; height: 0.5rem; display: block; }
  .bar rect { fill: var(--accent); }
  .bar-value { text-align: right; }
  .bar-note { grid-column: 1 / -1; }

  /* The medal line on a map page. */
  .ladder-frame { margin-top: 2.5rem; }
  .ladder { display: block; width: 100%; height: auto; }
  /* On a phone the line would be too small to read, so the same times are listed instead. */
  .medal-list { display: none; margin-top: 2rem; }
  .medal-list li { display: flex; align-items: center; gap: 0.25rem; padding-block: 0.45rem; border-top: 1px solid var(--line); }
  .medal-list .name { flex: 1; }
  .medal-list .you { color: var(--accent-2); font-weight: 700; }
  .medal-list .you .name { padding-left: 0.2rem; }
  @media (max-width: 44rem) {
    .ladder-frame { display: none; }
    .medal-list { display: block; }
  }
  .ladder-axis { stroke: var(--line); stroke-width: 2; }
  .ladder-gap { stroke: var(--accent-2); stroke-width: 4; stroke-linecap: round; }
  .ladder-stem { stroke: var(--line); stroke-width: 1; }
  .ladder text { font-family: var(--mono); font-size: 13px; fill: var(--text-2); }
  .ladder .value { fill: var(--text); font-weight: 600; }
  .ladder-you { fill: var(--accent-2); }
  .ladder .you { fill: var(--accent-2); font-weight: 700; font-size: 14px; }
}

@layer palette {
  dialog.palette {
    width: min(40rem, calc(100vw - 2rem)); margin-top: 13vh; padding: 0; overflow: hidden;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 28px 80px rgb(0 0 0 / 0.45);
    font-family: var(--mono); font-size: 0.8125rem;
  }
  dialog.palette::backdrop { background: color-mix(in srgb, var(--bg) 60%, transparent); backdrop-filter: blur(3px); }
  @media (prefers-reduced-motion: no-preference) {
    dialog.palette[open] { animation: palette-in 130ms cubic-bezier(0.2, 0.8, 0.2, 1); }
    @keyframes palette-in { from { opacity: 0; transform: translateY(-6px) scale(0.985); } }
  }

  .palette-top { display: flex; align-items: center; gap: 0.7rem; padding: 0.95rem 1.1rem; border-bottom: 1px solid var(--line); }
  .palette-top::before { content: ">"; color: var(--accent); font-weight: 700; font-size: 1rem; }
  .palette-crumb { font-weight: 600; background: var(--surface-2); color: var(--text); border-radius: 5px; padding: 0.2rem 0.55rem; white-space: nowrap; }
  #palette-input { flex: 1; min-width: 0; background: transparent; border: 0; font-size: 0.9375rem; outline: none; caret-color: var(--accent); }
  #palette-input::placeholder { color: var(--text-2); }

  #palette-list { max-height: min(27rem, 56vh); overflow-y: auto; padding: 0.4rem; scroll-padding-block: 0.4rem; }
  #palette-list .group { padding: 0.8rem 0.75rem 0.35rem; font-size: 0.6875rem; color: var(--text-2); }
  #palette-list .group:first-child { padding-top: 0.35rem; }
  #palette-list .item {
    display: grid; grid-template-columns: minmax(1.25rem, auto) minmax(0, 1fr) auto; align-items: center; gap: 0.75rem;
    padding: 0.55rem 0.75rem; border-radius: 7px; cursor: pointer; color: var(--text-2);
  }
  /* The chosen row is filled and brought up to full strength; the rest sit back. */
  #palette-list .item[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 17%, transparent); color: var(--text); }
  #palette-list .item[aria-selected="true"] .lead .icon { color: var(--accent); }
  #palette-list .lead { display: grid; place-items: center; height: 1.25rem; }
  #palette-list .lead .icon { width: 1.05rem; height: 1.05rem; stroke-width: 1.8; }
  #palette-list .lead .sw { margin: 0; width: 0.7rem; height: 0.7rem; }
  #palette-list .dots { display: flex; }
  #palette-list .dots i { width: 0.7rem; height: 0.7rem; border-radius: 50%; margin-left: -0.2rem; box-shadow: 0 0 0 1px var(--line); }
  #palette-list .dots i:first-child { margin-left: 0; }
  #palette-list .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #palette-list .hit { color: var(--accent); font-weight: 700; }
  /* In a track's own colours the match is underlined instead of recoloured. */
  #palette-list .tm .hit { color: inherit; font-weight: inherit; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.2em; }
  #palette-list .meta { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: var(--text-2); white-space: nowrap; }
  #palette-list .meta .icon { width: 0.9rem; height: 0.9rem; }
  #palette-list .empty { padding: 1.25rem 0.75rem; color: var(--text-2); }

  .palette-help { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; border-top: 1px solid var(--line); padding: 0.55rem 1.1rem; font-size: 0.6875rem; color: var(--text-2); }
  .palette-help kbd { margin-right: 0.25rem; font-size: 0.625rem; }
  .palette-help kbd + kbd { margin-left: -0.1rem; }
  #palette-count { margin-left: auto; }
  @media (max-width: 30rem) { .palette-help span:not(#palette-count) { display: none; } }
}

@layer live {
  .live-dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--accent); flex: none; }
  @media (prefers-reduced-motion: no-preference) {
    .live-dot { animation: live-pulse 1.6s ease-in-out infinite; }
    @keyframes live-pulse { 50% { opacity: 0.35; } }
  }

  /* A dot beside "Live" in the header while a Track of the Day is being played. */
  .site-header nav a[data-live]::before {
    content: ""; order: 2; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--accent); flex: none;
  }
  @media (prefers-reduced-motion: no-preference) {
    .site-header nav a[data-live]::before { animation: live-pulse 1.6s ease-in-out infinite; }
  }

  /* The bar under the header on every page while a Track of the Day is being played. */
  .live-bar { display: block; position: relative; border-bottom: 1px solid transparent; color: var(--text); text-decoration: none; }
  /* The bar's fill and the line under it are their own layer, one step further back than the
     attractor (.backdrop, at -1), so the particles drift across the bar like the rest of the page
     top and only the text sits above them. (The bar keeps a see-through border so its height is
     unchanged; the layer reaches down over it and draws the line there.) */
  .live-bar::before { content: ""; position: absolute; inset: 0 0 -1px; z-index: -2; background: var(--surface); border-bottom: 1px solid var(--line); }
  .live-bar:hover::before { background: var(--surface-2); }
  .live-bar-in {
    display: flex; align-items: baseline; gap: 0.5rem 1rem; flex-wrap: wrap;
    max-width: calc(var(--page) + 2 * var(--gutter)); margin-inline: auto; padding: 0.5rem var(--gutter);
  }
  .live-bar .live-dot { align-self: center; }
  .live-bar-track { font-style: italic; font-stretch: 72%; font-weight: 800; font-size: 1.125rem; }
  .live-bar-clock { font-size: 1rem; font-weight: 700; min-width: 4.5ch; }
  .live-bar-note { font-family: var(--mono); font-size: 0.75rem; color: var(--text-2); }

  /* On the track's own page the top becomes the running clock. */
  [data-map].is-live .result { display: none; }
  .live-top { margin-top: 1.75rem; }
  .live-flag { display: flex; align-items: center; gap: 0.5rem; font-family: var(--mono); font-size: 0.75rem; font-weight: 600; color: var(--accent); }
  .live-clock { font-size: clamp(3.5rem, 2rem + 7vw, 6.5rem); line-height: 0.95; margin-top: 0.35rem; }
  .live-clock.idle { color: var(--text-2); }
  .live-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.75rem; margin-top: 0.75rem; }
  .live-run { font-family: var(--mono); font-size: 0.8125rem; color: var(--text-2); }
  .live-best { display: inline-flex; align-items: center; gap: 0.5rem; }
  .live-best .medal { margin: 0; }

  /* A new best: the clock flares once and a note sits beside "Live" for a few seconds. */
  .live-top.new-best .live-flag::after {
    content: "New best"; margin-left: 0.5rem; padding: 0.1rem 0.5rem; border-radius: 999px;
    background: var(--accent); color: var(--bg);
  }
  @media (prefers-reduced-motion: no-preference) {
    .live-top.new-best .live-clock { animation: new-best 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) 2; transform-origin: left center; }
    @keyframes new-best { 30% { color: var(--accent); transform: scale(1.06); } }
  }

  /* One segment per checkpoint, slanted like the wall's days; the finish is the last one. */
  .live-strip { margin-top: 2.25rem; }
  .strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
  .strip li { position: relative; min-width: 0; }
  .strip .seg { display: block; height: 0.75rem; border-radius: 2px; transform: skewX(-12deg); background: var(--unplayed); }
  .strip .done .seg { background: color-mix(in srgb, var(--accent) 55%, var(--unplayed)); }
  .strip .ahead .seg { background: var(--accent); }
  .strip .behind .seg { background: var(--text-2); }
  .strip .now .seg { box-shadow: inset 0 0 0 2px var(--accent); }
  .strip .num { display: block; margin-top: 0.3rem; font-size: 0.6875rem; overflow: hidden; white-space: nowrap; text-align: center; }
  .strip .behind .num { color: var(--text-2); }
  .strip .ahead .num { color: var(--accent); }
  .strip .seg-respawn { position: absolute; top: -0.45rem; left: 50%; width: 0.3rem; height: 0.3rem; border-radius: 50%; background: var(--text-2); }
  .strip-note { margin-top: 0.5rem; min-height: 1.2em; }
  .c.is-live { outline: 2px solid var(--accent); outline-offset: 2px; z-index: 1; }
  .ladder .pace path { fill: var(--bg); stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }

  /* Sessions: pick one sitting, then read its runs. */
  .session-tabs { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.25rem; margin-bottom: 1.5rem; }
  .session-tabs a {
    flex: none; padding: 0.45rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius);
    font-family: var(--mono); font-size: 0.8125rem; color: var(--text); text-decoration: none;
  }
  .session-tabs a:hover { border-color: var(--accent); }
  .session-tabs a[aria-current="true"] { background: var(--surface); border-color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
  .session-tabs .sub { display: block; font-size: 0.6875rem; color: var(--text-2); margin-top: 0.1rem; }
  .session-tabs .sub .num { font-size: inherit; }
  .stat-row .quiet { color: var(--text-2); }
  .stat-row.small { margin: 1.25rem 0 0; gap: 0.75rem 2rem; }
  /* The totals over the TOTD wall: the same row of figures, with a quieter second half where a
     figure comes with one ("213 of 2,342", a track and its time). */
  .stat-row.totals { margin: 1.5rem 0 1.75rem; gap: 1rem 3rem; }
  .stat-row.totals .of { font-size: 1rem; color: var(--text-2); }
  .stat-row.totals .of .num { color: var(--text); }
  .stat-row.totals a { color: var(--text); text-decoration: none; }
  .stat-row.totals .most .of { margin-left: 0.4rem; }
  .stat-row.totals a:hover, .stat-row.totals a:focus-visible { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
  .stat-row.small dd { font-size: 1rem; }
  .day-heading { margin-top: 2.25rem; font-size: 1.25rem; }
  table.session-log td .medal { width: 1.573em; height: 1.573em; vertical-align: -0.36em; }

  /* The run tape: bars on a scale of checkpoints. */
  .chart-scroll { overflow-x: auto; }
  .tape { display: block; width: 100%; min-width: 36rem; height: auto; }
  .tape-level { stroke: var(--line); stroke-width: 1; stroke-dasharray: 1 5; }
  .tape-base { stroke: var(--line); stroke-width: 1; }
  .tape-axis { font-family: var(--mono); font-size: 11px; fill: var(--text-2); }
  .tape-bar { cursor: pointer; outline: none; }
  /* What a bar says, quietest first: reset or left (dim), finished (plain), finished as a new
     best (the second accent). Colour is spent only on the bests; an ordinary finish stays plain so
     it never looks like the one to notice. The marker stands over the best on the track as it is now. */
  .tape-short { fill: var(--text-2); fill-opacity: 0.38; }
  .tape-done { fill: var(--text-2); }
  .tape-pb { fill: var(--accent-2); }
  .tape-mark { fill: var(--accent-2); pointer-events: none; }
  .tape-key { display: flex; flex-wrap: wrap; gap: 0.35rem 1.5rem; margin: 0.75rem 0 0; padding: 0; list-style: none; font-size: 0.875rem; color: var(--text-2); }
  .tape-key li { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
  .tape-key i { width: 0.5rem; height: 0.9rem; border-radius: 1.5px; background: var(--text-2); flex: none; }
  .tape-key .k-short { opacity: 0.38; }
  .tape-key .k-pb { background: var(--accent-2); }
  .tape-key .k-picked { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text); }
  .tape-key .k-mark { width: 0.7rem; height: 0.46rem; fill: var(--accent-2); flex: none; }
  /* Pointing at a bar or picking it only outlines it: the fill keeps saying what kind of run it was. */
  .tape-bar:hover, .tape-bar:focus-visible { stroke: var(--text); stroke-width: 1.5; }
  .tape-bar.is-picked { stroke: var(--text); stroke-width: 2; }

  .run-detail { margin-top: 1.25rem; }
  .run-title { display: flex; align-items: baseline; gap: 0.9rem; margin-bottom: 0.6rem; }
  .run-title .display { font-size: 1.5rem; line-height: 1.1; }

  /* Typical time lost per section: one hue, stronger where more is lost. */
  .strip.loss .seg { background: var(--unplayed); }
  .strip.loss .l0 .seg { background: var(--surface-2); }
  .strip.loss .l1 .seg { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
  .strip.loss .l2 .seg { background: color-mix(in srgb, var(--accent) 40%, var(--surface)); }
  .strip.loss .l3 .seg { background: color-mix(in srgb, var(--accent) 58%, var(--surface)); }
  .strip.loss .l4 .seg { background: color-mix(in srgb, var(--accent) 78%, var(--surface)); }
  .strip.loss .l5 .seg { background: var(--accent); }
  .strip.loss .num { color: var(--text-2); }
}

/* The profile page: who, where they stand, where the total is heading. */
@layer parts {
  .sub, .unit, .zone { font-family: var(--mono); font-size: 0.75rem; font-weight: 500; font-style: normal; font-stretch: normal; letter-spacing: 0; color: var(--text-2); }

  .plate { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.25rem 2.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
  .plate-name { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
  .plate-name .display { font-size: clamp(2.75rem, 1.25rem + 6vw, 5.25rem); line-height: 0.9; overflow-wrap: anywhere; }
  /* Club tags are written for the game's dark panels, so the tag keeps a dark plate in every theme. */
  .club-tag {
    font-family: var(--font); font-weight: 800; font-stretch: 85%; font-size: clamp(1.125rem, 0.75rem + 1.5vw, 1.75rem); line-height: 1;
    padding: 0.3em 0.5em; border-radius: 4px; background: #15181d; color: #fff; white-space: nowrap;
  }
  /* The zone sits close under the name. Most of the space between them is not a margin: the name
     is set very large, and its line keeps room below the letters for tails (g, y) that this name
     does not have, and the echelon emblem beside it is a little taller still. On a wide screen the
     zone is pulled up into that room; on a narrow one the emblem wraps to its own line above the
     zone, so it only sits snug under it. */
  .plate-zone { margin-top: 0.1rem; color: var(--text-2); }
  @media (min-width: 48rem) { .plate-zone { margin-top: -0.6rem; } }
  .plate .links { margin-top: 1.25rem; }
  /* The echelon follows the name on the same line. The emblem images are a quarter empty down each
     side, so the image is pulled in by most of that, or the gaps around it would look far too wide. */
  .plate-echelon { --emblem: clamp(3.75rem, 2.5rem + 3.5vw, 5.25rem); display: flex; align-items: center; gap: 0.625rem; }
  .plate-echelon img { width: var(--emblem); height: auto; aspect-ratio: 1; margin-inline: calc(var(--emblem) * -0.25); }
  .plate-name .plate-echelon b { font-size: clamp(1.75rem, 1.25rem + 1.6vw, 2.5rem); line-height: 1; white-space: nowrap; }

  .standing { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.5rem 3rem; margin-top: 1.5rem; }
  .total .display { display: block; font-size: clamp(2.5rem, 1.5rem + 3.5vw, 3.75rem); line-height: 1; }
  .total .unit { display: block; margin-top: 0.4rem; }
  .ranks-row { display: flex; flex-wrap: wrap; gap: 1rem 0; }
  .ranks-row li { padding-inline: 1.25rem; border-left: 1px solid var(--line); }
  .ranks-row li:first-child { padding-left: 0; border-left: 0; }
  .ranks-row .display { display: block; font-size: 1.625rem; line-height: 1.1; }
  .ranks-row .zone { display: block; }

  .trophy-top { display: grid; gap: 2rem 2.5rem; align-items: start; }
  @media (min-width: 62rem) { .trophy-top { grid-template-columns: minmax(0, 1fr) 17.5rem; } }

  .trophy-top > * { min-width: 0; }
  .goal-panel h2 { margin-bottom: 0.5rem; }
  .goal-name { font-weight: 600; }
  .goal-gap { margin-top: 0.75rem; }
  .goal-gap .display { display: block; font-size: 2.75rem; line-height: 1; }
  .goal-gap .unit { display: block; margin-top: 0.3rem; }
  .goal-error { margin-bottom: 0.5rem; padding: 0.5rem 0.7rem; border: 1px solid var(--accent-2); border-radius: var(--radius); font-size: 0.875rem; }
  .facts { margin-top: 1rem; }
  .facts div { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding-block: 0.45rem; border-top: 1px solid var(--line); }
  .facts dt { font-family: var(--mono); font-size: 0.75rem; font-weight: 500; color: var(--text-2); }
  .facts dd { text-align: right; }
  .facts dd .sub { display: block; }
  .pace { display: grid; gap: 0.75rem 2.5rem; align-items: center; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
  @media (min-width: 40rem) { .pace { grid-template-columns: max-content minmax(0, 1fr); } }
  .pace-rate .display { display: block; font-size: 2.25rem; line-height: 1; }
  .pace-rate .unit { display: block; margin-top: 0.3rem; }
  .pace .fine { grid-column: 1 / -1; margin-top: 0; }
  .pace-bars li { display: grid; grid-template-columns: 8rem 1fr 3.25rem; gap: 0.75rem; align-items: center; padding-block: 0.25rem; }
  .pace-bars .bar-label { font-size: 0.8125rem; }
  .pace-bars .num { text-align: right; font-size: 0.8125rem; }

  .goal-edit { margin-top: 1rem; }
  .goal-edit summary { cursor: pointer; width: max-content; font-family: var(--mono); font-size: 0.8125rem; font-weight: 500; color: var(--accent); }
  .goal-edit form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 0.75rem; margin-top: 0.75rem; }
  .goal-edit label { display: flex; align-items: center; gap: 0.5rem; }
  .goal-edit input, .goal-edit select {
    font: inherit; font-family: var(--mono); font-size: 0.875rem; color: var(--text);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.4rem 0.55rem;
  }
  .goal-edit input { width: 6.5rem; }
  .goal-edit select { max-width: 100%; }
  .goal-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; width: 100%; }
  .button {
    font: inherit; font-family: var(--mono); font-size: 0.8125rem; font-weight: 500; cursor: pointer; color: var(--text);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.45rem 0.85rem;
  }
  .button:hover { border-color: var(--accent); background: var(--surface-2); }
  .button.quiet { background: none; color: var(--text-2); }

  .season h2 .sub { margin-left: 0.875rem; white-space: nowrap; }
  .season-grid { display: grid; gap: 1.5rem 3.5rem; align-items: start; }
  @media (min-width: 56rem) { .season-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 25rem); } }
  .standings li { display: flex; align-items: center; gap: 1.25rem; padding-block: 0.875rem; border-top: 1px solid var(--line); }
  .standings img { width: 5.5rem; height: 5.5rem; flex: none; }
  .standings .place { flex: none; min-width: 5.5rem; font-size: 2rem; line-height: 1; text-align: center; }
  .standings b { display: block; font-size: 1.5rem; line-height: 1.1; }
  .standings span { display: block; }
  .standings .sub { margin-top: 0.2rem; }
  .ledger { width: 100%; border-collapse: collapse; }
  .ledger th { text-align: left; font-weight: 400; padding: 0.5rem 1rem 0.5rem 0; }
  .ledger td { text-align: right; padding-block: 0.5rem; white-space: nowrap; }
  .ledger tr { border-top: 1px solid var(--line); }
  .ledger .loss { color: var(--text-2); }
  .ledger tfoot tr { border-top: 2px solid var(--text); }
  .ledger tfoot th { font-family: var(--mono); font-size: 0.75rem; font-weight: 500; color: var(--text-2); vertical-align: baseline; }
  .ledger tfoot td { font-size: 2.25rem; line-height: 1.2; }

  .echelons, .cabinet { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
  @media (min-width: 46rem) { .echelons, .cabinet { grid-template-columns: repeat(9, minmax(0, 1fr)); } }
  .echelons li, .cabinet li { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0.75rem 0.25rem; border: 1px solid transparent; border-radius: var(--radius); }
  .echelons img { width: 3.45rem; height: 3.45rem; }
  .echelons b { font-size: 0.8125rem; font-weight: 600; margin-top: 0.35rem; white-space: nowrap; }
  .echelons li.current { background: var(--surface); border-color: var(--line); }
  .echelons li.current ~ li, .cabinet li.none { opacity: 0.38; }
  .cabinet img { width: 5.175rem; height: 5.175rem; }
  .cabinet .display { font-size: 1.5rem; line-height: 1.2; }
}

@layer data {
  .trophy-chart.ahead-chart .ahead { stroke-dasharray: 5 5; }
  .trophy-chart .goal { stroke: var(--accent-2); stroke-width: 1.5; stroke-dasharray: 1 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
  .trophy-chart .goal-label { fill: var(--accent-2); font-family: var(--mono); font-size: 12px; font-weight: 600; }
  .trophy-chart .today, .trophy-chart .season { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
  .trophy-chart .now-dot { fill: var(--accent); }
  .trophy-chart .reach-dot { fill: var(--bg); stroke: var(--accent-2); stroke-width: 2; vector-effect: non-scaling-stroke; }
}

/*
 * Track names in their authors' own styling. Each coloured run carries its colour as data-c.
 * Names are written for the game's dark panels, so a colour keeps its hue but is held to a
 * lightness that reads on the theme in use: not too dark on dark themes, not too pale on light ones.
 * (Browsers that can't read a colour out of an attribute get the same thing from app.js.)
 */
@layer base {
  :root { --name-l-min: 0; --name-l-max: 1; }
  :root[data-scheme="dark"] { --name-l-min: 0.68; }
  :root[data-scheme="light"] { --name-l-max: 0.52; }
  .tm [data-c] {
    color: oklch(from attr(data-c type(<color>)) clamp(var(--name-l-min), l, var(--name-l-max)) c h);
  }
  .club-tag [data-c] { color: attr(data-c type(<color>)); }
  .tm .f-o { font-weight: 700; }
  .tm .f-i { font-style: italic; }
  .tm .f-w { font-stretch: 125%; }
  .tm .f-n { font-stretch: 75%; }
  .tm .f-t { text-transform: uppercase; }
  /* Titles are already heavy, slanted and narrow: there, wide and narrow are steps either side of that. */
  :is(h1, .display, .live-bar-track) .tm .f-o { font-weight: 800; }
  :is(h1, .display, .live-bar-track) .tm .f-w { font-stretch: 100%; }
  :is(h1, .display, .live-bar-track) .tm .f-n { font-stretch: 62%; }
}


/*
 * Motion. Everything here is switched off for visitors who ask their system for less motion.
 *
 * Moving between pages uses the browser's own page-to-page transitions (no script swaps the
 * content): the header stays where it is, the marker under the current page glides along the
 * header line to its new place, and the content slides in from the side it is "towards":
 * from the right going on to a later section or day, from the left going back.
 * A browser without this simply changes page as before.
 */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }

  .site-header { view-transition-name: site-header; }
  .site-header nav a[aria-current="page"]::after { view-transition-name: nav-marker; }
  main { view-transition-name: page; }

  ::view-transition-group(nav-marker) { animation-duration: 280ms; animation-timing-function: cubic-bezier(0.3, 0.7, 0.2, 1); }
  ::view-transition-old(page) { animation: 110ms ease-in both page-out; }
  ::view-transition-new(page) { animation: 260ms cubic-bezier(0.2, 0.8, 0.2, 1) 70ms both page-in; }
  @keyframes page-out { to { opacity: 0; transform: translateX(-12px); } }
  @keyframes page-in { from { opacity: 0; transform: translateX(18px); } }
  html:active-view-transition-type(back)::view-transition-old(page) { animation-name: page-out-back; }
  html:active-view-transition-type(back)::view-transition-new(page) { animation-name: page-in-back; }
  @keyframes page-out-back { to { opacity: 0; transform: translateX(12px); } }
  @keyframes page-in-back { from { opacity: 0; transform: translateX(-18px); } }

  /* Switching between light and dark: the new colours sweep across behind a slanted edge. */
  :root[data-vt="theme"] :is(.site-header, main, .site-header nav a[aria-current="page"]::after) { view-transition-name: none; }
  :root[data-vt="theme"]::view-transition-old(root) { animation: none; }
  :root[data-vt="theme"]::view-transition-new(root) { animation: 480ms cubic-bezier(0.4, 0, 0.2, 1) both theme-sweep; }
  @keyframes theme-sweep {
    from { clip-path: polygon(0 0, 0 0, -21.3vh 100%, -21.3vh 100%); }
    to { clip-path: polygon(0 0, calc(100% + 21.3vh) 0, 100% 100%, 0 100%); }
  }

  /* Small answers to the pointer. */
  .site-header nav a::after { transform-origin: left; transition: scale 140ms cubic-bezier(0.2, 0.8, 0.2, 1); scale: 0 1; }
  .site-header nav a:hover::after, .site-header nav a[aria-current="page"]::after { scale: 1 1; }
  .c { transition: scale 90ms ease-out; }
  .c:hover, .c:focus-visible { scale: 1.4; }
  :is(.palette-open, .theme-toggle, .button) { transition: scale 80ms ease-out; }
  :is(.palette-open, .theme-toggle, .button):active { scale: 0.95; }

  /* The trophy chart draws itself from the left, once, when the profile opens. */
  .trophy-chart .drawn { animation: chart-draw 900ms cubic-bezier(0.4, 0.2, 0.3, 1) 150ms both; }
  @keyframes chart-draw { from { clip-path: inset(-10% 100% -10% 0); } to { clip-path: inset(-10% -1% -10% 0); } }
  .trophy-chart .now-dot { animation: chart-dot 200ms ease-out 620ms both; }
  .trophy-chart .reach-dot { animation: chart-dot 200ms ease-out 1000ms both; }
  @keyframes chart-dot { from { opacity: 0; } }
}

/*
 * The strange attractor behind the top of every page, drawn by attractor-worker.js (see "backdrop"
 * in app.js). It is part of the page, so it scrolls with it, and fades out towards the bottom.
 */
.backdrop {
  position: absolute; top: 0; left: 0; width: 100%; height: 48rem; z-index: -1; pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent);
  mask-image: linear-gradient(to bottom, #000 62%, transparent);
}

/* A list of sessions: the whole row opens the track, so the name needs no underline or link colour. */
@layer parts {
  .session-log tbody tr { position: relative; }
  .session-log a { color: var(--text); font-weight: 600; text-decoration: none; }
  .session-log a::after { content: ""; position: absolute; inset: 0; }
  .session-log tbody tr:hover a, .session-log a:focus-visible { text-decoration: underline; text-decoration-color: var(--text-2); text-decoration-thickness: 1px; }
  .session-log tbody tr:hover td.muted { color: var(--text); }
  /* The medal stays beside the name, and a long name wraps under itself, not under the medal. */
  .session-track { display: flex; align-items: center; }
  .session-track .medal { vertical-align: 0; }
  /* Everything in a row sits on the row's middle, so the medal, the name and the figures line up. */
  table.session-log td { vertical-align: middle; }
  .session-log td.num { white-space: nowrap; }
  /* Every day is its own table. The columns are given their widths here, not left to each table's
     own rows, so one day's columns stand exactly under the last day's; the track takes what is left.
     On a narrow screen the table keeps a workable width and scrolls sideways. */
  table.session-log { table-layout: fixed; min-width: 46rem; }
  .session-log .col-started { width: 5.25rem; }
  .session-log .col-runs { width: 4.5rem; }
  .session-log .col-finished { width: 6.25rem; }
  .session-log .col-driven { width: 7rem; }
  .session-log .col-best { width: 9.5rem; }
  /* A name wraps between its words; only a single word too long for the column is broken. */
  .session-track a { overflow-wrap: break-word; min-width: 0; }

  /* Under a list shown a page at a time (pager.ts): a step back, where this is, a step on. */
  .pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; margin-top: 2.25rem; }
  .pager a {
    display: inline-flex; align-items: center; gap: 0.5rem; height: 2.5rem; padding: 0 0.9rem; justify-self: start;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    font-size: 0.9375rem; font-weight: 600; color: var(--text); text-decoration: none;
  }
  .pager a[rel="next"] { justify-self: end; }
  .pager a:hover { background: var(--surface-2); border-color: var(--accent); }
  .pager-where { text-align: center; font-size: 0.9375rem; }
  .pager-where .sub { display: block; font-family: var(--mono); font-size: 0.75rem; color: var(--text-2); }
}
