/* =========================================================================
   Elettra Marconia — Photo Booth
   Design tokens allineati al design system Elettra (look "Matchday": superfici
   navy scure, accento rosso, dettagli oro). Mobile-first. Font: Inter self-hostato
   (nessuna dipendenza di rete, rendering deterministico anche su canvas).
   ========================================================================= */

:root {
  --navy:      #070D2D;   /* superfici scure / sfondo */
  --navy-800:  #141C4A;   /* card, hint, box */
  --navy-600:  #202A69;   /* superfici piu' chiare */
  --red:       #E11330;   /* accento / azione primaria */
  --red-600:   #C10A22;   /* rosso profondo */
  --red-hover: #F42A45;   /* hover azione */
  --gold:      #FFD34E;   /* dettaglio oro / link */
  --gold-500:  #E9B949;
  --white:     #FFFFFF;
  --mist:      #C3C9D6;   /* testo secondario chiaro */
  --muted:     #7C86A3;   /* testo attenuato su navy */
  --line:      rgba(255, 255, 255, 0.14);

  --radius: 12px;
  --radius-lg: 18px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* L'attributo [hidden] deve sempre vincere sulle regole display: * sotto. */
[hidden] { display: none !important; }

/* Inter self-hostato (latin) per UI e disegno su canvas. */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../assets/fonts/inter-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../assets/fonts/inter-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 800; font-display: swap;
  src: url('../assets/fonts/inter-800.woff2') format('woff2');
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--navy);
  color: var(--white);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
}

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

/* ----------------------------- Screens ----------------------------------- */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: calc(24px + var(--safe-top)) 22px calc(24px + var(--safe-bottom));
}
.screen[hidden] { display: none; }

/* ----------------------------- Buttons ----------------------------------- */

.btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
  padding: 15px 22px;
  cursor: pointer;
  transition: background-color .18s ease, transform .06s ease, border-color .18s ease;
  width: 100%;
}
.btn:active { transform: scale(0.985); }

.btn--primary { background: var(--red); color: var(--white); }
.btn--primary:hover { background: var(--red-hover); }

.btn--ghost {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.28);
}
.btn--ghost:hover { border-color: rgba(255, 255, 255, 0.5); }

.btn--lg { padding: 18px 24px; font-size: 17px; }
.btn--sm { padding: 11px 16px; font-size: 14px; width: auto; }

.link-reset {
  appearance: none;
  background: none;
  border: 0;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  padding: 8px;
  cursor: pointer;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.link-reset:hover { color: var(--mist); }
.link-arrow { display: block; }

.cta-link {
  display: inline-block;
  color: var(--gold);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
}
.cta-link:hover { text-decoration: underline; }

/* ----------------------------- Intro ------------------------------------- */

.screen--intro { justify-content: space-between; }

.intro__inner {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  gap: 24px;
}

.intro__badge {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.intro__logo-aw { width: 158px; height: auto; opacity: 0.95; }
.intro__sponsor {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.intro__hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: auto;
  margin-bottom: auto;
}
.intro__logo {
  width: auto;
  max-width: 200px;
  max-height: 40dvh;
  height: auto;
  margin-bottom: 6px;
}
.intro__subtitle {
  margin: 12px 0 0;
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.intro__accent {
  display: block;
  width: 56px;
  height: 4px;
  border-radius: 3px;
  background: var(--red);
  margin: 20px 0;
}
.intro__body {
  margin: 0;
  max-width: 34ch;
  font-size: 16px;
  line-height: 1.55;
  color: var(--mist);
}
.intro__link {
  color: var(--gold);
  font-weight: 600;
  text-decoration: none;
}
.intro__link:hover { text-decoration: underline; }

/* ----------------------------- Camera / Stage ---------------------------- */

.screen--camera {
  justify-content: center;
  align-items: center;
  padding: 0;
  background: #000;
}

/* Stage: aspect impostato da JS (unico template 9:16). */
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1080 / 1920;
  max-height: calc(100dvh - 150px);
  margin: auto;
  overflow: hidden;
  border-radius: 6px;
  background: #000;
}

.stage__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0B1236;
}

.stage__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ----------------------------- Controlli camera -------------------------- */

.controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(132px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0));
}
.controls > * { justify-self: center; }
.controls__spacer { width: 52px; height: 52px; }

/* Controlli flottanti agli angoli in alto: X (chiudi) a sinistra, ruota-camera a
   destra. Stanno nella fascia superiore, per non sovrapporsi ai loghi della cornice. */
.switch-float,
.close-float {
  position: absolute;
  top: calc(16px + var(--safe-top));
  z-index: 6;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: rgba(7, 13, 45, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.switch-float { right: 16px; }
.close-float { left: 16px; }
.switch-float:active,
.close-float:active { transform: scale(0.94); }

.shutter {
  appearance: none;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 4px solid var(--white);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.shutter__core {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--white);
  transition: transform .08s ease, background-color .12s ease;
}
.shutter:active .shutter__core { transform: scale(0.88); background: var(--mist); }

/* ----------------------------- Preview ----------------------------------- */

.screen--preview {
  overflow-y: auto;
  justify-content: flex-start;
  gap: 18px;
}

.preview__frame {
  display: flex;
  justify-content: center;
  flex: 0 0 auto;
}
.preview__img {
  max-height: 60dvh;
  width: auto;
  max-width: 100%;
  border-radius: 6px;
  background: var(--navy-800);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.preview__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.preview__row {
  display: flex;
  gap: 12px;
}
.preview__row .btn { flex: 1; }

.hint {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--mist);
  background: var(--navy-800);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.hint strong { color: var(--white); }

.ios-share {
  background: var(--navy-800);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ios-share__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--mist);
}
.ios-share__text strong { color: var(--white); }
.ios-share .btn { align-self: flex-start; }

/* ----------------------------- Finale / Branding ------------------------- */

.final {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.contest {
  background: var(--navy-800);
  border: 1px solid rgba(225, 19, 48, 0.4);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.contest__headline { margin: 0; font-size: 17px; font-weight: 700; }
.contest__body { margin: 0; font-size: 14px; color: var(--mist); line-height: 1.5; }

.final__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.final__logo-aw { width: 150px; height: auto; opacity: 0.9; }
.final__line { margin: 0; font-size: 14px; color: var(--muted); }

/* ----------------------------- Errore ------------------------------------ */

.screen--error { justify-content: center; align-items: center; text-align: center; }
.error__inner { display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 34ch; }
.error__mark { color: var(--muted); }
.error__title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.error__body { margin: 0; font-size: 15px; line-height: 1.55; color: var(--mist); }
.error__inner .btn { width: auto; margin-top: 4px; }

/* ----------------------------- Larghezze maggiori ------------------------ */

@media (min-width: 620px) {
  .intro__inner, .preview__actions, .final { max-width: 460px; width: 100%; margin-left: auto; margin-right: auto; }
  .screen--preview { align-items: center; }
}
