/* Tire detail page: a characteristic index of six columns (rating, distance, grip, cost,
   noise, wear). Column rules, end dots and hover are CSS only. */

.tire {
  padding: clamp(1rem, 2.4vw, 1.75rem) var(--page-pad) clamp(1.5rem, 4vw, 3rem);
}

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

.tire__header {
  margin-bottom: 0.875rem;
}
.tire__title {
  margin-top: 0.25rem;
  font-size: clamp(1.75rem, 4.4vw, 2.75rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
.tire__category {
  margin-top: 0.25rem;
  font-family: var(--font-data);
  font-size: var(--fs-small);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
/* What the tire is and what the page shows, in one or two plain sentences. */
.tire__definition {
  max-width: var(--measure);
  margin-top: 0.5rem;
  font-family: var(--font-data);
  font-size: var(--fs-small);
  line-height: 1.5;
  color: var(--ink-soft);
}
.tire__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin-top: 0.75rem;
}
.tire__back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0 1rem;
  background: var(--ink);
  color: var(--ground);
  font-family: var(--font-data);
  font-size: var(--fs-small);
  white-space: nowrap;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background-color 0.2s ease;
}
.tire__back:hover {
  background: var(--accent);
}
.tire__switch .switch__option {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.875rem;
}
/* An axle without data: plain text, not a link. */
.tire__nodata.switch__option {
  gap: 0.5rem;
  border-style: dashed;
  color: var(--ink-soft);
}
.tire__nodata.switch__option:hover {
  border-color: var(--line-strong);
  color: var(--ink-soft);
}
.tire__nodata.switch__option[aria-current="true"],
.tire__nodata.switch__option[aria-current="true"]:hover {
  background: transparent;
  border-color: var(--line-strong);
  border-style: solid;
  color: var(--ink);
}
.tire__nodata-note {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
}

.tire__summary {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0.125rem;
  margin-left: auto;
  font-size: var(--fs-small);
  text-align: right;
}
.tire__summary-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem 0.875rem;
}
/* Every item of the summary stays on one line; the group wraps between items. */
.tire__summary-line > *,
.tire__wobble {
  white-space: nowrap;
}
.tire__wobble {
  color: var(--ink-soft);
}
/* The bikes behind the row by weight class, bands in the visitor's unit; wraps as one paragraph and
   takes the summary's alignment (right on a wide screen, left on a narrow one). */
.tire__weight {
  margin: 0;
  color: var(--ink-soft);
}
.tire__weight .label {
  margin-right: 0.375rem;
}
.tire__weight-bands {
  white-space: normal;
}

.tire__empty {
  max-width: var(--measure);
  padding: 2rem 0;
  font-size: 1.125rem;
}
.tire__insufficient {
  max-width: var(--measure);
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--line-strong);
}
.tire__insufficient-title {
  margin-bottom: 0.5rem;
  font-size: clamp(1.75rem, 5vw, 3rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

/* --- the grid of telemetry blocks -------------------------------------- */

.tire__grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border-top: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-strong);
}

.tire__block {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0.875rem clamp(0.625rem, 1.2vw, 1rem) 1rem;
  border-left: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  transition:
    transform 0.3s ease,
    background-color 0.3s ease;
}
/* Small dot at the top and bottom of each column rule. */
.tire__block::before,
.tire__block::after {
  content: "";
  position: absolute;
  left: -3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink);
}
.tire__block::before {
  top: -3px;
}
.tire__block::after {
  bottom: -3px;
}
.tire__block:hover,
.tire__block:focus-within {
  transform: translateY(-4px);
  background-color: color-mix(in srgb, var(--ink) 4%, transparent);
}

/* Big metallic numeral, turned to read upward; the box rotates with it (writing-mode). */
.tire__numeral {
  align-self: flex-start;
  margin-bottom: 0.5rem;
  font-size: clamp(3.25rem, 5vw, 4.75rem);
  font-weight: 900;
  line-height: 1;
  /* Equal advance for every digit, so the six headings line up. */
  font-variant-numeric: tabular-nums;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.tire__label {
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: color 0.3s ease;
}
.tire__block:hover .tire__label,
.tire__block:focus-within .tire__label {
  color: var(--accent);
}

/* Headline figure under the label. */
.tire__lead {
  margin-bottom: 0.5rem;
}
.tire__lead-row dt {
  letter-spacing: 0.08em;
  margin-bottom: 0.125rem;
  line-height: 1.4;
  white-space: nowrap;
}
.tire__lead-row dd {
  white-space: nowrap;
}
.tire__figure {
  font-size: clamp(1.25rem, 1.8vw, 1.625rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.tire__unit {
  font-family: var(--font-data);
  font-size: var(--fs-small);
  color: var(--ink-soft);
}
.tire__pending {
  margin-bottom: 0.5rem;
  font-family: var(--font-data);
  font-size: var(--fs-small);
  line-height: 1.5;
  color: var(--ink-soft);
}

/* Framed box with the drawing: as wide as the card's text above and below it. */
.tire__specimen-wrap {
  flex: 1 0 auto;
  display: block;
  padding: 0.5rem 0 0.75rem;
}
.tire__specimen {
  width: 100%;
  height: 112px;
  background: var(--box);
  border: 1px solid var(--line-strong);
}
.tire__art {
  display: block;
  width: 100%;
  height: 100%;
}
.tire__legend {
  margin-top: 0.25rem;
  font-size: var(--fs-label);
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  white-space: nowrap;
}
.tire__track {
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 0.75;
}
.tire__track--empty {
  stroke-dasharray: 3 3;
}
.tire__fill {
  fill: var(--ink);
}
.tire__coin {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
}
.tire__ghost {
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.tire__plus {
  stroke: var(--ink);
  stroke-width: 1.5;
}
/* Noise: a tire with sound arcs; arcs beyond the level are faint and dashed. */
.tire__tick {
  stroke: var(--ink);
  stroke-width: 1.6;
}
.tire__hub {
  fill: var(--ink);
}
.tire__arc {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.4;
  stroke-linecap: round;
}
.tire__arc--off {
  stroke: var(--ink-soft);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}
/* Wear: tread lost from a block is shown dashed. */
.tire__worn {
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 0.7;
  stroke-dasharray: 1.2 1.2;
}
/* Grip: one colour and one hatch per surface (patterns in the markup, colours in tokens.css). */
.grip--dry {
  --c: var(--grip-dry);
}
.grip--wet {
  --c: var(--grip-wet);
}
.grip--light {
  --c: var(--grip-light);
}
.grip--deep {
  --c: var(--grip-deep);
}
.grip__bg {
  fill: color-mix(in srgb, var(--c) 22%, transparent);
}
.grip__ln {
  stroke: var(--c);
}
.grip__dot {
  fill: var(--c);
}
.grip__beam {
  stroke: var(--c);
  stroke-width: 1;
}

/* Metadata at the foot: label ..... value, joined by a dotted leader. Label and value each
   stay on one line; a value that cannot fit beside its label drops below it, whole. */
.tire__meta {
  margin-top: auto;
  padding-top: 0.625rem;
  border-top: 1px solid var(--line-strong);
}
.tire__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.375rem;
  margin-bottom: 0.25rem;
  font-family: var(--font-data);
  font-size: var(--fs-label);
  line-height: 1.4;
}
.tire__row dt {
  display: flex;
  flex: 1 1 auto;
  align-items: baseline;
  gap: 0.375rem;
  min-width: 0;
  color: var(--ink-soft);
  text-transform: uppercase;
  white-space: nowrap;
}
.tire__row dt::after {
  content: "";
  flex: 1 1 0.5rem;
  min-width: 0.5rem;
  margin-bottom: 0.2em;
  border-bottom: 1px dotted var(--ink-soft);
}
.tire__row dd {
  flex: 0 0 auto;
  margin-left: auto;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}
.tire__note {
  margin-top: 0.375rem;
}
.tire__pending--foot {
  margin: 0.5rem 0 0;
}
.tire__refresh {
  margin: 1.5rem 0 0;
  font-family: var(--font-data);
  font-size: var(--fs-small);
  color: var(--accent);
  text-align: center;
}

/* Narrow screens: the back link on its own row, Axle and Unit side by side in one row (PC33). */
@media (max-width: 40rem) {
  .tire__controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 0.75rem 0.5rem;
  }
  .tire__back {
    grid-column: 1 / -1;
    justify-self: start;
  }
  /* Narrow: the summary wraps below the controls, left-aligned. */
  .tire__summary {
    grid-column: 1 / -1;
    align-items: flex-start;
    text-align: left;
  }
  .tire__summary-line {
    justify-content: flex-start;
  }
  .tire__summary-line > *,
  .tire__wobble {
    white-space: normal;
  }
  .tire__controls > .tire__switch {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.375rem;
    min-width: 0;
  }
  .tire__controls > .tire__switch .switch__option {
    flex-wrap: wrap;
    justify-content: center;
    padding: 0.25rem 0.375rem;
    text-align: center;
  }
}

/* --- responsive: 6 columns, 3, 2, 1 ------------------------------------- */

@media (max-width: 1199px) {
  .tire__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 759px) {
  .tire__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 519px) {
  .tire__grid {
    grid-template-columns: minmax(0, 1fr);
  }
  /* One column: the numeral stands upright and smaller. */
  .tire__numeral {
    writing-mode: horizontal-tb;
    transform: none;
    margin-bottom: 0.5rem;
    font-size: 3.5rem;
  }

}

/* Six columns side by side: keep the specimen boxes on one line whatever the lead holds. */
@media (min-width: 75rem) {
  .tire__lead {
    min-height: 3.5rem;
  }
  /* A placeholder sentence in the lead position takes the lead's room. */
  .tire__label + .tire__pending {
    min-height: 3.5rem;
    margin-bottom: 0.5rem;
  }
  /* A block without a lead figure (grip, noise) leaves the same room above its box. */
  .tire__label + .tire__specimen-wrap {
    padding-top: calc(0.5rem + 3.5rem + 0.5rem);
  }
}


/* --- published photos of the model (TW3): thumbnails linking to /photo/:id ---------- */

.tire-photos {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-strong);
}
.tire-photos__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 1rem 0.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.tire-photos__item {
  display: grid;
  gap: 0.25rem;
  align-content: start;
  min-width: 0;
}
.tire-photos__thumb {
  display: block;
  line-height: 0;
  border: 1px solid var(--photo-frame);
  background: var(--box);
}
.tire-photos__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  filter: var(--photo-filter);
}
.tire-photos__thumb:hover,
.tire-photos__thumb:focus-visible {
  border-color: var(--accent);
}
.tire-photos__thumb:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.tire-photos__caption {
  margin: 0;
}

/* --- the large view of one photo (GET /photo/:id, C37) ---------------------- */

.photo-page {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
  padding: clamp(1rem, 2.4vw, 1.75rem) var(--page-pad) clamp(1.5rem, 4vw, 3rem);
  text-align: center;
}
.photo-page__title {
  font-size: var(--fs-base);
  font-weight: 700;
}
.photo-page__figure {
  max-width: 100%;
}
.photo-page__img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--photo-frame);
  background: var(--box);
  filter: var(--photo-filter);
}
.photo-page__bike {
  margin: 0;
  color: var(--ink-soft);
}
/* The picture is the link to the full-size file; the frame moves to the link so the focus ring wraps it. */
.photo-page__full {
  display: inline-block;
  max-width: 100%;
}
.photo-page__full:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.photo-page__hint {
  margin: 0.5rem 0 0;
  color: var(--ink-soft);
}
.photo-page__back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0 1rem;
  background: var(--ink);
  color: var(--ground);
  font-family: var(--font-data);
  font-size: var(--fs-small);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
}
.photo-page__back:hover,
.photo-page__back:focus-visible {
  background: var(--accent);
}

/* The related links close the page; the page's own padding is the side margin. */
.tire .related {
  margin-top: 1.5rem;
  padding-inline: 0;
}
