/*
 * This is a manifest file that'll be compiled into application.css.
 */

/* Runs filter row — keep comboboxes a stable width so they don't shrink on select */
.runs-filters .ts-wrapper {
  min-inline-size: 10rem;
}

.runs-filters .ts-control {
  inline-size: 100%;
}

/* Sortable table headers */
.sort-link {
  display: inline-flex;
  align-items: center;
  gap: var(--size-1);
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.sort-link:hover {
  color: var(--color-accent);
}

.sort-link__icon {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  opacity: .5;
}

.sort-link.active {
  color: var(--color-accent);
  font-weight: var(--font-semibold);
}

.sort-link.active .sort-link__icon {
  color: var(--color-accent);
  opacity: 1;
}

/* Header branding with logo */
.header-logo {
  display: flex;
  align-items: center;
  gap: var(--size-2);
  text-decoration: none;
}

.header-logo-icon {
  width: 30px;
  height: 30px;
  border-radius: 0;
}

.header-logo-text {
  font-family: var(--rk-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

@media (max-width: 48rem) {
  .header-logo-icon {
    width: 26px;
    height: 26px;
  }

  .header-logo-text {
    font-size: var(--text-base);
  }
}

.pb-card-mark {
  transition: opacity 0.2s ease;
}

.pb-card-mark:hover {
  opacity: var(--opacity-75);
}

/* Stats cards grid */
.stats-cards {
  display: flex;
  flex-wrap: wrap;
  gap: var(--size-4);
}

@media (max-width: 48rem) {
  .stats-cards {
    flex-direction: column;
  }

  .stats-cards .card {
    margin: 0;
    width: 100%;
  }

  .page-title {
    font-size: var(--text-2xl);
  }

  .flex.items-center.justify-between {
    flex-wrap: wrap;
    gap: var(--size-2);
  }
}

/* Run Show Page */
.run-hero {
  background: var(--rk-pink);
  border: var(--rk-line);
  border-radius: 0;
  box-shadow: var(--rk-shadow-ink);
  padding: var(--size-8);
  margin-bottom: var(--size-6);
  color: white;
  text-align: center;
}

.run-hero-header {
  margin-bottom: var(--size-4);
}

.run-photo {
  margin-bottom: var(--size-6);
}

.run-photo-img {
  width: 100%;
  height: auto;
  max-height: 28rem;
  object-fit: cover;
  border: var(--rk-line);
  border-radius: 0;
  display: block;
}

.run-image-preview {
  width: 100%;
  max-width: 12rem;
  height: auto;
  border: var(--rk-line);
  border-radius: 0;
  object-fit: cover;
}

.run-race-name {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: var(--size-1) 0;
}

.run-date {
  font-size: var(--text-sm);
  opacity: 0.8;
  font-weight: 400;
}

.run-time-display {
  margin-top: var(--size-5);
}

.run-time-label {
  display: block;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  opacity: 0.75;
  margin-bottom: var(--size-2);
}

.run-time {
  font-size: clamp(3rem, 10vw, 4.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.run-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--size-4);
  margin-bottom: var(--size-6);
}

.run-stat-card {
  background-color: var(--color-bg);
  border: var(--rk-line);
  border-radius: 0;
  padding: var(--size-4);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--size-2);
  box-shadow: 3px 3px 0 0 var(--rk-ink);
}

.run-stat-icon {
  width: 26px;
  height: 26px;
  color: var(--color-accent);
}

.run-stat-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.run-stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.run-details {
  display: flex;
  flex-wrap: wrap;
  gap: var(--size-4);
  margin-bottom: var(--size-4);
}

.run-detail {
  display: flex;
  flex-direction: column;
  gap: var(--size-1);
}

.run-detail-label {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.run-detail-value {
  font-weight: 600;
}

@media (max-width: 48rem) {
  .run-stats {
    grid-template-columns: 1fr;
  }

  .run-hero {
    padding: var(--size-6);
    border-radius: 0;
  }

  .run-race-name {
    font-size: var(--text-xl);
  }
}

/* Stats Page */
.stats-header {
  margin-bottom: var(--size-8);
}

.stats-title {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--color-text);
  line-height: 1.05;
  margin-bottom: var(--size-2);
}

.stats-subtitle {
  color: var(--color-text-subtle);
  font-size: var(--text-base);
  font-weight: 400;
}

.stats-section {
  background: var(--color-bg);
  border: var(--rk-line);
  border-radius: 0;
  padding: var(--size-6);
  margin-bottom: var(--size-6);
  box-shadow: var(--rk-shadow-ink);
}

.stats-section--highlight {
  background: var(--rk-pink-soft);
  border-color: var(--rk-pink);
  box-shadow: var(--rk-shadow-pink);
}

.stats-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--size-5);
  flex-wrap: wrap;
  gap: var(--size-2);
}

.stats-section-title {
  display: flex;
  align-items: center;
  gap: var(--size-2);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.stats-section-icon {
  width: 20px;
  height: 20px;
  color: var(--color-accent);
  flex-shrink: 0;
}

.stats-section-badge {
  background: var(--rk-pink);
  color: white;
  font-family: var(--rk-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 4px 10px;
  border: 1.5px solid var(--rk-ink);
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stats-section-description {
  color: var(--color-text-subtle);
  font-size: var(--text-sm);
  margin-bottom: var(--size-4);
  font-weight: 400;
}

.stats-info {
  margin-bottom: var(--size-4);
}

.stats-info-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--size-1);
  width: fit-content;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-subtle);
  transition: color 0.15s ease;
}

.stats-info-toggle::-webkit-details-marker {
  display: none;
}

.stats-info-toggle:hover {
  color: var(--color-accent);
}

.stats-info-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.stats-info-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.stats-info[open] .stats-info-chevron {
  transform: rotate(180deg);
}

.stats-info-panel {
  margin-top: var(--size-3);
  padding: var(--size-3) var(--size-4);
  background: var(--color-bg-subtle);
  border: 2px solid var(--rk-ink);
  border-left: 5px solid var(--rk-pink);
  border-radius: 0;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-text-subtle);
}

.stats-info-panel p {
  margin: 0;
}

/* Personal Bests Grid */
.pb-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--size-3);
}

.pb-card {
  background: var(--color-bg);
  border: 2px solid var(--pb-color);
  border-radius: 0;
  box-shadow: 4px 4px 0 0 var(--pb-color);
  padding: var(--size-4) var(--size-5);
  text-align: left;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--size-4);
  min-height: 4.5rem;
}

.pb-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 0 var(--pb-color);
  background: var(--pb-color-light);
}

.pb-card-heading {
  display: flex;
  flex-direction: column;
  gap: var(--size-1);
  min-width: 0;
  max-width: 16rem;
}

.pb-card-distance {
  font-size: 11px;
  font-weight: 700;
  color: var(--pb-color);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.pb-card-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-card-time {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text);
  line-height: 1;
}

.pb-card-pace {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--size-1);
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
  font-weight: 500;
}

.pb-card-pace-icon {
  width: 13px;
  height: 13px;
}

.pb-card-date {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  opacity: 0.7;
  font-weight: 400;
  margin-inline-start: auto;
}

.pb-card--has-photo {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: 11.5rem;
  align-items: flex-end;
}

.pb-card-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}

.pb-card--has-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgb(0 0 0 / 0) 35%, rgb(0 0 0 / 0.5) 100%);
}

.pb-card--has-photo:hover {
  background: var(--color-bg);
}

.pb-card--has-photo .pb-card-distance {
  color: white;
}

.pb-card--has-photo .pb-card-name,
.pb-card--has-photo .pb-card-time,
.pb-card--has-photo .pb-card-pace,
.pb-card--has-photo .pb-card-date {
  color: white;
  opacity: 1;
}

.pb-card--has-photo .pb-card-pace {
  opacity: 0.9;
}

/* Stats Grid 2 columns */
.stats-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--size-6);
}

/* Your Numbers */
.stats-numbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--size-3);
  margin-bottom: var(--size-6);
}

.stats-number {
  background: var(--color-bg);
  border: var(--rk-line);
  border-radius: 0;
  padding: var(--size-5) var(--size-4);
  display: flex;
  flex-direction: column;
  gap: var(--size-1);
  box-shadow: 3px 3px 0 0 var(--rk-ink);
}

.stats-number-value {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text);
  line-height: 1;
}

.stats-number-unit {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text-subtle);
  margin-inline-start: 2px;
}

.stats-number-label {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* Progression */
.progression-list {
  display: flex;
  flex-direction: column;
  gap: var(--size-4);
}

.progression-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: var(--size-1) var(--size-4);
}

.progression-meta {
  display: flex;
  flex-direction: column;
  gap: var(--size-1);
  grid-row: 1 / 3;
}

.progression-distance {
  font-size: 11px;
  font-weight: 700;
  color: var(--pr-color);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.progression-delta {
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progression-delta.is-faster {
  color: #059669;
}

.progression-delta.is-slower {
  color: var(--color-text-subtle);
}

.progression-chart {
  width: 100%;
  max-width: 360px;
  height: auto;
  background: var(--pr-color-light);
  border: 1.5px solid var(--pr-color);
  border-radius: 0;
  padding: var(--size-2);
  box-sizing: border-box;
}

.progression-point {
  cursor: pointer;
}

.progression-dot {
  transition: r 0.12s ease;
}

.progression-point:hover .progression-dot,
.progression-point:focus-visible .progression-dot {
  r: 5.5;
}

.progression-years {
  grid-column: 2;
  display: flex;
  justify-content: space-between;
  max-width: 360px;
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  font-weight: 500;
}

/* Section header link */
.stats-section-link {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
}

.stats-section-link:hover {
  text-decoration: underline;
}

/* This Season */
.season-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--size-3);
}

.season-card {
  border: 2px solid var(--season-color);
  border-radius: 0;
  box-shadow: 3px 3px 0 0 var(--season-color);
  padding: var(--size-4);
  display: flex;
  flex-direction: column;
  gap: var(--size-1);
}

.season-distance {
  font-size: 11px;
  font-weight: 700;
  color: var(--season-color);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.season-time {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text);
  line-height: 1;
  text-decoration: none;
}

.season-time:hover {
  color: var(--season-color);
}

.season-delta {
  font-size: var(--text-xs);
  font-weight: 600;
}

.season-delta.is-faster {
  color: #059669;
}

.season-delta.is-slower,
.season-delta--new {
  color: var(--color-text-subtle);
}

/* Activity Calendar */
.calendar-heatmap {
  display: flex;
  flex-direction: column;
  gap: var(--size-1);
  overflow-x: auto;
}

.calendar-row {
  display: grid;
  grid-template-columns: 2.5rem repeat(12, 1fr);
  gap: var(--size-1);
  align-items: center;
  min-width: 320px;
}

.calendar-year-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-subtle);
}

.calendar-month-label {
  font-size: 10px;
  text-align: center;
  color: var(--color-text-subtle);
  opacity: 0.7;
}

.calendar-cell {
  aspect-ratio: 1;
  border-radius: 0;
  background: var(--color-border-light);
}

.calendar-cell--l1 {
  background: rgb(from var(--color-accent) r g b / 0.35);
}

.calendar-cell--l2 {
  background: rgb(from var(--color-accent) r g b / 0.65);
}

.calendar-cell--l3 {
  background: var(--color-accent);
}

/* Estimated Paces */
.estimated-paces-list {
  display: flex;
  flex-direction: column;
  gap: var(--size-2);
}

.estimated-pace-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--size-3) var(--size-4);
  background: var(--color-bg);
  border: 2px solid var(--rk-ink);
  border-left: 5px solid var(--ep-color);
  border-radius: 0;
}

.estimated-pace-distance {
  font-weight: 700;
  color: var(--ep-color);
  min-width: 40px;
  font-size: var(--text-sm);
}

.estimated-pace-time {
  font-weight: 700;
  color: var(--color-text);
  flex: 1;
  text-align: center;
  letter-spacing: -0.02em;
}

.estimated-pace-per-km {
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
  min-width: 70px;
  text-align: right;
  font-weight: 500;
}

/* Page actions */
.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--size-2);
  margin-top: var(--size-4);
}

@media (max-width: 48rem) {
  .page-actions {
    margin-bottom: var(--size-16);
  }
}

/* Top Three per Distance */
.top-three-rows {
  display: flex;
  flex-direction: column;
  gap: var(--size-4);
}

.top-three-row {
  background: var(--color-bg);
  border-radius: 0;
  padding: var(--size-4) var(--size-5);
  box-shadow: 3px 3px 0 0 var(--rk-ink);
  border: var(--rk-line);
  border-left: 6px solid var(--tt-color);
  display: flex;
  flex-direction: column;
  gap: var(--size-3);
}

.top-three-row-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--tt-color);
  letter-spacing: -0.01em;
}

.top-three-items {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: var(--size-1_5);
}

.top-three-item {
  display: flex;
  align-items: center;
  gap: var(--size-3);
  padding: var(--size-2_5) var(--size-3);
  border: 2px solid var(--rk-ink);
  border-radius: 0;
  text-decoration: none;
  transition: background-color 0.15s ease;
  background: var(--color-bg);
}

.top-three-item:hover {
  background: var(--tt-color-light);
}

.top-three-rank {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tt-color);
  color: white;
  font-family: var(--rk-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  border-radius: 0;
  flex-shrink: 0;
}

.top-three-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.top-three-time {
  font-size: var(--text-base);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text);
  line-height: 1;
}

.top-three-pace {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  font-weight: 400;
}

.top-three-name {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: 500;
  flex: 1;
}

.top-three-date {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  white-space: nowrap;
  font-weight: 400;
}

/* Races List */
.races-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--size-4);
}

.race-card {
  background: var(--color-bg);
  border: 2px solid var(--race-color);
  border-radius: 0;
  box-shadow: 4px 4px 0 0 var(--race-color);
  padding: var(--size-5);
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: var(--size-2);
}

.race-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 0 var(--race-color);
  background: var(--race-color-light);
}

.race-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--size-2);
}

.race-card-distance {
  font-size: 11px;
  font-weight: 700;
  color: var(--race-color);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.race-card-badge {
  background: var(--rk-pink);
  color: white;
  font-family: var(--rk-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border: 1.5px solid var(--rk-ink);
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.race-card-name {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
  line-height: 1.2;
}

.race-card-location {
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
  font-weight: 400;
}

.race-card-best {
  display: flex;
  align-items: center;
  gap: var(--size-2);
  margin-top: var(--size-2);
  padding-top: var(--size-2);
  border-top: 1px solid var(--color-border-light);
}

.race-card-best-label {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.race-card-best-time {
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--race-color);
}

/* Mobile responsive */
@media (max-width: 48rem) {
  .stats-grid-2 {
    grid-template-columns: 1fr;
  }

  .pb-grid {
    grid-template-columns: 1fr;
  }

  .stats-numbers {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-section {
    border-radius: 0;
  }
}

/* Runs table */
.runs-table thead th {
  font-family: var(--rk-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-subtle);
  font-weight: var(--font-semibold);
}

.runs-table th,
.runs-table td {
  padding-block: var(--size-3);
  vertical-align: middle;
}

.runs-table tbody tr {
  transition: background-color 0.15s ease;
}

.runs-table__name {
  font-weight: var(--font-semibold);
  color: var(--color-text);
  text-decoration: none;
}

.runs-table__name:hover {
  color: var(--color-accent);
}

.runs-table__time {
  font-weight: var(--font-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

.runs-table__pace {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-subtle);
}

.distance-pill {
  display: inline-block;
  padding: 2px 10px;
  font-family: var(--rk-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--d-color);
  background: var(--d-bg);
  border: 1.5px solid var(--d-color);
  border-radius: 0;
}

.runs-table__row--pb {
  background-color: rgb(from var(--color-accent) r g b / 0.06);
}

.runs-table__row--pb:hover {
  background-color: rgb(from var(--color-accent) r g b / 0.1);
}

.runs-table__row--pb > th:first-child {
  box-shadow: inset 3px 0 0 0 var(--color-accent);
}

.runs-table__pb {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-inline-start: var(--size-2);
  padding: 1px 8px 1px 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: white;
  background: var(--rk-pink);
  border: 1px solid var(--rk-ink);
  border-radius: 0;
  vertical-align: middle;
  white-space: nowrap;
}

.runs-table__pb-icon {
  width: 11px;
  height: 11px;
}

.runs-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--size-4);
  padding: var(--size-12) var(--size-4);
  text-align: center;
  border: 2px dashed var(--rk-ink);
  border-radius: 0;
}

.runs-empty__text {
  color: var(--color-text-subtle);
  font-size: var(--text-base);
}

@media (max-width: 48rem) {
  .runs-table__row--pb > th:first-child {
    box-shadow: none;
  }

  .runs-table__row--pb {
    border-inline-start: 3px solid var(--color-accent);
  }
}
