/* Pagina storia — Registra il pagamento (7 scene, zero AWS) */

body.story-page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
}

.story-page main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.story-toolbar {
  flex-shrink: 0;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}

.story-toolbar-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.story-toolbar-intro h1 {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--blue-dark);
  margin: 0 0 0.2rem;
}

.story-toolbar-intro p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 36rem;
}

.story-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.story-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.story-btn:hover {
  border-color: var(--border-strong);
  color: var(--blue);
}

.story-btn--primary {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
}

.story-btn--primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: var(--white);
}

.story-btn--ghost {
  background: transparent;
  border-color: var(--blue);
  color: var(--blue);
}

.story-btn--ghost:hover {
  background: rgba(0, 113, 194, 0.08);
  color: var(--blue-dark);
}

.story-btn--hidden {
  display: none !important;
}

.story-progress {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
}

.story-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.25s, transform 0.25s;
}

.story-dot--active {
  background: var(--blue);
  transform: scale(1.25);
}

.story-dot--done {
  background: var(--light-blue);
}

.story-stage {
  position: relative;
  flex: 1 0 auto;
  min-height: max(26rem, calc(100dvh - 12.5rem));
  background: linear-gradient(
    180deg,
    rgba(0, 113, 194, 0.08) 0%,
    var(--surface) 45%,
    var(--yellow-soft) 100%
  );
  overflow: visible;
}

.story-scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.45s ease, transform 0.45s ease, visibility 0.45s;
}

.story-scene--active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.story-scene--illust {
  overflow: visible;
}

.story-scene[data-scene="1"],
.story-scene[data-scene="2"],
.story-scene[data-scene="3"],
.story-scene[data-scene="4"] {
  padding-top: 1.35rem;
}

.story-scene--phone {
  align-items: center;
}

.story-scene--phone .phone-device {
  flex: 0 0 auto;
  width: 100%;
  margin-inline: auto;
}

/* ── Vignette fumetto (scene 1–4) ── */

.comic-frame {
  position: relative;
  width: min(100%, 22rem);
}

.comic-panel {
  margin: 0;
  width: min(100%, 22rem);
  border: 4px solid #1a1a1a;
  border-radius: 6px;
  box-shadow: 6px 6px 0 rgba(26, 26, 26, 0.15);
  background: var(--white);
  overflow: hidden;
}

.comic-frame .comic-panel {
  width: 100%;
}

.comic-balloon {
  position: absolute;
  z-index: 3;
  margin: 0;
  padding: 0.55rem 0.75rem;
  background: var(--white);
  border: 3px solid #1a1a1a;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
  color: #1a1a1a;
  text-align: center;
  box-shadow: 4px 4px 0 rgba(26, 26, 26, 0.14);
  max-width: 11rem;
  opacity: 0;
  transform: scale(0.88);
}

.comic-balloon--waitress {
  top: -0.9rem;
  left: 0;
  max-width: 10.5rem;
  transform: rotate(-1deg) scale(0.88);
}

.comic-balloon--waitress::after,
.comic-balloon--guest::after {
  content: '';
  position: absolute;
  bottom: -13px;
  width: 0;
  height: 0;
  border: 12px solid transparent;
  border-top-color: #1a1a1a;
  border-bottom: 0;
  transform-origin: top center;
}

.comic-balloon--waitress::before,
.comic-balloon--guest::before {
  content: '';
  position: absolute;
  bottom: -7px;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-top-color: var(--white);
  border-bottom: 0;
  transform-origin: top center;
  z-index: 1;
}

.comic-balloon--waitress::after {
  left: 68%;
  transform: translateX(-50%) rotate(14deg);
}

.comic-balloon--waitress::before {
  left: 68%;
  transform: translateX(-50%) rotate(14deg);
}

.comic-balloon--guest {
  top: 8%;
  right: -0.15rem;
  left: auto;
  max-width: 5.5rem;
  padding: 0.45rem 0.65rem;
  transform: rotate(2deg) scale(0.88);
}

.comic-balloon--guest::after {
  left: 30%;
  transform: translateX(-50%) rotate(-16deg);
}

.comic-balloon--guest::before {
  left: 30%;
  transform: translateX(-50%) rotate(-16deg);
}

.story-scene--active .comic-balloon--waitress {
  animation: comic-balloon-in-waitress 0.55s ease-out 0.45s forwards;
}

.story-scene--active .comic-balloon--guest {
  animation: comic-balloon-in-guest 0.45s ease-out 1.15s forwards;
}

.comic-balloon--cassa-guest {
  top: 5%;
  left: -0.1rem;
  right: auto;
  max-width: 7.5rem;
  padding: 0.45rem 0.65rem;
  transform: rotate(-2deg) scale(0.88);
}

.comic-balloon--cassa-waitress {
  top: -0.85rem;
  right: 0;
  left: auto;
  max-width: 11rem;
  transform: rotate(1deg) scale(0.88);
}

.comic-balloon--cassa-guest::after,
.comic-balloon--cassa-waitress::after {
  content: '';
  position: absolute;
  bottom: -13px;
  width: 0;
  height: 0;
  border: 12px solid transparent;
  border-top-color: #1a1a1a;
  border-bottom: 0;
  transform-origin: top center;
}

.comic-balloon--cassa-guest::before,
.comic-balloon--cassa-waitress::before {
  content: '';
  position: absolute;
  bottom: -7px;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-top-color: var(--white);
  border-bottom: 0;
  transform-origin: top center;
  z-index: 1;
}

.comic-balloon--cassa-guest::after {
  left: 70%;
  transform: translateX(-50%) rotate(12deg);
}

.comic-balloon--cassa-guest::before {
  left: 70%;
  transform: translateX(-50%) rotate(12deg);
}

.comic-balloon--cassa-waitress::after {
  left: 32%;
  transform: translateX(-50%) rotate(-14deg);
}

.comic-balloon--cassa-waitress::before {
  left: 32%;
  transform: translateX(-50%) rotate(-14deg);
}

.story-scene--active .comic-balloon--cassa-guest {
  animation: comic-balloon-in-cassa-guest 0.55s ease-out 0.45s forwards;
}

.story-scene--active .comic-balloon--cassa-waitress {
  animation: comic-balloon-in-cassa-waitress 0.55s ease-out 1.15s forwards;
}

@keyframes comic-balloon-in-cassa-guest {
  from {
    opacity: 0;
    transform: rotate(-2deg) scale(0.75) translateY(8px);
  }
  to {
    opacity: 1;
    transform: rotate(-2deg) scale(1) translateY(0);
  }
}

@keyframes comic-balloon-in-cassa-waitress {
  from {
    opacity: 0;
    transform: rotate(1deg) scale(0.75) translateY(8px);
  }
  to {
    opacity: 1;
    transform: rotate(1deg) scale(1) translateY(0);
  }
}

@keyframes comic-balloon-in-waitress {
  from {
    opacity: 0;
    transform: rotate(-1deg) scale(0.75) translateY(8px);
  }
  to {
    opacity: 1;
    transform: rotate(-1deg) scale(1) translateY(0);
  }
}

@keyframes comic-balloon-in-guest {
  from {
    opacity: 0;
    transform: rotate(2deg) scale(0.75) translateY(6px);
  }
  to {
    opacity: 1;
    transform: rotate(2deg) scale(1) translateY(0);
  }
}

.comic-thought {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.comic-balloon--thought {
  top: -0.85rem;
  left: 5%;
  right: auto;
  max-width: 9.5rem;
  padding: 0.6rem 0.8rem;
  border-width: 2.5px;
  border-radius: 45% 55% 48% 52% / 52% 48% 52% 48%;
  box-shadow: 3px 3px 0 rgba(26, 26, 26, 0.1);
  transform: rotate(-2deg) scale(0.88);
}

.comic-balloon--thought-driver {
  top: -0.65rem;
  left: 10%;
  max-width: 11rem;
}

.comic-thought-dot {
  position: absolute;
  display: block;
  background: var(--white);
  border: 2px solid #1a1a1a;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0);
}

/* Catena testa (destra) → nuvola (sinistra) */
.comic-thought-dot--1 {
  top: 10%;
  left: 48%;
  width: 13px;
  height: 13px;
}

.comic-thought-dot--2 {
  top: 18%;
  left: 58%;
  width: 9px;
  height: 9px;
}

/* Scena 1 — testa uomo (destra) → nuvola pensiero (sinistra) */
.comic-thought-dot--driver-1 {
  top: 11%;
  left: 46%;
  width: 13px;
  height: 13px;
}

.comic-thought-dot--driver-2 {
  top: 19%;
  left: 61%;
  width: 9px;
  height: 9px;
}

.story-scene--active .comic-balloon--thought {
  animation: comic-thought-in 0.55s ease-out 0.85s forwards;
}

.story-scene--active .comic-thought-dot--2 {
  animation: comic-thought-dot-in 0.3s ease-out 0.4s forwards;
}

.story-scene--active .comic-thought-dot--1 {
  animation: comic-thought-dot-in 0.3s ease-out 0.55s forwards;
}

.story-scene--active .comic-thought-dot--driver-2 {
  animation: comic-thought-dot-in 0.3s ease-out 0.4s forwards;
}

.story-scene--active .comic-thought-dot--driver-1 {
  animation: comic-thought-dot-in 0.3s ease-out 0.55s forwards;
}

@keyframes comic-thought-in {
  from {
    opacity: 0;
    transform: rotate(-2deg) scale(0.75) translateY(6px);
  }
  to {
    opacity: 1;
    transform: rotate(-2deg) scale(1) translateY(0);
  }
}

@keyframes comic-thought-dot-in {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes comic-balloon-in {
  from {
    opacity: 0;
    transform: rotate(-2deg) scale(0.75) translateY(8px);
  }
  to {
    opacity: 1;
    transform: rotate(-2deg) scale(1) translateY(0);
  }
}

.comic-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  vertical-align: top;
}

.story-scene--active .comic-img {
  animation: comic-img-in 0.55s ease-out;
}

@keyframes comic-img-in {
  from { opacity: 0.6; transform: scale(1.03); }
  to { opacity: 1; transform: scale(1); }
}

.comic-prop {
  opacity: 0;
  transform: scale(0.7) translateY(8px);
  transform-origin: center;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.comic-prop--visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.story-scene--active .comic-animate--truck {
  animation: comic-truck-in 1s ease-out forwards;
}

.story-scene--active .comic-animate--sit {
  animation: comic-sit-in 0.85s ease-out forwards;
}

.story-scene--active .comic-animate--waiter {
  animation: comic-fade-in 0.6s ease-out forwards;
}

.story-scene--active .comic-animate--cash {
  animation: comic-cash-shake 1.2s ease-in-out infinite;
}

@keyframes comic-truck-in {
  from { transform: translateX(-60px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes comic-sit-in {
  from { transform: translateY(-24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes comic-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes comic-cash-shake {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ── Telefono mock (scene 5–8) ── */

.phone-device {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.phone-device .phone-frame {
  flex-shrink: 0;
  margin-inline: auto;
}

.phone-frame {
  width: min(100%, 260px);
  background: #1a1a1a;
  border-radius: 28px;
  padding: 10px 8px 14px;
  box-shadow: 0 8px 28px rgba(35, 56, 126, 0.18);
}

.phone-notch {
  width: 40%;
  height: 5px;
  background: #333;
  border-radius: 99px;
  margin: 0 auto 8px;
}

.phone-screen {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 18px;
  overflow: hidden;
  min-height: 340px;
}

.phone-screen > .app-step {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app-bar {
  background: var(--blue);
  color: var(--white);
  text-align: center;
  padding: 0.65rem 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.app-body {
  padding: 0.75rem 0.85rem 1rem;
}

.app-body--cream {
  background: var(--surface);
  min-height: 280px;
}

.app-body--centered {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0.75rem 0.85rem;
}

.app-step--cashback .app-body--cream,
.app-step--sent .app-body--cream,
.app-step--accepted .app-body--cream {
  min-height: 0;
}

.app-hero-brand {
  text-align: center;
  margin-bottom: 0.85rem;
  padding: 0.35rem 0 0.5rem;
}

.app-hero-brand--compact {
  margin-bottom: 0.65rem;
  padding-top: 0.15rem;
}

.app-hero-brand--compact .app-hero-title {
  font-size: 1rem;
}

.app-hero-brand--compact .app-hero-sub {
  font-size: 0.72rem;
}

.app-hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--blue-dark);
  line-height: 1.1;
}

.app-hero-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(150px, 90%);
  margin: 0.35rem auto;
  gap: 0.35rem;
}

.app-hero-line {
  flex: 1;
  height: 1px;
  background: var(--light-blue);
}

.app-hero-ornament img {
  display: block;
  width: 28px;
  height: auto;
  object-fit: contain;
}

.app-hero-brand--compact .app-hero-ornament img {
  width: 24px;
}

.app-hero-sub {
  margin: 0.2rem 0 0;
  font-family: var(--font-body);
  font-style: normal;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.app-step--outro {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.app-body--outro {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 1.25rem 1rem;
}

.app-hero-brand--outro {
  margin: 0;
  padding: 0;
  width: 100%;
}

.app-hero-brand--outro .app-hero-title {
  font-size: 1.35rem;
}

.app-hero-brand--outro .app-hero-ornament {
  width: min(180px, 92%);
  margin: 0.5rem auto;
}

.app-hero-brand--outro .app-hero-ornament img {
  width: 34px;
}

.app-hero-brand--outro .app-hero-sub {
  font-size: 0.88rem;
}

.story-scene--active .app-hero-brand--outro {
  animation: logo-reveal 0.85s ease-out;
}

@keyframes logo-reveal {
  0% { opacity: 0; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

.app-cta {
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--blue);
  color: var(--white);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: default;
  transition: box-shadow 0.25s, transform 0.25s;
}

.app-cta--highlight {
  animation: cta-glow 1s ease-in-out infinite;
}

.app-cta--accept {
  margin-top: 0.75rem;
  background: var(--yellow);
  color: var(--text);
}

.app-cta--accept:hover {
  background: #ffc933;
}

@keyframes cta-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 113, 194, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(0, 113, 194, 0); }
}

.app-venue-name {
  margin: 0 0 0.75rem;
  font-weight: 700;
  color: var(--blue-dark);
  font-size: 0.95rem;
}

.app-field span {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.app-amount {
  background: var(--white);
  border: 2px solid var(--light-blue);
  border-radius: 10px;
  padding: 0.65rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--blue-dark);
  text-align: center;
}

.app-amount--typing {
  animation: amount-blink 0.6s step-end 3;
}

@keyframes amount-blink {
  50% { border-color: var(--blue); }
}

.app-cash-note {
  margin: 0.75rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.app-success-card,
.app-notification,
.app-cashback-card {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.app-success-title,
.app-notification-title,
.app-cashback-label {
  margin: 0 0 0.35rem;
  font-weight: 700;
  color: var(--blue-dark);
}

.app-cashback-card {
  border-color: var(--yellow);
  background: linear-gradient(180deg, var(--yellow-soft) 0%, var(--white) 100%);
}

.app-summary-card {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 0.9rem 0.95rem;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.app-summary-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 0.5rem;
  border-radius: 50%;
  background: var(--yellow-soft);
  border: 1px solid var(--border);
  color: var(--blue-dark);
}

.app-summary-title {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  font-size: 1rem;
  color: var(--blue-dark);
}

.app-summary-rows {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.app-summary-row {
  display: grid;
  grid-template-columns: 1fr 4.75rem;
  align-items: center;
  gap: 0.35rem 0.5rem;
  text-align: left;
}

.app-summary-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.app-summary-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.app-summary-value--emphasized {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--blue);
}

.story-scene--active .app-summary-value--emphasized {
  animation: cashback-pop 0.6s ease-out;
}

.app-summary-note {
  margin: 0;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.app-cashback-amount {
  margin: 0.25rem 0;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--blue-dark);
}

.story-scene--active .app-cashback-amount {
  animation: cashback-pop 0.6s ease-out;
}

.app-cashback-sub {
  margin: 0;
  font-size: 0.8rem;
}

@keyframes cashback-pop {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.app-step[hidden] {
  display: none !important;
}

/* ── Scena 8: device alto come le altre scene telefono ── */

.story-scene--device-full {
  padding: 0.75rem 1rem 1rem;
  gap: 0.5rem;
}

.story-scene--device-full .phone-device {
  flex-shrink: 0;
}

.story-scene--device-full .phone-screen {
  min-height: 380px;
}

@media (prefers-reduced-motion: reduce) {
  .story-scene,
  .comic-img,
  .comic-animate--truck,
  .comic-animate--sit,
  .comic-animate--cash,
  .comic-prop,
  .comic-balloon--thought,
  .comic-balloon--waitress,
  .comic-balloon--guest,
  .comic-balloon--cassa-guest,
  .comic-balloon--cassa-waitress,
  .comic-thought-dot,
  .app-cta--highlight,
  .app-cashback-amount,
  .app-summary-value--emphasized,
  .app-hero-brand--outro {
    animation: none !important;
    transition: none !important;
  }

  .comic-prop {
    opacity: 1;
    transform: none;
  }

  .comic-balloon--thought {
    opacity: 1;
    transform: rotate(-2deg) scale(1);
  }

  .comic-balloon--waitress {
    opacity: 1;
    transform: rotate(-1deg) scale(1);
  }

  .comic-balloon--guest {
    opacity: 1;
    transform: rotate(2deg) scale(1);
  }

  .comic-balloon--cassa-guest {
    opacity: 1;
    transform: rotate(-2deg) scale(1);
  }

  .comic-balloon--cassa-waitress {
    opacity: 1;
    transform: rotate(1deg) scale(1);
  }

  .comic-thought-dot {
    opacity: 1;
    transform: scale(1);
  }
}

@media (min-width: 768px) {
  .story-toolbar-intro h1 {
    font-size: 1.45rem;
  }

  .comic-panel {
    width: min(100%, 26rem);
  }

  .comic-frame {
    width: min(100%, 26rem);
  }

  .comic-balloon {
    font-size: 0.88rem;
    max-width: 12rem;
  }

  .phone-screen {
    min-height: 360px;
  }

  .story-scene--device-full .phone-screen {
    min-height: 400px;
  }
}
