@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --navy-950: #071b30;
  --navy-900: #0b2c4f;
  --navy-800: #003768; /* navy exato da marca, sampled do logotipo oficial */
  --navy-700: #1a4a7a;
  --blue-500: #0e93d1;
  --blue-400: #29ade0;
  --blue-300: #7cc9ea;
  --blue-100: #e6f5fb;
  --paper: #ffffff;
  --ink: #14263b;
  --ink-soft: #55708a;
  --danger: #c0392b;
  --radius: 18px;
  --shadow-lg: 0 24px 60px -20px rgba(7, 27, 48, 0.55);
  --tap-min: 44px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(41, 173, 224, 0.18), transparent 45%),
    radial-gradient(circle at 85% 100%, rgba(11, 44, 79, 0.55), transparent 55%),
    var(--navy-950);
  display: flex;
  justify-content: center;
  padding: 28px 16px 56px;
}

.wrap {
  width: 100%;
  max-width: 480px;
}

.brand {
  text-align: center;
  margin-bottom: 24px;
  color: var(--paper);
}

.brand-mark {
  display: block;
  height: 40px;
  width: auto;
  margin: 0 auto 12px;
}

.brand h1 {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: clamp(28px, 6.5vw, 38px);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0 auto;
  max-width: 360px;
  color: rgba(247, 249, 252, 0.72);
  font-size: 15px;
  line-height: 1.5;
}

.screen { display: none; }
.screen.active { display: block; animation: fade-up 0.4s ease both; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 26px 22px 24px;
  box-shadow: var(--shadow-lg);
}

.toggle-group {
  display: flex;
  background: rgba(11, 44, 79, 0.06);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 22px;
}

.toggle-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 6px;
  min-height: var(--tap-min);
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.25;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.toggle-btn.active {
  background: var(--navy-900);
  color: var(--blue-400);
  box-shadow: 0 6px 16px -6px rgba(11, 44, 79, 0.5);
}

/* ---- Layout de campos ---- */

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 14px;
}

.field { margin-bottom: 16px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-900);
  margin-bottom: 6px;
}

.optional { font-weight: 400; color: var(--ink-soft); }

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="password"] {
  width: 100%;
  min-height: var(--tap-min);
  padding: 12px 14px;
  border: 1.5px solid rgba(11, 44, 79, 0.15);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

input:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(26, 74, 122, 0.14);
}

input.invalid {
  border-color: var(--danger);
}

.hint {
  display: block;
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--ink-soft);
  min-height: 15px;
}

.hint.error { color: var(--danger); }
.hint.ok { color: #157a3e; }

/* ---- Grupos de campos (fieldset) ---- */

.field-group {
  border: none;
  padding: 0;
  margin: 4px 0 18px;
}

.field-group legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-900);
  padding: 0;
  margin-bottom: 10px;
  width: 100%;
}

.check-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap-min);
  padding: 10px 12px;
  border: 1.5px solid rgba(11, 44, 79, 0.14);
  border-radius: 10px;
  font-size: 14.5px;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.check:has(input:checked) {
  border-color: var(--blue-500);
  background: var(--blue-100);
}

.check input[type="checkbox"],
.check input[type="radio"] {
  width: 19px;
  height: 19px;
  accent-color: var(--blue-500);
  flex-shrink: 0;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-row .check { flex: 1 1 140px; }

.sub-field {
  margin-top: 10px;
  padding-left: 2px;
}

/* ---- Matriculas dinamicas ---- */

.vehicles-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.vehicle-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1.5px solid rgba(11, 44, 79, 0.1);
  border-radius: 12px;
}

.vehicle-row-main {
  display: flex;
  gap: 8px;
  align-items: center;
}

.vehicle-row-insurance {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.check-sm {
  padding: 7px 12px;
  min-height: 36px;
  font-size: 13px;
  gap: 6px;
}
.check-sm input[type="radio"] { width: 16px; height: 16px; }

.vehicle-input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap-min);
  padding: 10px 12px;
  border: 1.5px solid rgba(11, 44, 79, 0.15);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  text-transform: uppercase;
}

.vehicle-input:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(26, 74, 122, 0.14);
}

.btn-remove-vehicle {
  flex-shrink: 0;
  width: var(--tap-min);
  height: var(--tap-min);
  border: 1.5px solid rgba(192, 57, 43, 0.3);
  background: #fff;
  color: var(--danger);
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
}

.btn-add {
  border: 1.5px dashed rgba(11, 44, 79, 0.3);
  background: transparent;
  color: var(--navy-800);
  font-family: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 14px;
  min-height: var(--tap-min);
  border-radius: 10px;
  cursor: pointer;
  width: 100%;
}

/* ---- Contactos adicionais (empresa) ---- */

.field-hint {
  margin: -4px 0 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.additional-contacts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.additional-contact-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.additional-contact-name,
.additional-contact-email {
  flex: 1;
  min-width: 0;
  min-height: var(--tap-min);
  padding: 10px 12px;
  border: 1.5px solid rgba(11, 44, 79, 0.15);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
}

.additional-contact-name:focus,
.additional-contact-email:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(26, 74, 122, 0.14);
}

.btn-add:hover { border-color: var(--blue-500); color: var(--blue-500); }

/* ---- Consentimento / erro / submit ---- */

.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 18px 0 6px;
}

.consent input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--blue-500);
  flex-shrink: 0;
}
.consent a { color: var(--navy-700); font-weight: 600; }

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
}

.btn-primary {
  width: 100%;
  border: none;
  min-height: 52px;
  background: linear-gradient(135deg, var(--blue-400), var(--blue-500));
  color: #ffffff;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 12px 24px -10px rgba(14, 147, 209, 0.55);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary {
  width: 100%;
  min-height: var(--tap-min);
  border: 1.5px solid rgba(247, 249, 252, 0.3);
  background: transparent;
  color: var(--paper);
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 18px;
}

/* --- Convite / landing --- */

/* A animacao fica num wrapper a parte do SVG (nao no SVG diretamente). */
.landing-wheel-spin {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  animation: spin-burst 7s cubic-bezier(0.33, 0.9, 0.3, 1) infinite;
}

#landing-wheel-svg {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  background: var(--navy-900);
}

/* Roda em rajadas: fica parada e legivel na maior parte do ciclo, gira
   por um instante, e volta a parar num angulo multiplo de 360deg (o mesmo
   angulo de "descanso") para o loop ser continuo. Uma roda a girar sempre
   nunca teria texto legivel em nenhum instante — por isso passou a girar
   em rajadas, como uma roda fisica real que gira e depois trava. */
@keyframes spin-burst {
  0%   { transform: rotate(0deg); }
  55%  { transform: rotate(0deg); }
  90%  { transform: rotate(1080deg); }
  100% { transform: rotate(1080deg); }
}

.landing-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: clamp(22px, 5.5vw, 30px);
  color: var(--paper);
  text-align: center;
  margin: 0 auto 10px;
  max-width: 380px;
}

.landing-note {
  text-align: center;
  color: rgba(247, 249, 252, 0.72);
  font-size: 14.5px;
  max-width: 340px;
  margin: 0 auto 22px;
}

#start-btn {
  max-width: 320px;
  margin: 0 auto;
  display: block;
}

/* Colunas do ecra de convite: em mobile/tablet ficam simplesmente
   empilhadas (fluxo normal do documento) e o bloco extra (premios, como
   funciona, QR) fica escondido — so aparece no layout de duas colunas do
   desktop, la em baixo. */
.landing-extra { display: none; }

/* --- Roda --- */

.wheel-stage {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 12px auto 28px;
}

/* Halo desfocado atrás da roda, para chamar mais à atenção à distância
   (pedido do cliente) — tom quente (dourado), de propósito destacado do
   azul/navy que domina o resto da página. */
.wheel-stage::before {
  content: '';
  position: absolute;
  inset: -16%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 166, 35, 0.55), rgba(245, 166, 35, 0) 70%);
  filter: blur(20px);
  pointer-events: none;
  animation: wheel-glow-pulse 3.5s ease-in-out infinite;
}

@keyframes wheel-glow-pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.07); }
}

.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 24px solid var(--blue-400);
  z-index: 5;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.35));
}

.wheel-outer {
  position: relative;
  width: min(78vw, 340px);
  height: min(78vw, 340px);
  border-radius: 50%;
  padding: 10px;
  background: linear-gradient(135deg, var(--blue-400), var(--blue-500));
  box-shadow: var(--shadow-lg);
}

#wheel-svg {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  transition: transform 5.5s cubic-bezier(0.12, 0.65, 0.1, 1);
  background: var(--navy-900);
}

.wheel-hub {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--blue-400);
  display: flex; align-items: center; justify-content: center;
  color: var(--navy-900);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.hub-icon { width: 26px; height: 26px; }

#spin-btn {
  max-width: 300px;
  margin: 0 auto;
  display: block;
}

/* Aviso do premio "bonus" (Analise a Carteira de Seguros): fica visivel
   entre a 1a e a 2a rodada, enquanto se espera o clique em "Girar outra
   vez". Cor propria (tom mais claro de azul) para se distinguir do resto. */
.wheel-bonus-banner {
  max-width: 360px;
  margin: 0 auto 16px;
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(124, 201, 234, 0.14);
  border: 1.5px solid rgba(124, 201, 234, 0.4);
  text-align: center;
}
.wheel-bonus-banner p {
  margin: 0;
  font-size: 14px;
  color: var(--paper);
  line-height: 1.5;
}
.wheel-bonus-banner p + p { margin-top: 4px; color: rgba(247, 249, 252, 0.75); }

/* --- Resultado --- */

.result-card { text-align: center; }
.confetti { font-size: 46px; margin-bottom: 4px; }
.result-card h2 {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 27px;
  color: var(--navy-900);
  margin: 0 0 10px;
}
.result-prize {
  font-size: 19px;
  font-weight: 700;
  color: var(--navy-800);
  background: var(--blue-100);
  border: 1.5px dashed var(--blue-400);
  border-radius: 12px;
  padding: 14px;
  margin: 0 0 12px;
}
.result-prize-bonus {
  font-size: 16px;
  background: rgba(124, 201, 234, 0.16);
  border-style: solid;
}
.result-note {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0;
}

/* =======================================================
   Responsividade — telemóvel (base), tablet e ecrã de expositor
   ======================================================= */

@media (max-width: 380px) {
  .card { padding: 20px 16px; }
}

/* Tablet em pé / telemóvel grande */
@media (min-width: 640px) {
  .wrap { max-width: 640px; }

  body { padding-top: 40px; }

  .card { padding: 34px 36px 32px; }

  .field-grid { grid-template-columns: 1fr 1fr; gap: 0 18px; }
  .field { margin-bottom: 18px; }

  .check-grid { grid-template-columns: 1fr 1fr; }

  .wheel-outer { width: min(52vw, 420px); height: min(52vw, 420px); }

  .btn-primary, .btn-secondary { max-width: 360px; margin-left: auto; margin-right: auto; display: block; }

  #spin-btn { max-width: 320px; }
}

/* Tablet de expositor (ex: iPad em suporte, quiosque) */
@media (min-width: 900px) {
  .wrap { max-width: 720px; }

  body { font-size: 17px; }

  .brand-mark { height: 48px; }
  .brand h1 { font-size: clamp(34px, 4vw, 44px); }
  .subtitle { font-size: 16px; max-width: 440px; }

  .card { padding: 40px 44px; }

  .wheel-outer { width: min(40vw, 460px); height: min(40vw, 460px); }

  .btn-primary { font-size: 17px; }
}

/* Desktop / ecrã grande (ex: monitor do stand a mostrar o ecrã de convite) */
@media (min-width: 1200px) {
  .wrap { max-width: 960px; }

  /* O ecrã de convite usa uma coluna mais larga que os outros ecrãs, para
     caber a roda gigante + a coluna de texto lado a lado. */
  body:has(#screen-landing.active) .wrap { max-width: 1180px; }

  /* O titulo e subtitulo do topo (comuns a todos os ecrãs) ficam
     redundantes no ecrã de convite, que ja tem o seu proprio titulo/nota
     junto a roda — escondem-se so aqui para o convite ficar so com "Gira
     a roda e ganha já um prémio!" como mensagem principal. */
  body:has(#screen-landing.active) .brand h1,
  body:has(#screen-landing.active) .subtitle { display: none; }

  body { font-size: 18px; padding-top: 56px; }

  .brand-mark { height: 54px; }
  .brand h1 { font-size: clamp(40px, 3.4vw, 54px); }
  .subtitle { font-size: 17px; max-width: 520px; }

  .card { padding: 48px 56px; }

  .wheel-outer { width: min(30vw, 520px); height: min(30vw, 520px); }

  .field-grid { gap: 0 24px; }
  .check-grid { grid-template-columns: repeat(3, 1fr); }

  .btn-primary { font-size: 18px; }
  #start-btn, #spin-btn { max-width: 380px; }

  /* ---- Convite: duas colunas (roda gigante + texto) ---- */
  #screen-landing.active {
    display: grid;
    grid-template-columns: minmax(460px, 620px) 1fr;
    align-items: center;
    gap: 12px 48px;
  }

  .landing-wheel-col .wheel-outer { width: min(34vw, 620px); height: min(34vw, 620px); }
  .landing-wheel-col .wheel-stage { margin: 0 auto 0 0; }

  .landing-copy-col { text-align: left; }
  .landing-title, .landing-note { text-align: left; margin-left: 0; margin-right: 0; max-width: none; }
  .landing-title { font-size: clamp(30px, 2.6vw, 40px); }
  .landing-note { font-size: 16px; max-width: 440px; }
  #screen-landing #start-btn { margin: 0; }

  .landing-extra {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 28px;
    margin-top: 36px;
    padding-top: 28px;
    border-top: 1px solid rgba(247, 249, 252, 0.14);
  }

  .landing-block h3 {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--blue-300);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 12px;
  }

  .landing-steps {
    list-style: none;
    counter-reset: landing-step;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .landing-steps li {
    counter-increment: landing-step;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14.5px;
    color: rgba(247, 249, 252, 0.88);
  }

  .landing-steps li::before {
    content: counter(landing-step);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--blue-500);
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 12px;
  }

  .landing-qr-block p {
    font-size: 13px;
    color: rgba(247, 249, 252, 0.62);
    margin: 10px 0 0;
  }

  .landing-qr-code {
    width: 128px;
    background: #fff;
    padding: 8px;
    border-radius: 10px;
    line-height: 0;
  }

  .landing-qr-code svg { width: 100%; height: auto; display: block; }
}

/* Ecrãs muito baixos em landscape (tablet deitado) — evita que a roda empurre o botão para fora */
@media (max-height: 500px) and (orientation: landscape) {
  body { padding-top: 16px; padding-bottom: 24px; }
  .brand { margin-bottom: 14px; }
  .wheel-outer { width: min(30vh, 300px); height: min(30vh, 300px); }
  .wheel-stage { margin: 6px auto 16px; }
}

/* --- Rodapé (logo + contactos) --- */

.site-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid rgba(247, 249, 252, 0.14);
  text-align: center;
}

.site-footer-logo {
  display: block;
  height: 22px;
  width: auto;
  margin: 0 auto 10px;
  opacity: 0.9;
}

.site-footer-contact {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 4px;
}

.site-footer-contact a {
  color: rgba(247, 249, 252, 0.72);
  font-size: 13px;
  text-decoration: none;
}
.site-footer-contact a:hover { color: var(--paper); text-decoration: underline; }

.site-footer-offices {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(247, 249, 252, 0.1);
  display: grid;
  gap: 8px;
  text-align: left;
  font-size: 12.5px;
  line-height: 1.5;
  color: rgba(247, 249, 252, 0.6);
}
.site-footer-offices strong { color: rgba(247, 249, 252, 0.85); }

/* A morada de Portalegre e destacada e mostrada primeiro — e a mais
   procurada (feira local), mas nao e obvia no meio das outras moradas. */
.site-footer-office-primary {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(124, 201, 234, 0.1);
  border: 1px solid rgba(124, 201, 234, 0.25);
}
.site-footer-office-primary strong { color: var(--blue-300); }

/* Rodapé compacto (index.html): só a morada de Portalegre, à frente,
   para quem esta na feira e nao sabe onde fica o escritorio local. */
.site-footer-address-compact {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(124, 201, 234, 0.1);
  border: 1px solid rgba(124, 201, 234, 0.25);
  font-size: 12.5px;
  color: rgba(247, 249, 252, 0.72);
}

@media (min-width: 640px) {
  .site-footer-offices { grid-template-columns: 1fr 1fr; }
}
