@font-face {
  font-family: "Archivo";
  src: url("/archivo.woff") format("woff");
  font-weight: 400 800;
  font-stretch: 100% 125%;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --ink: #004685;
  --ink-soft: #55708f;
  --line: #cfdbe8;
  --tint: #eef3f9;
  --error: #b3261e;
  --rule: 1px solid var(--line);
  --pad: 20px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Archivo", system-ui, sans-serif;
  font-stretch: 100%;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.header, .films, .status, .footer {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

/* Intestazione della scheda */

.header {
  padding-top: max(28px, calc(env(safe-area-inset-top) + 16px));
}

.header::after { content: ""; display: block; margin-top: 24px; border-bottom: var(--rule); }

.logo { display: block; height: 48px; width: auto; margin-bottom: 28px; }

.headline {
  margin: 0;
  font-size: 1.85rem;
  line-height: 1.1;
  font-weight: 600;
  font-stretch: 108%;
  letter-spacing: -.01em;
}

.intro { margin: 8px 0 0; font-size: 1rem; max-width: 34em; color: var(--ink-soft); }
.progress { margin: 14px 0 0; font-size: .9rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.status { margin-top: 14px; margin-bottom: 0; font-weight: 600; }

/* Righe dei film */

.films { flex: 1 0 auto; padding-top: 0; padding-bottom: 32px; }
.loading, .empty { margin: 24px 0 0; color: var(--ink-soft); }

.film { padding: 24px 0 26px; border-bottom: var(--rule); }

.title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
  font-weight: 600;
  font-stretch: 104%;
}

.trailer-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 4px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  cursor: pointer;
}

.trailer-btn svg { width: 11px; height: 11px; fill: currentColor; }

/* Scala 1-5: cerchi da compilare, come su una scheda di valutazione */

.scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  max-width: 300px;
  margin: 10px 0 0;
  padding: 0;
  border: 0;
}

.scale[hidden] { display: none; }

.scale label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-height: 46px;
  border: 1.5px solid #9db4cf;
  border-radius: 50%;
  font-size: 1.05rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .12s, color .12s;
}

.scale input { position: absolute; inset: 0; opacity: 0; margin: 0; pointer-events: none; }
.scale label.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.scale label:active { background: var(--tint); }
.scale label.on:active { background: var(--ink); }

.trailer-btn:focus-visible, .scale label:focus-within, .lightbox-close:focus-visible, .credits-link:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

/* Footer */

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding-top: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.credits-label { margin: 0; color: var(--ink-soft); font-size: .7rem; }
.credits-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }
.credits-link img { display: block; height: 13px; width: auto; }

/* Conferma */

.toast {
  position: fixed;
  left: var(--pad);
  right: var(--pad);
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 8px));
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  z-index: 20;
}

.toast.error { background: var(--error); }

/* Lightbox */

.lightbox {
  width: min(960px, 100vw);
  max-width: 100vw;
  max-height: 100dvh;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
}

.lightbox::backdrop { background: #000; }
.lightbox-inner { padding: 12px; }
.lightbox-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }

.lightbox-title {
  flex: 1;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-player video { display: block; width: 100%; max-height: calc(100dvh - 90px); background: #000; }
.lightbox-error { margin: 0; padding: 48px 16px; border-radius: 12px; background: rgba(255, 255, 255, .08); text-align: center; }

body.lightbox-open { overflow: hidden; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
