/* pokerlab: crema y azafran de dia, carbon cafe de noche. Una sola familia (Archivo):
   ancho normal para leer, condensada y pesada para la respuesta. */

:root {
  --bg: #f4ead5;
  --surface: #faf2e2;
  --panel: #ebddbf;
  --ink: #3a2817;
  --ink-soft: #6b5640;
  --line: #d9c6a1;
  --accent: #e5a11c;
  --on-accent: #3a2817;
  --focus: #94560a;
  --go: #2d6a33;
  --call: #3c5d7e;
  --fold: #675e55;
  --warn: #a3450b;
  --suit-red: #a8322b;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1814;
    --surface: #27201a;
    --panel: #2e261f;
    --ink: #f0e4ce;
    --ink-soft: #bca98f;
    --line: #463b30;
    --accent: #edb045;
    --on-accent: #2a1d10;
    --focus: #edb045;
    --go: #7dc283;
    --call: #93b1cf;
    --fold: #b5ab9f;
    --warn: #f0904e;
    --suit-red: #ee8a7d;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1d1814;
  --surface: #27201a;
  --panel: #2e261f;
  --ink: #f0e4ce;
  --ink-soft: #bca98f;
  --line: #463b30;
  --accent: #edb045;
  --on-accent: #2a1d10;
  --focus: #edb045;
  --go: #7dc283;
  --call: #93b1cf;
  --fold: #b5ab9f;
  --warn: #f0904e;
  --suit-red: #ee8a7d;
  color-scheme: dark;
}

/* --- Base --- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--line) var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* La lista de un select la pinta el navegador; donde deja (Chromium y Firefox de
   escritorio), en los colores del tema. En iOS y Android es el selector nativo. */
option {
  background-color: var(--surface);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

/* --- Encabezado --- */

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0 12px;
}

.brand {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  font-stretch: 80%;
  letter-spacing: -0.01em;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-soft);
}

.status[data-state="loading"]::before {
  animation: pulse 1.2s ease-in-out infinite;
}

.status[data-state="ready"]::before {
  background: var(--go);
}

.status[data-state="error"] {
  color: var(--warn);
}

.status[data-state="error"]::before {
  background: var(--warn);
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-sun {
  display: none;
}

:root[data-theme="dark"] .icon-sun {
  display: block;
}

:root[data-theme="dark"] .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun {
    display: block;
  }

  :root:not([data-theme="light"]) .icon-moon {
    display: none;
  }
}

/* --- Distribucion --- */

.layout {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding-bottom: 32px;
}

@media (min-width: 960px) {
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 460px);
    gap: 56px;
    align-items: start;
  }

  .answer {
    position: sticky;
    top: 24px;
    order: 2;
  }
}

/* --- Respuesta: lo mas visible --- */

.answer {
  container-type: inline-size;
  padding: 24px 24px 20px;
  border-radius: 20px;
  background: var(--panel);
}

.answer-line {
  margin: 0;
  font-size: 3rem; /* respaldo si el navegador no entiende cqi */
  font-size: clamp(3rem, 19cqi, 6rem);
  font-weight: 800;
  font-stretch: 72%;
  line-height: 0.95;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
}

.answer-line .pct {
  font-weight: 500;
}

.answer-line .w {
  white-space: nowrap;
}

.answer-line.is-new {
  animation: arrive 180ms ease-out;
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.act-go {
  color: var(--go);
}

.act-call {
  color: var(--call);
}

.act-fold {
  color: var(--fold);
}

.act-warn {
  color: var(--warn);
}

.answer-alt {
  margin: 14px 0 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.answer-why,
.answer-detail {
  margin: 10px 0 0;
  font-size: 0.9375rem;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.answer-detail {
  margin-top: 2px;
}

.answer-meta {
  margin: 18px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.answer.is-busy .answer-line {
  opacity: 0.45;
}

/* --- Formulario --- */

.form {
  display: flex;
  flex-direction: column;
  gap: 40px;
  min-width: 0;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.section-title {
  margin: 0 0 16px;
  padding: 0;
  font-size: 1.25rem;
  font-weight: 700;
  font-stretch: 85%;
}

.hint {
  margin: -8px 0 16px;
  font-size: 0.875rem;
  color: var(--ink-soft);
  max-width: 60ch;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
  gap: 16px 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span,
.label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-soft);
}

input[type="text"],
select,
textarea {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 1rem;
}

textarea {
  height: auto;
  min-height: 7rem;
  padding: 10px 12px;
  resize: vertical;
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: var(--ink-soft);
  opacity: 0.75;
}

input:disabled {
  opacity: 0.6;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: flex-end;
  margin-bottom: 16px;
}

/* Segmentos (formato, unidad) */
.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.seg label {
  position: relative;
}

.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg span {
  display: block;
  min-width: 3.25rem;
  padding: 8px 14px;
  border-radius: 9px;
  text-align: center;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.seg input:checked + span {
  background: var(--accent);
  color: var(--on-accent);
}

.seg input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}

/* Radios y casillas dibujados aqui: el control nativo trae fondo blanco puro.
   Borde --ink-soft (>= 3:1 sobre el fondo, como pide WCAG para controles). */
.check input,
.pick input {
  -webkit-appearance: none;
  appearance: none;
  display: inline-grid;
  place-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 1.5px solid var(--ink-soft);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
}

.check input {
  border-radius: 5px;
}

.pick input:checked {
  border-color: var(--focus);
  background: var(--focus);
  box-shadow: inset 0 0 0 4px var(--surface);
}

.check input:checked {
  border-color: var(--focus);
  background: var(--focus);
}

.check input::before {
  content: "";
  width: 12px;
  height: 12px;
  background: var(--surface);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  transform: scale(0);
}

.check input:checked::before {
  transform: scale(1);
}

/* Asientos */
.seats {
  --cols: 3.5rem minmax(0, 1fr) 2.75rem 2.75rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 36rem;
}

.seats.show-committed {
  --cols: 3.5rem minmax(0, 1fr) minmax(0, 1fr) 2.75rem 2.75rem;
}

.seats.show-bounty {
  --cols: 3.5rem minmax(0, 1fr) minmax(0, 1fr) 2.75rem 2.75rem;
}

.seats.show-committed.show-bounty {
  --cols: 3.5rem minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 0.8fr) 2.75rem 2.75rem;
}

.seat,
.seat-head {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 8px;
  align-items: center;
}

.seat-head {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.seat-head span:nth-last-child(-n + 2) {
  text-align: center;
}

.seat input[type="text"] {
  height: 40px;
  padding: 0 10px;
}

.seat-n {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  font-weight: 700;
}

.seat-n small {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-soft);
  min-height: 1em;
}

.seat.is-hero .seat-n {
  color: var(--focus);
}

.col-committed,
.col-bounty {
  display: none;
}

.show-committed .col-committed,
.show-bounty .col-bounty {
  display: block;
}

.pick {
  display: grid;
  place-items: center;
  height: 40px;
}

/* Plegables */
details {
  margin-top: 12px;
}

summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 120ms ease-out;
}

details[open] > summary::before {
  transform: rotate(45deg);
}

.fold-body {
  padding: 8px 0 4px;
}

/* Cartas */
.cards-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.cards-row .field {
  flex: 1 1 auto;
  max-width: 16rem;
}

.preview {
  display: flex;
  gap: 6px;
  min-height: 44px;
  align-items: center;
  font-size: 1.375rem;
  font-weight: 700;
  font-stretch: 85%;
}

.preview .card {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.preview .red {
  color: var(--suit-red);
}

.preview .bad {
  color: var(--warn);
  font-size: 1rem;
  font-weight: 500;
}

/* Botones */
.btn {
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  flex: 1 1 auto;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.125rem;
  font-weight: 700;
}

.btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

.actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  gap: 12px;
  margin: -16px -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

@media (min-width: 960px) {
  .actions {
    position: static;
    margin: 0;
    padding: 0;
    border-top: 0;
  }

  .btn-primary {
    flex: 0 1 18rem;
  }
}

/* Spots de prueba */
.tests {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.tests .row {
  margin: 12px 0 0;
}

.tests select {
  flex: 1 1 16rem;
}

.small {
  margin: 10px 0 0;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.ok {
  color: var(--go);
}

.bad-text {
  color: var(--warn);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.row-top {
  margin-top: 16px;
}

.narrow {
  max-width: 16rem;
}

.hint.flush {
  margin-top: 0;
}

.seat-head span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 420px) {
  .seats {
    --cols: 2.75rem minmax(0, 1fr) 2.125rem 2.125rem;
  }

  .seats.show-committed,
  .seats.show-bounty {
    --cols: 2.75rem minmax(0, 1fr) minmax(0, 1fr) 2.125rem 2.125rem;
  }

  .seats.show-committed.show-bounty {
    --cols: 2.75rem repeat(3, minmax(0, 1fr)) 2.125rem 2.125rem;
  }

  .seat,
  .seat-head {
    gap: 5px;
  }

  .seat-head {
    font-size: 0.75rem;
  }

  .seat input[type="text"] {
    padding: 0 6px;
  }
}

.btn-retry {
  margin-top: 16px;
  border-color: var(--warn);
  color: var(--warn);
}

/* Pliegue con datos: no se puede plegar (folds.js) y lo dice. */
.badge {
  padding: 1px 8px;
  border: 1px solid var(--focus);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--focus);
}

details[data-filled] > summary {
  cursor: default;
}

details[data-filled] > summary::before {
  opacity: 0.35;
}

/* Asiento elegido como all-in: lo escrito se conserva, tachado y deshabilitado. */
.seat.is-allin [data-k="stack"],
.seat.is-allin [data-k="committed"] {
  text-decoration: line-through;
}
