/* Ronda 3 — WE3: valores protegidos, declaración, historial de cambios, tarjetas y código r.
   Hoja propia del carril (los tokens y colores siguen en app.css: use var(--…)). */

/* ---- valores protegidos del foto-finish (R3.3) ------------------------------------------ */
.lock-badge { display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; color: var(--info-ink); }
.lock-badge .icon { display: block; }
.notice.protect-note { display: flex; gap: 8px; align-items: flex-start; }
.notice.protect-note .lock-badge { margin-top: 1px; }
.lock-badge[hidden] { display: none !important; }
.results-grid .rt-cell { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.results-grid .rt-cell .in-rt { flex: 0 1 5.6em; min-width: 0; }
.results-grid tr.is-protected .in-mark:disabled,
.results-grid tr.is-protected .in-rt:disabled,
.results-grid tr.is-protected .in-status:disabled { cursor: not-allowed; border-style: dashed; }
.results-grid .in-status { width: 10.6em; }
.mark-line { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* ---- declaración de modificación ------------------------------------------------------------ */
.decl-dialog .notice.decl-intro { display: flex; gap: 8px; align-items: flex-start; }
.decl-dialog .notice.decl-intro .icon { margin-top: 2px; color: var(--accent-ink); flex: none; }
.decl-changes table.data th, .decl-changes table.data td { padding: 6px 10px; }
.decl-diff, .history-diff { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.decl-old { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.decl-new { font-weight: 700; color: var(--ink); }
.decl-arrow { color: var(--muted); }
.decl-dialog textarea { resize: vertical; min-height: 5.5em; }
.form-error.field-msg { display: block; font-size: .8rem; margin-top: 2px; }
.import-changes .notice { display: flex; gap: 8px; align-items: flex-start; }
.import-changes .notice .icon { margin-top: 2px; color: var(--accent-ink); flex: none; }

/* ---- tarjetas (R3.6) ------------------------------------------------------------------------ */
.card-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.cards-host:empty, .notes-host:empty, .status-host:empty { display: none; }
.results-grid .cards-host { display: flex; justify-content: flex-end; margin-top: 4px; }
.card-chip {
  display: inline-grid; place-items: center; min-width: 30px; min-height: 22px; padding: 0 6px; border-radius: 4px;
  font: 800 .72rem var(--font-mono); letter-spacing: .02em; line-height: 1; border: 1px solid transparent;
}
/* tarjeta amarilla: el ámbar de alerta (--warn), no el cian de interacción; tinta --on-accent (oscura sobre el
   ámbar del tema oscuro, blanca sobre el del claro: ≥ 4,5:1 en ambos) */
.card-yc { background: var(--warn); color: var(--on-accent); border-color: var(--warn); }
.card-rc { background: var(--danger); color: var(--bg); border-color: var(--danger); }
.card-yrc { background: var(--danger); color: var(--bg); border-color: var(--danger); box-shadow: inset 6px 0 0 var(--accent); padding-left: 10px; }
button.card-chip { cursor: pointer; min-height: 28px; }
button.card-chip:hover { filter: brightness(1.08); text-decoration: line-through; }
button.card-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.card-btn { min-height: 32px; padding: 0 8px; font-size: .8rem; white-space: nowrap; }
.c-flags .card-btn { margin-left: 4px; }
.card-menu fieldset.card-types { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); min-width: 0; }
.card-menu fieldset.card-types legend { font-weight: 650; margin-bottom: 6px; padding: 0; }
.card-choice {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); cursor: pointer; background: var(--surface-2);
}
.card-choice input { width: 18px; height: 18px; flex: none; accent-color: var(--focus); }
.card-choice:has(input:checked) { border-color: var(--focus); box-shadow: inset 0 0 0 1px var(--focus); }
.card-choice:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.card-choice .card-chip { min-width: 36px; min-height: 28px; }
.card-choice > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.notice.card-outcome.danger { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

/* ---- hoja de campo: r · Retirado y tarjetas ----------------------------------------------------- */
.field-sheet .who-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.field-sheet .who-actions .btn { min-height: 30px; padding: 0 8px; font-size: .78rem; }
.r-toggle { font-family: var(--font-mono); font-weight: 700; border: 1px solid var(--line); }
.r-toggle[aria-pressed="true"] { color: var(--danger-ink); border-color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.field-sheet tr.is-retired td.who .cell-name::after { content: " · r"; color: var(--danger-ink); font-family: var(--font-mono); }
.field-sheet td.att.is-retired-mark input:not(.wind):disabled { color: var(--danger-ink); font-weight: 800; opacity: 1; border-color: var(--danger); border-style: dashed; }
.field-sheet td.c-best { white-space: nowrap; }
.field-sheet td.c-best .status-host, .field-sheet td.c-best .cards-host { display: inline-flex; margin-left: 4px; vertical-align: middle; }
.status-pill .pill { cursor: help; }
.ranking-list .mark .card-chips { margin-left: 2px; }

/* ---- historial de cambios ------------------------------------------------------------------------ */
.history-filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; }
.history-filters .field { min-width: 160px; flex: 0 1 220px; }
.history-table td { vertical-align: top; }
.history-table td.history-decl { min-width: 16em; max-width: 32em; white-space: normal; overflow-wrap: anywhere; }
.history-table tr.is-declared td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.history-export { gap: 8px; flex-wrap: wrap; }
.history-card .field .select { width: 100%; }

@media (max-width: 640px) {
  .results-grid td.c-flags:has(.card-btn) { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
  .results-grid .in-status { width: 100%; }
  .results-grid .cards-host { justify-content: flex-start; }
  .results-grid .rt-cell .in-rt { flex: 1 1 auto; }
  /* the change log as stacked cards with the column name before each value */
  .history-table table, .history-table tbody, .history-table tr, .history-table td { display: block; }
  .history-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .history-table tr { padding: 10px 6px; border-bottom: 1px solid var(--line); }
  .history-table table.data td { border: 0; padding: 2px 0; display: grid; grid-template-columns: 8.5em minmax(0, 1fr); gap: 8px; }
  .history-table table.data td::before { content: attr(data-label); color: var(--muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
  .history-table td.history-decl { min-width: 0; max-width: none; }
  .history-table .history-diff { white-space: normal; }
  .history-table tr.is-declared td:first-child { box-shadow: none; }
  .history-table tr.is-declared { box-shadow: inset 3px 0 0 var(--accent); }
}

/* ---- ronda 4 (carril C): códigos WA, regla de la DQ y clasificación a la ronda siguiente ---------- */
.code-tag {
  display: inline-grid; place-items: center; min-width: 30px; min-height: 22px; padding: 0 6px; border-radius: 4px;
  font: 800 .78rem var(--font-mono); line-height: 1; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong);
}
.codes-dialog .codes-body { max-height: min(70vh, 640px); overflow-y: auto; }
.codes-dialog .codes-body:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.codes-table { width: 100%; }
.codes-table th.c-code { width: 4.5em; vertical-align: top; }
.codes-table td, .codes-table th { vertical-align: top; }
.codes-table td.c-where { color: var(--muted); font-size: .86rem; }
.codes-table .c-kind { text-transform: uppercase; letter-spacing: .04em; font-size: .68rem; }
.codes-table tr.is-highlight th, .codes-table tr.is-highlight td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.codes-sub { font-size: .95rem; margin: 14px 0 6px; }
.codes-help-btn { white-space: nowrap; }
.card-codes { display: grid; gap: 8px; justify-items: start; }
.card-codes .codes-table { font-size: .86rem; }
.card-codes-section { border-top: 1px solid var(--line); padding-top: 8px; }
.card-codes-section .codes-sub { margin-top: 2px; }
.results-grid .in-rule { width: 10.6em; margin-top: 4px; display: block; }
.results-grid .in-rule[hidden] { display: none; }
.codes-btn .icon { color: var(--info-ink); }
.notation-menu fieldset.code-group { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0; display: grid; gap: 8px; min-width: 0; }
.notation-menu fieldset.code-group legend { font-weight: 650; padding: 0 4px; }
.code-choice {
  display: flex; align-items: center; gap: 10px; min-height: var(--hit); padding: 6px 10px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); cursor: pointer; background: var(--surface-2);
}
.code-choice input { width: 18px; height: 18px; flex: none; accent-color: var(--focus); }
.code-choice:has(input:checked) { border-color: var(--focus); box-shadow: inset 0 0 0 1px var(--focus); }
.code-choice:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.code-choice:has(input:disabled) { opacity: .6; cursor: not-allowed; }
.code-choice > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.walk-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.walk-item { display: grid; grid-template-columns: auto 1fr 5em; align-items: center; gap: 8px; }
.walk-item .walk-count { width: 5em; }
.qual-summary { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 8px; }
.qual-actions { flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.qual-tie ul { margin: 6px 0; padding-left: 1.2em; }
.qual-tie { display: grid; gap: 4px; justify-items: start; }

@media (max-width: 640px) {
  .results-grid .in-rule { width: 100%; }
  /* the code table as stacked rows: code + meaning, then where it is used */
  .codes-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .codes-table, .codes-table tbody, .codes-table tr { display: block; width: 100%; }
  .codes-table tr { display: grid; grid-template-columns: 4em minmax(0, 1fr); gap: 2px 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .codes-table th.c-code, .codes-table td { display: block; border: 0; padding: 0; width: auto; }
  .codes-table td.c-where, .codes-table.codes-compact td.mono { grid-column: 2; }
  .walk-item { grid-template-columns: auto 1fr 4.5em; }
}
