/* huahinrackets shared shell — three visual themes via CSS vars.
   Switch by setting <html data-theme="forest|material|strava">. Default = forest.

   Architecture: the 7000-line templates use inline styles with hard-coded hex
   (#1a5040, #ffd673, #ffe8c4, etc). Theme-switching is done at CSS level via
   attribute-selector overrides that retarget every legacy hex to a var. The
   shell rules in this file are for the small set of base classes; everything
   else is handled by the overrides at the bottom. */

/* v3 (2026-06-20): all color values now sourced from the Tailwind v3 default
   palette (tested for WCAG AA contrast across hundreds of millions of sites).
   We picked specific shades per theme so contrast pairings are guaranteed:
     - dark themes use 900/950 surfaces with 50/100/300 text
     - light themes use 0/50 surfaces with 700/800 text
     - accents come from amber (forest), blue (material), orange (strava)

   Hex reference (no Tailwind dependency; values inlined):
     emerald-950 #022c22  emerald-900 #064e3b  emerald-800 #065f46
     emerald-700 #047857  emerald-300 #6ee7b7  amber-200 #fde68a
     amber-300 #fcd34d    amber-400 #fbbf24    amber-50 #fffbeb
     slate-50  #f8fafc    slate-100 #f1f5f9    slate-200 #e2e8f0
     slate-300 #cbd5e1    slate-600 #475569    slate-700 #334155
     slate-800 #1e293b    slate-900 #0f172a
     blue-50   #eff6ff    blue-600  #2563eb    blue-700  #1d4ed8
     neutral-900 #171717  neutral-800 #262626  neutral-950 #0a0a0a
     orange-50 #fff7ed    orange-600 #ea580c   orange-700 #c2410c
     red-300   #fca5a5    red-500   #ef4444    red-700   #b91c1c
     green-300 #86efac    green-600 #16a34a    green-700 #15803d
*/

/* ---------- forest (default) — emerald + amber, sport-club dark green ---------- */
:root, html[data-theme="forest"] {
  --bg: #022c22;                     /* emerald-950 */
  --bg-card: #064e3b;                 /* emerald-900 */
  --bg-card-hover: #065f46;           /* emerald-800 */
  --bg-header: #022c22;               /* emerald-950 */
  --border: #047857;                  /* emerald-700 */
  --border-strong: #6ee7b7;           /* emerald-300 — visible on dark surfaces */
  --text: #fffbeb;                    /* amber-50 — warm cream over green */
  --text-muted: rgba(255,251,235,.72);
  --accent: #fcd34d;                  /* amber-300 — gold */
  --accent-ink: #022c22;              /* emerald-950 for ink on accent */
  --accent-soft: rgba(252,211,77,.14);
  --accent-soft-strong: rgba(252,211,77,.28);
  --danger: #fca5a5;                  /* red-300 — visible on dark */
  --success: #86efac;                 /* green-300 — visible on dark */
  --radius-card: 8px;
  --radius-button: 8px;
  --shadow-card: none;
  --font: system-ui;
}

/* ---------- material — slate surfaces, blue-600 accent ---------- */
html[data-theme="material"] {
  --bg: #f8fafc;                     /* slate-50 */
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;          /* slate-100 */
  --bg-header: #ffffff;
  --border: #e2e8f0;                 /* slate-200 */
  --border-strong: #cbd5e1;          /* slate-300 */
  --text: #1e293b;                   /* slate-800 */
  --text-muted: #475569;             /* slate-600 — AA-compliant against bg-card */
  --accent: #2563eb;                 /* blue-600 — Material-ish blue */
  --accent-ink: #ffffff;
  --accent-soft: rgba(37,99,235,.10);
  --accent-soft-strong: rgba(37,99,235,.18);
  --danger: #b91c1c;                 /* red-700 — needs to be dark on light bg */
  --success: #15803d;                /* green-700 */
  --radius-card: 16px;
  --radius-button: 24px;
  --shadow-card: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.05);
  --font: 'Inter', system-ui, sans-serif;
}

/* ---------- strava — neutral-near-black with orange-600 accent ---------- */
html[data-theme="strava"] {
  --bg: #0a0a0a;                     /* neutral-950 */
  --bg-card: #171717;                /* neutral-900 */
  --bg-card-hover: #262626;          /* neutral-800 */
  --bg-header: #000000;
  --border: #262626;                 /* neutral-800 */
  --border-strong: #404040;          /* neutral-700 */
  --text: #ffffff;
  --text-muted: rgba(255,255,255,.65);
  --accent: #ea580c;                 /* orange-600 — Strava */
  --accent-ink: #ffffff;
  --accent-soft: rgba(234,88,12,.12);
  --accent-soft-strong: rgba(234,88,12,.22);
  --danger: #ef4444;                 /* red-500 */
  --success: #16a34a;                /* green-600 */
  --radius-card: 4px;
  --radius-button: 4px;
  --shadow-card: none;
  --font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* ---------- shell ---------- */
*{box-sizing:border-box}
/* Body var bindings are !important so per-page <style> blocks (which load
   after base.css and frequently hardcode forest-theme hex like
   `body{background:#0a2a20;color:#ffe8c4}`) don't break the theme switch.
   Found by VL on 2026-06-20 — leaderboard rendered as forest in Material. */
body{font-family:var(--font)!important;background:var(--bg)!important;color:var(--text)!important;margin:0;padding:0;min-height:100vh;line-height:1.45}
main{padding:14px;max-width:600px;margin:0 auto}
a{color:var(--accent)!important}
h1,h2,h3{color:var(--accent)!important}
h1{font-size:1.15em;margin:0}
h2{font-size:1em;margin:14px 0 6px 0}
h3{font-size:.95em;margin:12px 0 6px 0}
.hdr{background:var(--bg-header);border-bottom:1px solid var(--border);padding:10px 12px;display:flex;align-items:center;gap:10px;position:sticky;top:0;z-index:100}
/* Header h1 used to truncate — allow wrapping on mobile so "Hua Hin Racket Sports" fits */
.hdr h1{flex:1;min-width:0;font-size:1.05em;line-height:1.2;overflow:visible;white-space:normal}
.hdr .back{flex-shrink:0;color:var(--accent);text-decoration:none;font-size:1em;padding:8px 12px;background:var(--accent-soft);border-radius:var(--radius-button);font-weight:600;border:none;cursor:pointer;font-family:inherit}
.hdr .back:active{background:var(--accent-soft-strong)}
.kind-tag{display:inline-block;background:var(--bg-card);color:var(--accent);padding:2px 8px;border-radius:4px;font-size:.7em;text-transform:uppercase;letter-spacing:.05em}
.muted{color:var(--text-muted);font-size:.9em}
/* All non-secondary buttons re-bound to theme vars with !important so
   per-page <style> blocks that hardcode forest hex (background:#ffd673,
   color:#0f3a2e) don't break Material/Strava themes. Secondary buttons
   opt out explicitly with class="secondary". */
button:not(.secondary):not(.danger),.cta,[type="submit"]:not(.secondary){font-family:inherit;background:var(--accent)!important;color:var(--accent-ink)!important;border:none;padding:12px 18px;border-radius:var(--radius-button)!important;font-weight:700;cursor:pointer;font-size:1em;box-shadow:var(--shadow-card)!important}
button.secondary{background:var(--bg-card)!important;color:var(--text)!important}
input,select,textarea{font-family:inherit;background:var(--bg-card)!important;color:var(--text)!important;border:1px solid var(--border-strong)!important;padding:10px;border-radius:6px;font-size:1em;width:100%;box-sizing:border-box}
table{width:100%;border-collapse:collapse}
.row{display:flex;justify-content:space-between;padding:6px 0;border-bottom:1px solid var(--border);font-size:.9em}
.row:last-child{border-bottom:none}
.row .label{color:var(--text-muted)}
.row .value{font-weight:600}
.panel{background:var(--bg-card);padding:14px;border-radius:var(--radius-card);margin:10px 0;box-shadow:var(--shadow-card)}
.venue-card{box-shadow:var(--shadow-card);border-radius:var(--radius-card)!important}
footer{text-align:center;padding:24px 16px 80px;font-size:.75em;color:var(--text-muted)}
@media (max-width: 480px){main{padding:10px}}

/* ============================================================
   Inline-style overrides — retarget legacy palette to theme vars
   for every page in main.py without refactoring the templates.

   Color counts in main.py (so we know what we're covering):
     117× color:#ffd673    (accent text)
      55× background:#1a5040 (card)
      54× color:#ffe8c4    (text)
      28× background:#ffd673 (accent button)
      28× background:#0a2a20 (header)
      22× background:rgba(255,214,115,0.08)  (accent-soft)
      20× background:#0f3a2e (page bg)
      17× color:#0a2a20     (accent-ink)
      13× color:#0f3a2e     (accent-ink)
      11× background:#3a8e60 (success)
       9× color:#ff8a8a     (danger)
       6× color:#fff
       6× background:#5a2a2a (cancel red)
       5× background:#226044 (card-hover)
   ============================================================ */

/* page / surface backgrounds */
[style*="background:#0a2a20"], [style*="background: #0a2a20"]{background:var(--bg-header)!important}
[style*="background:#0f3a2e"], [style*="background: #0f3a2e"]{background:var(--bg)!important}
[style*="background:#1a5040"], [style*="background: #1a5040"]{background:var(--bg-card)!important}
[style*="background:#226044"], [style*="background: #226044"]{background:var(--bg-card-hover)!important}
[style*="background:#3a8e60"], [style*="background: #3a8e60"]{background:var(--success)!important;color:#fff!important}
[style*="background:#ff8a8a"]{background:var(--danger)!important;color:#fff!important}
[style*="background:#5a2a2a"]{background:var(--danger)!important;color:#fff!important;opacity:.9}
[style*="background:#fff"]{background:var(--bg-card)!important}
[style*="background:#2a2f35"]{background:var(--bg-card)!important}

/* the two gradients used for pre-pitch and the gold-stat row.
   NB: parens inside attribute-selector values broke parsing in Chromium
   (everything after this rule was dropped). Use a shorter unique substring. */
[style*="135deg,#1a5040"]{background:linear-gradient(135deg,var(--bg-card),var(--bg-card-hover))!important}
[style*="90deg,#234034"]{background:linear-gradient(90deg,var(--bg-card),var(--bg-card-hover))!important}

/* accent button surface */
[style*="background:#ffd673"], [style*="background: #ffd673"]{background:var(--accent)!important;color:var(--accent-ink)!important}

/* accent-soft pill backgrounds (footer chips, header back button, etc) */
[style*="background:rgba(255,214,115,0.08)"]{background:var(--accent-soft)!important}
[style*="background:rgba(255,214,115,0.12)"]{background:var(--accent-soft)!important}
[style*="background:rgba(255,214,115,0.25)"]{background:var(--accent-soft-strong)!important}
[style*="background:rgba(255,214,115"]{background:var(--accent-soft)!important}

/* text colors */
[style*="color:#ffd673"], [style*="color: #ffd673"]{color:var(--accent)!important}
[style*="color:#ffe8c4"], [style*="color: #ffe8c4"]{color:var(--text)!important}
[style*="color:#0a2a20"], [style*="color: #0a2a20"]{color:var(--accent-ink)!important}
[style*="color:#0f3a2e"], [style*="color: #0f3a2e"]{color:var(--accent-ink)!important}
[style*="color:#ff8a8a"]{color:var(--danger)!important}
/* New v3 inline colors used by venue card + Tonight hero (Tailwind tokens).
   On Material these were unreadable on white bg — VL flagged 2026-06-20. */
[style*="color:#86efac"]{color:var(--success)!important}
[style*="color:#f87171"]{color:var(--danger)!important}
[style*="color:#fcd34d"]{color:var(--accent)!important}
[style*="background:#1a5040"]{background:var(--bg-card)!important}
[style*="color:#ffd0d0"]{color:var(--danger)!important;opacity:.9}
[style*="color:#cfd0d2"]{color:var(--text-muted)!important}
[style*="color:#c9d142"]{color:var(--success)!important}
[style*="color:#3a8e60"]{color:var(--success)!important}
[style*="color:#fff"]{color:var(--text)!important}

/* borders */
[style*="border:1px solid #226044"]{border-color:var(--border-strong)!important}
[style*="border:1px solid #1a5040"]{border-color:var(--border)!important}
[style*="border:1px solid #2a6a4e"]{border-color:var(--border)!important}
[style*="border-bottom:1px solid #2a6a4e"]{border-bottom-color:var(--border)!important}
[style*="border-bottom:1px solid #1a5040"]{border-bottom-color:var(--border)!important}
[style*="border-bottom:1px solid #226044"]{border-bottom-color:var(--border-strong)!important}
[style*="border-color:#ffd673"]{border-color:var(--accent)!important}
[style*="border-left:4px solid #ffd673"]{border-left-color:var(--accent)!important}

/* ============================================================
   Class-rule overrides — many pages declare class-level CSS in
   per-page <style> blocks with hardcoded colors (`.venue-card`,
   `.lead`, `.flow`, `.sectionbox`, `.cta`, `.code`, `.btn`,
   `.warn`, `.pitch`, `.q`, `.val`, etc). base.css ships BEFORE
   the page <style> so the page wins specificity ties — we use
   !important here to flip the result back to theme vars.
   ============================================================ */
.venue-card{background:var(--bg-card)!important;border-radius:var(--radius-card)!important;box-shadow:var(--shadow-card)!important}
.venue-card:hover{background:var(--bg-card-hover)!important}
.section-card{background:var(--bg-card)!important;border-radius:var(--radius-card)!important;box-shadow:var(--shadow-card)!important;color:var(--text)!important}
.section-card:hover{background:var(--bg-card-hover)!important}
.lead{background:var(--bg-card)!important;border-left-color:var(--accent)!important;color:var(--text)!important}
.sectionbox{background:var(--bg-card)!important;color:var(--text)!important}
.flow{background:var(--bg-card)!important;color:var(--text)!important}
.pitch{background:var(--bg-header)!important;border-color:var(--border)!important;color:var(--text)!important}
.step{border-bottom-color:var(--border)!important}
.step .n{background:var(--accent)!important;color:var(--accent-ink)!important}
.cta{background:var(--accent)!important;color:var(--accent-ink)!important;border-radius:var(--radius-button)!important;box-shadow:var(--shadow-card)!important}
.code{background:var(--bg-card)!important;color:var(--accent)!important;border-color:var(--border-strong)!important}
.code:not(:has(*)){color:var(--accent)!important}
.btn{background:var(--accent)!important;color:var(--accent-ink)!important;border-radius:var(--radius-button)!important;box-shadow:var(--shadow-card)!important}
.danger{border-color:var(--danger)!important;color:var(--danger)!important;border-radius:var(--radius-button)!important}
.warn{background:rgba(220,38,38,.10)!important;color:var(--danger)!important;border-left-color:var(--danger)!important}
.q{color:var(--accent)!important}
.val{color:var(--accent)!important}
.kind{color:var(--text-muted)!important}
.subtle{color:var(--text-muted)!important}
.footnote{color:var(--text-muted)!important}

/* booking form (/v/{venue}/c/{section}/new) — Alexey 2026-06-19 VL-flagged
   that the Visibility "Public" radio button used hardcoded forest hex
   (.opts label = #1a5040, .opts input:checked + span = #ffd673), which
   in Material theme rendered pale yellow text on dark green. The page's
   inline <style> is loaded after base.css so the page wins normal
   specificity — we re-bind to theme vars with !important. */
.opts label{background:var(--bg-card)!important;color:var(--text)!important;border:1px solid var(--border)!important;border-radius:var(--radius-button)!important;transition:background-color .15s, border-color .15s}
.opts input:checked + span{color:var(--accent)!important;font-weight:700}
/* Material 3 'choice chip' / 'filter chip' selected-state — tints the
   surface to make selection obvious without relying on text color alone.
   VL-flagged 2026-06-20 — Alexey couldn't tell which Player/Visibility
   chip was active. Modern browser support: Chrome 105+, Safari 15.4+,
   Firefox 121+. Falls back gracefully on older browsers (just text color
   changes, same as before). */
.opts label:has(input:checked){background:var(--accent-soft-strong)!important;border-color:var(--accent)!important}

/* Promo container ('Tonight in Hua Hin' hero) — Material needs proper
   M3 treatment instead of the pale-tint rgba which reads as gray.
   Recipe: solid card surface + 3px accent top stripe + elevation shadow
   + a faint accent overlay. Strava follows the same pattern with its
   own accent. Forest keeps the gradient (inline style wins). */
html[data-theme="material"] .hhr-promo, html[data-theme="strava"] .hhr-promo {
  background: var(--bg-card)!important;
  border: 1px solid var(--border)!important;
  border-top: 3px solid var(--accent)!important;
  box-shadow: 0 2px 8px rgba(15,23,42,.10), 0 1px 3px rgba(15,23,42,.06)!important;
  position: relative!important;
}
html[data-theme="material"] .hhr-promo::before,
html[data-theme="strava"] .hhr-promo::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent);
  opacity: .045;
  pointer-events: none;
}
html[data-theme="material"] .hhr-promo > *,
html[data-theme="strava"] .hhr-promo > * { position: relative }

/* ============================================================
   QA pass 2026-06-20: VL-driven sweep across 36 cells
   (12 pages × 3 themes). Fix all systemic issues in one batch.
   ============================================================ */

/* --- 1. Back link in headers (a.back / .hdr .back) ---
   Material: was light blue on white, barely visible. Force solid
   tinted pill with bold font and contrast-safe accent text. */
a.back, .hdr .back {
  font-weight: 700!important;
  background: var(--accent-soft-strong)!important;
  color: var(--accent)!important;
  padding: 8px 14px!important;
  border-radius: var(--radius-button)!important;
  text-decoration: none!important;
  display: inline-block!important;
}

/* --- 2. Muted text contrast ---
   .muted was using var(--text-muted) (slate-600 on Material) which
   is mid-gray, then inline opacity:.7 multiplied to <30% effective.
   Force a stronger color and cap opacity. */
.muted, [class*="muted"] {
  color: var(--text-muted)!important;
  opacity: 1!important;
}
html[data-theme="material"] .muted {
  color: #475569!important;  /* slate-600 — AA on white */
}
html[data-theme="strava"] .muted {
  color: rgba(255,255,255,.78)!important;
}

/* --- 3. Empty grid cells —
   transparent + border was too subtle on Material (read as broken).
   Add a faint fill so empty reads as 'available, not broken'. */
[style*="background:transparent;border:1px solid #226044"] {
  background: rgba(127,127,127,.08)!important;
}
html[data-theme="material"] [style*="background:transparent;border:1px solid #226044"] {
  background: #f1f5f9!important;     /* slate-100 */
  border-color: #cbd5e1!important;   /* slate-300 */
}
html[data-theme="strava"] [style*="background:transparent;border:1px solid #226044"] {
  background: rgba(255,255,255,.06)!important;
  border-color: rgba(255,255,255,.18)!important;
}

/* --- 4. Input placeholders ---
   Globally style ::placeholder so it's readable on all themes. */
input::placeholder, textarea::placeholder {
  color: var(--text-muted)!important;
  opacity: .85!important;
}
html[data-theme="material"] input::placeholder,
html[data-theme="material"] textarea::placeholder { color: #94a3b8!important }
html[data-theme="strava"] input::placeholder,
html[data-theme="strava"] textarea::placeholder { color: rgba(255,255,255,.55)!important }

/* --- 5. Input focus rings ---
   Was invisible (no focus state) on all themes. */
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent)!important;
  outline-offset: 1px!important;
  border-color: var(--accent)!important;
}

/* --- 6. Footer text bumped ---
   'Pet project of a Hua Hin resident' was nearly invisible on Material. */
footer, .footer, [style*="opacity:.5"][style*="font-size"] {
  opacity: 1!important;
}
footer .muted, footer p {
  color: var(--text-muted)!important;
  opacity: 1!important;
}

/* --- 7. Inline links must be clearly clickable on Material/Strava ---
   '<a href="/contact">drop a note</a>' inside paragraphs was rendered
   in body color with no underline → invisible as interactive. */
p a, li a {
  color: var(--accent)!important;
  text-decoration: underline!important;
  text-underline-offset: 2px!important;
}
html[data-theme="forest"] p a, html[data-theme="forest"] li a {
  text-decoration: none!important;  /* dark theme: yellow on green is clear enough */
}

/* --- 8. Cancel/danger outlined button border thickened on Material --- */
html[data-theme="material"] button[style*="border:1px solid #ff8a8a"],
html[data-theme="material"] button[style*="border:1px solid var(--danger)"] {
  border-width: 2px!important;
  font-weight: 700!important;
}

/* ============================================================
   Comprehensive class-level retargets — VL-flagged 2026-06-20.
   These classes are defined inside per-page <style> blocks with
   hardcoded forest hex (e.g. .starts{background:#1a5040;color:#ffd673}).
   base.css attribute selectors only catch style="..." inline attrs,
   not CSS rules — so we explicitly !important these classes here.
   ============================================================ */
.starts, .day-chip, .surface, .skill, .copy, .share, .info,
.total, .num, .big, .now, .slot, .role, .item, .occupied,
.selected, .continuation, .score-board, .modal-backdrop > .modal,
.section-card, .venue-card, .lead, .flow, .pitch, .sectionbox,
.code, .btn, .cta, .primary {
  background-color: var(--bg-card)!important;
  color: var(--text)!important;
}
/* Restore accent for chips/labels that should be highlighted */
.starts, .day-chip.now, .slot.now, .total .num, .skill {
  color: var(--accent)!important;
}
/* Primary/CTA buttons keep accent fill */
.btn, .cta, .primary, button.primary {
  background-color: var(--accent)!important;
  color: var(--accent-ink)!important;
}
/* Selected/highlight states keep the strong accent surface */
.day-chip.selected, .slot.selected, .item.selected {
  background-color: var(--accent-soft-strong)!important;
  color: var(--accent)!important;
  border-color: var(--accent)!important;
}
/* Danger/cancel pills */
.bad, .danger, button.danger {
  background-color: transparent!important;
  color: var(--danger)!important;
  border-color: var(--danger)!important;
}
/* Form surfaces */
form, fieldset { background-color: transparent!important }
form > div, form > label, form > p {
  background-color: transparent!important;
  color: var(--text)!important;
}
/* Table elements in checkout/profile summaries */
th, td { background-color: transparent!important; color: var(--text)!important }
th { color: var(--text-muted)!important }
tr { border-color: var(--border)!important }
legend{color:var(--accent)!important}
button.cta, .modal button{background:var(--accent)!important;color:var(--accent-ink)!important;border-radius:var(--radius-button)!important;box-shadow:var(--shadow-card)!important}
select, .modal input, .modal select{background:var(--bg-card)!important;color:var(--text)!important;border:1px solid var(--border-strong)!important;border-radius:var(--radius-card)!important}
.modal{background:var(--bg-header)!important;border:1px solid var(--border)!important;color:var(--text)!important}
.modal label.field{color:var(--text-muted)!important}

/* ============================================================
   Material-only fine adjustments — light theme has different
   needs (e.g. inline `opacity:.5` is fine on dark but too light
   on white).
   ============================================================ */
html[data-theme="material"] [style*="opacity:.5"]{opacity:.62!important}
html[data-theme="material"] [style*="opacity:.6"]{opacity:.7!important}
html[data-theme="material"] [style*="opacity:.65"]{opacity:.75!important}
html[data-theme="material"] [style*="opacity:.7"]{opacity:.78!important}
/* Material wants white-ink on its blue accent; success badge should look like Material green */
html[data-theme="material"] [style*="background:#3a8e60"]{color:#fff!important}

/* ============================================================
   Strava — match its sport-app feel: bolder header borders,
   slight orange tint on accent-soft pills.
   ============================================================ */
html[data-theme="strava"] [style*="background:rgba(255,214,115"]{background:var(--accent-soft)!important}
