/*
 * components.css — componentes da Arenna portados para a web (Fase 2).
 * Só usa variáveis de tokens.css. Sem transição nem animação até a Fase 7.
 * Origem de cada componente: DESIGN.md §8.
 */

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

html {
  background: var(--role-page-bg);
  color: var(--role-text);
  font-family: var(--font-body);
  font-size: var(--text-body1-size);
  line-height: var(--text-body1-lh);
  letter-spacing: var(--text-body1-ls);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}
body { margin: var(--space-0); }

::selection { background: var(--role-accent-fill); color: var(--role-on-accent); }
:focus-visible { outline: var(--border-width-strong) solid var(--role-focus); outline-offset: var(--border-width-strong); }
html { scrollbar-color: var(--role-surface-2) var(--role-page-bg); caret-color: var(--role-text); }

a { color: var(--role-link); text-decoration-color: var(--role-accent-fill); text-decoration-thickness: var(--border-width-strong); text-underline-offset: var(--space-4); }
a:hover { text-decoration-color: currentColor; }

/* --- Ícone (Material Icons Filled, SVG) --------------------------------- */
.icon { width: var(--size-icon); height: var(--size-icon); flex: none; fill: currentColor; }
.icon--sm { width: var(--size-icon-sm); height: var(--size-icon-sm); }
.icon--inline { width: var(--size-icon-inline); height: var(--size-icon-inline); }

/* --- Tipografia ---------------------------------------------------------- */
.t-display-1 { font-family: var(--font-display); font-weight: var(--weight-display); font-size: var(--text-display-1-size); line-height: var(--text-display-1-lh); letter-spacing: var(--text-display-1-ls); text-wrap: balance; margin: var(--space-0); }
.t-display-2 { font-family: var(--font-display); font-weight: var(--weight-display); font-size: var(--text-display-2-size); line-height: var(--text-display-2-lh); letter-spacing: var(--text-display-2-ls); text-wrap: balance; margin: var(--space-0); }
.t-h4 { font-weight: var(--weight-bold); font-size: var(--text-h4-size); line-height: var(--text-h4-lh); letter-spacing: var(--text-h4-ls); margin: var(--space-0); }
.t-h5 { font-weight: var(--weight-bold); font-size: var(--text-h5-size); line-height: var(--text-h5-lh); letter-spacing: var(--text-h5-ls); margin: var(--space-0); }
.t-h6 { font-weight: var(--weight-bold); font-size: var(--text-h6-size); line-height: var(--text-h6-lh); letter-spacing: var(--text-h6-ls); margin: var(--space-0); }
.t-lead { font-size: var(--text-lead-size); line-height: var(--text-lead-lh); color: var(--role-text-2); max-width: var(--measure-lead); text-wrap: pretty; margin: var(--space-0); }
.t-body { font-size: var(--text-body1-size); line-height: var(--text-body1-lh); letter-spacing: var(--text-body1-ls); max-width: var(--measure); text-wrap: pretty; margin: var(--space-0); }
.t-body-2 { font-size: var(--text-body2-size); line-height: var(--text-body2-lh); letter-spacing: var(--text-body2-ls); margin: var(--space-0); }
.t-caption { font-size: var(--text-caption-size); line-height: var(--text-caption-lh); letter-spacing: var(--text-caption-ls); margin: var(--space-0); }
.t-label { font-size: var(--text-caption-size); line-height: var(--text-caption-lh); letter-spacing: var(--text-caption-ls); font-weight: var(--weight-bold); text-transform: uppercase; color: var(--role-label); margin: var(--space-0); }
.t-num { font-variant-numeric: tabular-nums; }

/* --- Botões · DS/components/button/PrimaryButton.kt, SecondaryButton.kt --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-8);
  min-height: var(--size-button-h);
  padding: var(--space-8) var(--space-24);
  border: var(--space-0); border-radius: var(--radius-button);
  font: inherit; font-weight: var(--weight-bold);
  font-size: var(--text-subtitle1-size); line-height: var(--text-subtitle1-lh); letter-spacing: var(--text-subtitle1-ls);
  text-decoration: none; cursor: pointer;
}
.btn--primary { background: var(--role-accent-fill); color: var(--role-on-accent); }
.btn--primary:hover { background: color-mix(in srgb, var(--role-accent-fill), var(--role-on-accent) calc(var(--alpha-tint) * 100%)); }
.btn--secondary { background: transparent; color: var(--role-text); border: var(--border-width) solid var(--role-control-border); }
.btn--secondary:hover { background: color-mix(in srgb, var(--role-accent-fill) calc(var(--alpha-tint-strong) * 100%), transparent); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--role-surface-2); color: var(--role-text-3); border-color: transparent; cursor: not-allowed; }
.btn--secondary:disabled { background: transparent; }
.btn[aria-busy="true"] { cursor: progress; }
.btn__spinner { width: var(--size-icon-sm); height: var(--size-icon-sm); border-radius: var(--radius-full); border: var(--border-width-strong) solid currentColor; border-right-color: transparent; }

/* --- Card · DS/components/card/ArennaCard.kt ----------------------------- */
.card {
  background: var(--role-surface);
  border: var(--border-width) solid var(--role-border);
  border-radius: var(--radius-24);
  padding: var(--space-16);
}
.card--accent {
  background: color-mix(in srgb, var(--role-accent-fill) calc(var(--alpha-tint) * 100%), var(--role-surface));
  border-color: var(--role-accent-fill);
}
.card--hero {
  background:
    radial-gradient(circle at 0% 0%,
      color-mix(in srgb, var(--role-accent-fill) calc(var(--alpha-tint-strong) * 100%), transparent),
      color-mix(in srgb, var(--role-accent-fill) calc(var(--alpha-tint-weak) * 100%), transparent)),
    var(--role-surface);
  border: var(--border-width-strong) solid var(--role-accent-fill);
}
.kpi__value { font-weight: var(--weight-bold); font-size: var(--text-h6-size); line-height: var(--text-h6-lh); letter-spacing: var(--text-h6-ls); margin: var(--space-4) var(--space-0) var(--space-0); }
.kpi__value--hero { font-size: var(--text-h3-size); line-height: var(--text-h3-lh); letter-spacing: var(--text-h3-ls); }
.kpi__sub { font-size: var(--text-caption-size); line-height: var(--text-caption-lh); letter-spacing: var(--text-caption-ls); color: var(--role-text-3); margin: var(--space-4) var(--space-0) var(--space-0); }
.card--hero .t-label { color: var(--role-label); }

/* --- Card de seção · DS/components/card/SectionCard.kt ------------------- */
.section-card {
  display: flex; align-items: center; gap: var(--space-12);
  background: var(--role-surface);
  border: var(--border-width) solid var(--role-border);
  border-radius: var(--radius-16);
  padding: var(--space-16);
  color: var(--role-text); text-decoration: none;
}
a.section-card:hover { border-color: var(--role-control-border); }
.section-card__icon {
  display: grid; place-items: center; flex: none;
  width: var(--size-icon-box); height: var(--size-icon-box);
  border-radius: var(--radius-12);
  background: color-mix(in srgb, var(--role-accent-fill) calc(var(--alpha-tint-strong) * 100%), transparent);
  color: var(--role-text);
}
.section-card__body { flex: 1; min-width: 0; }
.section-card__title, .section-card__sub { display: block; }
.section-card__title { font-weight: var(--weight-bold); font-size: var(--text-subtitle1-size); line-height: var(--text-subtitle1-lh); letter-spacing: var(--text-subtitle1-ls); margin: var(--space-0); }
.section-card__sub { font-size: var(--text-caption-size); line-height: var(--text-caption-lh); letter-spacing: var(--text-caption-ls); color: var(--role-text-3); margin: var(--space-4) var(--space-0) var(--space-0); }
.section-card__chevron { color: var(--role-text-3); }
.section-card[aria-disabled="true"] { opacity: var(--alpha-disabled); pointer-events: none; }

/* --- Input · DS/components/textfield/TextField.kt ------------------------ */
.field { display: grid; gap: var(--space-4); }
.field__label { font-weight: var(--weight-bold); font-size: var(--text-caption-size); line-height: var(--text-caption-lh); letter-spacing: var(--text-caption-ls); color: var(--role-text-2); }
.field__control {
  width: 100%;
  min-height: var(--size-action-h);
  padding: var(--space-12) var(--space-16);
  background: transparent;
  border: var(--border-width) solid var(--role-control-border);
  border-radius: var(--radius-input);
  color: var(--role-text);
  font: inherit; font-size: var(--text-subtitle1-size); line-height: var(--text-subtitle1-lh); letter-spacing: var(--text-subtitle1-ls);
}
textarea.field__control { resize: vertical; min-height: calc(var(--size-action-h) * 2); }
.field__control::placeholder { color: var(--role-text-3); opacity: 1; }
.field__control:hover { border-color: var(--role-text-2); }
.field__control:focus { outline: none; border-color: var(--role-text); box-shadow: 0 0 0 var(--border-width) var(--role-text); }
.field__control[aria-invalid="true"] { border-color: var(--role-error); }
.field__control[aria-invalid="true"]:focus { box-shadow: 0 0 0 var(--border-width) var(--role-error); }
.field__error { display: flex; align-items: center; gap: var(--space-4); color: var(--role-error); font-size: var(--text-caption-size); line-height: var(--text-caption-lh); letter-spacing: var(--text-caption-ls); }
.field__control:disabled { opacity: var(--alpha-disabled); cursor: not-allowed; }

/* --- Chip · DS/components/chip/ChoiceChip.kt ----------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: var(--space-4);
  min-height: var(--size-chip-min-h);
  padding: var(--space-0) var(--space-12);
  border: var(--space-0); border-radius: var(--radius-12);
  background: var(--role-surface-2);
  color: var(--role-text);
  font: inherit; font-weight: var(--weight-bold);
  font-size: var(--text-subtitle2-size); line-height: var(--text-subtitle2-lh); letter-spacing: var(--text-subtitle2-ls);
}
.chip[aria-pressed="true"] { background: var(--role-accent-fill); color: var(--role-on-accent); }
button.chip { cursor: pointer; }

/* --- Pílula · DS/components/pill/LabelPill.kt ---------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-full);
  font-weight: var(--weight-bold);
  font-size: var(--text-caption-size); line-height: var(--text-caption-lh); letter-spacing: var(--text-caption-ls);
  white-space: nowrap;
}
.pill--brand   { background: color-mix(in srgb, var(--role-accent-fill) calc(var(--alpha-tint-strong) * 100%), transparent); color: var(--role-text); }
.pill--error   { background: color-mix(in srgb, var(--role-error) calc(var(--alpha-tint-error) * 100%), transparent); color: var(--role-error); }
.pill--neutral { background: color-mix(in srgb, var(--role-text) calc(var(--alpha-tint-neutral) * 100%), transparent); color: var(--role-text-2); }

/* --- Grid e container [ext] ---------------------------------------------- */
.container { width: calc(100% - var(--grid-margin) * 2); max-width: var(--container-max); margin-inline: auto; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: var(--grid-gutter); }
@media (min-width: 768px)  { .grid { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr)); } }
.section { padding-block: var(--space-section); }
.divider { border: var(--space-0); border-top: var(--border-width) solid var(--role-border); margin: var(--space-0); }

/* --- Dobra invertida (fechamento em azul-marinho) ----------------------- */
.inverse { background: var(--role-inverse-bg); color: var(--role-inverse-text); }
.inverse .t-lead, .inverse .t-body, .inverse .t-body-2 { color: var(--role-inverse-text-2); }
.inverse .t-label { color: var(--role-inverse-accent); }
.inverse a:not(.btn) { color: var(--role-inverse-text); }
.inverse :focus-visible { outline-color: var(--role-inverse-accent); }
.inverse .btn--secondary { color: var(--role-inverse-text); border-color: var(--role-inverse-text-2); }

.visually-hidden { position: absolute; width: var(--space-1px); height: var(--space-1px); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Movimento (Fase 7) ---------------------------------------------------
 * Cada transição tem uma função (DESIGN.md §10):
 * - botão: scale 0.97 no :active = feedback de que o clique foi ouvido (160 ms, ease-out)
 * - botão/link: troca de cor no hover = mostra que é clicável (200 ms, ease)
 * - input: borda no foco = mostra onde está o cursor (200 ms)
 * Hover só com ponteiro fino (no toque o hover dispara no tap).
 */
.btn { transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-ui) ease, color var(--dur-ui) ease, border-color var(--dur-ui) ease; }
.btn:active:not(:disabled) { transform: scale(0.97); }
a { transition: text-decoration-color var(--dur-ui) ease, color var(--dur-ui) ease; }
.field__control { transition: border-color var(--dur-ui) ease, box-shadow var(--dur-ui) ease; }
@media not (hover: hover) {
  .btn--primary:hover { background: var(--role-accent-fill); }
  .btn--secondary:hover { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .btn:active:not(:disabled) { transform: none; }
}
.field__error[hidden] { display: none; }
