/* ==========================================================================
   Dispensa · usedispensa.it
   Regole di forma: pulsanti a capsula, card 28px, iPhone 54px.
   Un solo accento (verde). Tema automatico chiaro/scuro.
   ========================================================================== */

:root {
  --bg: #f4f6f4;
  --surface: #fcfdfc;
  --surface-2: #eaeeea;
  --text: #0e1210;
  --muted: #545d58;
  --line: rgba(14, 18, 16, 0.1);
  --accent: #1e7a36;
  --accent-ink: #f6fbf7;
  --accent-soft: rgba(30, 122, 54, 0.1);
  --shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.3);

  /* Interfaccia dell'app (colori di sistema iOS) */
  --ios-bg: #f2f2f7;
  --ios-card: #ffffff;
  --ios-label: #000000;
  --ios-secondary: rgba(60, 60, 67, 0.62);
  --ios-tertiary: rgba(60, 60, 67, 0.3);
  --ios-separator: rgba(60, 60, 67, 0.18);
  --ios-fill: rgba(120, 120, 128, 0.14);
  --ios-green: #248a3d;
  --ios-orange: #ff9500;
  --ios-red: #ff3b30;
  --ios-blue: #32ade6;
  --ios-indigo: #5856d6;
  --ios-brown: #a2845e;
  --bezel: #1b1e1c;

  --radius-card: 28px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  /* Curva senza rimbalzo (smorzamento critico), come le animazioni di sistema di iOS. */
  --ease-settle: cubic-bezier(0.2, 0.9, 0.25, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d0c;
    --surface: #131715;
    --surface-2: #1a1f1c;
    --text: #edf2ee;
    --muted: #9ba49e;
    --line: rgba(237, 242, 238, 0.09);
    --accent: #34d267;
    --accent-ink: #04140a;
    --accent-soft: rgba(52, 210, 103, 0.13);
    --shadow: 0 30px 90px -30px rgba(0, 0, 0, 0.8);

    --ios-bg: #050505;
    --ios-card: #1c1c1e;
    --ios-label: #ffffff;
    --ios-secondary: rgba(235, 235, 245, 0.62);
    --ios-tertiary: rgba(235, 235, 245, 0.3);
    --ios-separator: rgba(84, 84, 88, 0.6);
    --ios-fill: rgba(120, 120, 128, 0.3);
    --ios-green: #30d158;
    --ios-orange: #ff9f0a;
    --ios-red: #ff453a;
    --ios-blue: #64d2ff;
    --ios-indigo: #5e5ce6;
    --ios-brown: #ac8e68;
    --bezel: #2a2e2c;
  }
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* SF Pro su iPhone e Mac, come l'app; il font di sistema altrove. */
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI Variable Display', 'Segoe UI', Roboto, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: inherit;
}

.i {
  width: 1em;
  height: 1em;
  flex: none;
  fill: currentColor;
}

.wrap {
  width: min(1180px, 100% - 40px);
  margin-inline: auto;
}

.skip {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}

.skip:focus {
  top: 12px;
}

:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}

.top-sentinel {
  position: absolute;
  top: 0;
  height: 24px;
  width: 1px;
}

/* ---------- Pulsanti ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 26px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12), 0 8px 20px -10px rgba(0, 0, 0, 0.35);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out), background 0.2s;
}

.btn .i {
  font-size: 18px;
  transition: transform 0.35s var(--ease-out);
}

.btn:hover {
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12), 0 14px 28px -12px rgba(0, 0, 0, 0.4);
}

.btn:hover .i {
  transform: translateX(3px);
}

.btn:active {
  transform: scale(0.97);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.btn-ghost:hover {
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px transparent, 0 10px 30px -18px rgba(0, 0, 0, 0.3);
}

.btn-small {
  padding: 9px 16px;
  font-size: 14px;
  box-shadow: none;
}

/* ---------- Navigazione ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background 0.3s, box-shadow 0.3s;
}

.nav.is-scrolled {
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 1px 0 var(--line);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand img {
  border-radius: 8px;
}

.nav-links {
  display: flex;
  gap: 28px;
  font-size: 15px;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--text);
}

/* ---------- Titoli di sezione ---------- */

.section-title {
  margin: 0 0 20px;
  font-size: clamp(34px, 4.6vw, 60px);
  line-height: 1.06;
  letter-spacing: -0.04em;
  font-weight: 650;
  max-width: 16ch;
  text-wrap: balance;
}

.section-title.center,
.section-lead.center {
  margin-inline: auto;
  text-align: center;
}

.section-lead {
  max-width: 58ch;
  margin: 0 0 56px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.55;
  text-wrap: pretty;
}

/* ==========================================================================
   iPhone e interfaccia dell'app (scalata con le container query)
   ========================================================================== */

.phone {
  position: relative;
  width: clamp(250px, 25vw, 318px);
  aspect-ratio: 9 / 19.4;
  padding: 3.4%;
  border-radius: 54px;
  background: var(--bezel);
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.08),
    inset 0 0 0 5px rgba(0, 0, 0, 0.45),
    var(--shadow);
  container-type: inline-size;
}

.phone-screen {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 13cqw;
  background: var(--ios-bg);
  color: var(--ios-label);
  font-family: -apple-system, 'SF Pro Text', 'Segoe UI', Roboto, system-ui, sans-serif;
  font-size: 4.6cqw;
  line-height: 1.3;
}

.app {
  padding: 0 4.6cqw;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 13cqw;
  padding: 0 3cqw;
  font-weight: 600;
  font-size: 4.6cqw;
}

.island {
  width: 30cqw;
  height: 8.6cqw;
  border-radius: 99px;
  background: #000;
}

.battery {
  width: 8cqw;
  height: 3.8cqw;
  border-radius: 1.2cqw;
  background: var(--ios-label);
  opacity: 0.85;
}

.app-title {
  margin: 1.5cqw 0 3cqw;
  font-size: 10cqw;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-title.small {
  margin-top: 9cqw;
  font-size: 9cqw;
}

.app-search {
  display: flex;
  align-items: center;
  gap: 2cqw;
  height: 10cqw;
  margin-bottom: 4cqw;
  padding: 0 3cqw;
  border-radius: 99px;
  background: var(--ios-fill);
  color: var(--ios-secondary);
  font-size: 4.4cqw;
}

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3cqw;
  margin-bottom: 4cqw;
}

.tile {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  row-gap: 1.6cqw;
  padding: 3.2cqw;
  border-radius: 5cqw;
  background: var(--ios-card);
}

.tile b {
  font-size: 7.4cqw;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.tile small {
  grid-column: 1 / -1;
  color: var(--ios-secondary);
  font-weight: 600;
  font-size: 4.2cqw;
}

.tile.selected {
  background: var(--ios-orange);
  color: #fff;
}

.tile.selected small {
  color: rgba(255, 255, 255, 0.92);
}

.tile-icon,
.thumb {
  display: grid;
  place-items: center;
  color: #fff;
}

.tile-icon {
  width: 7.4cqw;
  height: 7.4cqw;
  border-radius: 50%;
  font-size: 4.4cqw;
}

.thumb {
  width: 9cqw;
  height: 9cqw;
  flex: none;
  border-radius: 2.4cqw;
  font-size: 5cqw;
}

.orange { background: var(--ios-orange); }
.blue { background: var(--ios-blue); }
.indigo { background: var(--ios-indigo); }
.brown { background: var(--ios-brown); }
.red { background: var(--ios-red); }
.tile-icon.white { background: #fff; color: var(--ios-orange); }

.group-title {
  margin: 0 1cqw 1.6cqw;
  font-size: 5cqw;
  font-weight: 650;
}

.group {
  overflow: hidden;
  border-radius: 5cqw;
  background: var(--ios-card);
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 3cqw;
  min-height: 13cqw;
  padding: 2.4cqw 3.4cqw;
}

.row + .row::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 15.4cqw;
  height: 1px;
  background: var(--ios-separator);
}

.shop .row + .row::before {
  left: 12cqw;
}

.row-text {
  display: grid;
  flex: 1;
  min-width: 0;
}

.row-text b {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-text small {
  color: var(--ios-secondary);
  font-size: 3.8cqw;
}

.row em {
  color: var(--ios-secondary);
  font-style: normal;
  font-size: 3.8cqw;
  white-space: nowrap;
}

.row em.soon {
  color: var(--ios-orange);
  font-weight: 650;
}

.row em.late {
  color: var(--ios-red);
  font-weight: 650;
}

.tabbar {
  position: absolute;
  right: 4cqw;
  bottom: 4cqw;
  left: 4cqw;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 2.4cqw 1cqw;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ios-card) 70%, transparent);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), 0 6px 20px rgba(0, 0, 0, 0.12);
}

.tabbar span {
  display: grid;
  justify-items: center;
  gap: 0.6cqw;
  color: var(--ios-secondary);
  font-size: 2.8cqw;
  font-weight: 600;
}

.tabbar .i {
  font-size: 6cqw;
}

.tabbar .active {
  color: var(--ios-green);
}

/* Casella di spunta della lista della spesa */
.box {
  position: relative;
  width: 6.4cqw;
  height: 6.4cqw;
  flex: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 0.45cqw var(--ios-tertiary);
  transition: background 0.35s var(--ease-out), box-shadow 0.35s;
}

.box::after {
  content: '';
  position: absolute;
  left: 2.3cqw;
  top: 1.25cqw;
  width: 1.5cqw;
  height: 3cqw;
  border: solid #fff;
  border-width: 0 0.7cqw 0.7cqw 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.35s var(--ease-settle);
}

.row.checked .box {
  background: var(--ios-green);
  box-shadow: none;
}

.row.checked .box::after {
  transform: rotate(45deg) scale(1);
}

.row.checked .row-text b {
  color: var(--ios-secondary);
  text-decoration: line-through;
}

/* ==========================================================================
   HERO
   ========================================================================== */

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  align-items: center;
  gap: 48px;
  min-height: calc(100dvh - 64px);
  padding: 32px 0 72px;
}

.hero h1 {
  margin: 0 0 24px;
  font-size: clamp(42px, 5vw, 70px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 680;
  text-wrap: balance;
}

.lead {
  max-width: 34ch;
  margin: 0 0 36px;
  color: var(--muted);
  font-size: clamp(18px, 1.6vw, 21px);
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-stage {
  position: relative;
  display: grid;
  place-items: center;
  perspective: 1400px;
}

.hero-stage .phone {
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.6s var(--ease-out);
  will-change: transform;
}

.glow {
  position: absolute;
  inset: 8% 4%;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, color-mix(in srgb, var(--accent) 34%, transparent), transparent 70%),
    radial-gradient(closest-side at 70% 30%, color-mix(in srgb, var(--ios-orange) 16%, transparent), transparent 70%);
  filter: blur(30px);
  pointer-events: none;
}

.notification {
  position: absolute;
  top: 9%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(360px, 92%);
  padding: 12px 14px;
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 24px 50px -20px rgba(0, 0, 0, 0.45);
  font-size: 14px;
  line-height: 1.4;
}

.notification img {
  border-radius: 9px;
}

.notification > div {
  display: grid;
  flex: 1;
}

.notification span {
  color: var(--muted);
}

.notification-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.notification-head strong {
  font-weight: 600;
}

/* ==========================================================================
   STORY (racconto a scorrimento)
   ========================================================================== */

.story {
  padding: 80px 0 40px;
}

.story-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
}

.step {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 72vh;
  max-width: 440px;
  opacity: 0.28;
  transition: opacity 0.5s var(--ease-out);
}

.step.is-active {
  opacity: 1;
}

.step-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.step h3 {
  margin: 0;
  font-size: clamp(26px, 2.6vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 650;
}

.step p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.step-icon {
  display: inline-flex;
  color: var(--accent);
  font-size: 30px;
  transition: transform 0.6s var(--ease-settle);
}

.step.is-active .step-icon {
  transform: scale(1.08) rotate(-6deg);
}

.story-stage {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  height: 100dvh;
}

.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translateY(5%) scale(0.97);
  transition: opacity 0.55s var(--ease-out), transform 0.7s var(--ease-out);
  pointer-events: none;
}

.screen.is-active {
  opacity: 1;
  transform: none;
}

.story-dots {
  display: flex;
  gap: 8px;
}

.story-dots i {
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: var(--line);
  transition: background 0.3s, transform 0.45s var(--ease-out);
}

.story-dots i.is-active {
  background: var(--accent);
  transform: scale(1.5);
}

/* Schermata: scanner */
.screen-scan {
  background: #0d0f0e;
}

.camera {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 40% at 50% 45%, rgba(255, 255, 255, 0.1), transparent 70%),
    linear-gradient(160deg, #2b2f2c, #0d0f0e 70%);
}

.pack {
  display: grid;
  place-items: center;
  width: 56cqw;
  height: 38cqw;
  border-radius: 4cqw;
  background: linear-gradient(150deg, #d8463a, #a8261c);
  box-shadow: 0 6cqw 12cqw rgba(0, 0, 0, 0.45);
  transform: rotate(-5deg);
}

.pack-code {
  width: 38cqw;
  height: 22cqw;
  padding: 1.4cqw 2.4cqw;
  border-radius: 1.6cqw;
  background: #fff;
  color: #111;
}

.finder {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72cqw;
  height: 50cqw;
  transform: translate(-50%, -50%);
}

.finder span {
  position: absolute;
  width: 11cqw;
  height: 11cqw;
  border: 0 solid #fff;
}

.finder span:nth-child(1) { top: 0; left: 0; border-top-width: 1.1cqw; border-left-width: 1.1cqw; border-top-left-radius: 5cqw; }
.finder span:nth-child(2) { top: 0; right: 0; border-top-width: 1.1cqw; border-right-width: 1.1cqw; border-top-right-radius: 5cqw; }
.finder span:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 1.1cqw; border-left-width: 1.1cqw; border-bottom-left-radius: 5cqw; }
.finder span:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 1.1cqw; border-right-width: 1.1cqw; border-bottom-right-radius: 5cqw; }

.laser {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 50%;
  height: 0.7cqw;
  border-radius: 99px;
  background: var(--ios-green);
  box-shadow: 0 0 4cqw 1cqw color-mix(in srgb, var(--ios-green) 70%, transparent);
  opacity: 0;
}

.glass-btn {
  position: absolute;
  top: 16cqw;
  display: grid;
  place-items: center;
  width: 11cqw;
  height: 11cqw;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 5cqw;
}

.glass-btn.left { left: 5cqw; }
.glass-btn.right { right: 5cqw; }

.scan-result {
  position: absolute;
  right: 4.6cqw;
  bottom: 6cqw;
  left: 4.6cqw;
  display: flex;
  align-items: center;
  gap: 3cqw;
  padding: 3.4cqw;
  border-radius: 6cqw;
  background: var(--ios-card);
  color: var(--ios-label);
  transform: translateY(140%);
  opacity: 0;
}

.scan-result .check {
  color: var(--ios-green);
  font-size: 7cqw;
}

/* Schermata: scadenze, con lo swipe "Consumato" */
.swipe-demo {
  padding: 0;
  background: var(--ios-green);
}

.swipe-action {
  position: absolute;
  inset: 0 auto 0 0;
  display: flex;
  align-items: center;
  gap: 1.6cqw;
  padding-left: 3.4cqw;
  color: #fff;
  font-weight: 650;
  font-size: 3.8cqw;
}

.swipe-content {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  gap: 3cqw;
  min-height: 13cqw;
  padding: 2.4cqw 3.4cqw;
  background: var(--ios-card);
}

.toast {
  position: absolute;
  bottom: 7cqw;
  left: 50%;
  display: flex;
  gap: 3cqw;
  padding: 3cqw 5cqw;
  border-radius: 99px;
  background: var(--ios-label);
  color: var(--ios-bg);
  font-size: 3.8cqw;
  font-weight: 600;
  white-space: nowrap;
  transform: translate(-50%, 200%);
  opacity: 0;
}

.toast b {
  color: var(--ios-green);
}

/* Schermata: spesa */
.row.arrive {
  opacity: 0;
  transform: translateY(-30%);
}

.row.new {
  color: var(--ios-secondary);
}

.row.new .plus {
  width: 6.4cqw;
  height: 6.4cqw;
  padding: 1.2cqw;
  border-radius: 50%;
  background: var(--ios-green);
  color: #fff;
}

/* Schermata: ricette */
.recipe {
  margin-bottom: 3cqw;
  padding: 4cqw;
  border-radius: 5cqw;
  background: var(--ios-card);
  opacity: 0;
  transform: translateY(8%);
}

.recipe-title {
  display: block;
  font-size: 5.6cqw;
  font-weight: 650;
}

.recipe p {
  margin: 1cqw 0 2.4cqw;
  color: var(--ios-secondary);
  font-size: 3.8cqw;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6cqw;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 1cqw;
  padding: 0.8cqw 2.4cqw;
  border-radius: 99px;
  background: var(--ios-fill);
  color: var(--ios-secondary);
  font-size: 3.2cqw;
  font-weight: 600;
}

.tag.green {
  background: color-mix(in srgb, var(--ios-green) 16%, transparent);
  color: var(--ios-green);
}

.steps {
  margin: 3cqw 0 0;
  padding-left: 5cqw;
  font-size: 3.8cqw;
}

.steps li + li {
  margin-top: 1.2cqw;
}

.recipe-small {
  padding-block: 3.4cqw;
}

/* Animazioni che ripartono ogni volta che la schermata diventa attiva */
.screen-scan.is-active.is-playing .laser {
  animation: laser 1.6s var(--ease-out) 0.3s 2 both;
}

.screen-scan.is-active .scan-result {
  animation: rise-in 0.7s var(--ease-settle) 3.4s forwards;
}

.screen.is-active .swipe-content {
  animation: swipe-right 2.4s var(--ease-out) 0.9s forwards;
}

.screen.is-active .toast {
  animation: toast-in 0.6s var(--ease-settle) 2.1s forwards;
}

.screen.is-active.is-playing .row:has(.tick) .box {
  animation: tick-box 0.4s var(--ease-settle) calc(1s + var(--t) * 0.9s) forwards;
}

.screen.is-active.is-playing .row:has(.tick) .box::after {
  animation: tick-mark 0.45s var(--ease-settle) calc(1.05s + var(--t) * 0.9s) forwards;
}

.screen.is-active.is-playing .row:has(.tick) b {
  animation: strike 0.3s linear calc(1.1s + var(--t) * 0.9s) forwards;
}

.screen.is-active .row.arrive {
  animation: arrive 0.7s var(--ease-out) 3.2s forwards;
}

.screen.is-active .recipe {
  animation: rise-in 0.8s var(--ease-out) 0.25s forwards;
}

.screen.is-active .recipe-small {
  animation-delay: 0.45s;
}

@keyframes laser {
  0% { opacity: 0; transform: translateY(-20cqw); }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translateY(20cqw); }
}

@keyframes rise-in {
  to { opacity: 1; transform: none; }
}

@keyframes swipe-right {
  0% { transform: none; }
  35% { transform: translateX(32%); }
  55% { transform: translateX(32%); }
  100% { transform: translateX(105%); }
}

@keyframes toast-in {
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes tick-box {
  to { background: var(--ios-green); box-shadow: none; }
}

@keyframes tick-mark {
  to { transform: rotate(45deg) scale(1); }
}

@keyframes strike {
  to { color: var(--ios-secondary); text-decoration: line-through; }
}

@keyframes arrive {
  to { opacity: 1; transform: none; }
}

/* ==========================================================================
   INSIEME (sincronizzazione)
   ========================================================================== */

.together {
  padding: 120px 0;
  background: radial-gradient(50% 60% at 50% 70%, var(--accent-soft), transparent 70%);
}

.duo {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  max-width: 820px;
  margin: 0 auto;
}

.mini {
  display: grid;
  justify-items: center;
  gap: 18px;
  margin: 0;
}

.phone-mini {
  width: clamp(150px, 22vw, 250px);
  aspect-ratio: 9 / 15;
  border-radius: 42px;
}

.mini figcaption {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 15px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.a1 { background: #c4492b; }
.a2 { background: #2f68bd; }

.duo .row {
  transition: opacity 0.45s var(--ease-out), transform 0.6s var(--ease-settle);
}

.duo .row.hidden {
  opacity: 0;
  transform: translateY(-30%);
}

.row.flash {
  animation: flash 1.2s var(--ease-out);
}

@keyframes flash {
  0% { background: color-mix(in srgb, var(--ios-green) 26%, transparent); }
  100% { background: transparent; }
}

.wire {
  position: relative;
  height: 60px;
  margin: 0 -6px;
}

.wire-line {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--line) 0 8px, transparent 8px 14px);
}

.pulse {
  position: absolute;
  top: calc(50% - 5px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
  opacity: 0;
}

.duo.send-right .pulse.to-right {
  animation: travel-right 0.9s var(--ease-out) forwards;
}

.duo.send-left .pulse.to-left {
  animation: travel-left 0.9s var(--ease-out) forwards;
}

@keyframes travel-right {
  0% { left: 0; opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { left: calc(100% - 10px); opacity: 0; }
}

@keyframes travel-left {
  0% { left: calc(100% - 10px); opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { left: 0; opacity: 0; }
}

.wire-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 20px;
  box-shadow: 0 0 0 1px var(--line), 0 10px 30px -12px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
}

.duo.send-right .wire-badge .i,
.duo.send-left .wire-badge .i {
  animation: spin 0.9s var(--ease-out);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   FUNZIONI (bento)
   ========================================================================== */

.features {
  padding: 40px 0 120px;
}

.bento {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-areas:
    'off off rem rem'
    'off off pri inv'
    'nat nat nat nat';
  gap: 16px;
  margin-top: 48px;
}

.cell {
  position: relative;
  overflow: hidden;
  padding: 30px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}

.cell h3 {
  margin: 0 0 8px;
  font-size: 23px;
  line-height: 1.3;
  letter-spacing: -0.025em;
  font-weight: 650;
}

.cell p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.cell-icon {
  display: block;
  margin-bottom: 18px;
  font-size: 30px;
  color: var(--accent);
}

.cell-offline {
  grid-area: off;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  min-height: 420px;
  background:
    radial-gradient(80% 60% at 100% 0%, rgba(52, 210, 103, 0.35), transparent 60%),
    linear-gradient(160deg, #123d22, #08180f 70%);
  color: #effaf2;
  box-shadow: none;
}

.cell-offline h3 {
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.12;
  max-width: 12ch;
}

.cell-offline p {
  max-width: 36ch;
  color: rgba(239, 250, 242, 0.8);
}

.cell-offline .cell-icon {
  color: #6ee79a;
}

.sync-chip {
  position: relative;
  align-self: flex-start;
  height: 46px;
  min-width: 250px;
}

.chip-state {
  position: absolute;
  inset: 0 auto 0 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-radius: 99px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.chip-wait {
  background: rgba(255, 159, 10, 0.18);
  color: #ffc46b;
  box-shadow: inset 0 0 0 1px rgba(255, 196, 107, 0.3);
}

.chip-done {
  background: rgba(52, 210, 103, 0.2);
  color: #7ff0a8;
  box-shadow: inset 0 0 0 1px rgba(127, 240, 168, 0.3);
  opacity: 0;
}

.sync-chip.is-playing .chip-wait {
  animation: chip-out 5s var(--ease-out) infinite;
}

.sync-chip.is-playing .chip-done {
  animation: chip-in 5s var(--ease-out) infinite;
}

@keyframes chip-out {
  0%, 45% { opacity: 1; transform: none; }
  55%, 92% { opacity: 0; transform: translateY(-40%); }
  100% { opacity: 1; transform: none; }
}

@keyframes chip-in {
  0%, 45% { opacity: 0; transform: translateY(40%); }
  55%, 92% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(40%); }
}

.cell-reminder {
  grid-area: rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 24px;
}

.stack {
  position: relative;
  height: 110px;
}

.stack-card {
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  display: flex;
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  box-shadow: 0 14px 30px -18px rgba(0, 0, 0, 0.4);
  transition: transform 0.6s var(--ease-settle);
}

.stack-card img {
  height: 22px;
  border-radius: 6px;
}

.stack-card span {
  display: grid;
}

.stack-card b {
  color: var(--text);
  font-weight: 600;
}

.stack-card.back {
  z-index: 0;
  height: 62px;
  transform: translateY(18px) scale(0.92);
  opacity: 0.6;
}

.cell-reminder:hover .stack-card:not(.back) {
  transform: translateY(-6px) rotate(-1.5deg);
}

.cell-privacy {
  grid-area: pri;
  background: var(--accent-soft);
  box-shadow: none;
}

.cell-invite {
  grid-area: inv;
}

.code {
  display: flex;
  gap: 6px;
  margin-top: 20px;
  perspective: 400px;
}

.code span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 42px;
  border-radius: 10px;
  background: var(--surface-2);
  font-weight: 650;
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}

.cell-invite.is-in .code span {
  animation: flip-in 0.6s var(--ease-settle) calc(0.3s + var(--n, 0) * 0.07s) both;
}

.code span:nth-child(1) { --n: 0; }
.code span:nth-child(2) { --n: 1; }
.code span:nth-child(3) { --n: 2; }
.code span:nth-child(4) { --n: 3; }
.code span:nth-child(5) { --n: 4; }
.code span:nth-child(6) { --n: 5; }

@keyframes flip-in {
  from { opacity: 0; transform: rotateX(80deg) translateY(10px); }
}

.cell-native {
  grid-area: nat;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  background: linear-gradient(120deg, var(--surface) 40%, color-mix(in srgb, var(--accent) 12%, var(--surface)));
}

.cell-native .cell-copy {
  max-width: 46ch;
}

.gestures {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.gestures span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 99px;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 15px;
  transition: transform 0.4s var(--ease-settle);
}

.gestures span:nth-child(1) {
  color: var(--accent);
}

.gestures span:hover {
  transform: translateY(-4px);
}

/* ==========================================================================
   MANIFESTO
   ========================================================================== */

.manifesto {
  padding: 60px 0 140px;
}

.manifesto-text {
  max-width: 20ch;
  margin: 0;
  font-size: clamp(36px, 5.8vw, 80px);
  line-height: 1.08;
  letter-spacing: -0.045em;
  font-weight: 650;
  text-wrap: balance;
}

.manifesto-text .w {
  display: inline-block;
  opacity: 0.2;
  transition: opacity 0.6s var(--ease-out);
}

.manifesto-text.is-lit .w {
  opacity: 1;
}

@supports (animation-timeline: view()) {
  .manifesto-text .w {
    animation: word-light linear both;
    animation-timeline: view();
    animation-range: entry 60% cover 45%;
    transition: none;
  }
}

@keyframes word-light {
  from { opacity: 0.2; }
  to { opacity: 1; }
}

/* ==========================================================================
   BETA
   ========================================================================== */

.beta {
  padding: 40px 0 140px;
}

.beta-inner {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 80px 24px;
  border-radius: 40px;
  background:
    radial-gradient(60% 70% at 50% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  text-align: center;
  overflow: hidden;
}

.beta-icon {
  border-radius: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 24px 44px -20px rgba(0, 0, 0, 0.45);
}

.beta-inner.is-in .beta-icon {
  animation: bob 1s var(--ease-settle) 0.15s both;
}

@keyframes bob {
  from { transform: translateY(30px) scale(0.85) rotate(-8deg); opacity: 0; }
}

.beta h2 {
  margin: 8px 0 0;
  font-size: clamp(32px, 4.4vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.04em;
  font-weight: 650;
}

.beta p {
  max-width: 44ch;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 19px;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.footer {
  padding: 32px 0 48px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
}

.footer .brand {
  color: var(--text);
}

.footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.footer a {
  text-decoration: none;
}

.footer nav a:hover {
  color: var(--text);
}

/* ==========================================================================
   Pagine di testo (privacy, supporto)
   ========================================================================== */

.doc {
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 0 100px;
}

.doc h1 {
  margin: 0 0 10px;
  font-size: clamp(38px, 6vw, 60px);
  line-height: 1.06;
  letter-spacing: -0.045em;
  font-weight: 680;
}

.doc .updated {
  margin: 0 0 44px;
  color: var(--muted);
}

.doc h2 {
  margin: 48px 0 12px;
  font-size: 25px;
  line-height: 1.3;
  letter-spacing: -0.025em;
  font-weight: 650;
}

.doc p,
.doc li {
  line-height: 1.7;
}

.doc ul {
  padding-left: 22px;
}

.doc li + li {
  margin-top: 8px;
}

.doc a {
  color: var(--accent);
  text-underline-offset: 3px;
}

.panel {
  margin: 28px 0;
  padding: 26px 28px;
  border-radius: var(--radius-card);
  background: var(--accent-soft);
}

.panel p {
  margin: 0;
}

details {
  margin: 10px 0;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  transition: box-shadow 0.3s;
}

details[open] {
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent);
}

summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary .i {
  color: var(--muted);
  transition: transform 0.4s var(--ease-out);
}

details[open] summary .i {
  transform: rotate(180deg);
}

details p {
  margin: 0;
  padding: 0 24px 22px;
  color: var(--muted);
}

/* ==========================================================================
   Ingressi
   ========================================================================== */

.enter {
  animation: enter 1s var(--ease-out) calc(var(--d, 0) * 0.12s) both;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(26px); filter: blur(8px); }
}

.hero-stage.enter {
  animation-name: stage-in;
  animation-duration: 1.4s;
}

@keyframes stage-in {
  from { opacity: 0; transform: translateY(70px) scale(0.94); }
}

.hero .pop {
  animation: pop 0.7s var(--ease-out) calc(0.7s + var(--i) * 0.08s) both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
}

.hero .notification {
  animation: notify 0.9s var(--ease-settle) 1.7s both;
}

@keyframes notify {
  from { opacity: 0; transform: translateY(-40px) scale(0.9); }
}

.js [data-reveal] {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
}

.js [data-reveal].is-in {
  opacity: 1;
  transform: none;
}

.bento [data-reveal]:nth-child(2) { transition-delay: 0.08s; }
.bento [data-reveal]:nth-child(3) { transition-delay: 0.16s; }
.bento [data-reveal]:nth-child(4) { transition-delay: 0.24s; }
.bento [data-reveal]:nth-child(5) { transition-delay: 0.1s; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 960px) {
  .nav-links {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 56px;
    min-height: 0;
    padding: 40px 0 80px;
  }

  .hero-stage .phone {
    width: min(300px, 74vw);
  }

  .story-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .story-stage {
    order: -1;
    top: 64px;
    z-index: 2;
    height: auto;
    padding: 12px 0 18px;
    background: linear-gradient(var(--bg) 85%, transparent);
  }

  .phone-story {
    width: min(150px, 40vw);
    border-radius: 30px;
    padding: 2.6%;
  }

  .step {
    min-height: 55vh;
    max-width: none;
    justify-content: flex-end;
    padding-bottom: 12vh;
  }

  .duo {
    grid-template-columns: 1fr auto 1fr;
  }

  .phone-mini {
    width: min(170px, 38vw);
    border-radius: 30px;
  }

  .wire {
    width: 48px;
  }

  .wire-badge {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .bento {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      'off off'
      'rem rem'
      'pri inv'
      'nat nat';
  }

  .cell-native {
    flex-direction: column;
    align-items: flex-start;
  }

  .gestures {
    justify-content: flex-start;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .nav .btn-small {
    padding: 8px 14px;
  }

  .hero-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .bento {
    grid-template-columns: 1fr;
    grid-template-areas: 'off' 'rem' 'pri' 'inv' 'nat';
  }

  .cell-offline {
    min-height: 0;
  }

  .cell-reminder {
    grid-template-columns: 1fr;
  }

  .mini figcaption {
    flex-direction: column;
    font-size: 13px;
    text-align: center;
  }

  .together {
    padding: 90px 0;
  }

  .beta-inner {
    padding: 56px 20px;
    border-radius: 32px;
  }
}

/* ==========================================================================
   Accessibilità: movimento e trasparenza ridotti
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0s !important;
  }

  .js [data-reveal],
  .enter {
    opacity: 1;
    transform: none;
    filter: none;
  }

  .manifesto-text .w {
    animation: none !important;
    opacity: 1;
  }

  .hero-stage .phone {
    transform: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .nav.is-scrolled,
  .notification,
  .tabbar {
    background: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
