/*
 * Horses to Watch — magazine-style cards layout.
 *
 * Two-tier visual hierarchy:
 *   • Hero card (the top pick) gets a full-width spread with a
 *     prominent silk + stats column. Reads like a centre-fold ad.
 *   • Grid cards (picks 2-5) are a 2-column responsive grid of
 *     compact cards. Each carries its own ribbon, silk, narrative,
 *     and result chip — a self-contained "advert" per pick.
 *
 * Ribbon colour tints are driven by the signal kind (HOT_STREAK
 * → red, FOX_VERDICT → gold, etc.) — see SIGNAL_TINTS in the
 * generator.
 *
 * The result chip in the corner of each card updates LIVE off the
 * Runner.finish_position field: pending → gold WON / silver 2nd /
 * bronze 3rd / neutral mid-pack / grey unplaced / red DNF. The
 * `result_chip_for` service computes the payload at render time.
 */

:root {
  --htw-bg-card:    #faf6ec;
  --htw-bg-deep:    #1a1612;
  --htw-text:       #1a1612;
  --htw-text-dim:   rgba(26, 22, 18, 0.62);
  --htw-text-faint: rgba(26, 22, 18, 0.40);
  --htw-line:       rgba(26, 22, 18, 0.10);
  --htw-gold:       #c39e2a;
  --htw-gold-lt:    #f5e49a;
  --htw-red:        #c0392b;
  --htw-green:      #2f7d3a;
  --htw-purple:     #6b4baf;
  --htw-cyan:       #1f7a8c;
  --htw-amber:      #d18b27;
  --htw-navy:       #1f3a8a;
  --htw-slate:      #475569;
}

.htw {
  display: flex;
  flex-direction: column;
  gap: 36px;
  margin: 28px 0;
}

/* ── Intro / pulse ────────────────────────────────────────────── */
.htw-intro {
  border-left: 4px solid var(--htw-gold);
  background: rgba(212, 175, 55, 0.06);
  padding: 18px 22px;
  border-radius: 4px;
}
.htw-intro__text {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-size: 19px;
  line-height: 1.55;
  color: var(--htw-text);
  margin: 0 0 8px;
}
.htw-intro__author {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--htw-gold);
}

/* ── Card shell ───────────────────────────────────────────────── */
.htw-card {
  position: relative;
  background: var(--htw-bg-card);
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    0 1px 0 var(--htw-line),
    0 4px 18px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--htw-line);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.htw-card:hover {
  box-shadow:
    0 1px 0 var(--htw-line),
    0 8px 28px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

/* ── Ribbon ──────────────────────────────────────────────────── */
.htw-card__ribbon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 11px;
}
.htw-card__ribbon-tag    { opacity: 0.85; }
.htw-card__ribbon-signal { font-size: 12px; }

.htw-card__ribbon--gold   { background: linear-gradient(95deg, #c39e2a 0%, #f5e49a 100%); color: #2a1f08; }
.htw-card__ribbon--red    { background: linear-gradient(95deg, #c0392b 0%, #e74c3c 100%); }
.htw-card__ribbon--green  { background: linear-gradient(95deg, #2f7d3a 0%, #5cb85c 100%); }
.htw-card__ribbon--purple { background: linear-gradient(95deg, #6b4baf 0%, #9b6bd8 100%); }
.htw-card__ribbon--cyan   { background: linear-gradient(95deg, #1f7a8c 0%, #4ecdc4 100%); }
.htw-card__ribbon--amber  { background: linear-gradient(95deg, #d18b27 0%, #f4b942 100%); }
.htw-card__ribbon--navy   { background: linear-gradient(95deg, #1f3a8a 0%, #4361ee 100%); }
.htw-card__ribbon--slate  { background: linear-gradient(95deg, #475569 0%, #64748b 100%); }

/* ── Hero card ───────────────────────────────────────────────── */
.htw-card--hero .htw-card__hero {
  display: grid;
  grid-template-columns: 140px 1fr 200px;
  gap: 28px;
  padding: 28px 28px 22px;
  align-items: start;
}

.htw-card__silk {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.silk-jersey--lg { width: 130px; height: auto; }
.silk-jersey--md { width: 56px;  height: auto; }
.silk-jersey--sm { width: 34px;  height: auto; }
.silk-jersey--img.silk-jersey--lg { width: 120px; border-radius: 6px; }
.silk-jersey--img.silk-jersey--md { width: 56px;  border-radius: 4px; }

.htw-card__meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}
.htw-card__rank {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  color: var(--htw-gold);
}
.htw-card__race {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--htw-text-dim);
  text-decoration: none;
  border-bottom: 1px dashed transparent;
  transition: color 0.15s, border-color 0.15s;
}
a.htw-card__race:hover {
  color: var(--htw-gold);
  border-bottom-color: var(--htw-gold);
}

.htw-card__horse {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 900;
  line-height: 1.02;
  color: var(--htw-text);
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}
.htw-card__horse a { color: inherit; text-decoration: none; }
.htw-card__horse a:hover { color: var(--htw-gold); }

.htw-card__narrative {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px;
  line-height: 1.55;
  color: var(--htw-text);
  margin: 0 0 18px;
  font-style: italic;
  border-left: 3px solid var(--htw-gold);
  padding: 4px 0 4px 14px;
}

.htw-card__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.htw-card__chip {
  display: inline-flex;
  align-items: center;
  background: rgba(26, 22, 18, 0.06);
  border: 1px solid var(--htw-line);
  color: var(--htw-text);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.htw-card__connections {
  display: flex;
  gap: 18px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--htw-text-dim);
  padding-top: 12px;
  border-top: 1px dashed var(--htw-line);
}
.htw-card__connections strong {
  color: var(--htw-gold);
  font-weight: 800;
  margin-right: 4px;
}

/* ── Stats column ────────────────────────────────────────────── */
.htw-card__stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  text-align: center;
}
.htw-card__stat {
  background: var(--htw-bg-deep);
  color: var(--htw-gold-lt);
  border-radius: 6px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.htw-card__stat--odds .htw-card__stat-num {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  color: var(--htw-gold-lt);
}
.htw-card__stat--sr .htw-card__stat-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--htw-gold-lt);
  letter-spacing: 0.02em;
}
.htw-card__stat-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(245, 228, 154, 0.55);
}

/* ── Result chip ─────────────────────────────────────────────── */
.htw-card__result {
  border-radius: 6px;
  padding: 12px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(26, 22, 18, 0.06);
  border: 1px dashed var(--htw-line);
  color: var(--htw-text-dim);
}
.htw-card__result--settled {
  border-style: solid;
}
.htw-card__result-label {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.htw-card__result-detail {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}

/* Tints — gold (won) carries the celebratory gradient + glow. */
.htw-card__result--gold {
  background: linear-gradient(135deg, #f5e49a 0%, #c39e2a 100%);
  color: #2a1f08;
  border-color: var(--htw-gold);
  box-shadow: 0 0 0 1px rgba(195, 158, 42, 0.4),
              0 4px 14px rgba(195, 158, 42, 0.25);
}
.htw-card__result--silver {
  background: linear-gradient(135deg, #f0f0f0 0%, #b8bcc4 100%);
  color: #2a2f38;
  border-color: #b8bcc4;
}
.htw-card__result--bronze {
  background: linear-gradient(135deg, #e8b783 0%, #b8702c 100%);
  color: #2a1808;
  border-color: #b8702c;
}
.htw-card__result--neutral {
  background: rgba(26, 22, 18, 0.05);
  color: var(--htw-text);
  border-color: var(--htw-line);
}
.htw-card__result--grey {
  background: rgba(26, 22, 18, 0.04);
  color: var(--htw-text-faint);
  border-color: var(--htw-line);
}
.htw-card__result--red {
  background: rgba(192, 57, 43, 0.10);
  color: var(--htw-red);
  border-color: rgba(192, 57, 43, 0.35);
}
.htw-card__result--pending {
  background: rgba(212, 175, 55, 0.08);
  color: var(--htw-amber);
  border-color: rgba(212, 175, 55, 0.30);
  border-style: dashed;
}

/* ── CTA ─────────────────────────────────────────────────────── */
.htw-card__cta {
  display: block;
  text-align: center;
  padding: 14px;
  background: var(--htw-bg-deep);
  color: var(--htw-gold-lt);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background 0.15s;
}
.htw-card__cta:hover {
  background: var(--htw-red);
  color: #fff;
}

/* ── Grid cards (picks 2-5) ──────────────────────────────────── */
.htw-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.htw-card--grid .htw-card__row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  padding: 18px 18px 12px;
  align-items: center;
}
.htw-card--grid .htw-card__row-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.htw-card__race--sm { font-size: 11px; }
.htw-card__horse--sm {
  font-size: 22px;
  margin: 0;
  line-height: 1.1;
}
.htw-card__pricetag {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.htw-card__odds-pill {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 900;
  font-size: 16px;
  color: var(--htw-text);
  background: var(--htw-gold-lt);
  padding: 2px 10px;
  border-radius: 4px;
}
.htw-card__sr-pill {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: var(--htw-bg-deep);
  color: var(--htw-gold-lt);
  padding: 4px 10px;
  border-radius: 4px;
}

.htw-card__narrative--sm {
  font-size: 15px;
  margin: 0 18px 14px;
  padding-left: 12px;
  border-left-width: 2px;
}
.htw-card__chips--sm {
  margin: 0 18px 12px;
}
.htw-card__chips--sm .htw-card__chip { font-size: 11px; }

.htw-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(26, 22, 18, 0.03);
  border-top: 1px dashed var(--htw-line);
}
.htw-card__connections--sm {
  flex-direction: column;
  gap: 4px;
  padding-top: 0;
  border-top: 0;
}
.htw-card__connections--sm span { font-size: 11px; }

.htw-card--grid .htw-card__result {
  flex: 0 0 auto;
  padding: 8px 12px;
  min-width: 90px;
}
.htw-card--grid .htw-card__result-label { font-size: 12px; }

/* ── Verdict ─────────────────────────────────────────────────── */
.htw-verdict {
  background: var(--htw-bg-deep);
  color: var(--htw-gold-lt);
  border-radius: 8px;
  padding: 24px 28px;
  position: relative;
}
.htw-verdict__title {
  display: inline-block;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--htw-gold);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--htw-gold);
}
.htw-verdict__text {
  margin: 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 19px;
  line-height: 1.5;
  font-style: italic;
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .htw-card--hero .htw-card__hero {
    grid-template-columns: 90px 1fr;
    gap: 16px;
    padding: 20px 20px 16px;
  }
  .silk-jersey--lg { width: 80px; }
  .htw-card__horse { font-size: 28px; }
  .htw-card__narrative {
    font-size: 16px;
    /* Belt-and-braces: any freak-long word (URL, unbroken hash)
       breaks inside the card rather than punching through it. */
    overflow-wrap: anywhere;
  }
  /* min-width:0 lets the body track shrink inside its grid cell
     instead of adopting the widest chip's min-content. Without
     this the whole hero grid gets pushed wider than the card and
     .htw-card's overflow:hidden clips the narrative + chips on
     the right. */
  .htw-card__body { min-width: 0; }
  /* Chips wrap onto multiple lines on mobile — nowrap on desktop
     is fine (row has room), on 320-480px it forces the parent
     track wider than the viewport. */
  .htw-card__chip { white-space: normal; }
  /* Stats column drops below body on mobile.
     flex-wrap: wrap lets the Verify chip drop to a new line when
     the three tiles + chip don't fit — was previously being
     clipped by .htw-card's overflow:hidden. */
  .htw-card__stats {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
  }
  /* Three equal tiles, each ~33% minus the gap so they always fit
     one row. min-width:0 lets a long result label wrap inside the
     tile rather than push the tile wider than its share. */
  .htw-card__stat,
  .htw-card__result {
    flex: 1 1 calc(33.33% - 6px);
    min-width: 0;
    padding: 10px 6px;
  }
  /* Shrink the big serif numbers so a 3/1 or 97 doesn't dominate
     the row — they were sized for a 200px desktop column. */
  .htw-card--hero .htw-card__stat--odds .htw-card__stat-num { font-size: 22px; }
  .htw-card--hero .htw-card__stat--sr   .htw-card__stat-num { font-size: 18px; }
  .htw-card--hero .htw-card__stat-label,
  .htw-card--hero .htw-card__result-label { font-size: 9px; letter-spacing: 0.18em; }
  .htw-card--hero .htw-card__result-detail {
    font-size: 10px;
    line-height: 1.3;
    letter-spacing: 0.02em;
  }
  /* Verify chip: force its own row beneath the tiles so it can't
     be clipped by the card edge. flex-basis 100% pushes it to a
     new line; justify-center keeps it visually anchored. */
  .htw-card__stats .verify-chip {
    flex: 1 1 100%;
    justify-content: center;
  }

  .htw-grid {
    grid-template-columns: 1fr;
  }
  .htw-verdict__text { font-size: 16px; }
}
