/*
 * Sito statico di SandmApp (sandmapp.com): pagina d'attesa, /verifica, /reimposta e la pagina
 * d'invito /r/<CODICE>. Stesso look dell'app
 * (navy, oro, lavanda, Lora e Inter locali). Nessuno stile inline: la CSP è `style-src 'self'`.
 * Percorsi relativi, così il sito funziona anche servito da una sottocartella.
 */

@font-face {
  font-family: 'Lora';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/lora-italic-latin-ext.woff2') format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}
@font-face {
  font-family: 'Lora';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/lora-italic-latin.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --navy: #0b1026;
  --navy-light: #1a1b4b;
  --gold: #d4a44c;
  --gold-light: #e8c47a;
  --lavender: #a78bfa;
  --warm-white: #f5f0eb;
  color-scheme: dark;
}

/* Gli elementi nascosti dal JS restano nascosti anche se una regola qui sotto dà loro un display. */
[hidden] {
  display: none !important;
}

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

html {
  background: var(--navy);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--warm-white);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Canvas della sabbia (js/sand.js): sopra il contenuto come nell'app, ma non intercetta i tocchi. */
.sand {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.stage {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  /* L'alone del logo è più largo dello schermo dei telefoni: niente scroll orizzontale. */
  overflow: hidden;
  text-align: center;
}

/* Logo con l'alone dorato dell'app (AuthPage): il cappello è navy e sul fondo scuro si vede solo
   così. Gradiente radiale oro sfocato dietro l'immagine e drop-shadow dorato. */
.logo {
  position: relative;
  width: 144px;
  height: 144px;
  margin-bottom: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: appear 1.4s ease-out both;
}

.logo__glow {
  position: absolute;
  inset: -96px;
  border-radius: 50%;
  background: radial-gradient(circle, #d4a44c 0%, #d4a44c55 40%, #d4a44c22 60%, transparent 85%);
  filter: blur(72px);
  opacity: 0.4;
  animation: breathe 7s ease-in-out 1.4s infinite;
}

.logo__img {
  position: relative;
  width: 128px;
  height: 128px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(212, 164, 76, 0.4));
}

.logo--small {
  width: 104px;
  height: 104px;
  margin-bottom: 32px;
}

.logo--small .logo__glow {
  inset: -72px;
  filter: blur(56px);
}

.logo--small .logo__img {
  width: 92px;
  height: 92px;
}

.tagline {
  margin: 0;
  max-width: 100%;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.375rem, 1rem + 2.2vw, 2.125rem);
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: var(--gold);
  /* Accento lavanda lieve, come i bagliori dell'app. */
  text-shadow: 0 0 28px rgba(167, 139, 250, 0.35);
  text-wrap: balance;
  animation: rise 1.6s ease-out 0.6s both;
}

/* Pannello delle pagine /verifica, /reimposta e /r/ */
.panel {
  width: 100%;
  max-width: 400px;
  padding: 28px 20px;
  background: rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  animation: rise 1.2s ease-out 0.4s both;
}

.message {
  margin: 0;
  min-height: 1.5em;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 1.1875rem;
  line-height: 1.5;
  color: var(--warm-white);
  text-wrap: pretty;
}

.button {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 24px;
  padding: 12px 20px;
  border: 0;
  border-radius: 12px;
  background: var(--gold);
  color: var(--navy);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(212, 164, 76, 0.15);
  transition:
    background-color 0.2s ease,
    opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.button:hover {
  background: var(--gold-light);
}

.button:focus-visible {
  outline: 2px solid var(--lavender);
  outline-offset: 3px;
}

.button:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Anche un link può avere l'aspetto del pulsante (Google Play). */
a.button {
  text-align: center;
  text-decoration: none;
}

.button--ghost {
  background: transparent;
  color: var(--gold);
  border: 1px solid rgba(212, 164, 76, 0.6);
  box-shadow: none;
}

.button--ghost:hover {
  background: rgba(212, 164, 76, 0.1);
}

.button--small {
  display: inline-block;
  width: auto;
  min-height: 40px;
  margin-top: 6px;
  padding: 8px 22px;
  font-size: 0.9375rem;
}

/* Pagine con un form (/reimposta, /r/): titolo, testo, codice invito, campi ed errori */
.title {
  margin: 0;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.3;
  color: var(--gold);
  text-shadow: 0 0 28px rgba(167, 139, 250, 0.35);
  text-wrap: balance;
}

/* Il titolo riceve il fuoco dal JS (esito della registrazione) solo per i lettori di schermo. */
.title:focus {
  outline: none;
}

.lead {
  margin: 10px 0 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: rgba(245, 240, 235, 0.78);
  text-wrap: pretty;
}

.code-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  padding: 16px;
  border: 1px dashed rgba(212, 164, 76, 0.45);
  border-radius: 14px;
  background: rgba(212, 164, 76, 0.06);
}

.code-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(245, 240, 235, 0.6);
}

/* Selezionabile per intero con un tocco lungo, se la copia automatica non è disponibile. */
.code-card__code {
  padding-left: 0.14em;
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
  color: var(--gold-light);
  -webkit-user-select: all;
  user-select: all;
}

.code-card__hint {
  margin: 2px 0 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: rgba(245, 240, 235, 0.7);
}

.form {
  text-align: left;
}

/* Titolo e testo d'apertura centrati come nella pagina d'invito, anche dentro il form (/reimposta). */
.form > .title,
.form > .lead {
  text-align: center;
}

.field {
  margin-top: 16px;
}

.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(245, 240, 235, 0.85);
}

/* 16px: sotto questa misura Safari su iOS ingrandisce la pagina al tocco sul campo. */
.field__input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  background: rgba(11, 16, 38, 0.55);
  color: var(--warm-white);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.field__input::placeholder {
  color: rgba(245, 240, 235, 0.4);
}

.field__input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 164, 76, 0.2);
}

.field__input[aria-invalid='true'] {
  border-color: #f87171;
}

.field__error {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #fca5a5;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 44px;
  padding-top: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.check__input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  accent-color: var(--gold);
  cursor: pointer;
}

.check__input:focus-visible {
  outline: 2px solid var(--lavender);
  outline-offset: 2px;
}

.check__input[aria-invalid='true'] {
  outline: 2px solid #f87171;
  outline-offset: 2px;
}

.check__label {
  font-size: 0.9375rem;
  line-height: 1.5;
}

.legal {
  margin: 12px 0 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: rgba(245, 240, 235, 0.7);
}

.legal a {
  color: var(--gold-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.legal a:focus-visible {
  outline: 2px solid var(--lavender);
  outline-offset: 2px;
  border-radius: 2px;
}

.form-error {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 12px;
  background: rgba(248, 113, 113, 0.1);
  color: #fecaca;
  font-size: 0.9375rem;
  line-height: 1.5;
  text-wrap: pretty;
}

/* "Presto su Google Play": al posto del pulsante finché l'app non è pubblicata (js/config.js). */
.store-soon {
  margin: 24px 0 0;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: rgba(245, 240, 235, 0.75);
  font-size: 0.9375rem;
  font-weight: 600;
}

@keyframes appear {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

@keyframes breathe {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 0.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  .logo,
  .logo__glow,
  .tagline,
  .panel {
    animation: none;
  }

  .button,
  .field__input {
    transition: none;
  }
}
