/* ==========================================================================
   main.css — Thoroughbred Trainers Information Guide
   Loaded on every page. Reset, :root design tokens, base typography,
   layout helpers, masthead, sticky nav, buttons, footer.
   Never hardcode a color or font in a component rule — use the tokens.
   Mobile rules live directly under each section's base rules (look for
   the "Mobile:" comment right below a component), not in one big block.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  /* Base colors */
  --bg: #f3f4f8;
  --surface: #ffffff;
  --ink: #1b1f33;
  --ink-soft: #5b5f76;
  --line: #dfe2ec;

  /* Brand colors */
  --primary: #5b6ba6;
  --primary-soft: #eceef7;
  --secondary: #ffc745;
  --secondary-deep: #f0b21f;
  --secondary-soft: #fff3cf;
  --accent-dark: #262d52;

  /* On dark backgrounds */
  --on-dark-soft: rgba(255, 255, 255, 0.74);
  --line-on-dark: rgba(255, 255, 255, 0.14);
  --tag-on-any: rgba(27, 31, 51, 0.55);

  /* Saddle-cloth colors, post positions 1–5 (jockey rank chips) */
  --cloth-1: #d62b2b;
  --cloth-2: #ffffff;
  --cloth-3: #1e4fc2;
  --cloth-4: #f6d10a;
  --cloth-5: #1f8a3f;

  /* Type */
  --font-head: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Jost', 'Helvetica Neue', Arial, sans-serif;

  /* Layout */
  --container: 1200px;
  --gutter: 1.5rem;
  --section-pad: 4rem;
  --nav-height: 64px;
  --ticker-height: 52px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(27, 31, 51, 0.05), 0 14px 32px -22px rgba(27, 31, 51, 0.3);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* Mobile: slightly larger base type reads better at arm's length on phones */
@media (max-width: 768px) {
  body { font-size: 1.0625rem; }
}

img,
svg { display: block; max-width: 100%; }
img { height: auto; }

h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
ul[class], ol[class] { list-style: none; padding: 0; }

a { color: var(--primary); }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

table { border-collapse: collapse; width: 100%; }

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

/* ---------- Base typography ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
}

h1 {
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.75rem);
  font-weight: 800;
}

h2 { font-size: clamp(1.5rem, 1.15rem + 1.2vw, 2.125rem); }
h3 { font-size: clamp(1.1rem, 1rem + 0.4vw, 1.3rem); }

/* Key-phrase emphasis inside headlines */
h1 em,
h2 em {
  font-style: italic;
  color: var(--primary);
}

.eyebrow {
  display: block;
  margin-bottom: 0.6rem;
  font: 700 0.72rem/1.2 var(--font-head);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
}

.lead {
  font-size: 1.125rem;
  color: var(--ink);
}

/* ---------- Layout helpers ---------- */
.container {
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}

section { padding-block: var(--section-pad); }

.section-head { max-width: 64ch; }
.section-head .lead { margin-top: 0.75rem; color: var(--accent-dark); font-size: 1.25rem; }

/* Mobile: tighter section padding and page gutter as the viewport narrows */
@media (max-width: 1100px) {
  :root { --section-pad: 3.25rem; }
}
@media (max-width: 768px) {
  :root {
    --section-pad: 2.75rem;
    --gutter: 1.1rem;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--accent-dark);
  color: var(--surface);
  border-radius: var(--radius-sm);
  font: 700 0.9rem/1 var(--font-head);
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* ---------- Masthead (title + persistent ad, top of every page) ---------- */
.masthead {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding-block: 1.25rem;
}

.masthead__brand {
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.masthead__edition {
  display: block;
  margin-bottom: 0.35rem;
  font: 700 0.7rem/1.2 var(--font-head);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
}

.masthead__title {
  font-size: clamp(1.45rem, 0.95rem + 2vw, 2.4rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
}

.masthead__tagline {
  margin-top: 0.4rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.masthead .spotlight--masthead {
  flex: none;
  width: min(100%, 440px);
}

/* Mobile: stack title above the ad once there isn't room for both side by side */
@media (max-width: 768px) {
  .masthead__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  .masthead .spotlight--masthead { width: 100%; }

  .masthead__edition {
    font-size: 0.62rem;
    letter-spacing: 0.1em;
  }
}

/* ---------- Sticky nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.nav .container {
  /* Nav content (long brand + 6 links + button) needs ~1736px; unlike the
     rest of the site it isn't capped at --container so it has room to fit
     on real desktop widths instead of overlapping. */
  width: min(100% - 2rem, 1800px);
}

.nav__inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  height: 100%;
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font: 800 1.25rem/1 var(--font-head);
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.nav__brand svg {
  width: 26px;
  height: 26px;
  color: var(--primary);
}

/* On desktop the panel is transparent to the grid: links center, CTA right */
.nav__panel { display: contents; }

.nav__links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 0;
}

.nav__links a {
  display: inline-block;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  font: 600 1.01rem/1 var(--font-head);
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}
.nav__links a:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav__cta { justify-self: end; }

.nav__toggle {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--ink);
}
.nav__toggle svg { width: 26px; height: 26px; }
.nav__toggle .icon-close { display: none; }

/* Mobile: below 1800px there isn't room for the full brand + 6 links +
   button on one row (see the width note above), so it collapses to a
   hamburger-driven dropdown panel instead of overlapping. */
@media (max-width: 1800px) {
  .nav__inner { grid-template-columns: auto 1fr auto; }

  .nav__toggle {
    display: inline-flex;
    grid-column: 3;
  }
  .nav--open .nav__toggle .icon-menu { display: none; }
  .nav--open .nav__toggle .icon-close { display: block; }

  .nav__panel {
    display: block;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    max-height: 0;
    overflow: hidden;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    transition: max-height 0.3s ease;
  }
  .nav--open .nav__panel {
    max-height: 80vh;
    overflow-y: auto;
  }

  .nav__links {
    position: static;
    transform: none;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.75rem var(--gutter) 0.25rem;
  }
  .nav__links a {
    display: block;
    padding: 0.85rem 0.75rem;
    font-size: 1rem;
  }

  .nav__panel .nav__cta {
    display: flex;
    justify-self: auto;
    width: fit-content;
    margin: 0.5rem auto 1rem;
  }
}

/* Mobile: the brand text alone ("Thoroughbred Information Trainers Guide"
   at 1.25rem, nowrap) is wider than a phone screen — shrink and let it
   wrap instead of pushing the nav bar into horizontal overflow. */
@media (max-width: 480px) {
  .nav__brand {
    font-size: 0.9rem;
    line-height: 1.15;
    white-space: normal;
  }
}

/* ---------- Buttons & links ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.35rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font: 700 0.92rem/1 var(--font-head);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.15s, background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { transform: translateY(-1px); }

.btn--primary {
  background: var(--secondary);
  color: var(--accent-dark);
}
.btn--primary:hover { background: var(--secondary-deep); }

.btn--dark {
  background: var(--accent-dark);
  color: var(--surface);
}
.btn--dark:hover { background: var(--primary); }

.btn--ghost {
  border-color: var(--primary);
  color: var(--primary);
  background: transparent;
}
.btn--ghost:hover { background: var(--primary-soft); }

.btn--light {
  background: var(--surface);
  color: var(--accent-dark);
}
.btn--light:hover { background: var(--primary-soft); }

.btn--small {
  padding: 0.6rem 0.95rem;
  font-size: 0.8rem;
}

.more-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font: 700 0.85rem/1 var(--font-head);
  color: var(--primary);
  text-decoration: none;
}
.more-link svg {
  width: 18px;
  height: 18px;
  transition: transform 0.15s;
}
.more-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}
.more-link:hover svg { transform: translateX(3px); }

/* ---------- Footer ---------- */
.footer {
  background: var(--primary);
  color: var(--on-dark-soft);
  padding-block: 3.5rem 2rem;
}

.footer__grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr 1fr 1fr;
  gap: 2.5rem;
}

.footer__title {
  margin-bottom: 0.6rem;
  font: 800 1.15rem/1.2 var(--font-head);
  letter-spacing: -0.01em;
  color: var(--surface);
}
.footer__title em {
  font-style: italic;
  color: var(--secondary);
}

.footer__blurb {
  max-width: 40ch;
  font-size: 0.95rem;
}

.footer__contact {
  margin-top: 1.25rem;
  font-size: 0.95rem;
}
.footer__contact li + li { margin-top: 0.35rem; }

.footer h3 {
  margin-bottom: 0.9rem;
  font: 700 0.7rem/1.2 var(--font-head);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--secondary);
}

.footer__links li + li { margin-top: 0.5rem; }

.footer a {
  color: inherit;
  text-decoration: none;
}
.footer a:hover {
  color: var(--surface);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.footer__contact a { color: var(--surface); }

.footer__partners {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line-on-dark);
}
.footer__partners .eyebrow { color: var(--secondary); }

.footer__partner-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.footer__partner-row li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
}
.footer__partner-row img {
  height: 26px;
  width: auto;
}
.footer__partner-row span {
  font: 700 0.72rem/1.1 var(--font-head);
  color: var(--ink);
  max-width: 12ch;
}

.footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line-on-dark);
  font-size: 0.85rem;
}

/* Mobile: 4 footer columns → 2, then 1, as the row narrows */
@media (max-width: 1100px) {
  .footer__grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .footer__grid { grid-template-columns: 1fr; gap: 2rem; }
}

/* ---------- Accessibility: reduced motion (applies at every width) ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
