/* ezis — componentes reutilizáveis */

@layer components {
  /* ---- Skip link ---- */
  .skip-link {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: var(--z-skip);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-pill);
    background: var(--brand-navy);
    color: var(--brand-white);
    font-weight: var(--weight-label);
    text-decoration: none;
    transform: translateY(-200%);
  }

  .skip-link:focus {
    transform: none;
    outline-color: var(--brand-neon);
  }

  /* ---- Ícones: traço, sem preenchimento (manual p. 37) ---- */
  .icon {
    width: 1.5rem;
    height: 1.5rem;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: var(--icon-stroke);
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .icon--lg {
    width: 2rem;
    height: 2rem;
  }

  /* Seta da marca: peça do símbolo, sem rotação nem distorção. */
  .chevron {
    flex: none;
    fill: var(--graphic);
  }

  /* ---- Rótulo ---- */
  .eyebrow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    color: var(--detail);
    font-size: var(--text-label);
    font-weight: var(--weight-label);
    line-height: 1.4;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
  }

  .eyebrow__index {
    color: var(--text);
  }

  .eyebrow__index::after {
    content: "";
    display: inline-block;
    width: var(--space-6);
    height: 1px;
    margin-left: var(--space-3);
    background: currentColor;
    vertical-align: middle;
  }

  /* ---- Cabeçalho de seção ---- */
  .section-head {
    max-width: 52rem;
    margin-bottom: var(--space-8);
  }

  .section-head > * + * {
    margin-top: var(--space-5);
  }

  .section-head__title {
    font-size: var(--text-h2);
  }

  .lead {
    font-size: var(--text-lead);
    font-weight: var(--weight-subtitle);
    line-height: 1.45;
  }

  .muted {
    color: var(--text-muted);
  }

  /* ---- Botões ---- */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 3rem;
    padding: var(--space-2) var(--space-5);
    border: 1.5px solid transparent;
    border-radius: var(--radius-pill);
    font-size: 1rem;
    font-weight: var(--weight-subtitle);
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    transition:
      background-color var(--dur-fast) var(--ease),
      border-color var(--dur-fast) var(--ease),
      color var(--dur-fast) var(--ease);
  }

  .btn--primary {
    background: var(--accent);
    color: var(--accent-contrast);
  }

  .btn--primary:hover {
    background: var(--btn-hover-bg);
    color: var(--btn-hover-text);
  }

  .btn--secondary {
    border-color: currentColor;
    background: transparent;
    color: var(--text);
  }

  .btn--secondary:hover {
    border-color: var(--text);
    background: var(--text);
    color: var(--bg);
  }

  .btn--cta {
    min-height: 2.75rem;
    background: var(--cta-bg);
    color: var(--cta-text);
    font-size: 0.9375rem;
  }

  .btn--cta:hover {
    background: var(--cta-hover-bg);
    color: var(--cta-hover-text);
  }

  .btn[aria-disabled="true"],
  .btn:disabled {
    cursor: progress;
    opacity: 0.7;
  }

  .btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
  }

  /* ---- Cartão ---- */
  .card {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-6);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--card-bg);
    --text-muted: var(--text-muted-on-surface);
    --detail: var(--detail-on-surface);
  }

  .card--outline {
    border-color: var(--divider);
    background: transparent;
  }

  .card__icon {
    color: var(--icon);
  }

  .card__title {
    font-size: var(--text-h3);
    font-weight: var(--weight-label);
  }

  .card__foot {
    margin-top: auto;
    padding-top: var(--space-4);
    border-top: 1px solid var(--divider);
  }

  .section--surface {
    --card-bg: var(--bg);
  }

  /* ---- Lista com marcador da marca ---- */
  .list-mark {
    display: grid;
    gap: var(--space-2);
  }

  .list-mark > li {
    position: relative;
    padding-left: var(--space-5);
  }

  .list-mark > li::before {
    content: "";
    position: absolute;
    top: 0.72em;
    left: 0;
    width: var(--space-3);
    height: 1.5px;
    background: var(--detail);
  }

  /* ---- Etiqueta de estado ---- */
  .tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    align-self: flex-start;
    padding: 0.3rem var(--space-3);
    border: 1px solid var(--field-border);
    border-radius: var(--radius-pill);
    color: var(--text);
    font-size: var(--text-label);
    font-weight: var(--weight-label);
    line-height: 1.3;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  /* ---- Leitura de dado: rótulo + valor ---- */
  .readout {
    display: grid;
    gap: var(--space-1);
  }

  .readout__label {
    color: var(--text-muted);
    font-size: var(--text-label);
    font-weight: var(--weight-label);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
  }

  .readout__value {
    font-size: var(--text-h3);
    font-weight: var(--weight-label);
    line-height: 1.2;
  }

  /* ---- Placeholder visível para dados pendentes ---- */
  .placeholder {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-5);
    border: 1.5px dashed var(--field-border);
    border-radius: var(--radius-md);
  }

  .placeholder__value {
    font-size: var(--text-h3);
    font-weight: var(--weight-label);
    line-height: 1.2;
  }

  /* ---- Formulário ---- */
  .field {
    display: grid;
    gap: var(--space-2);
  }

  .field__label {
    font-size: var(--text-small);
    font-weight: var(--weight-subtitle);
  }

  .field__optional {
    color: var(--text-muted);
    font-weight: var(--weight-body);
  }

  .field__control {
    width: 100%;
    min-height: 3rem;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    background: var(--field-bg);
    color: var(--text);
  }

  textarea.field__control {
    min-height: 9rem;
    resize: vertical;
  }

  .field__control:focus-visible {
    outline-offset: 1px;
  }

  .field__control[aria-invalid="true"] {
    border: 2px solid var(--signal-negative);
  }

  .field__error {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-small);
    font-weight: var(--weight-subtitle);
  }

  .field__error::before {
    content: "";
    flex: none;
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    background: var(--signal-negative);
  }

  .form-status {
    padding: var(--space-4);
    border-left: 3px solid var(--detail);
    border-radius: var(--radius-sm);
    background: var(--field-bg);
  }

  .form-status[data-state="error"] {
    border-left-color: var(--signal-negative);
  }

  /* ---- Cabeçalho do site ---- */
  .site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    border-bottom: 1px solid var(--divider);
    background: var(--bg);
    color: var(--text);
  }

  html:not(.js) .site-header {
    position: static;
  }

  .site-header__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--logo-clear);
    min-height: var(--header-h);
  }

  .logo {
    display: block;
    flex: none;
    /* área de proteção x em volta do logo (manual p. 9) */
    margin-block: var(--logo-clear);
    margin-inline-start: max(0px, var(--logo-clear) - var(--gutter));
    border-radius: 2px;
  }

  .logo svg {
    width: auto;
    height: var(--logo-height);
  }

  .logo__wordmark {
    fill: var(--logo-wordmark);
  }

  .logo__symbol {
    fill: var(--logo-symbol);
  }

  .site-header__tools {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
  }

  .icon-btn {
    display: inline-grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
  }

  .icon-btn:hover {
    background: var(--surface);
  }

  html:not(.js) .icon-btn[data-requires-js] {
    display: none;
  }

  .theme-toggle .icon--moon,
  .theme-toggle[aria-pressed="true"] .icon--sun {
    display: block;
  }

  .theme-toggle .icon--sun,
  .theme-toggle[aria-pressed="true"] .icon--moon {
    display: none;
  }

  .nav-toggle .icon--close,
  .nav-toggle[aria-expanded="true"] .icon--menu {
    display: none;
  }

  .nav-toggle[aria-expanded="true"] .icon--close {
    display: block;
  }

  .nav {
    flex-basis: 100%;
    order: 3;
    padding-bottom: var(--space-5);
  }

  .js .nav {
    display: none;
  }

  .js .nav.is-open {
    display: block;
  }

  .nav__list {
    display: grid;
    margin: 0;
  }

  .nav__link {
    display: flex;
    align-items: center;
    min-height: 3rem;
    border-bottom: 1px solid var(--divider);
    font-weight: var(--weight-subtitle);
    text-decoration: none;
  }

  .nav__link:hover,
  .nav__link[aria-current="true"] {
    color: var(--detail);
  }

  .nav__cta {
    width: 100%;
    margin-top: var(--space-5);
  }

  .site-header__cta {
    display: none;
  }

  @media (min-width: 40rem) {
    .site-header__cta {
      display: inline-flex;
    }

    .nav__cta {
      display: none;
    }
  }

  @media (min-width: 72rem) {
    .nav,
    .js .nav {
      display: block;
      flex: 1;
      flex-basis: auto;
      order: 0;
      padding-bottom: 0;
    }

    .nav__list {
      display: flex;
      justify-content: center;
      gap: clamp(var(--space-4), 2vw, var(--space-6));
    }

    .nav__link {
      position: relative;
      min-height: 2.75rem;
      border-bottom: 0;
      font-size: 0.9375rem;
    }

    .nav__link::after {
      content: "";
      position: absolute;
      right: 0;
      bottom: 0.4rem;
      left: 0;
      height: 2px;
      border-radius: 1px;
      background: currentColor;
      transform: scaleX(0);
      transform-origin: left;
      transition: transform var(--dur-base) var(--ease);
    }

    .nav__link:hover::after,
    .nav__link[aria-current="true"]::after {
      transform: scaleX(1);
    }

    .nav-toggle {
      display: none;
    }
  }

  /* ---- Rodapé ---- */
  .site-footer {
    padding-block: var(--space-9) var(--space-6);
    border-top: 1px solid var(--divider);
    background: var(--bg);
    color: var(--text);
    font-size: var(--text-small);
  }

  .site-footer__grid {
    display: grid;
    gap: var(--space-8) var(--grid-gap);
  }

  .site-footer__logo {
    --footer-logo-h: 7.5rem;
    display: block;
    width: fit-content;
    /* x = 57,6% da altura na versão prioritária */
    padding: calc(var(--footer-logo-h) * 0.576);
    margin: calc(var(--footer-logo-h) * -0.576 + var(--space-2));
    margin-bottom: 0;
  }

  .site-footer__logo img {
    width: auto;
    height: var(--footer-logo-h);
  }

  .site-footer__title {
    margin-bottom: var(--space-4);
    color: var(--detail);
    font-size: var(--text-label);
    font-weight: var(--weight-label);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
  }

  .site-footer__list {
    display: grid;
    gap: var(--space-1);
    margin: 0;
  }

  .site-footer__list a {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    text-decoration: none;
  }

  .site-footer__list a:hover {
    text-decoration: underline;
  }

  .site-footer__legal {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-6);
    justify-content: space-between;
    margin-top: var(--space-8);
    padding-top: var(--space-5);
    border-top: 1px solid var(--divider);
    color: var(--text-muted);
  }

  @media (min-width: 48rem) {
    .site-footer__grid {
      grid-template-columns: 1.4fr 1fr 1fr;
    }
  }

  @media (min-width: 68rem) {
    .site-footer__grid {
      grid-template-columns: 1.6fr 0.8fr 1.2fr 1.2fr;
    }
  }
}
