/* ==========================================================================
   Popup de talentos e perícias (TASK_004) — mesmo "Grimório" do app:
   superfícies escuras, ouro para ações, verde (disponível), âmbar (confira),
   brasa (falta requisito).
   ========================================================================== */
.dialog.choices {
  width: min(980px, calc(100vw - 32px));
  font-variant-numeric: lining-nums tabular-nums; /* Alegreya Sans usa algarismos antigos: o 0 parece um o */
  max-height: calc(100dvh - 32px);
  overflow: hidden;
}

/* o atalho "font" dos controles zera font-variant-numeric: reaplica os algarismos alinhados */
.dialog.choices input,
.dialog.choices select,
.dialog.choices button {
  font-variant-numeric: lining-nums tabular-nums;
}

.choices__frame {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 34px);
}

.choices__head {
  padding: var(--sp-5) var(--sp-6) 0;
  border-bottom: 1px solid var(--line);
}

.choices__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
}

.choices__head .dialog__title {
  margin-bottom: var(--sp-1);
}

.choices__who {
  color: var(--gold);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
}

.choices__lead {
  margin: var(--sp-2) 0 var(--sp-4);
  max-width: 70ch;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.choices__tabs {
  display: flex;
  gap: var(--sp-1);
}

.choices__tabs [role='tab'] {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: transparent;
  color: var(--text-muted);
  font: 600 var(--fs-md) var(--font-ui);
  cursor: pointer;
}

.choices__tabs [role='tab'] svg {
  width: 18px;
  height: 18px;
}

.choices__tabs [role='tab'][aria-selected='true'] {
  border-color: var(--line-strong);
  background: var(--surface-1);
  color: var(--gold-bright);
  margin-bottom: -1px;
}

.choices__tabs [role='tab']:focus-visible {
  outline: 2px solid var(--line-focus);
  outline-offset: -2px;
}

.choices__badge {
  padding: 2px var(--sp-2);
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.choices__badge.is-bad {
  background: var(--ember-bg);
  color: var(--ember);
}

.choices__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--sp-5) var(--sp-6);
  background: var(--surface-1);
}

.choices__summary {
  display: grid;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}

.choices__hint,
.choices__granted {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.choices__granted strong {
  color: var(--text);
}

.choices__summary .is-bad,
.choices__status .is-bad {
  color: var(--ember);
}

.choices__check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.choices__check input,
.feat__pick input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.choices__empty {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

/* ---------- Perícias ---------- */
.choices__table-wrap {
  overflow-x: auto;
}

.choices__table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.choices__table th,
.choices__table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.choices__table thead th {
  position: sticky;
  top: calc(-1 * var(--sp-5));
  z-index: 1;
  background: var(--surface-1);
  color: var(--text-dim);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.choices__table tbody th {
  font-weight: 600;
  white-space: normal;
}

.choices__table tr.is-set th {
  color: var(--gold-bright);
}

.choices__table tr.is-locked {
  opacity: 0.55;
}

.choices__untrained {
  margin-left: var(--sp-1);
  color: var(--gold);
  font-size: 0.7em;
}

.choices__tag {
  display: inline-block;
  padding: 1px var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.choices__tag.is-class {
  border-color: var(--verdant-line);
  color: var(--verdant);
}

.choices__tag.is-cross {
  border-color: var(--azure-line);
  color: var(--azure);
}

.choices__tag.is-locked {
  border-color: var(--ember-line);
  color: var(--ember);
}

.choices__total {
  color: var(--gold-bright);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stepper__btn {
  width: 32px;
  height: 32px;
  border: 0;
  background: var(--surface-3);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}

.stepper__btn:hover:not(:disabled) {
  background: var(--surface-4);
  color: var(--gold-bright);
}

.stepper__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stepper__input {
  width: 52px;
  height: 32px;
  border: 0;
  border-inline: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: 700 var(--fs-sm) var(--font-ui);
  text-align: center;
  -moz-appearance: textfield;
}

.stepper__input::-webkit-outer-spin-button,
.stepper__input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.stepper__btn:focus-visible,
.stepper__input:focus-visible {
  outline: 2px solid var(--line-focus);
  outline-offset: -2px;
}

/* ---------- Talentos ---------- */
.choices__slot {
  display: inline-block;
  margin-right: var(--sp-4);
}

.choices__slot strong {
  color: var(--gold-bright);
}

.choices__levels {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.choices__levels li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
}

.choices__level {
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
}

.choices__vaga {
  padding: 1px var(--sp-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: var(--fs-xs);
}

.choices__vaga.is-guerreiro {
  border-color: var(--gold-deep);
}

.choices__vaga.is-mago {
  border-color: var(--arcane-line);
}

.choices__legend {
  display: flex;
  gap: var(--sp-2);
  color: var(--text-dim);
}

.choices__vaga.is-filled {
  border-style: solid;
  background: var(--surface-3);
  color: var(--text);
}

.choices__vaga.is-geral.is-filled {
  border-color: var(--verdant-line);
}

.choices__filters {
  position: sticky;
  top: calc(-1 * var(--sp-5));
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: 0 calc(-1 * var(--sp-6));
  padding: var(--sp-3) var(--sp-6);
  border-block: 1px solid var(--line);
  background: var(--surface-1);
}

.choices__filters select,
.choices__search input {
  height: 38px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: var(--fs-sm) var(--font-ui);
}

.choices__search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 220px;
}

.choices__notice {
  align-items: flex-start;
  font-size: var(--fs-sm);
}

.choices__notice > svg {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--gold);
}

.choices__notice p {
  margin-bottom: var(--sp-2);
}

.choices__vaga small {
  color: var(--gold);
  font-size: 0.85em;
}

.choices__search svg {
  position: absolute;
  left: var(--sp-3);
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}

.choices__search input {
  width: 100%;
  padding-left: calc(var(--sp-3) + 22px);
}

.choices__count {
  margin: var(--sp-3) 0 var(--sp-2);
  color: var(--text-dim);
  font-size: var(--fs-xs);
}

.feats {
  display: grid;
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.feat {
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.feat.is-disponivel { border-left-color: var(--verdant-line); }
.feat.is-confirmar { border-left-color: var(--gold-deep); }
.feat.is-bloqueado { border-left-color: var(--ember-line); }
.feat.is-bloqueado .feat__name { color: var(--text-dim); }
.feat.is-granted { border-left-color: var(--azure-line); }

.feat.is-chosen {
  border-color: var(--line-strong);
  border-left-color: var(--gold);
  background: var(--surface-3);
}

.feat__main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.feat__pick {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
}

.feat__pick input:disabled + .feat__name {
  cursor: not-allowed;
}

.feat__name {
  font-weight: 700;
}

.feat.is-chosen .feat__name {
  color: var(--gold-bright);
}

.feat__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.feat__line {
  min-width: 0;
  font-size: var(--fs-sm);
}

.feat__status {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}

.feat__status svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.feat__status.is-ok { color: var(--verdant); }
.feat__status.is-confirm { color: var(--gold); }
.feat__status.is-blocked { color: var(--ember); }
.feat__status.is-granted { color: var(--azure); }

.feat__params {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-2) 0 0 calc(18px + var(--sp-3));
}

.feat__param {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
}

.feat__param input,
.feat__param select {
  height: 34px;
  min-width: 200px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text);
  font: var(--fs-sm) var(--font-ui);
}

.feat__count {
  color: var(--gold-bright);
  font-weight: 800;
}

.feat__details {
  margin: 2px 0 0 calc(18px + var(--sp-3));
  font-size: var(--fs-sm);
}

/* status + "detalhes" numa linha só: o item ocupa ~2 linhas em vez de 4 */
.feat__details summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  list-style: none;
  cursor: pointer;
}

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

.feat__details summary:focus-visible {
  outline: 2px solid var(--line-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.feat__more {
  flex: none;
  color: var(--text-dim);
  font-size: var(--fs-xs);
}

.feat__more::before {
  content: '▸ ';
}

.feat__details[open] .feat__more::before {
  content: '▾ ';
}

.feat__details dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--sp-1) var(--sp-3);
  margin: var(--sp-2) 0 0;
  color: var(--text-muted);
}

.feat__details dt {
  color: var(--text-dim);
  font-weight: 700;
}

.feat__details dd {
  margin: 0;
}

/* ---------- Rodapé ---------- */
.choices__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-6);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.choices__status {
  flex: 1 1 360px;
  font-size: var(--fs-sm);
}

.choices__status p {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 700;
}

.choices__status svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.choices__status .is-ok { color: var(--verdant); }
.choices__status .is-warn { color: var(--gold); }

.choices__status ul {
  margin: var(--sp-1) 0 0;
  padding-left: var(--sp-5);
  color: var(--text-muted);
}

.choices__actions {
  display: flex;
  gap: var(--sp-2);
}

.choices__max-label {
  display: none;
}

@media (max-width: 640px) {
  /* no celular a introdução sai: título, abas e filtros já ocupam boa parte da tela */
  .choices__lead {
    display: none;
  }

  .choices__head {
    padding-top: var(--sp-4);
  }

  .choices__tabs {
    margin-top: var(--sp-3);
  }

  /* perícias viram cartões: nome e botões em cima; habilidade, tipo, máximo e total embaixo */
  .choices__table thead {
    display: none;
  }

  .choices__table,
  .choices__table tbody {
    display: block;
  }

  .choices__table tr {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-areas: 'name name name step' 'hab tipo max total';
    align-items: center;
    gap: var(--sp-1) var(--sp-3);
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--line);
  }

  .choices__table th,
  .choices__table td {
    padding: 0;
    border: 0;
  }

  .choices__table tbody th { grid-area: name; }
  .choices__table td:nth-child(2) { grid-area: hab; color: var(--text-dim); }
  .choices__table td:nth-child(3) { grid-area: tipo; }
  .choices__table td:nth-child(4) { grid-area: max; color: var(--text-dim); }
  .choices__table td:nth-child(5) { grid-area: step; }
  .choices__table td:nth-child(6) { grid-area: total; justify-self: end; }

  .choices__max-label {
    display: inline;
  }

  .dialog.choices {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .choices__frame {
    max-height: 100dvh;
  }

  .choices__head,
  .choices__body,
  .choices__foot {
    padding-inline: var(--sp-4);
  }

  .choices__filters {
    margin-inline: calc(-1 * var(--sp-4));
    padding-inline: var(--sp-4);
  }

  .choices__tabs [role='tab'] {
    flex: 1;
    justify-content: center;
    padding-inline: var(--sp-2);
    font-size: var(--fs-sm);
  }

  .choices__tabs .choices__badge {
    display: block;
  }

  .choices__actions {
    width: 100%;
  }

  .choices__actions .btn {
    flex: 1;
  }
}
