/* Clublete form controls.
 *
 * Two contexts, one vocabulary. The default is the dark app surface
 * (--bg / --nav / --preview) used by add-player and upload-video. Wrapping a
 * form in .f-light switches it to the light card used by club-details, where
 * the --ink text set applies instead of --text. Nothing here assumes a
 * particular page, so club-details, add-player, upload-video and beta can all
 * share it.
 *
 * Sizes are taken from club-details.html's existing form so the conversion is
 * a like-for-like swap: 8px radius, 8px/12px control padding, 14px control
 * text, 12px labels and errors.
 *
 * State classes (.is-invalid, .is-bad, .is-off, .is-current, .is-done) are toggled by
 * page scripts. Their names are fixed; do not rename them here.
 */

/* ---------- layout ---------- */
.f-grid { display:grid; grid-template-columns:1fr; gap:16px; }
@media (min-width:640px) { .f-grid--2 { grid-template-columns:repeat(2,minmax(0,1fr)); } }
.f-grid--3 { grid-template-columns:repeat(2,minmax(0,1fr)); }
@media (min-width:640px) { .f-grid--3 { grid-template-columns:repeat(3,minmax(0,1fr)); } }
.f-span-2 { grid-column:1/-1; }
.f-section + .f-section { margin-top:28px; }
.f-section > h2, .f-legend { margin:0 0 4px; font-size:16px; font-weight:700; color:var(--text); }
.f-light .f-section > h2, .f-light .f-legend { color:var(--ink); }

/* ---------- label, hint, error ---------- */
.f-label { display:block; margin-bottom:4px; font-size:12px; font-weight:500; color:var(--text-muted); }
.f-light .f-label { color:var(--ink-muted); }
.f-req { color:var(--gold); }
.f-hint { margin-top:4px; font-size:12px; color:var(--text-muted); }
.f-light .f-hint { color:var(--ink-muted); }
/* A hint that has turned into a warning, e.g. a password that is too short.
   .is-bad is set by the page script. */
.f-hint.is-bad { color:var(--danger); }
.f-light .f-hint.is-bad { color:var(--danger-ink); }
/* The counter is text, not decoration, so it takes a text colour that passes
   on its own background. text-gray-400 on white measured 2.54:1. */
.f-count { margin-top:4px; text-align:right; font-size:12px; color:var(--text-muted); }
.f-light .f-count { color:var(--ink-muted); }
.f-err { margin-top:4px; font-size:12px; color:var(--danger); }
.f-light .f-err { color:var(--danger-ink); }

/* ---------- inputs, selects, textareas ---------- */
.f-input {
  width:100%;
  border:1px solid var(--nav-line);
  border-radius:8px;
  padding:8px 12px;
  background:var(--nav);
  color:var(--text);
  font:inherit;
  font-size:14px;
}
.f-input::placeholder { color:var(--text-dim); opacity:1; }
.f-input:focus { outline:none; border-color:var(--gold); box-shadow:inset 0 0 0 1px var(--gold); }
.f-input.is-invalid { border-color:var(--danger); }
.f-input.is-invalid:focus { box-shadow:inset 0 0 0 1px var(--danger); }
.f-input:disabled { opacity:.5; cursor:not-allowed; }

.f-light .f-input { border-color:var(--field-line); background:var(--card-active); color:var(--ink); }
.f-light .f-input::placeholder { color:var(--ink-muted); opacity:.75; }
.f-light .f-input:disabled { background:var(--card-row); }

textarea.f-input { resize:vertical; min-height:96px; }

/* Native date controls render a light-on-light picker icon otherwise. */
.f-input[type=date] { color-scheme:dark; }
.f-light .f-input[type=date] { color-scheme:light; }

/* Select: the native arrow is unstyleable, so it is replaced by .f-chev.
   .f-select must sit in a position:relative wrapper alongside the chevron. */
.f-control { display:block; position:relative; }
.f-select { appearance:none; -webkit-appearance:none; padding-right:32px; }
.f-chev {
  position:absolute; right:12px; top:50%; transform:translateY(-50%);
  pointer-events:none; font-size:10px; color:var(--text-muted);
}
.f-light .f-chev { color:var(--ink-muted); }

/* ---------- calendar date picker (js/date-picker.js) ----------
   A field that shows the chosen date and opens a calendar. The month and
   year in its header open month and year grids. */
.f-cal { position:relative; }
.f-cal-trigger { display:flex; align-items:center; justify-content:space-between; gap:8px; text-align:left; cursor:pointer; }
.f-cal-trigger i { flex-shrink:0; font-size:14px; color:var(--text-muted); }
.f-cal-trigger.is-empty .f-cal-text { color:var(--text-dim); }
.f-cal.is-open .f-cal-trigger { border-color:var(--gold); }

.f-cal-pop {
  position:absolute; top:calc(100% + 6px); left:0; z-index:40;
  width:300px; padding:12px;
  border:1px solid var(--nav-line); border-radius:12px;
  background:var(--nav); box-shadow:0 16px 40px rgba(0,0,0,.55);
}
/* Narrow phones: the calendar matches the field instead of overhanging it. */
@media (max-width:420px) { .f-cal-pop { width:auto; right:0; } }

.f-cal-head { display:flex; align-items:center; gap:2px; margin-bottom:8px; }
.f-cal-switch {
  display:inline-flex; align-items:center; gap:6px; padding:6px 8px;
  border:0; border-radius:8px; background:none; cursor:pointer;
  font:inherit; font-size:15px; font-weight:700; color:var(--text);
}
.f-cal-switch i { font-size:10px; color:var(--text-muted); }
.f-cal-switch:hover, .f-cal-switch[aria-expanded="true"] { background:var(--preview-line); }
.f-cal-nav {
  display:inline-flex; align-items:center; justify-content:center;
  border:0; border-radius:8px; background:none; cursor:pointer; color:var(--text);
}
.f-cal-head .f-cal-nav:first-of-type { margin-left:auto; }
.f-cal-nav:hover:not(:disabled) { background:var(--preview-line); }
.f-cal-nav:disabled { opacity:.3; cursor:default; }

.f-cal-week, .f-cal-grid { display:grid; grid-template-columns:repeat(7, minmax(0, 1fr)); }
.f-cal-week { margin-bottom:4px; font-size:12px; font-weight:600; text-align:center; color:var(--text-muted); }
.f-cal-grid { gap:2px; }
.f-cal-grid--months { grid-template-columns:repeat(3, minmax(0, 1fr)); gap:6px; }
.f-cal-grid--years { grid-template-columns:repeat(4, minmax(0, 1fr)); gap:6px; max-height:236px; overflow-y:auto; padding:2px; }
/* Three classes deep to beat accessibility.css's 44px button minimum: seven
   44px days don't fit a phone-width calendar. 36px stays above WCAG's 24px. */
.f-cal .f-cal-pop .f-cal-cell {
  min-width:0; min-height:36px; padding:0;
  border:0; border-radius:8px; background:none; cursor:pointer;
  font:inherit; font-size:14px; color:var(--text);
}
.f-cal .f-cal-pop .f-cal-grid--months .f-cal-cell,
.f-cal .f-cal-pop .f-cal-grid--years .f-cal-cell { min-height:44px; font-weight:600; }
.f-cal .f-cal-pop .f-cal-cell:hover { background:var(--preview-line); }
.f-cal .f-cal-pop .f-cal-cell.is-selected { background:var(--gold); color:var(--bg); font-weight:700; }
/* Past maxDate (e.g. tomorrow for a date joined): visible but not choosable. */
.f-cal .f-cal-pop .f-cal-cell:disabled { background:none; color:var(--text-dim); opacity:.4; cursor:default; }

.f-cal-foot { display:flex; justify-content:space-between; margin-top:8px; padding-top:8px; border-top:1px solid var(--nav-line); }
.f-cal-foot .f-cal-link:only-child { margin-left:auto; }
.f-cal-link { padding:0 8px; border:0; border-radius:8px; background:none; cursor:pointer; font:inherit; font-size:13px; font-weight:600; color:var(--gold); }
.f-cal-link:hover { background:var(--preview-line); }

/* ---------- switch ----------
   A checkbox drawn as an on/off switch (give the input role="switch"). The
   label holds the text on the left and the switch on the right. */
.f-switch { position:relative; display:flex; align-items:center; justify-content:space-between; gap:16px; min-height:44px; cursor:pointer; }
.f-switch-text { display:flex; flex-direction:column; gap:2px; min-width:0; }
.f-switch-title { font-size:14px; font-weight:600; color:var(--text); }
.f-switch-note { font-size:12px; color:var(--text-muted); }
.f-switch-input { position:absolute; right:0; width:44px; height:26px; margin:0; opacity:0; cursor:pointer; }
.f-switch-track {
  position:relative; flex-shrink:0; width:44px; height:26px; border-radius:999px;
  border:1px solid var(--dash); background:var(--nav-line); transition:background-color .15s, border-color .15s;
}
.f-switch-track::after {
  content:''; position:absolute; top:3px; left:3px; width:18px; height:18px; border-radius:50%;
  background:var(--text-muted); transition:transform .15s, background-color .15s;
}
.f-switch-input:checked + .f-switch-track { background:var(--gold); border-color:var(--gold); }
.f-switch-input:checked + .f-switch-track::after { transform:translateX(18px); background:var(--bg); }
.f-switch-input:focus-visible + .f-switch-track { outline:3px solid var(--gold); outline-offset:2px; }

/* ---------- checkbox ---------- */
.f-check { display:flex; align-items:flex-start; gap:12px; font-size:14px; color:var(--text); cursor:pointer; line-height:1.5; }
.f-light .f-check { color:var(--ink); }
.f-check input {
  appearance:none; -webkit-appearance:none;
  width:18px; height:18px; flex-shrink:0; margin-top:1px;
  border:1px solid var(--nav-line); border-radius:5px;
  background:var(--nav); cursor:pointer; position:relative;
}
.f-light .f-check input { border-color:var(--field-line); background:var(--card-active); }
.f-check input:checked { background:var(--gold); border-color:var(--gold); }
.f-check input:checked::after {
  content:''; position:absolute; left:5px; top:1px; width:5px; height:10px;
  border:solid var(--bg); border-width:0 2px 2px 0; transform:rotate(45deg);
}
.f-check input:focus-visible { outline:2px solid var(--gold); outline-offset:2px; }
.f-check input:disabled { opacity:.5; cursor:not-allowed; }
.f-check:has(input:disabled) { cursor:not-allowed; }

/* ---------- radio / checkbox card ---------- */
.f-card {
  display:flex; align-items:flex-start; gap:12px;
  border:1px solid var(--nav-line); border-radius:8px;
  background:var(--nav); padding:16px; cursor:pointer;
}
.f-light .f-card { border-color:var(--field-line); background:var(--card-active); }
.f-card input { accent-color:var(--gold); width:16px; height:16px; margin-top:2px; flex-shrink:0; cursor:pointer; }
.f-card-title { display:block; font-size:14px; font-weight:600; color:var(--text); }
.f-card-note { display:block; margin-top:4px; font-size:12px; color:var(--text-muted); }
.f-light .f-card-title { color:var(--ink); }
.f-light .f-card-note { color:var(--ink-muted); }
.f-card:has(input:checked) { border-color:var(--gold); }
.f-card:has(input:disabled) { cursor:not-allowed; }
.f-card input:focus-visible { outline:2px solid var(--gold); outline-offset:2px; }

/* ---------- dropzone ---------- */
.f-drop {
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px;
  width:100%; padding:24px 16px; text-align:center; cursor:pointer;
  border:2px dashed var(--dash); border-radius:8px;
}
.f-drop:hover, .f-drop:focus-within { border-color:var(--gold); }
.f-drop i { font-size:18px; color:var(--text-muted); }
.f-drop-title { font-size:14px; color:var(--text); }
.f-drop-note { font-size:12px; color:var(--text-muted); }
.f-light .f-drop i, .f-light .f-drop-note { color:var(--ink-muted); }
.f-light .f-drop-title { color:var(--ink); }
/* Compact square variant, for a crest or avatar rather than a document. */
.f-drop--compact { width:64px; height:64px; padding:0; flex-shrink:0; position:relative; overflow:hidden; }

/* The chosen file replaces the dropzone rather than sitting under it. */
.f-file {
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  width:100%; padding:10px 12px;
  border:1px solid var(--nav-line); border-radius:8px; background:var(--nav);
  font-size:14px; color:var(--text);
}
.f-light .f-file { border-color:var(--field-line); background:var(--card-active); color:var(--ink); }
.f-file-name { display:flex; align-items:center; gap:8px; min-width:0; }
.f-file-name span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.f-file-name i { color:var(--text-muted); flex-shrink:0; }
.f-light .f-file-name i { color:var(--ink-muted); }
.f-file button {
  flex-shrink:0; border:0; background:none; font:inherit; font-size:12px; font-weight:600;
  color:var(--text-muted); cursor:pointer;
}
.f-file button:hover { color:var(--text); }
.f-light .f-file button { color:var(--ink-muted); }
.f-light .f-file button:hover { color:var(--ink); }

/* ---------- chips ---------- */
/* A selectable chip, for multi-select fields such as tagging players.
   Pressed state is driven by aria-pressed, so the accessible state and the
   visible state cannot drift apart. */
.f-chip {
  border:1px solid var(--nav-line); border-radius:999px; padding:6px 12px;
  background:var(--nav); font:inherit; font-size:12px; font-weight:600;
  color:var(--text); cursor:pointer;
}
.f-chip:hover { border-color:var(--gold); }
.f-chip[aria-pressed="true"] { background:var(--gold); border-color:var(--gold); color:var(--bg); }
.f-chip:disabled { opacity:.5; cursor:not-allowed; }
.f-light .f-chip { border-color:var(--field-line); background:var(--card-active); color:var(--ink); }
.f-light .f-chip[aria-pressed="true"] { background:var(--gold); border-color:var(--gold); color:var(--bg); }
.f-chips { display:flex; flex-wrap:wrap; gap:8px; }

.f-chip-options { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.f-chip-add {
  border:1px solid var(--nav-line); border-radius:6px; padding:4px 10px;
  background:none; font:inherit; font-size:12px; font-weight:500;
  color:var(--text-muted); cursor:pointer;
}
.f-chip-add:hover { border-color:var(--gold); color:var(--text); }
.f-light .f-chip-add { border-color:var(--field-line); color:var(--ink-muted); }
.f-light .f-chip-add:hover { border-color:var(--gold); color:var(--ink); }

/* ---------- shared state ---------- */
/* .is-off marks a control that is deliberately unavailable rather than broken. */
.is-off { opacity:.5; }
.f-sr { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
