/* =====================================================================
   ui-polish.css — responsive / typography / contrast fixes for the public site
   Loaded LAST (after frontend.css, the admin theme palette and the page CSS),
   so it can correct details without touching the source stylesheets.
   Every colour is derived from the palette tokens (--ux-* / --color-* / --sr-*)
   with color-mix(), so all 100 admin palettes keep working in light + dark mode.
   ===================================================================== */

/* ---------- 1. Global text safety ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-wrap: break-word; text-rendering: optimizeLegibility; }
h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; text-wrap: balance; }
p, li, dd, figcaption { text-wrap: pretty; }
img, video, iframe { max-width: 100%; }
/* card / list titles sit in flex or grid cells: let a very long word break instead of spilling out */
.ux-news-item__title, .ux-top-story__title, .ux-hero__title, .sr-n__title, .ct-row__title, .nc__title, .sc__name,
.tc__name, .hf-title, .cb-title, .ux-latest-title, .sh-title, .sr-title, h3 > a, h4 > a { overflow-wrap: anywhere; }

/* tap highlight + focus ring that matches the brand on every control */
a, button, [role="button"], [role="tab"], summary { -webkit-tap-highlight-color: transparent; }
:where(a, button, input, select, textarea, [tabindex]):focus-visible { outline: 2px solid var(--ux-orange); outline-offset: 2px; }

/* ---------- 2. Header: keep logo + actions on ONE row on phones ---------- */
.ux-search-input { text-overflow: ellipsis; }
.ux-search-input::placeholder { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
@media (max-width: 767px) {
  .ux-row { flex-wrap: wrap; column-gap: 6px; }
  .ux-burger { flex: none; }
  .ux-brand { flex: 1 1 0; min-width: 0; padding: 0 2px; }
  .ux-brand .ux-logo--full { width: auto; height: auto; max-width: 100%; max-height: 26px; }
  .ux-auth { flex: none; gap: 6px; }
  .ux-search { margin-top: 2px; }
}
@media (max-width: 399px) {
  .ux-theme-toggle { width: 34px; height: 34px; }
  .ux-btn-login { min-height: 34px; width: 34px; padding: 0; }
  .ux-brand .ux-logo--full { max-height: 22px; }
}
@media (min-width: 768px) {
  .ux-row { flex-wrap: nowrap; }
  .ux-search { flex: 1 1 0; min-width: 0; }
  .ux-brand, .ux-auth, .ux-burger { flex: none; }
}
@media (min-width: 768px) and (max-width: 991px) {
  .ux-search-cat { max-width: 76px; padding-right: 20px; }
  .ux-search { margin: 0 6px; }
}
/* the sr-only "Sign in" text on tiny phones: proper visually-hidden pattern */
@media (max-width: 399px) {
  .ux-btn-outline .ux-btn-text { white-space: nowrap; margin: -1px; padding: 0; border: 0; }
}

/* ---------- 3. Badges / pills never get squeezed ---------- */
.ct .badge, .sr-pill, .sw-badge, .ct-tag, .sgroup__count { flex-shrink: 0; }
.ct .mc__series, .ct .sc__name { min-width: 0; }

/* ---------- 4. Filter bar + sticky group headers (Upcoming / Live / Series list) ---------- */
/* chips scroll sideways inside the fixed-height bar instead of wrapping out of it */
.ct .fbar .chips { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; padding-inline-end: 24px; }
.ct .fbar .chip { scroll-snap-align: start; }
.ct .fbar__group { overflow: hidden; }
/* sticky bars use the page colour, bleed to the screen edge and keep the text off the edge */
.ct .fbar, .ct .sgroup__head, .ct .day-head { background: var(--ux-page-bg); }
@media (max-width: 991px) {
  .ct .fbar { margin-inline: -16px; padding-inline: 16px; }
  .ct .sgroup__head, .ct .day-head { margin-inline: -16px; padding-inline: 16px; }
}
.ct .sgroup__head { gap: 10px; }
.ct .day-head--sub { padding-top: 4px; }
@supports (backdrop-filter: blur(1px)) {
  @media (max-width: 991px) {
    .ct .fbar { background: color-mix(in srgb, var(--ux-page-bg) 92%, transparent); }
  }
}

/* ---------- 5. Contrast: small coloured text on tinted backgrounds (WCAG AA 4.5:1) ---------- */
/* Light mode: links / accents that sit on the grey page or on soft tints get a slightly deeper shade */
html:not([data-theme="dark"]) :is(.hf-head > a, .cb-head > a, .ux-latest-link, .sr-cardh > .sr-link, .pg-muted a, .ct .link-more) { color: color-mix(in srgb, var(--ux-link) 80%, #000); }
html:not([data-theme="dark"]) :is(.hf-head > a, .cb-head > a, .ux-latest-link, .sr-cardh > .sr-link, .pg-muted a, .ct .link-more):hover { color: var(--ux-link-hover); }
html:not([data-theme="dark"]) .ct .badge--live { color: color-mix(in srgb, var(--color-live) 78%, #000); }
html:not([data-theme="dark"]) .ct .badge--info { color: color-mix(in srgb, var(--color-info) 75%, #000); }
html:not([data-theme="dark"]) .ct .badge--done { color: color-mix(in srgb, var(--color-primary-strong) 85%, #000); }
html:not([data-theme="dark"]) .ct .seg__btn.is-active { color: color-mix(in srgb, var(--color-primary) 80%, #000); }
html:not([data-theme="dark"]) .ux-top-story__tag,
html:not([data-theme="dark"]) .ux-news-item__tag { color: color-mix(in srgb, var(--ux-red) 82%, #000); }
html:not([data-theme="dark"]) :is(.sr-tab.is-active, .sr-day__tag, .sr-pill--upcoming, .sr-table--stats th.key) { color: color-mix(in srgb, var(--sr-accent) 78%, #000); }
html:not([data-theme="dark"]) .sr-pill--ongoing { color: color-mix(in srgb, var(--sr-live) 80%, #000); }
/* orange "kicker" labels + numbered icons on light surfaces */
html:not([data-theme="dark"]) .pg-sec .pg-kicker,
html:not([data-theme="dark"]) .pg-ico span,
html:not([data-theme="dark"]) .pg :not(.pg-hero) > .pg-kicker { color: color-mix(in srgb, var(--ux-orange) 55%, #000); }
html:not([data-theme="dark"]) .text-brand-orange:not(.fa):not(.pg-hero *):not(.ux-header *):not(.ux-footer *) { color: color-mix(in srgb, var(--ux-orange) 55%, #000); }

/* brand-coloured text on the tinted utility backgrounds (Tailwind bg-brand-hover / *-soft) */
html:not([data-theme="dark"]) :is(.bg-brand-hover, [class*="bg-brand-hover/"], .bg-brand-series-soft, .bg-brand-primary-soft) :is(.text-brand-primary, .text-brand-series, .text-brand-link),
html:not([data-theme="dark"]) :is(.bg-brand-hover, [class*="bg-brand-hover/"], .bg-brand-series-soft, .bg-brand-primary-soft):is(.text-brand-primary, .text-brand-series, .text-brand-link) { color: color-mix(in srgb, currentColor 72%, #000); }

html[data-theme="dark"] :is(.bg-brand-hover, [class*="bg-brand-hover/"], .bg-brand-series-soft, .bg-brand-primary-soft) :is(.text-brand-primary, .text-brand-series, .text-brand-link),
html[data-theme="dark"] :is(.bg-brand-hover, [class*="bg-brand-hover/"], .bg-brand-series-soft, .bg-brand-primary-soft):is(.text-brand-primary, .text-brand-series, .text-brand-link) { color: color-mix(in srgb, currentColor 75%, #fff); }

/* Dark mode: white text on bright red badges, muted text on raised surfaces */
html[data-theme="dark"] .sw-badge,
html[data-theme="dark"] .sh__body .badge--live,
html[data-theme="dark"] .ct .badge--live.badge--solid { background-color: color-mix(in srgb, var(--ux-red) 72%, #000); }
html[data-theme="dark"] :is(.cz-stats th, .sr-table th, .pg-table th, .cz-menu__h, .sr-day__n, .ct .seg__btn:not(.is-active)) { color: color-mix(in srgb, var(--ux-muted) 70%, #fff); }
html[data-theme="dark"] :is(.sr-day__tag, .sr-pill--upcoming) { color: color-mix(in srgb, var(--sr-accent) 75%, #fff); }
html[data-theme="dark"] .sr-cardh .sr-link { color: color-mix(in srgb, var(--ux-link) 80%, #fff); }
html[data-theme="dark"] .text-brand-muted { color: color-mix(in srgb, var(--ux-muted) 80%, #fff); }

/* ---------- 6. Touch targets (phones/tablets) ---------- */
@media (max-width: 991px) {
  .ux-legal { row-gap: 2px; }
  .ux-legal a { display: inline-block; padding: 8px 4px; }
  .ux-foot-col li a { display: inline-block; padding: 6px 0; }
  .hf-head > a, .cb-head > a, .sw-all, .ux-latest-link, .sr-cardh > .sr-link, .ct .link-more { position: relative; }
  .hf-head > a::after, .cb-head > a::after, .sw-all::after, .ux-latest-link::after, .sr-cardh > .sr-link::after, .ct .link-more::after,
  .ct-crumb a::after, .sr-crumbs a::after { content: ""; position: absolute; inset: -12px -6px; }
  .ct-crumb a, .sr-crumbs a { position: relative; }
  .ct-share a, .ct-share button { min-height: 36px; display: inline-flex; align-items: center; }
}

/* ---------- 7. Static info pages (About, Contact, Legal...) ---------- */
@media (max-width: 600px) {
  .pg-hero__actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .pg-hero__actions .pg-btn { justify-content: center; width: 100%; }
  .pg-hero h1 { font-size: clamp(26px, 7.5vw, 34px); line-height: 1.15; }
  .pg-hero p { font-size: 15.5px; }
  .pg-sec__head h2 { font-size: 21px; }
  .pg-cta h2 { font-size: 22px; }
  .pg-stat { font-size: 24px; }
}
.pg-prose { overflow-wrap: break-word; }
.pg-prose a { overflow-wrap: anywhere; }
.pg-table { min-width: max-content; }
.pg :where(table):not(.pg-table) { max-width: 100%; }

/* ---------- 8. Article body (news detail) ---------- */
.ct-body table { display: block; width: max-content; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 1.2em 0; border-collapse: collapse; font-size: .875em; line-height: 1.45; font-variant-numeric: tabular-nums;
  border: 1px solid var(--ux-border); border-radius: 8px; overflow-wrap: normal; word-break: normal; }
.ct-body th, .ct-body td { padding: 9px 12px; border-bottom: 1px solid var(--ux-border); text-align: left; white-space: nowrap; }
.ct-body thead th { background: var(--ux-hover-bg); font-size: .85em; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ux-muted); }
.ct-body tbody tr:last-child td { border-bottom: 0; }
.ct-body tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--ux-hover-bg) 45%, transparent); }
.ct-body ul, .ct-body ol { padding-left: 1.35em; margin: 0 0 1.2em; }
.ct-body ul { list-style: disc; } .ct-body ol { list-style: decimal; }
.ct-body li { margin-bottom: .4em; }
.ct-body li::marker { color: var(--ux-orange); }
.ct-body h2 { font-size: 1.4em; line-height: 1.25; font-weight: 800; }
.ct-body h3 { font-size: 1.2em; line-height: 1.3; font-weight: 700; }
.ct-body blockquote p:last-child { margin-bottom: 0; }
.ct-body pre { max-width: 100%; overflow-x: auto; }
.ct-body iframe, .ct-body video { width: 100%; border: 0; border-radius: 8px; }
.ct-body figure { margin: 1.2em 0; }
.ct-body figcaption { font-size: 13px; color: var(--ux-muted); margin-top: 6px; }
.ct-title { text-wrap: balance; letter-spacing: -.015em; }
.ct-excerpt { text-wrap: pretty; }
@media (max-width: 767px) { .ct-body table { font-size: 14px; } }

/* ---------- 9. Series / team / player / venue pages ---------- */
@media (max-width: 767px) {
  .sr--series { margin-inline: 0; }
}
/* profile hero card (team / player / venue): series.css .sr-head padding was cancelling Tailwind p-4 */
.sr > .sr-head.rounded-2xl { padding: 16px; }
@media (min-width: 640px) { .sr > .sr-head.rounded-2xl { padding: 20px; } }
/* scrollable stat tables: keep the first column visible while swiping */
.sr-scroll { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.sr-scroll table th.tm, .sr-scroll table td.tm { position: sticky; left: 0; z-index: 1; background: var(--ux-panel-bg); box-shadow: 1px 0 0 var(--ux-border); }
.sr-scroll table thead th.tm { background: var(--ux-mc-head-bg, var(--ux-hover-bg)); }
.sr-scroll table tfoot td.tm { background: color-mix(in srgb, var(--ux-hover-bg) 60%, var(--ux-panel-bg)); }
/* player hero stat tiles: 2 x 2 on small phones so labels never clip */
@media (max-width: 399px) {
  .sr .grid.grid-cols-4:has(> .rounded-xl) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.sr .rounded-xl > .uppercase { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr .rounded-xl > .tabular-nums { overflow: hidden; text-overflow: ellipsis; }
.cz-tbl { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- 10. Dark-mode finishing ---------- */
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="dark"] .ux-search-bar { background: #f3f5f7; }
html[data-theme="dark"] img:not([src$=".svg"]) { color-scheme: normal; }
html[data-theme="dark"] .ct-body thead th { color: color-mix(in srgb, var(--ux-muted) 70%, #fff); }
html[data-theme="dark"] .ct-body tbody tr:nth-child(even) td { background: rgba(255, 255, 255, .025); }
html[data-theme="dark"] ::selection { background: color-mix(in srgb, var(--ux-orange) 45%, transparent); color: #fff; }

/* ---------- 11. Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- 12. Interactive states in dark mode ---------- */
html[data-theme="dark"] .ct .chip:hover { border-color: color-mix(in srgb, var(--color-border) 60%, #fff); color: var(--color-text); }
html[data-theme="dark"] .ct a.card:hover { border-color: color-mix(in srgb, var(--color-border) 70%, #fff); }
.ct .chip:active, .pg-chip:active, .ct-chip:active { transform: scale(.97); }
:where(button, .btn, .pg-btn, .ux-btn)[disabled], :where(button, .btn, .pg-btn, .ux-btn)[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
