/* ==========================================================================
   Credenciamento 2026 — Presencial
   Hero único, centralizado, com campo de CPF e retorno em QR Code
   Estilo: Glassmorphism Moderno & Premium (ver docs/design-system.md)
   ========================================================================== */

/* ------------------------------------------------------------------ Tokens */
:root {
  /* Cores base */
  --color-primary-900: #003456;
  --color-primary-700: #195181;
  --color-primary-600: #1f69a8;
  --color-primary-500: #388ecc;
  --color-primary-300: #56aee2;
  --color-white: #ffffff;
  --color-gray-300: #cac9c9;

  /* Semânticos */
  --bg-base: linear-gradient(135deg, #003456 0%, #382f2a 100%);
  --text-primary: #ffffff;
  --text-secondary: #cac9c9;
  --text-muted: #979797;
  --border-glass: rgba(255, 255, 255, 0.18);
  --accent-premium: #c2b067;
  --focus-ring: #56aee2;

  /* Tipografia */
  --font-display: 'NORD', 'Montserrat', sans-serif;
  --font-body: 'Montserrat', system-ui, sans-serif;

  /* Espaçamento (base 4px) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radius */
  --radius-card: 20px;
  --radius-input: 12px;
  --radius-pill: 999px;
}

/* ------------------------------------------------------------------ Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ================================================================== HERO == */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(28px, 5vw, 64px) clamp(16px, 5vw, 64px);
}

.hero__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
}

.hero__overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(ellipse at center,
      rgba(0, 18, 34, 0.58) 0%,
      rgba(0, 18, 34, 0.82) 100%),
    linear-gradient(to bottom,
      rgba(0, 18, 34, 0.5) 0%,
      rgba(0, 18, 34, 0.3) 45%,
      rgba(0, 18, 34, 0.62) 100%);
}

/* margin auto no eixo vertical centraliza sem cortar o topo quando o conteúdo
   fica mais alto que a viewport (estado com o QR Code) */
.hero__inner {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 580px;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(18px, 2.6vw, 28px);
}

/* --- Logos: Presencial + selo de 10 anos --- */
.hero__logos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2.6vw, 24px);
}

/* Dimensionados pela altura para os dois blocos ficarem na mesma linha óptica */
.hero__logo--presencial {
  height: clamp(44px, 11vw, 64px);
  width: auto;
}

.hero__logo--anos {
  height: clamp(58px, 14.5vw, 84px);
  width: auto;
}

.hero__logos-sep {
  width: 1px;
  align-self: stretch;
  background: linear-gradient(to bottom,
    rgba(194, 176, 103, 0) 0%,
    rgba(194, 176, 103, 0.65) 50%,
    rgba(194, 176, 103, 0) 100%);
}

/* --- Título + apoio --- */
.hero__heading {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.hero__title {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22em;
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-shadow: 0 2px 28px rgba(0, 14, 28, 0.7), 0 1px 2px rgba(0, 14, 28, 0.55);
  /* fallback: o @supports abaixo ajusta a palavra à largura real do container */
  font-size: clamp(1.4rem, 7.4vw, 2.6rem);
}

/* "CREDENCIAMENTO" é uma palavra longa: escalar pelo container evita que ela
   encoste nas bordas ou quebre em duas linhas */
@supports (font-size: 1cqw) {
  .hero__heading {
    container-type: inline-size;
  }

  .hero__title {
    font-size: clamp(1.4rem, 7.7cqw, 2.85rem);
  }
}

.hero__title-lead {
  white-space: nowrap;
}

/* o "2026" em Montserrat (os dígitos da NORD são pouco legíveis), com filetes
   dourados preenchendo a largura restante */
.hero__title-year {
  display: flex;
  align-items: center;
  gap: clamp(10px, 2.4vw, 18px);
  font-family: var(--font-body);
  font-weight: 900;
  font-size: 0.74em;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  color: var(--accent-premium);
}

.hero__title-year::before,
.hero__title-year::after {
  content: '';
  flex: 0 0 clamp(26px, 7vw, 58px);
  height: 2px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg,
    rgba(194, 176, 103, 0) 0%,
    rgba(194, 176, 103, 0.75) 100%);
}

.hero__title-year::after {
  background: linear-gradient(90deg,
    rgba(194, 176, 103, 0.75) 0%,
    rgba(194, 176, 103, 0) 100%);
}

.hero__lead {
  max-width: 28rem;
  font-size: clamp(0.92rem, 1.5vw, 1.05rem);
  font-weight: 500;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.84);
  text-shadow: 0 1px 14px rgba(0, 14, 28, 0.7);
}

.hero__lead strong {
  color: var(--accent-premium);
  font-weight: 800;
}

.hero__legal {
  font-size: clamp(0.62rem, 1.1vw, 0.72rem);
  font-weight: 500;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.58);
}

/* ============================================= CARD DE CREDENCIAMENTO == */
.glass-card {
  background: rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-card);
  box-shadow:
    0 8px 32px rgba(0, 20, 40, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.credencial {
  width: 100%;
  padding: clamp(20px, 4vw, 32px);
  text-align: left;
}

/* ------------------------------------------------------- Formulário (CPF) */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form[hidden],
.result[hidden] {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.field__label .req {
  color: var(--accent-premium);
}

.input {
  width: 100%;
  padding: var(--space-4);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  background: rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-input);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

/* CPF: centralizado e espaçado, para leitura/conferência rápida */
.input--cpf {
  text-align: center;
  font-size: clamp(1.1rem, 4.4vw, 1.4rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.input::placeholder {
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.06em;
}

.input:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px rgba(86, 174, 226, 0.25);
}

.field__error {
  font-size: 13px;
  color: #ff9a8b;
  display: none;
}

.field.is-invalid .field__error {
  display: block;
}

.field.is-invalid .input {
  border-color: #ff9a8b;
}

.form__note {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.form__feedback,
.result__feedback {
  font-size: 14px;
  text-align: center;
  padding: var(--space-3);
  border-radius: var(--radius-input);
  display: none;
}

.form__feedback.is-success,
.result__feedback.is-success {
  display: block;
  background: rgba(56, 142, 204, 0.18);
  border: 1px solid var(--color-primary-300);
  color: var(--color-primary-300);
}

.form__feedback.is-error,
.result__feedback.is-error {
  display: block;
  background: rgba(255, 154, 139, 0.14);
  border: 1px solid #ff9a8b;
  color: #ff9a8b;
}

/* ------------------------------------------------ Retorno: QR Code + link */
.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-4);
  animation: result-in 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes result-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.result__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  background: rgba(0, 175, 17, 0.16);
  border: 1px solid rgba(62, 224, 77, 0.45);
  color: #3ee04d;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* O container recebe <canvas> ou <img> gerados pela lib de QR */
.result__qr {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(248px, 72vw);
  aspect-ratio: 1 / 1;
  padding: var(--space-3);
  border-radius: var(--radius-input);
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 20, 40, 0.35);
}

.result__qr canvas,
.result__qr img {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.result__qr table {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
}

.result__hint {
  max-width: 28rem;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.result__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  border: 1px solid rgba(194, 176, 103, 0.5);
  background: rgba(194, 176, 103, 0.12);
  color: var(--accent-premium);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
  transition: background 200ms ease;
}

.result__link:hover {
  background: rgba(194, 176, 103, 0.22);
}

.result__link[hidden] {
  display: none;
}

.result__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
}

/* ---------------------------------------------------------------- Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  border: none;
  border-radius: var(--radius-input);
  padding: var(--space-4) var(--space-6);
  transition: background 200ms ease-out, transform 200ms ease-out, box-shadow 200ms ease-out;
}

.btn--gold {
  background: #00AF11;
  color: var(--color-white);
  box-shadow: 0 4px 16px rgba(0, 20, 40, 0.25);
}

.btn--gold:hover {
  background: #009A0F;
  transform: translateY(-2px);
  box-shadow: 0 0 24px rgba(0, 175, 17, 0.45);
}

.btn--ghost {
  flex: 1 1 auto;
  min-width: 140px;
  padding: var(--space-3) var(--space-4);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.16);
}

.btn--print {
  background: #00AF11;
  border-color: #00AF11;
  color: var(--color-white);
}

.btn--print:hover {
  background: #009A0F;
}

.btn:disabled {
  background: rgba(151, 151, 151, 0.3);
  color: var(--text-secondary);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn:focus-visible,
.input:focus-visible,
.result__link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ============================================================= Responsivo == */
@media (max-width: 599px) {
  .hero {
    padding: var(--space-6) var(--space-4);
  }

  .result__actions .btn--ghost {
    flex: 1 1 100%;
  }
}

/* Fallback sem suporte a backdrop-filter */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass-card {
    background: rgba(0, 52, 86, 0.85);
  }
  .input {
    background-color: rgba(0, 52, 86, 0.6);
  }
}

/* ============================================================== Impressão == */
.print-sheet {
  display: none;
}

@media print {
  @page {
    margin: 1.5cm;
  }

  body {
    background: #ffffff;
  }

  /* Na impressão, só a folha com o QR Code aparece */
  body > *:not(.print-sheet) {
    display: none !important;
  }

  .print-sheet {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-top: 1cm;
    color: #003456;
    font-family: var(--font-body);
  }

  .print-sheet__title {
    font-size: 20pt;
    font-weight: 800;
  }

  .print-sheet__subtitle {
    margin-top: 2pt;
    font-size: 12pt;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
  }

  .print-sheet__qr {
    display: block;
    width: 9cm;
    height: 9cm;
    margin: 1cm 0 0.6cm;
  }

  .print-sheet__hint {
    font-size: 11pt;
  }
}

/* Reduzir movimento */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
