/* PlayTennisMarin shared web styles — the page-independent visual vocabulary
   (tokens, atoms, chrome) used by /enroll/ and /scores/. Page-specific rules
   stay in each page's own <style> block, loaded AFTER this file.
   NOTE: /assets/ files are cached for 7 days — any change here must bump the
   ?v= query on the <link> in EVERY consuming HTML page. */

/* ── Tokens (mirrors ptm-app/components/ui/tokens.js) ─────────────────── */
:root {
  --green: #34BD29;
  --green-bg: #F0FDF4;
  --ink: #0F1E1A;
  --border: #E5E7EB;
  --muted: #6B7280;
  --placeholder: rgba(60, 60, 67, .30);
  --bg-subtle: #F3F4F6;
  --red: #E53E3E;
  --stop-border: #D1D5DB;
  --white: #FFFFFF;
  /* Text links only: brand green fails contrast at text sizes on white
     (same darker variant privacy.html uses). */
  --link: #1a7a12;
  --radius-card: 14px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 48px;
  --shadow-card: 0 2px 8px rgba(0, 0, 0, .06);
  --font: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
}

/* ── Reset + base ─────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: #FFFFFF; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--white);
  -webkit-tap-highlight-color: transparent;
  /* Short views (success, closed) on tall desktop windows: the page fills
     the viewport and the footer rides its bottom edge instead of floating
     mid-screen. */
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100svh;
}
[hidden] { display: none !important; }
a { color: var(--link); }
main {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5) var(--sp-6);
  width: 100%;
  flex: 1;
  display: flex; flex-direction: column;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Honeypot (bot trap): parked off-screen rather than display:none, which
   some form-filling bots skip. Humans never see or tab to it; the server
   rejects any submission that gives it a value. */
.hp-wrap {
  position: absolute; left: -9999px; top: -9999px;
  width: 1px; height: 1px; overflow: hidden;
}

/* ── Page chrome ──────────────────────────────────────────────────────── */
/* Same header the enrollment emails use (email.js wrapEmail): white wordmark
   on the brand green gradient. */
.brand-header {
  background: #2FAE27;
  background: linear-gradient(135deg, #3ECF31 0%, #1E8C19 100%);
  padding: var(--sp-5) var(--sp-5);
  text-align: center;
}
.brand-header img { width: 190px; height: 47px; max-width: 100%; display: inline-block; }
.page-title {
  font-size: 34px; line-height: 41px; font-weight: 700;
  color: var(--green);
  padding-bottom: var(--sp-2);
}
.page-intro {
  font-size: 14px; line-height: 21px; color: var(--muted);
  margin-bottom: var(--sp-5);
}
.page-footer {
  color: var(--muted); font-size: 13px; font-weight: 400;
  padding-top: var(--sp-7);
  margin-top: auto; /* pins to the bottom of the flex-column main */
}

/* ── Field atom (mirrors components/ui/Field.js) ──────────────────────── */
.field { margin-bottom: var(--sp-6); border: 0; }
.field-label-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; margin-bottom: 10px;
}
.field-label {
  font-size: 12px; font-weight: 700; color: var(--ink);
  letter-spacing: 1.2px; text-transform: uppercase;
}
legend.field-label { margin-bottom: 10px; }
.req { color: var(--red); }
.field-helper { font-size: 12px; font-weight: 500; color: var(--muted); }
.field-error {
  color: var(--red); font-size: 12px; font-weight: 500; margin-top: 6px;
}
.field-note { font-size: 12px; line-height: 18px; color: var(--muted); margin: -4px 0 10px; }

/* ── Field-help tooltip (mirrors the app's FieldHelper info popover) ──── */
/* Icon centering comes from the flex label row (below), not baseline
   alignment — vertical-align math differs per browser engine. */
.field-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0;
  border: 0; background: none; cursor: pointer; color: var(--muted);
}
/* Any label/legend/dt hosting a help icon becomes a centered flex row.
   Whitespace between text and icon collapses in flex; gap replaces it. */
.field-label:has(.field-help), .summary-row dt:has(.field-help) {
  display: flex; align-items: center; gap: 4px; /* ≈ the word space flex drops */
}
.field-help svg { width: 16px; height: 16px; }
.field-help:hover, .field-help[aria-expanded="true"] { color: var(--green); }
.field-help:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 50%; }
.tooltip-bubble {
  position: absolute; z-index: 60;
  background: var(--white);
  border: 1px solid var(--border); border-radius: 12px;
  padding: var(--sp-3) var(--sp-4);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
}
.tooltip-bubble__title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.tooltip-bubble__msg { font-size: 13px; line-height: 1.5; color: var(--muted); white-space: pre-line; }

/* ── TextInput atom ───────────────────────────────────────────────────── */
.input {
  display: block; width: 100%;
  min-height: 52px;
  padding: 0 var(--sp-4);
  font-family: var(--font); font-size: 16px; font-weight: 400; color: var(--ink);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  caret-color: var(--green);
  outline: none;
  appearance: none;
}
.input::placeholder { color: var(--placeholder); }
/* 2px focus/error look without layout shift: 1px border + 1px inset ring */
.input:focus { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.input--error, .input--error:focus { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--white) inset;
  -webkit-text-fill-color: var(--ink);
}

/* ── Button atom ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  width: 100%;
  min-height: 52px;
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--font); font-size: 15px; font-weight: 600; letter-spacing: -0.14px;
  border-radius: var(--radius-card);
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, opacity .12s ease, background-color .12s ease;
}
.btn:active { transform: scale(.985); opacity: .94; }
.btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.btn--primary { background: var(--green); border: 1px solid var(--green); color: var(--white); }
.btn--secondary { background: var(--white); border: 1.5px solid var(--green); color: var(--green); }
/* Pointer devices only — on touch, :hover sticks after a tap. */
@media (hover: hover) {
  .btn--primary:not(:disabled):hover { background: #2FAE27; border-color: #2FAE27; }
  .btn--secondary:not(:disabled):hover { background: var(--green-bg); }
}
.btn:disabled {
  background: var(--border); border-color: var(--border); color: var(--muted);
  cursor: default; transform: none; opacity: 1;
}
.btn .arrow { width: 18px; height: 18px; flex: none; }

/* ── Selectable cards + chips (mirrors SelectableCard.js) ─────────────── */
.select-card {
  display: block;
  background: var(--white);
  border: 2px solid var(--border);       /* constant width — only color changes */
  border-radius: var(--radius-card);
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease, border-color .12s ease;
}
.select-card:active { transform: scale(.985); opacity: .94; }
.select-card:has(input:checked) { border-color: var(--green); background: var(--green-bg); }
.select-card:has(input:focus-visible) { outline: 2px solid var(--green); outline-offset: 2px; }
/* Hover hints at the selected state (border only, no bg — the green tint
   stays reserved for actually selected). Pointer devices only. */
@media (hover: hover) {
  .select-card:not(:has(input:checked)):hover {
    border-color: #A9DDA4; /* fallback */
    border-color: color-mix(in srgb, var(--green) 35%, var(--border));
  }
}
.select-card__body { padding: var(--sp-4); display: flex; flex-direction: column; gap: 4px; }
.select-card__title { font-size: 15px; font-weight: 600; letter-spacing: -0.15px; }
.select-card__sub { font-size: 12px; font-weight: 400; line-height: 18px; color: var(--muted); }
.select-card:has(input:checked) .select-card__sub { color: var(--ink); }

.division-card { min-height: 60px; display: flex; align-items: center; }
.division-card .select-card__body { padding: 14px; }
.division-card .select-card__title { font-size: 14px; letter-spacing: -0.14px; }

/* Pattern A: group error box holds its footprint at rest; error only recolors */
.group-box {
  border: 2px solid transparent;
  border-radius: 12px;
  padding: var(--sp-1);
}
.group-box--error { border-color: var(--red); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }

/* ── Sticky footer (wizard nav / single submit) ───────────────────────── */
.wizard-footer {
  position: sticky; bottom: 0; z-index: 10;
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-5);
  padding-bottom: max(var(--sp-4), env(safe-area-inset-bottom));
}
.wizard-footer-row {
  max-width: 600px; margin: 0 auto;
  display: flex; align-items: stretch; gap: var(--sp-3);
}
.wizard-footer-row .btn-back { flex: 0.9; }
.wizard-footer-row .btn-next { flex: 1.4; }

/* ── Composites ───────────────────────────────────────────────────────── */
.summary-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.summary-card__title { font-size: 16px; font-weight: 700; margin-bottom: var(--sp-3); }
.summary-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3);
  padding: 6px 0;
}
.summary-row dt {
  font-size: 12px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--muted); flex: none;
}
.summary-row dd { font-size: 14px; font-weight: 500; text-align: right; }
.summary-row--amount { border-top: 1px solid var(--border); margin-top: 6px; padding-top: var(--sp-3); }
.summary-row--amount dd { font-size: 18px; font-weight: 700; color: var(--green); }

.note-muted { font-size: 13px; line-height: 20px; color: var(--muted); margin-bottom: var(--sp-6); }

.fine-print {
  font-size: 12px; line-height: 18px; color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.fine-print p { margin-bottom: var(--sp-2); }

.banner-error {
  background: rgba(229, 62, 62, .08);
  border: 1px solid rgba(229, 62, 62, .30);
  border-radius: 12px;
  padding: var(--sp-3) var(--sp-4);
  color: var(--red);
  font-size: 14px; font-weight: 500;
  margin-bottom: var(--sp-4);
}

/* ── Centered states (loading / error / closed / success) ─────────────── */
.state-view { text-align: center; padding: var(--sp-8) 0; }
.state-view h2 { font-size: 22px; font-weight: 700; margin-bottom: var(--sp-2); }
.state-view p { font-size: 16px; line-height: 24px; color: var(--muted); }
.state-view .btn { max-width: 280px; margin: var(--sp-6) auto 0; }
.spinner {
  width: 28px; height: 28px; margin: 0 auto var(--sp-4);
  border: 3px solid var(--border); border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* flex:1 + centering mirrors the app's success ScrollView (flexGrow
   centering): content sits mid-viewport on desktop, flows normally when
   taller than the space on mobile. */
.success-view {
  text-align: center; padding: var(--sp-7) 0;
  flex: 1; display: flex; flex-direction: column; justify-content: center;
}
.success-circle {
  width: 88px; height: 88px; border-radius: 44px;
  background: var(--green);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--sp-6);
}
.success-circle svg { width: 44px; height: 44px; }
.success-heading { font-size: 26px; font-weight: 700; margin-bottom: var(--sp-3); }
.success-message {
  font-size: 16px; font-weight: 400; line-height: 24px; color: var(--muted);
  margin-bottom: var(--sp-6);
}
.success-actions { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-6); }

/* ── Copy rows (tap-to-copy, pairs with PTM.wireCopyRows) ─────────────── */
.copy-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  width: 100%;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px var(--sp-3);
  margin-bottom: var(--sp-2);
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
}
.copy-row:last-child { margin-bottom: 0; }
.copy-row:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.copy-row__text { min-width: 0; }
.copy-row__label {
  display: block;
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 2px;
}
.copy-row__value { font-size: 14px; font-weight: 500; color: var(--ink); word-break: break-all; }
.copy-row__action { font-size: 12px; font-weight: 600; color: var(--green); flex: none; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* Anchor error scrolls below any sticky header (e.g. the enroll step bar) */
.field, fieldset.field { scroll-margin-top: 96px; }

@media (prefers-reduced-motion: reduce) {
  .btn, .select-card { transition: none; }
  .btn:active, .select-card:active { transform: none; }
  .spinner { animation-duration: 1.6s; }
}
