/* Track selection screen (tracks.html) */

/* ── Outer layout: fixed full-screen container ────────────────────────────── */
#track-select {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg-screen);
  font: 14px/1.4 var(--font-body); color: var(--ink);
}

/* ── Two-column header: title/subtitle left, tire-coin balance right ───────── */
#track-select .ts-header-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: min(440px, calc(100vw - 28px));
  text-align: left;
}
#track-select .ts-header-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
#track-select .wallet-pill { flex-shrink: 0; }

.wallet-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 14px; border-radius: 20px;
  background: rgba(255,180,60,.14);
  border: 1px solid rgba(255,180,60,.3);
  color: #ffce6a; font: 700 14px var(--font-body);
  font-variant-numeric: tabular-nums;
}

/* ── Normal / Reversed toggle ────────────────────────────────────────────── */
#ts-mode {
  display: flex; gap: 8px;
  width: 100%; max-width: 370px;
  margin-top: 6px;
}

.mode-btn {
  flex: 1;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 2px solid var(--surface-line);
  background: var(--surface);
  color: rgba(255,255,255,.5);
  font: 600 14px var(--font-body);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
}

.mode-btn.is-active {
  border-color: var(--accent-glow);
  background: var(--accent-tint);
  color: var(--accent);
}

.mode-btn.is-locked {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

.lock-icon { flex-shrink: 0; }

/* ── Cards grid ──────────────────────────────────────────────────────────────
   Desktop: fixed 3 columns. Tablet (≤880px): 2. Mobile (≤600px): 1.
   Columns cap card width at 280px and the whole grid is centred. */
#track-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 280px));
  justify-content: center;
  align-content: flex-start;
  gap: 16px;
}
#track-cards::-webkit-scrollbar { display: none; }
@media (max-width: 880px) {
  #track-cards { grid-template-columns: repeat(2, minmax(0, 280px)); }
}

@media (max-width: 600px) {
  #track-cards { grid-template-columns: 1fr; }
}

/* ── Track card (fills its grid column) ──────────────────────────────────── */
.track-card {
  display: flex; flex-direction: column;
  width: 100%;
  border-radius: var(--r-card);
  background: var(--surface);
  border: 2px solid var(--surface-line);
  cursor: pointer; text-decoration: none; color: var(--ink);
  overflow: hidden;
  transition: border-color var(--ease), background var(--ease),
              transform var(--ease), box-shadow var(--ease);
}
.track-card:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(255,177,77,.12);
}

.track-card-top { display: block; position: relative; }

/* PPS star rating — top-left corner of thumbnail */
/* Top-left overlay: the stars pill and, to its right, the DDK crown badge. */
.track-badges {
  position: absolute;
  top: 9px; left: 9px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}
.track-stars {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 3px 7px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  line-height: 1;
}
.track-star-row { display: flex; gap: 2px; }
/* DDK crown — a separate pill sitting to the right of the stars once the instance best is 600+ PPS */
.track-crown {
  font-size: 13px; line-height: 1;
  padding: 4px 6px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.44);
  border: 1px solid rgba(255, 190, 60, 0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  filter: drop-shadow(0 0 4px rgba(255, 190, 60, 0.7));
}
/* Participation Trophy — same pill as the crown, cooler accent so the 1-PPS gag reads apart from gold DDK */
.track-trophy {
  font-size: 13px; line-height: 1;
  padding: 4px 6px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.44);
  border: 1px solid rgba(150, 200, 255, 0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  filter: drop-shadow(0 0 4px rgba(150, 200, 255, 0.6));
}
/* Perpetual Motion — same pill, mint accent so the unbroken-drift badge reads apart from crown + trophy */
.track-perpetual {
  font-size: 13px; line-height: 1;
  padding: 4px 6px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.44);
  border: 1px solid rgba(120, 230, 170, 0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  filter: drop-shadow(0 0 4px rgba(120, 230, 170, 0.6));
}
.track-stars .star-dim { font-size: 13px; color: rgba(255,255,255,0.28); }
.track-stars .star-lit { font-size: 13px; color: #ffc840; text-shadow: 0 0 6px rgba(255,180,0,0.6); }

/* Collectible chips (caps + tires) — in the card body, readable on the surface */
.track-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;            /* sits at the card bottom, below the record line */
}
.track-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px;
  font: 700 11px var(--font-body); letter-spacing: .3px;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}
/* Translucent red (caps) / amber (tires) plates; brighter once everything's collected */
.track-chip.cap  { background: rgba(180,28,0,.18);   color: rgba(220,90,60,.85);  border-color: rgba(180,28,0,.30); }
.track-chip.tire { background: rgba(255,180,60,.14); color: rgba(255,200,110,.9); border-color: rgba(255,180,60,.30); }
.track-chip.cap.is-done  { background: rgba(180,28,0,.34);   color: #ff7755; border-color: rgba(200,50,20,.55); }
.track-chip.tire.is-done { background: rgba(255,180,60,.30); color: #ffce6a; border-color: rgba(255,190,80,.55); }

/* Locked reversed card (inert div, not a link) + lock overlay on the thumbnail */
.track-card.is-locked { opacity: .6; cursor: not-allowed; }
.track-card.is-locked:hover {
  transform: none; border-color: var(--surface-line);
  box-shadow: none; background: var(--surface);
}
.track-lock {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(0,0,0,.5);
  color: rgba(255,255,255,.82);
  font: 700 12px var(--font-body); letter-spacing: .3px; text-align: center; padding: 10px;
}
.track-lock-ico { font-size: 22px; }

.track-card-score { display: none; }

.track-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  background: var(--bg-deep);
}

.track-card-body {
  padding: 12px 16px 14px;
  display: flex; flex-direction: column; gap: 5px;
}

.track-card-name {
  font: 800 15px var(--font-display);
  letter-spacing: .3px;
}

.track-card-desc {
  font: 400 12px var(--font-body);
  opacity: .45; line-height: 1.4;
}

.track-card-record {
  font: 500 12px var(--font-body);
  color: rgba(255,255,255,.35);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.track-card-record .val {
  color: var(--accent);
  font-weight: 700;
  margin-inline: 3px 6px;
}
.track-card-record .rec-sub {
  color: rgba(255,255,255,.3);
  font-weight: 400;
}

/* ── Mobile layout (≤ 480px) ─────────────────────────────────────────────── */
@media (max-width: 480px) {

  #track-cards {
    gap: 12px;
  }

  .track-card {
    width: clamp(340px, calc(100vw - 24px), 380px);
    flex-shrink: 0;   /* do not shrink inside flex-column container */
  }

  .track-card-top {
    display: flex;
    flex-direction: row;
    align-items: stretch;
  }

  .track-thumb {
    flex: 0 0 71%;
    width: auto;
    aspect-ratio: 267 / 146;
  }

  .track-thumb--full {
    flex: 1 1 100%;
  }

  .track-card-score {
    flex: 1;
    display: flex; flex-direction: column;
    justify-content: center;
    padding: 8px 10px 8px 8px;
    gap: 1px;
    min-width: 90px;
    border-left: 1px solid var(--surface-line);
  }

  .tcs-label {
    font: 400 9px var(--font-body);
    opacity: .4;
    letter-spacing: .4px;
    text-transform: uppercase;
    margin-block-start: 5px;
  }
  .tcs-label:first-child {
    margin-block-start: 0;
  }

  .tcs-pps {
    font: 700 15px var(--font-display);
    color: var(--accent);
    letter-spacing: -.3px;
    line-height: 1.1;
    margin-block-end: 20px;
  }

  .tcs-unit { font-size: 10px; font-weight: 600; }

  .tcs-total,
  .tcs-time {
    font: 500 11px var(--font-body);
    opacity: .55;
    font-variant-numeric: tabular-nums;
  }

  .tcs-none {
    font: 400 14px var(--font-body);
    opacity: .25;
    align-self: center;
  }

  .track-card-record { display: none; }

  .track-card-body {
    padding: 8px 12px 10px;
    gap: 3px;
  }

  .track-card-name { font-size: 14px; }
}
