/* Planner form and results. Loaded on top of base.css. */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.notice {
  padding: var(--space-3);
  background: var(--c-surface);
  border-radius: var(--radius);
  max-width: var(--measure);
}

.errors {
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) 2.25rem;
  max-width: var(--measure);
  border: 2px solid var(--c-accent);
  border-radius: var(--radius);
  color: var(--c-ink);
}

.errors:focus-visible { outline-offset: 4px; }

/* Steps ------------------------------------------------------------------- */

#planner-form {
  border: 0;
  padding: 0;
  margin: 0;
}

#planner-form > fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-inline-size: 0;
}

/* Five beats, filling as you go. The planner is a real sequence, so the
   dots carry progress rather than decorate it. */
.progress {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: var(--space-3);
}

.beat {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--c-border);
}

.beat-done { background: var(--c-ink); }
.beat-now {
  background: var(--c-accent);
  transform: scale(1.35);
}

#planner-form h2 {
  margin-bottom: var(--space-1);
}

#planner-form h2:focus-visible {
  outline: 3px solid var(--c-focus);
  outline-offset: 4px;
}

.hint {
  color: var(--c-ink-soft);
  max-width: var(--measure);
}

.field > .label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.field em,
.choices legend em {
  font-style: normal;
  font-weight: 400;
  color: var(--c-ink-soft);
}

/* Choice lists ------------------------------------------------------------ */

.choices {
  border: 0;
  padding: 0;
  margin: 0 0 var(--space-4);
  min-inline-size: 0;
  max-width: var(--measure);
}

.choices legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: var(--space-2);
}

.choice {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  padding: 0.75rem;
  margin-bottom: var(--space-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--c-link);
  box-shadow: inset 0 0 0 1px var(--c-link);
  background: var(--c-surface);
}

.choice:has(input:focus-visible) {
  outline: 3px solid var(--c-focus);
  outline-offset: 2px;
}

.choice input {
  margin-top: 0.3rem;
  width: 1.15rem;
  height: 1.15rem;
  flex: none;
}

.choice small {
  display: block;
  color: var(--c-ink-soft);
  font-size: 0.875rem;
  line-height: 1.4;
}

/* Goal time --------------------------------------------------------------- */

.time-input {
  display: flex;
  gap: var(--space-3);
}

.time-input label {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.time-input input {
  width: 5rem;
  font-size: 1.25rem;
  text-align: center;
}

/* Navigation -------------------------------------------------------------- */

.planner-nav {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-block: var(--space-3) var(--space-5);
  border-top: 1px solid var(--c-border);
  margin-top: var(--space-4);
}

.planner-nav .button { flex: 1 1 10rem; text-align: center; }

/* Three actions on the results page. Emailing the plan gets its own full
   width row so its label never wraps; editing and printing share the row
   below it, quietly. */
#results-actions #results-send { flex: 1 1 100%; }
#results-actions .button-secondary { flex: 1 1 8rem; }

/* Results ----------------------------------------------------------------- */

.results:focus-visible { outline: none; }

.results-head { margin-bottom: var(--space-4); }
.results-subtitle { color: var(--c-ink-soft); margin: 0; }

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
}

@media (min-width: 40rem) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
}

.tile {
  display: flex;
  flex-direction: column;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--space-3);
}

.tile dt {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--c-ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tile dd {
  /* pushes every number to the bottom, so a label that wraps onto two
     lines does not knock its tile's figure out of line with the rest */
  margin: 0.15rem 0 0;
  margin-top: auto;
  padding-top: 0.15rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.tile .unit {
  font-family: var(--font);
  font-weight: 400;
  font-size: 0.8125rem;
  letter-spacing: 0;
  color: var(--c-ink-soft);
}

.warnings {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  max-width: var(--measure);
}

.warning {
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  border-left: 4px solid var(--c-border);
  background: var(--c-surface);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.warning-warning { border-left-color: var(--c-accent); }

.table-wrap { overflow-x: auto; }

.results table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-3);
}

.results th,
.results td {
  text-align: left;
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}

.results thead th {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--c-ink-soft);
}

.results tbody th {
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.schedule-note { color: var(--c-ink-soft); max-width: var(--measure); }

/* Product options --------------------------------------------------------- */

.options { margin-top: var(--space-5); }

.option {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.option h4 { margin: 0 0 var(--space-1); font-size: 1.125rem; }
.option-body { color: var(--c-ink-soft); margin-bottom: var(--space-3); }

.items { list-style: none; margin: 0 0 var(--space-3); padding: 0; }

.item + .item {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--c-border);
}

.item-head { margin: 0; }
.item-head .unit { color: var(--c-ink-soft); font-weight: 400; }

.item-meta {
  margin: 0;
  font-size: 0.875rem;
  color: var(--c-ink-soft);
}

.retailers {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin: var(--space-1) 0 0;
  padding: 0;
  font-size: 0.9375rem;
}

.option-total {
  margin: 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--c-border);
  font-size: 1.0625rem;
}

.option-notes {
  margin: var(--space-2) 0 0;
  padding-left: 1.1rem;
  font-size: 0.875rem;
  color: var(--c-ink-soft);
}

.fineprint {
  font-size: 0.875rem;
  color: var(--c-ink-soft);
  max-width: var(--measure);
}

.print-only { display: none; }

/* Race pages -------------------------------------------------------------- */

.notice-warning {
  background: none;
  border-left: 4px solid var(--c-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.race-facts {
  display: grid;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  max-width: var(--measure);
}

.race-facts > div {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--c-border);
}

.race-facts dt {
  font-weight: 600;
  min-width: 8rem;
}

.race-facts dd { margin: 0; color: var(--c-ink-soft); }

.race-distances,
.race-list {
  list-style: none;
  margin: 0 0 var(--space-5);
  padding: 0;
  max-width: var(--measure);
}

.race-distances li { margin-bottom: var(--space-2); }
.race-distances .button { display: block; text-align: center; }

.race-list li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--c-border);
}

.race-list a { font-size: 1.125rem; }

.race-list-meta {
  display: block;
  color: var(--c-ink-soft);
  font-size: 0.9375rem;
}

/* The request box: after the list on a phone, and on a wide screen a
   column next to it that stays in view while the runner scrolls. */

.race-request-jump { margin-top: calc(-1 * var(--space-2)); }

.race-request {
  max-width: var(--measure);
  margin-bottom: var(--space-5);
  padding: var(--space-4) var(--space-3);
  background: var(--c-surface);
  border-radius: var(--radius);
  scroll-margin-top: var(--space-3);
}

.race-request h2 { margin-top: 0; }
.race-request .field { margin-bottom: var(--space-2); }
.race-request .hint { display: block; margin-top: var(--space-1); font-size: 0.875rem; }
.race-request .button { width: 100%; margin-top: var(--space-2); }

@media (min-width: 60rem) {
  .wrap-races { max-width: 66rem; }

  .race-request-jump { display: none; }

  .races-layout .race-list { max-width: none; }

  .races-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 21rem;
    gap: var(--space-5);
    align-items: start;
  }

  .race-request {
    position: sticky;
    top: var(--space-4);
    max-height: calc(100vh - 2 * var(--space-4));
    overflow-y: auto;
  }
}

/* Pre-order --------------------------------------------------------------- */

.option-actions { margin-top: var(--space-3); }

.preorder-button { width: 100%; }

.preorder-note {
  margin: var(--space-2) 0 0;
  font-size: 0.875rem;
  color: var(--c-ink-soft);
}

.preorder-dialog {
  width: min(32rem, calc(100vw - 2rem));
  padding: var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  color: var(--c-ink);
  background: var(--c-bg);
}

.preorder-dialog::backdrop { background: rgb(16 34 28 / 0.55); }

.preorder-dialog h2 { font-size: 1.25rem; }

.preorder-pack {
  padding: var(--space-3);
  background: var(--c-surface);
  border-radius: var(--radius);
  font-size: 0.9375rem;
}

.preorder-dialog .planner-nav { padding-bottom: 0; margin-bottom: 0; }

/* Long-form text pages ---------------------------------------------------- */

.prose-page {
  max-width: 42rem;
  padding-block: var(--space-4) var(--space-5);
}

.prose-page h1 { margin-bottom: var(--space-3); }

.prose-page h2 {
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  border-top: 1px solid var(--c-border);
}

.prose-page h3 {
  margin-top: var(--space-4);
  margin-bottom: var(--space-1);
}

.prose-page p { max-width: var(--measure); }

/* Flavour line on a product ------------------------------------------------ */

.item-flavour {
  margin: var(--space-1) 0 0;
  font-size: 0.875rem;
}

.item-flavour-unknown,
.item-flavour-mismatch {
  color: var(--c-ink-soft);
}

.item-flavour-note {
  font-style: italic;
}

/* The cadence strip ---------------------------------------------------------
   The plan's rhythm, drawn from the runner's own schedule: a line from start
   to finish with a beat where they eat. Same geometry as the brand mark, and
   the same thing runners already wear as a pace band. The shape is the
   information: you see the quiet first 25 minutes, the even beat through the
   middle, and the gap before the finish. */

.cadence {
  margin: 0 0 var(--space-4);
}

.cadence-track {
  position: relative;
  height: 2.75rem;
  margin: var(--space-2) 0 var(--space-1);
}

.cadence-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--c-border);
  transform: translateY(-50%);
}

.cadence-beat {
  position: absolute;
  top: 50%;
  width: 0.75rem;
  height: 0.75rem;
  margin: -0.375rem 0 0 -0.375rem;
  border-radius: 50%;
  background: var(--c-accent);
}

.cadence-cap {
  position: absolute;
  top: 50%;
  width: 2px;
  height: 0.9rem;
  margin-top: -0.45rem;
  background: var(--c-ink);
}

.cadence-cap-end { right: 0; }

.cadence-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--c-ink-soft);
  font-variant-numeric: tabular-nums;
}

.cadence-caption {
  margin: var(--space-2) 0 0;
  color: var(--c-ink-soft);
  max-width: var(--measure);
}

/* One orchestrated moment: the beats arrive in time, like a metronome
   starting. Nothing else on the page animates. */
@media (prefers-reduced-motion: no-preference) {
  .cadence-beat {
    animation: beat-in 260ms cubic-bezier(0.2, 0.9, 0.3, 1.2) backwards;
  }
}

@keyframes beat-in {
  from {
    opacity: 0;
    transform: scale(0.2);
  }
}

/* Product lines, now with a picture and a way to change them ---------------- */

.item {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.item-image,
.choice-image {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 8px;
}

.item-body { min-width: 0; flex: 1; }

.item-swap {
  margin-top: var(--space-2);
  padding: 0.4rem 0.8rem;
  font-size: 0.875rem;
}

.option-changed { border-color: var(--c-link); }

/* The picker ---------------------------------------------------------------- */

.swap-dialog { width: min(34rem, calc(100vw - 2rem)); }

.swap-list {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  max-height: 60vh;
  overflow-y: auto;
}

.choice-product {
  display: flex;
  gap: var(--space-3);
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--c-ink);
  padding: var(--space-3);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
}

.choice-product:hover { border-color: var(--c-link); }

.choice-current {
  border-color: var(--c-link);
  background: var(--c-surface);
  cursor: default;
}

.choice-body { display: block; min-width: 0; }

.choice-name {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: baseline;
}

.choice-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--c-link);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.macros {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin: var(--space-1) 0;
}

.macro { display: flex; gap: 0.3rem; align-items: baseline; }

.macro dt {
  font-size: 0.75rem;
  color: var(--c-ink-soft);
}

.macro dd {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

.choice-flavours,
.choice-price {
  display: block;
  font-size: 0.875rem;
  color: var(--c-ink-soft);
}

.choice-price { margin-top: var(--space-1); }
.choice-price strong { color: var(--c-ink); font-size: 1rem; }

/* Training schedule --------------------------------------------------------- */

.training { margin-top: var(--space-5); }

.training .week-down { color: var(--c-ink-soft); }

.week-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--c-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.week-sessions {
  white-space: normal;
  font-size: 0.875rem;
  color: var(--c-ink-soft);
  min-width: 14rem;
}

.paces { margin: var(--space-3) 0 var(--space-4); }
.paces h4 { margin-bottom: var(--space-1); font-size: 1rem; }

.pace-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  margin: 0;
}

@media (min-width: 30rem) {
  .pace-list { grid-template-columns: repeat(4, 1fr); }
}

.pace {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
}

.pace dt {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--c-ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pace dd {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
}

/* Training-block supplements ------------------------------------------------ */

.supplements { margin-top: var(--space-5); }

.supplement-group { margin-bottom: var(--space-4); }

.supplement-group h4 {
  margin-bottom: var(--space-1);
  font-size: 1.0625rem;
}

.supplement-list {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
}

.supplement {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) 0;
  border-top: 1px solid var(--c-border);
}

.supplement-usage {
  margin: var(--space-1) 0 0;
  font-size: 0.875rem;
  color: var(--c-ink-soft);
}

.supplement-bloodtest {
  padding: var(--space-3);
  border: 1px solid var(--c-accent);
  border-radius: var(--radius);
}

.supplement-bloodtest .supplement:first-of-type { border-top: 0; }

/* Race picker --------------------------------------------------------------- */

.race-card {
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  background: var(--c-surface);
  border-radius: var(--radius);
  max-width: var(--measure);
}

.race-card-head { margin: 0 0 var(--space-1); }
.race-card-head strong { font-family: var(--font-display); font-size: 1.125rem; }
.race-card-head span { display: block; color: var(--c-ink-soft); font-size: 0.9375rem; }
.race-card p:last-child { margin-bottom: 0; }

/* The race search is a combobox. The list sits in the page flow rather than
   floating over it, so on a phone it can never end up behind the keyboard or
   cut off by the edge of the form. */

.combobox > label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.combobox { scroll-margin-top: var(--space-3); }

.combobox-list {
  list-style: none;
  margin: var(--space-1) 0 var(--space-2);
  padding: var(--space-1);
  max-height: min(18rem, 45vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--c-bg);
  border: 1px solid var(--c-ink-soft);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgb(16 34 28 / 0.12);
}

.combobox-option {
  display: block;
  padding: 0.6rem 0.75rem;
  min-height: 2.75rem;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
}

.combobox-option + .combobox-option { margin-top: 2px; }

.combobox-option-name {
  display: block;
  font-weight: 600;
}

.combobox-option-meta {
  display: block;
  font-size: 0.875rem;
  color: var(--c-ink-soft);
}

.combobox-option[aria-selected="true"],
.combobox-option:hover {
  background: var(--c-surface);
  box-shadow: inset 3px 0 0 var(--c-link);
}

.combobox-empty {
  margin: var(--space-1) 0 var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--c-surface);
  border-radius: var(--radius);
}

#race-chosen:focus { outline: none; }

@media (forced-colors: active) {
  .combobox-option[aria-selected="true"] { outline: 2px solid Highlight; }
}
