/* SimPitch: United red on a mown pitch.
   Tokens first, then base, navbar, hero, ticker, strip, cards, band, footer, motion. */
:root {
  --red: #DB1D24;            /* manutd.com red */
  --red-dark: #B3141A;
  --pitch-dark: #1E6B32;     /* mown stripe, dark */
  --pitch-light: #2E8B43;    /* mown stripe, light */
  --deep: #0A2A17;           /* floodlit-night green for nav, footer, overlays */
  --chalk: #F5F7F2;
  --ink: #101A13;
  --line: #DCE3DA;
  --muted: #56635A;
  --white-line: rgba(255,255,255,.82);
  --head: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --page-max: 1180px;
  --ease: cubic-bezier(.2,.7,.2,1);
  --stripes: repeating-linear-gradient(90deg, var(--pitch-dark) 0 60px, var(--pitch-light) 60px 120px);
}

html, body { background: var(--chalk); color: var(--ink); }
body { font-family: var(--body); font-size: 1.04rem; line-height: 1.65; }

h1, h2, h3, h4, .quarto-title-block .title {
  font-family: var(--head); font-variation-settings: "SOFT" 0, "WONK" 0;
}
.navbar, .sp-tag, .sp-btn { font-family: var(--body); }
h1, h2, h3 { font-weight: 800; letter-spacing: -0.015em; line-height: 1.1; color: var(--ink); }
h1 { font-size: clamp(2.1rem, 4.4vw, 3.4rem); }
h2 { font-size: clamp(1.45rem, 2.5vw, 2rem); margin-top: 2.2rem; border-bottom: none; }
p, li { max-width: 72ch; }
a { color: var(--red); text-underline-offset: 3px; }
a:hover { color: var(--red-dark); }
::selection { background: var(--red); color: #fff; }

a:focus-visible, button:focus-visible, .sp-btn:focus-visible {
  outline: 3px solid var(--red); outline-offset: 2px;
}

/* ---------- Reading progress bar ---------- */
.sp-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 2000;
  background: var(--red); transform-origin: 0 50%; transform: scaleX(0); pointer-events: none;
}

/* ---------- Navbar ---------- */
.navbar {
  background: var(--deep) !important;
  border-bottom: 3px solid var(--red);
  padding-top: .5rem; padding-bottom: .5rem;
}
.navbar .nav-link {
  position: relative; font-weight: 600; font-size: .95rem; color: #fff !important;
  padding: .5rem .85rem; letter-spacing: .01em;
}
.navbar .nav-link::after {
  content: ""; position: absolute; left: .85rem; right: .85rem; bottom: .2rem; height: 2px;
  background: var(--red); transform: scaleX(0); transform-origin: 0 50%; transition: transform .25s var(--ease);
}
.navbar .nav-link:hover::after, .navbar .nav-link.active::after { transform: scaleX(1); }
.navbar .navbar-nav.ms-auto > .nav-item:last-child .nav-link {
  background: var(--red); border-radius: 999px; margin-left: .5rem; padding: .5rem 1.1rem;
  transition: background .2s, transform .2s var(--ease);
}
.navbar .navbar-nav.ms-auto > .nav-item:last-child .nav-link::after { display: none; }
.navbar .navbar-nav.ms-auto > .nav-item:last-child .nav-link:hover { background: var(--red-dark); transform: translateY(-1px); }
.navbar .navbar-brand img { height: 32px; }
#quarto-search .aa-DetachedSearchButtonIcon, .navbar .bi { color: #fff !important; }
#quarto-content, .page-columns { max-width: var(--page-max); margin-left: auto; margin-right: auto; }

/* ---------- Inner-page title banner: a strip of mown pitch ---------- */
.quarto-title-banner {
  background: var(--stripes) !important; color: #fff; position: relative; overflow: hidden;
  border-bottom: 4px solid var(--red); margin-bottom: 1.5rem !important;
}
.quarto-title-banner::after {
  content: ""; position: absolute; top: -40%; right: 6%; width: 260px; height: 260px;
  border: 3px solid var(--white-line); border-radius: 50%; opacity: .35; pointer-events: none;
}
.quarto-title-banner .title, .quarto-title-banner .subtitle, .quarto-title-banner .description { color: #fff !important; }
.quarto-title-banner .quarto-categories .quarto-category {
  background: var(--red); color: #fff; border: none; font-family: var(--body); font-weight: 700;
}
.quarto-title-meta-heading, .quarto-title-meta-contents { font-family: var(--body); }

/* ---------- Buttons and tags ---------- */
.sp-btn {
  display: inline-flex; align-items: center; gap: .5rem; background: var(--red); color: #fff !important;
  font-weight: 700; padding: .75rem 1.35rem; border-radius: 999px; text-decoration: none;
  transition: background .2s, transform .2s var(--ease), box-shadow .2s;
}
.sp-btn::after { content: "→"; transition: transform .2s var(--ease); }
.sp-btn:hover { background: var(--red-dark); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(219,29,36,.35); }
.sp-btn:hover::after { transform: translateX(4px); }
.sp-tag {
  display: inline-block; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--pitch-dark); background: #E2EFE4; padding: .2rem .55rem; border-radius: 3px;
}
.sp-tag.free { background: var(--red); color: #fff; }
.sp-hero-text .sp-tag { background: var(--red); color: #fff; }

/* ---------- Home layout (escape Quarto's page grid) ---------- */
.sp-wrap, .sp-wrap.page-columns { display: block !important; grid-column: 1 / -1 !important; width: min(1124px, calc(100% - 2rem)); margin: 0 auto; }
.sp-wrap > * { grid-column: auto !important; }

/* ---------- Home: hero with a live pitch ---------- */
.sp-hero, .sp-hero.page-columns { display: flex !important; gap: 1.5rem; margin: 1.5rem 0 1rem; }
.sp-hero > * { grid-column: auto !important; }
.sp-hero-main { flex: 2 1 0; min-width: 0; }
.sp-latest { flex: 1 1 0; min-width: 0; }
.sp-hero-main {
  position: relative; color: #fff; border-radius: 10px; overflow: hidden;
  min-height: 470px; display: flex; align-items: flex-end;
  background: repeating-linear-gradient(90deg, var(--pitch-dark) 0 9.09%, var(--pitch-light) 9.09% 18.18%);
  box-shadow: 0 18px 40px rgba(10,42,23,.25);
}
.sp-pitch-svg { position: absolute; inset: 0; width: 100%; height: 100%; transition: transform .4s var(--ease); }
.sp-pitch-svg .mark { fill: none; stroke: var(--white-line); stroke-width: 3; }
.sp-pitch-svg .spot { fill: var(--white-line); }
.sp-pitch-svg .run { fill: none; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 8 10; opacity: .9; }
.sp-pitch-svg .run.red { stroke: var(--red); }
.sp-pitch-svg .run.white { stroke: #fff; }
.sp-pitch-svg .pass { fill: none; stroke: #fff; stroke-width: 2; stroke-dasharray: 2 8; stroke-linecap: round; opacity: .7; }
.sp-pitch-svg .player { fill: var(--red); stroke: #fff; stroke-width: 3; }
.sp-pitch-svg .player.opp { fill: #fff; stroke: var(--deep); }
.sp-pitch-svg .halo { fill: none; stroke: var(--red); stroke-width: 3; transform-box: fill-box; transform-origin: center; }
.sp-pitch-svg .ball { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.sp-hero-main::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, rgba(10,42,23,.94) 0%, rgba(10,42,23,.78) 40%, rgba(10,42,23,.05) 75%);
}
.sp-hero-text { position: relative; z-index: 1; padding: 2rem; max-width: 600px; }
.sp-hero-text h1 { color: #fff; margin: .6rem 0 .7rem; }
.sp-hero-text h1 em { font-style: normal; color: var(--red); background: #fff; padding: 0 .2em; border-radius: 4px; }
.sp-hero-text p { color: #E3EEE6; margin-bottom: 1.2rem; }

/* Latest: a numbered team-sheet */
.sp-latest { padding: .25rem 0 0 1.5rem; border-left: 1px solid var(--line); counter-reset: sheet; }
.sp-latest h2 {
  font-size: .8rem; margin: 0 0 .5rem; font-family: var(--body); text-transform: uppercase; letter-spacing: .12em; color: var(--red);
}
.sp-latest ul { list-style: none; padding: 0; margin: 0; }
.sp-latest li {
  counter-increment: sheet; display: grid; grid-template-columns: 2.4rem 1fr; align-items: start;
  padding: .85rem 0; border-bottom: 1px solid var(--line); font-weight: 700; line-height: 1.3;
}
.sp-latest li::before {
  content: counter(sheet); font-family: var(--head); font-size: 1.7rem; font-weight: 800; color: var(--red); line-height: 1;
}
.sp-latest li:last-child { border-bottom: none; }
.sp-latest small { display: block; font-weight: 400; color: var(--muted); margin-top: .15rem; }
.sp-latest a { color: var(--ink); text-decoration: none; background: linear-gradient(var(--red), var(--red)) 0 100% / 0 2px no-repeat; transition: background-size .3s var(--ease); }
.sp-latest a:hover { color: var(--ink); background-size: 100% 2px; }

/* ---------- Home: stadium advertising-board ticker ---------- */
.sp-ticker {
  overflow: hidden; background: var(--red); color: #fff; border-radius: 6px; margin: 1.25rem 0 1rem;
  font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .85rem;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.sp-ticker-track { display: flex; width: max-content; }
.sp-ticker-track span { padding: .7rem 0; white-space: nowrap; }
.sp-ticker-track span::after { content: "●"; margin: 0 1.4rem; opacity: .6; font-size: .6rem; vertical-align: middle; }

/* ---------- Home: fixture strip ---------- */
.sp-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin: 0 0 2.5rem; }
.sp-strip > div {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.15rem;
  border-bottom: 3px solid var(--pitch-light); transition: transform .25s var(--ease), border-color .25s, box-shadow .25s;
}
.sp-strip > div:hover { transform: translateY(-3px); border-bottom-color: var(--red); box-shadow: 0 10px 22px rgba(16,26,19,.08); }
.sp-strip b { font-family: var(--head); display: block; font-size: 1.1rem; line-height: 1.25; margin-top: .2rem; }
.sp-strip span { color: var(--red); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }

/* ---------- Home: section headers ---------- */
.sp-section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin: 2.75rem 0 1.1rem; }
.sp-section-head h2 { margin: 0; display: flex; align-items: center; gap: .65rem; }
.sp-section-head h2::before {
  /* corner flag */
  content: ""; width: 14px; height: 22px; flex: none; background: var(--red);
  clip-path: polygon(0 0, 100% 25%, 0 50%); box-shadow: inset 2px 0 0 var(--ink);
}
.sp-section-head a { font-weight: 700; white-space: nowrap; text-decoration: none; }
.sp-section-head a::after { content: " →"; display: inline-block; transition: transform .2s var(--ease); }
.sp-section-head a:hover::after { transform: translateX(4px); }

/* ---------- Cards (listings and manual grids) ---------- */
.quarto-listing-grid .card, .sp-card {
  position: relative; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: none;
  transition: transform .3s var(--ease), box-shadow .3s, border-color .3s;
}
.quarto-listing-grid .card::before, .sp-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; z-index: 2;
  background: var(--red); transform: scaleX(0); transform-origin: 0 50%; transition: transform .35s var(--ease);
}
.quarto-listing-grid .card:hover, .sp-card:hover { transform: translateY(-5px); box-shadow: 0 16px 32px rgba(10,42,23,.12); border-color: transparent; }
.quarto-listing-grid .card:hover::before, .sp-card:hover::before { transform: scaleX(1); }
.quarto-listing-grid .card-img-top { transition: transform .5s var(--ease); }
.quarto-listing-grid .card:hover .card-img-top { transform: scale(1.04); }
.quarto-listing-grid .card-title, .sp-card h3 { font-family: var(--head); font-weight: 800; line-height: 1.2; }
.quarto-listing-grid .listing-categories .listing-category {
  background: #E2EFE4; color: var(--pitch-dark); border: none; border-radius: 3px; font-weight: 800;
}
.quarto-listing .listing-title, .quarto-listing .card-title { font-family: var(--head); font-weight: 800; color: var(--ink); line-height: 1.2; }
.quarto-listing .listing-category { text-transform: uppercase; letter-spacing: .06em; font-weight: 800; font-size: .7rem; }
.quarto-listing .listing-date, .quarto-listing .card-footer { color: var(--muted); text-transform: none; }
.quarto-listing-category .category.active, .quarto-listing-category .category:hover { color: var(--red); }

.sp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.sp-grid.two { grid-template-columns: repeat(2, 1fr); }
.sp-card { padding: 1.3rem 1.3rem 1.4rem; }
.sp-card::after {
  /* a corner of pitch that grows on hover */
  content: ""; position: absolute; right: -36px; bottom: -36px; width: 90px; height: 90px; border-radius: 50%;
  background: repeating-linear-gradient(90deg, var(--pitch-dark) 0 12px, var(--pitch-light) 12px 24px);
  opacity: .14; transition: transform .45s var(--ease), opacity .3s;
}
.sp-card:hover::after { transform: scale(1.6); opacity: .22; }
.sp-card h3 { font-size: 1.22rem; margin: .65rem 0 .35rem; }
.sp-card p { color: var(--muted); font-size: .97rem; margin: 0; position: relative; }

/* ---------- Subscribe band: centre circle on a mown pitch ---------- */
.sp-band {
  position: relative; overflow: hidden; color: #fff; border-radius: 12px; padding: 2.4rem 2.2rem; margin: 3.25rem 0 1.5rem;
  background: var(--stripes);
  display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.sp-band::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 240px; height: 240px; margin: -120px 0 0 -120px;
  border: 3px solid var(--white-line); border-radius: 50%; opacity: .45;
}
.sp-band::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--white-line); opacity: .45; }
.sp-band > * { position: relative; z-index: 1; }
.sp-band h2 { color: #fff; margin: 0 0 .3rem; }
.sp-band p { margin: 0; color: #E3EEE6; }

/* ---------- Footer ---------- */
.nav-footer { border-top: 3px solid var(--red); background: var(--deep); color: #DCE8DF; font-size: .9rem; }
.nav-footer a { color: #fff; }

/* ---------- Article pages ---------- */
.quarto-title-block .title { font-weight: 800; }
figure img, .figure img { border-radius: 6px; }
div.sourceCode { border-radius: 6px; }
main h2 { position: relative; padding-left: .9rem; }
main h2::before { content: ""; position: absolute; left: 0; top: .15em; bottom: .15em; width: 4px; border-radius: 2px; background: var(--red); }
.sp-wrap h2::before { display: none; }
.sp-wrap h2 { padding-left: 0; }
.sp-wrap .sp-section-head h2::before { display: block; position: static; }
table { font-size: .95rem; }
thead th { border-bottom: 2px solid var(--red) !important; }

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  .sp-hero, .sp-hero.page-columns { flex-direction: column; }
  .sp-hero-main, .sp-latest { flex: 0 0 auto; }
  .sp-latest { border-left: none; padding-left: 0; }
  .sp-hero-main { min-height: 400px; }
  .sp-hero-main::after { background: linear-gradient(to top, rgba(10,42,23,.95) 0%, rgba(10,42,23,.75) 55%, rgba(10,42,23,.1) 100%); }
  .sp-strip { grid-template-columns: 1fr 1fr; }
  .sp-grid, .sp-grid.two { grid-template-columns: 1fr; }
  .sp-band::before, .sp-band::after { opacity: .25; }
}

/* ---------- Motion (only when the visitor allows it) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .sp-hero-text > * { animation: sp-rise .7s var(--ease) both; }
  .sp-hero-text > :nth-child(2) { animation-delay: .1s; }
  .sp-hero-text > :nth-child(3) { animation-delay: .2s; }
  .sp-hero-text > :nth-child(4) { animation-delay: .3s; }
  .sp-pitch-svg .mark { stroke-dasharray: 1; stroke-dashoffset: 1; animation: sp-draw 1.8s var(--ease) forwards; }
  .sp-pitch-svg .mark:nth-of-type(odd) { animation-delay: .25s; }
  .sp-pitch-svg .run { animation: sp-march 1.4s linear infinite; }
  .sp-pitch-svg .halo { animation: sp-pulse 2s ease-out infinite; }
  .sp-ticker-track { animation: sp-ticker 32s linear infinite; }
  .sp-ticker:hover .sp-ticker-track { animation-play-state: paused; }
  .sp-js .sp-reveal { opacity: 0; transform: translateY(22px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
  .sp-js .sp-reveal.sp-in { opacity: 1; transform: none; }
  .sp-js .sp-reveal.sp-in:hover { transition-delay: 0s !important; }
  @keyframes sp-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
  @keyframes sp-draw { to { stroke-dashoffset: 0; } }
  @keyframes sp-march { to { stroke-dashoffset: -36; } }
  @keyframes sp-pulse { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(2.2); opacity: 0; } }
  @keyframes sp-ticker { to { transform: translateX(-50%); } }
}
@media (prefers-reduced-motion: reduce) {
  .sp-ticker-track { flex-wrap: wrap; width: auto; justify-content: center; }
  .sp-ticker-track [aria-hidden="true"] { display: none; }
  .sp-pitch-svg .ball { display: none; }
}
