/* ============================================================
   THE CHALLENGE — GEOVANNY · COMPONENTES (producción, vanilla)
   Traducción a clases de los componentes GV del design system.
   Requiere tokens.css cargado antes.
   ============================================================ */

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--control-h); padding: 0 22px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  font-family: var(--font-semi); font-weight: 700; font-size: 13px;
  letter-spacing: 0.08em; text-transform: uppercase;
  background: transparent; color: var(--text-primary);
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--primary { background: var(--brand); color: var(--text-on-brand); }
.btn--primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn--racing { background: var(--racing); color: #fff; }
.btn--racing:hover:not(:disabled) { background: var(--racing-strong); }
.btn--secondary { border-color: var(--border-strong); }
.btn--secondary:hover:not(:disabled) { background: rgba(255,255,255,0.06); }
.btn--ghost { color: var(--text-secondary); }
.btn--ghost:hover:not(:disabled) { background: rgba(255,255,255,0.06); }
.btn--sm { height: var(--control-h-sm); padding: 0 14px; font-size: 12px; }
.btn--lg { height: var(--control-h-lg); padding: 0 26px; font-size: 14px; }
.btn--full { width: 100%; }
.btn svg { flex: none; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--control-h-sm); height: var(--control-h-sm);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary); cursor: pointer;
}
.iconbtn:hover:not(:disabled) { background: rgba(255,255,255,0.06); }
.iconbtn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Badges / tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: var(--radius-pill); border: 1px solid var(--border-default);
  font-family: var(--font-semi); font-weight: 700; font-size: 11px;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-secondary);
  white-space: nowrap; flex: none;
}
.badge--success { border-color: rgba(31,182,122,0.45); color: var(--green-500); }
.badge--warning { border-color: rgba(245,165,36,0.45); color: var(--amber-500); }
.badge--racing  { border-color: var(--racing-line); color: var(--red-300); }
.badge--brand   { border-color: var(--brand-line); color: var(--cyan-300); }
.badge--neutral { color: var(--text-muted); }
/* W8.1 — badge legible SOBRE foto del hero: scrip chip oscuro sólido + blur
   ligero. El borde y el color se preservan por variante (--racing/--neutral);
   esto solo añade el fondo opaco que rescata el contraste perdido con foto clara.
   El texto del badge--neutral, casi invisible sobre foto, sube a ink-100. */
.badge--onphoto { background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); border-color: rgba(255,255,255,0.18); }
.badge--onphoto.badge--neutral { color: var(--ink-100); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--live .dot { animation: gvpulse 1.6s ease-in-out infinite; }
@keyframes gvpulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

.tag {
  display: inline-flex; align-items: center; height: 36px; padding: 0 16px;
  border-radius: var(--radius-pill); border: 1px solid var(--border-default);
  background: transparent; color: var(--text-secondary); cursor: pointer;
  font-family: var(--font-semi); font-weight: 700; font-size: 12.5px; letter-spacing: 0.04em;
}
.tag[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand-line); color: var(--cyan-300); }

.chip {
  height: 34px; padding: 0 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  font-family: var(--font-semi); font-weight: 700; font-size: 11.5px; letter-spacing: 0.05em;
  background: transparent; color: var(--text-secondary); border: 1px solid var(--border-default);
}
.chip[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 16px;
}
.card--flush { padding: 0; overflow: hidden; }
.card--accent-racing { border-left: 3px solid var(--racing); }
.card--accent-brand { border-left: 3px solid var(--brand); }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
/* W10.2: el atributo [hidden] debe ganarle al display:flex de arriba (si no,
   #otra-ciudad queda visible siempre — registro.js lo togglea por .hidden). */
.field[hidden] { display: none !important; }
.field > .field-label {
  font-family: var(--font-semi); font-weight: 700; font-size: 10.5px;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary);
}
.input, .select, .textarea {
  width: 100%; height: var(--control-h); padding: 0 12px;
  background: var(--surface-inset); color: var(--text-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  /* W5.7: font-size >=16px en el estado base de todo control de texto para
     evitar el auto-zoom de iOS Safari al enfocar (dispara con <16px). NO se
     usa user-scalable=no/maximum-scale=1 (mata accesibilidad). */
  font-family: var(--font-sans); font-size: 16px;
}
.textarea { height: auto; padding: 10px 12px; line-height: var(--lh-body); resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-400); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.6; cursor: not-allowed; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--red-300); }
.field-error { font-size: 11px; color: var(--red-300); }
.field-hint { font-size: 10.5px; color: var(--ink-400); }
.select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2369707E' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.select--mini { height: 26px; font-family: var(--font-mono); font-size: 10px; padding: 0 22px 0 4px; border-radius: 6px; color: var(--text-secondary); background-position: right 6px center; }
/* W5.7: en punteros gruesos (teléfono del staff en ruta) iOS hace auto-zoom si
   el control <16px. .select--mini vive en tablas densas de ancho fijo: subir su
   font-size en desktop rompe el layout, asi que solo se eleva a 16px bajo
   pointer:coarse, preservando la densidad en escritorio. */
@media (pointer: coarse) { .select--mini { font-size: 16px; } }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: var(--tap-min); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 44px; height: 26px; border-radius: 999px; flex: none; position: relative;
  background: var(--ink-700); border: 1px solid var(--border-default);
  transition: background var(--dur-fast) var(--ease-out);
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--ink-200); transition: transform var(--dur-fast) var(--ease-out);
}
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.switch .switch-label { font-size: 13.5px; color: var(--text-secondary); }

/* ---------- Placa de dorsal (número de carrera) ---------- */
.dorsal {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 46px; height: 30px; padding: 0 10px 0 8px; flex: none;
  background: linear-gradient(165deg, #1c2127 0%, #11151a 70%);
  border: 1px solid var(--border-strong); border-radius: 7px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 1px 2px rgba(0,0,0,0.4);
  font-family: var(--font-display); font-style: italic; font-weight: 800;
  font-size: 17px; line-height: 1; color: #fff; font-variant-numeric: tabular-nums;
}
.dorsal--sm { min-width: 38px; height: 26px; font-size: 14.5px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: var(--surface-overlay); backdrop-filter: blur(5px);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: min(520px, 94vw); max-height: 88vh; overflow-y: auto;
  background: var(--surface-raised); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; background: var(--surface-raised); z-index: 2;
}
.modal-head h3 {
  font-family: var(--font-display); font-style: italic; font-weight: 700;
  font-size: 17px; text-transform: uppercase; color: #fff;
}
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Toast ---------- */
.toast-host {
  position: fixed; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  display: flex; align-items: center; gap: 14px; pointer-events: auto;
  background: var(--ink-700); border: 1px solid var(--border-default);
  border-radius: 10px; padding: 10px 16px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; color: var(--text-primary); max-width: 92vw;
}
.toast button {
  background: none; border: none; cursor: pointer; padding: 0;
  font-family: var(--font-semi); font-weight: 700; font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--cyan-300);
}

/* ---------- Empty state / skeleton ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 28px 18px; text-align: center;
}
.empty span { font-size: 13.5px; color: var(--text-muted); line-height: 1.5; max-width: 32ch; }
.skel { border-radius: 4px; background: var(--ink-700); animation: gvskel 1.4s ease-in-out infinite; }
@keyframes gvskel { 0%,100% { opacity: 0.35; } 50% { opacity: 0.75; } }

/* ---------- Tipografía utilitaria ---------- */
.display { font-family: var(--font-display); font-style: italic; font-weight: 700; text-transform: uppercase; line-height: var(--lh-tight); color: #fff; }
.eyebrow { font-family: var(--font-semi); font-weight: 700; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brand); }
.label-up { font-family: var(--font-semi); font-weight: 700; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }

/* ---------- Slot fotográfico (placeholder honesto) ---------- */
.photo {
  position: relative; overflow: hidden;
  background: repeating-linear-gradient(115deg, #14171b 0 14px, #101316 14px 28px);
}
.photo > .photo-label {
  position: absolute; top: 10px; right: 12px; max-width: 55%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.18em;
  color: rgba(255,255,255,0.13);
}

/* ---------- Barra de dureza ---------- */
.dureza-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.dureza-segs { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.dureza-segs span { height: 8px; border-radius: 3px; background: var(--ink-700); }

/* ---------- Marca demo ---------- */
.demo-tag { border-color: rgba(245,165,36,0.45); color: var(--amber-500); }
