/* ==========================================================
   Un viaggio ti aspetta - Victorian vintage
   Italian = Italianno (sized up) - English = Playfair Display (small print)
   Printed text is brand plum. Buyer's typed text is pen blue.
   ========================================================== */

:root {
  --plum: #6c0d6e;
  --blue: #4f84a6;            /* Amalfi blue (buttons) */
  --blue-hover: #5a90b3;
  --gold: #b8902f;
  --gold-light: #d6b252;
  --ink: #3b2a1a;
  --pen: #1f3f9a;             /* buyer's pen-blue handwriting */
  --page: #1c4968;            /* deep Amalfi blue behind the pages */
  --cream: #fbf1d6;
  --serif: 'Playfair Display', Georgia, serif;
  --script: 'Italianno', 'Brush Script MT', cursive;
  --hand: 'Parisienne', 'Segoe Script', cursive;
  --name: 'Great Vibes', 'Brush Script MT', cursive;

  /* aged paper grain (inline SVG noise, no blur) */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .22 0 0 0 0 .08 0 0 0 .42 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--serif);
  color: var(--plum);
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100svh;
  background: radial-gradient(ellipse at 50% 28%, #2a6085 0%, var(--page) 58%, #112f45 100%);
  background-attachment: fixed;
}

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

/* ---------- language pairs ---------- */
.it {
  font-family: var(--script);
  font-weight: 400;
  line-height: 1;
  color: var(--plum);
}
.en {
  font-family: var(--serif);
  font-size: .78rem;
  letter-spacing: .02em;
  line-height: 1.25;
  color: var(--plum);
}
.title .it, .title .en,
.gift .it, .gift .en,
.t-title .it, .t-title .en,
.hint .it, .hint .en { display: block; }

/* never leave one word alone on a second line */
.ln { display: inline-block; }
.title .en, .gift .en, .lead .en { text-wrap: balance; }

/* ---------- buttons: Amalfi blue, gold ring, cream text ---------- */
.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  background: var(--blue);
  padding: 9px 32px 11px;
  border-radius: 10px;
  box-shadow: 0 0 0 2px var(--blue), 0 0 0 4px var(--gold), 0 6px 12px rgba(0, 0, 0, .35);
  transition: background .15s ease, transform .15s ease;
  font-family: var(--serif);
}
.btn .it { font-size: 2rem; color: var(--cream); }
.btn .en { font-size: .72rem; color: var(--cream); opacity: .92; }
.btn:hover, .btn:focus-visible { background: var(--blue-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 5px; }
.btn.small { padding: 6px 22px 8px; }
.btn.small .it { font-size: 1.6rem; }

.round-btn {
  width: 46px; height: 46px;
  border: 0; border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--cream);
  background: var(--blue);
  box-shadow: 0 0 0 2px var(--blue), 0 0 0 4px var(--gold), 0 4px 10px rgba(0, 0, 0, .4);
}
.round-btn svg { width: 22px; height: 22px; fill: currentColor; }
.round-btn:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 5px; }

/* thin engraved double rule */
.rule {
  height: 5px;
  margin: 16px auto;
  width: 62%;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  opacity: .55;
}

/* ==========================================================
   PAGE 1 - THE SCROLL
   ========================================================== */
.stage {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 16px 32px;
  overflow-x: clip;
}
.stage > .scroll { margin-top: auto; }
.stage > .hint   { margin-bottom: auto; }

.scroll {
  --rt: 68px;                         /* top roll is slimmer than the bottom one: never symmetrical */
  --rb: 90px;
  position: relative;
  width: min(calc(100vw - 88px), 540px);   /* the brass handles stick out ~38px on each side */
  display: flex;
  flex-direction: column;
  filter: drop-shadow(0 14px 16px rgba(0, 0, 0, .45));
}

/* brass handles on the ends of the rolls; the small offsets follow each roll's slight tilt */
.knob {
  position: absolute;
  z-index: 3;
  width: 54px; height: 24px;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35));
}
.knob.kl { left: -40px; }
.knob.kr { right: -40px; transform: scaleX(-1); }
.knob.kt.kl { top: calc(var(--rt) / 2 - 7px); }
.knob.kt.kr { top: calc(var(--rt) / 2 - 13px); }
.knob.kb.kl { bottom: calc(var(--rb) / 2 - 11px); }
.knob.kb.kr { bottom: calc(var(--rb) / 2 - 15px); }

/* ----- parchment rolls (matte, ragged, no shine) ----- */
.roll {
  position: relative;
  z-index: 2;
  height: var(--rb);
  border-radius: 40px / 50%;
  background:
    repeating-linear-gradient(94deg, rgba(120, 80, 30, .07) 0 1px, transparent 1px 8px),
    radial-gradient(ellipse at 0 50%, rgba(110, 70, 25, .45) 0, transparent 22%),
    radial-gradient(ellipse at 100% 50%, rgba(110, 70, 25, .45) 0, transparent 22%),
    linear-gradient(180deg, #b69259 0%, #d7bd86 14%, #ead8aa 36%, #f1e2bb 50%, #e1c993 72%, #c4a468 90%, #a98550 100%);
  filter: url(#rough);
}
.roll::before, .roll::after {        /* rolled-paper ends, plain shading only */
  content: "";
  position: absolute;
  top: 3px; bottom: 3px;
  width: 36px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 45% 50%, #efe0b6 0%, #d9c08a 55%, #b08a52 100%);
}
.roll::before { left: -8px; }
.roll::after  { right: -8px; }
.roll-top {
  height: var(--rt);
  width: 100%;
  margin-left: 0;
  transform: rotate(-1.1deg);
  transform-origin: 80% 100%;
}
.roll-top::before { width: 30px; left: -6px; }
.roll-top::after  { width: 42px; right: -12px; top: 1px; bottom: 5px; }
.roll-bottom {
  margin-top: -10px;                  /* tucks the paper under the bottom roll; also keeps the closed rolls pressed together */
  width: 100%;
  margin-left: 0;
  transform: rotate(.7deg);
  transform-origin: 20% 0;
}
.roll-bottom::before { width: 40px; left: -11px; top: 5px; bottom: 1px; }
.roll-bottom::after  { width: 32px; right: -5px; }

/* ----- the sheet that unfurls from the middle outward ----- */
/* The sheet's height is animated from 0 to the paper's real height (scroll.js sets the target),
   so the box and the visible paper are always exactly the same size and no gap can open between rolls. */
.sheet {
  height: 0;
  width: 94%;
  margin: -8px auto 0;                /* tucked under the top roll from the start (never animated) */
  overflow: hidden;
}
.sheet-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;            /* middle shows first */
}
.scroll.open .sheet {
  transition: height 2s cubic-bezier(.4, .1, .25, 1) .85s;
}

.paper {
  position: relative;
  flex: none;
  padding: 34px 28px 36px 36px;       /* more air at the sides; the extra 8px on the left centres the content on the parchment, whose left edge sits 8px further in than its right */
  text-align: center;
}
.paper::before {                      /* aged sheet with ragged sides */
  content: "";
  position: absolute;
  inset: 0 4px 0 12px;                /* uneven margins: left edge sits further in than right */
  z-index: 0;
  background:
    var(--grain),
    radial-gradient(circle at 18% 22%, rgba(120, 70, 20, .22) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 78% 14%, rgba(120, 70, 20, .2) 0 1px, transparent 2px),
    radial-gradient(circle at 64% 58%, rgba(120, 70, 20, .18) 0 2px, transparent 3px),
    radial-gradient(circle at 30% 84%, rgba(120, 70, 20, .2) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 88% 78%, rgba(120, 70, 20, .18) 0 1px, transparent 2px),
    linear-gradient(90deg, #cfb277 0%, #ebd9a8 9%, #f3e6c1 50%, #ebd9a8 91%, #cfb277 100%);
  box-shadow: inset 0 0 40px rgba(110, 70, 20, .35);
  filter: url(#rough);
}
.paper > * { position: relative; z-index: 1; }

.paper .title { margin: 0; font-weight: 400; }
.paper .title .it { font-size: clamp(3.2rem, 15vw, 4.4rem); line-height: .82; }
.paper .title .en { font-size: 1rem; font-style: italic; margin-top: 8px; }

.art {
  width: 86%;                         /* a bit smaller than the full width, centred between the two rules */
  margin: 0 auto;
  padding: 6px;
  aspect-ratio: 3 / 2;
  background: #e4d2a0;               /* plain tint shows if the picture is missing */
  border: 1px solid var(--ink);
  box-shadow: 0 0 0 3px #efe0b8, 0 0 0 4px rgba(59, 42, 26, .6), 0 5px 10px rgba(60, 35, 5, .35);
}
.art img { display: block; width: 100%; height: 100%; object-fit: cover; }

.gift { margin: 2px 0 10px; }
.gift .it { font-size: clamp(2.6rem, 12vw, 3.5rem); line-height: .86; }
.gift .en { font-size: .95rem; font-style: italic; margin-top: 4px; }

.note {
  margin: 4px auto 20px;
  max-width: 17rem;
  font-family: var(--hand);
  font-size: 1.45rem;
  line-height: 1.4;
  color: var(--pen);
  overflow-wrap: anywhere;
  white-space: pre-line;
}

/* text fades in just after the ends settle (picture is not delayed) */
.reveal { opacity: 0; }
.scroll.open .reveal {
  opacity: 1;
  transition: opacity .7s ease;
  transition-delay: calc(2.35s + var(--i, 0) * .12s);
}

/* ----- the parchment band and the wax seal ----- */
.band {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: -10px;
  width: 60px;
  height: calc(var(--rt) + var(--rb) + 4px);   /* the closed rolls overlap by 18px, so the band is shorter */
  margin-left: -30px;
  background:
    repeating-linear-gradient(0deg, rgba(120, 80, 30, .08) 0 1px, transparent 1px 7px),
    linear-gradient(90deg, #bda06a 0%, #e1ca97 18%, #efdfb6 50%, #dcc48c 82%, #b89a62 100%);
  filter: url(#rough);
  transform-origin: 50% 20%;
}

.seal {
  --s: 112px;
  position: absolute;
  z-index: 8;
  left: 50%;
  top: calc(var(--rt) - 9px);          /* centred on the seam between the closed rolls */
  width: var(--s);
  height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  animation: sealPulse 2.6s ease-in-out infinite;
  filter: drop-shadow(0 6px 4px rgba(45, 0, 0, .55)) drop-shadow(0 1px 1px rgba(45, 0, 0, .6));
}
.seal:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 6px; border-radius: 50%; }

.seal .half { position: absolute; inset: 0; }
.seal .blob {                         /* matte wax, uneven smudged edge */
  position: absolute;
  inset: 5px;
  border-radius: 47% 53% 45% 55% / 55% 45% 56% 44%;
  background: radial-gradient(circle at 36% 30%, #b8433b 0%, #a5302a 34%, #8f231e 68%, #741917 100%);
  /* thick, raised wax: soft lit edge top-left, heavy shade bottom-right (matte, no gloss) */
  box-shadow:
    inset 4px 5px 7px rgba(255, 175, 155, .26),
    inset -6px -8px 11px rgba(45, 0, 0, .5),
    inset 0 0 0 1px rgba(60, 0, 0, .25);
  filter: url(#smudge);
}
.seal .blob::before, .seal .blob::after {
  content: "";
  position: absolute;
  background: #8f231e;
  border-radius: 50%;
}
.seal .blob::before { width: 36px; height: 26px; left: -7px; top: 58%; transform: rotate(-18deg); }
.seal .blob::after  { width: 30px; height: 34px; right: -6px; top: 8%; transform: rotate(24deg); }

.seal .half::after {                  /* low raised rim around the pressed-in centre */
  content: "";
  position: absolute;
  inset: 17px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 160, 140, .2), inset 2px 3px 6px rgba(40, 0, 0, .45), inset -2px -2px 4px rgba(255, 160, 140, .14);
}
.seal .mark {                         /* Luce logo pressed in, same red */
  position: absolute;
  inset: 20px;
  /* a plain background image (not a mask) so it also shows when the page is opened from a folder */
  background: url("../images/seal-logo.png") center / contain no-repeat;
}
.seal .lip  { filter: brightness(0) invert(1); opacity: .2; transform: translate(1.3px, 1.3px); }
.seal .dent { filter: brightness(0); opacity: .5; }

.seal .left  { clip-path: polygon(0 0, 53% 0, 45% 17%, 57% 33%, 46% 51%, 58% 69%, 48% 100%, 0 100%); }
.seal .right { clip-path: polygon(53% 0, 100% 0, 100% 100%, 48% 100%, 58% 69%, 46% 51%, 57% 33%, 45% 17%); }

@keyframes sealPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }

.scroll.cracking .seal { animation: none; pointer-events: none; }
.scroll.cracking .seal .left  { animation: crackL .9s cubic-bezier(.5, 0, .6, 1) forwards; }
.scroll.cracking .seal .right { animation: crackR .9s cubic-bezier(.5, 0, .6, 1) forwards; }
@keyframes crackL {
  0%   { transform: none; opacity: 1; }
  20%  { transform: translate(-3px, 0) rotate(-3deg); }
  100% { transform: translate(-50px, 150px) rotate(-30deg); opacity: 0; }
}
@keyframes crackR {
  0%   { transform: none; opacity: 1; }
  20%  { transform: translate(3px, 0) rotate(3deg); }
  100% { transform: translate(50px, 170px) rotate(28deg); opacity: 0; }
}

.scroll.cracking .band { animation: bandFall 1s cubic-bezier(.5, 0, .9, .6) .45s forwards; }
@keyframes bandFall {
  0%   { transform: none; opacity: 1; }
  100% { transform: translateY(55vh) rotate(9deg); opacity: 0; }
}

/* tap hint on a small parchment label */
.hint {
  margin: 28px 0 0;
  padding: 8px 26px 10px;
  text-align: center;
  background: var(--grain), #eddcb0;
  border: 1px solid var(--ink);
  box-shadow: 0 0 0 3px #eddcb0, 0 0 0 4px rgba(59, 42, 26, .6), 0 6px 12px rgba(0, 0, 0, .35);
  transition: opacity .6s ease;
}
.hint .it { font-size: 2.2rem; }
.hint .en { font-size: .8rem; }
.hint.gone { opacity: 0; visibility: hidden; transition: opacity .6s ease, visibility 0s .6s; }

.replay { position: fixed; right: 16px; bottom: 16px; z-index: 40; display: none; }
.replay.show { display: grid; }

/* ==========================================================
   PAGE 2 - THE TICKET
   ========================================================== */
.ticket-page { padding: 30px 14px 44px; }

.ticket-shell {
  --notch: 15px;
  --stamp: 172px;
  --stub-w: 250px;
  position: relative;
  max-width: 460px;
  margin: 0 auto;
}

.ticket {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, .55);
}

/* tea-stained paper, darker toward the edges, faint foxing */
.t-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 6px;
  background:
    var(--grain),
    radial-gradient(circle at 9% 16%, rgba(125, 70, 20, .30) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 23% 71%, rgba(125, 70, 20, .24) 0 1px, transparent 2px),
    radial-gradient(circle at 41% 9%, rgba(125, 70, 20, .26) 0 2px, transparent 3px),
    radial-gradient(circle at 57% 47%, rgba(125, 70, 20, .18) 0 1px, transparent 2px),
    radial-gradient(circle at 72% 83%, rgba(125, 70, 20, .28) 0 2px, transparent 3.2px),
    radial-gradient(circle at 86% 27%, rgba(125, 70, 20, .24) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 93% 64%, rgba(125, 70, 20, .22) 0 1px, transparent 2px),
    radial-gradient(circle at 34% 93%, rgba(125, 70, 20, .22) 0 1.5px, transparent 2.5px),
    radial-gradient(ellipse at 50% 45%, #ecdcae 0%, #e3cd97 55%, #cfb277 82%, #b08c55 100%);
  box-shadow: inset 0 0 46px 6px rgba(95, 58, 16, .5);
}
.t-art {                              /* faded Luce picture through the lower half */
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 56%;
  background: url("../images/scene-web.jpg") center bottom / cover no-repeat;
  opacity: .34;
  mix-blend-mode: multiply;
  filter: sepia(.55) contrast(.9);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 55%);
          mask-image: linear-gradient(to bottom, transparent 0%, #000 55%);
}

/* engraved border: ink line, gold line, corner ornaments */
.frame {
  position: absolute;
  inset: 9px;
  border: 3px double var(--ink);
  outline: 1px solid var(--gold);
  outline-offset: -8px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 2;
}
.corner {
  position: absolute;
  z-index: 3;
  width: 38px; height: 38px;
  color: var(--ink);
  pointer-events: none;
}
.corner svg { width: 100%; height: 100%; display: block; }
.corner.tl { top: 11px; left: 11px; }
.corner.tr { top: 11px; right: 11px; transform: scaleX(-1); }
.corner.bl { bottom: 11px; left: 11px; transform: scaleY(-1); }
.corner.br { bottom: 11px; right: 11px; transform: scale(-1, -1); }

.t-main {
  position: relative;
  z-index: 1;
  padding: 50px 28px 104px;           /* room for the top half of the round stamp */
  text-align: center;
}

.serial {
  font-family: var(--serif);
  font-size: .78rem;
  letter-spacing: .18em;
  color: var(--plum);
}
.t-main > .serial { position: absolute; top: 24px; right: 30px; }

/* curved cartouche banner: lettering is sized from the banner width so it always sits inside */
.banner { position: relative; width: min(100%, 400px); margin: 0 auto; }
.banner img { display: block; width: 100%; height: auto; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* read by screen readers, not shown */
.banner.noimg { container-type: inline-size; aspect-ratio: 400 / 112; width: 100%; }
.banner.noimg img { display: none; }
.banner.noimg .t-title.vh { width: auto; height: auto; overflow: visible; clip: auto; }
.t-title {
  position: absolute;
  inset: 0 0 3% 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 400;
}
.t-title .it { font-size: clamp(2.2rem, 10vw, 3.4rem); font-size: 12.4cqw; line-height: 1; white-space: nowrap; }
.t-title .en { font-size: .7rem; font-size: 2.5cqw; letter-spacing: .32em; text-transform: uppercase; margin-top: 1cqw; }

.t-class { margin-top: 10px; }
.t-class .it { font-size: 1.7rem; display: block; }
.t-class .en { display: block; font-size: .6rem; }

/* small engraved divider with a diamond */
.orn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 80%;
  margin: 12px auto;
}
.orn::before, .orn::after { content: ""; flex: 1; height: 1px; background: var(--ink); opacity: .5; }
.orn i { width: 7px; height: 7px; border: 1px solid var(--ink); transform: rotate(45deg); opacity: .7; }

/* fields: passenger on top, paired rows with a centre line, wide ones below */
.fields-top, .fields-bottom { margin: 0; }
.fields-top {                         /* the name sits in the middle of its band, not hugging the banner */
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 7.6rem;
}
.fields-top .field { display: flex; flex-direction: column; flex: 1; }
.fields-top dd { flex: 1; display: flex; align-items: flex-end; justify-content: center; margin: 0; padding-bottom: 4px; }   /* name settles toward the line below it */
.fields-bottom { margin-top: 16px; }
.fields-bottom .field + .field { margin-top: 12px; }

.pairs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 30px;
  row-gap: 14px;
  margin: 0;
}
.pairs::before {                      /* engraved double line down the middle */
  content: "";
  position: absolute;
  left: 50%; top: 2px; bottom: 2px;
  width: 4px;
  transform: translateX(-50%);
  border-left: 1px solid var(--ink);
  border-right: 1px solid var(--ink);
  opacity: .5;
}
.field { margin: 0; min-width: 0; }

/* label: Italian (Italianno, big) with English (Playfair, a third of the size) to its right, underlined */
.field dt, .mfield label {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0 8px;
  padding-bottom: 1px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(59, 42, 26, .6);
}
.field dt .it, .mfield label .it { font-size: 1.85rem; white-space: nowrap; }
.field dt .en, .mfield label .en { font-size: .67rem; letter-spacing: .03em; }

.field dd {
  margin: 1px 0 0;
  font-family: var(--hand);
  font-size: 1.5rem;
  line-height: 1.25;
  color: var(--pen);
  overflow-wrap: anywhere;
}
.field.name dd {
  font-family: var(--name);
  font-size: clamp(3rem, 15vw, 4.2rem);
  line-height: 1.05;
}

.sample-note { margin: 14px 0 0; font-size: .75rem; color: var(--plum); }
.sample-note .it { font-size: 1.2rem; }

/* perforation + notches (notch colour = page colour) */
.perf {
  position: relative;
  z-index: 4;
  height: 0;
  margin: 0 22px;
  border-top: 3px dashed rgba(59, 42, 26, .55);
}
.perf::before, .perf::after {
  content: "";
  position: absolute;
  top: -15px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--page);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, .45);
}
.perf::before { left: -37px; }
.perf::after  { right: -37px; }

/* ----- stub ----- */
.stub {
  position: relative;
  z-index: 1;
  padding: calc(var(--stamp) / 2 + 40px) 22px 62px;   /* room below "Buon viaggio" for the serial number */
  text-align: center;
}
.stub-body { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.stub .serial { position: absolute; left: 0; right: 0; bottom: 30px; text-align: center; }   /* phone: centred under "Buon viaggio", clear of the border and the corner ornaments (laptop and print are set in the wide-screen block below) */

.go-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--plum);
  font: inherit;
}
.go-btn .it { font-size: 2.6rem; }
.go-btn .en { display: none; }        /* Italian only on the ticket */
.go-btn svg { width: 15px; height: 15px; fill: var(--plum); vertical-align: -2px; margin-left: 5px; }
.go-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }

.stub-fields { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.sf { min-width: 0; }
.sf .lab { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 0 6px; }
.sf .it { font-size: 1.8rem; }
/* the stub repeats the ticket, so its values are typed, not handwritten (same pen blue) */
.sf .v { display: block; font-family: 'Special Elite', 'Courier New', monospace; font-size: 1.05rem; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere; }
.sf.name { grid-column: 1 / -1; }

/* stamps: deliberately a little off, like a hand-struck stamp */
.roundstamp {
  position: absolute;
  z-index: 6;
  width: var(--stamp); height: var(--stamp);
  right: 4px;
  top: calc(var(--stamp) / -2 + 30px);
  transform: rotate(14deg);
  pointer-events: none;
}
.roundstamp svg { display: block; width: 100%; height: 100%; overflow: visible; }

.minstamp {
  position: absolute;
  z-index: 5;
  top: 24px;
  left: 20px;
  padding: 4px 14px 5px;
  transform: rotate(-6deg);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .14em;
  color: #25683f;
  border: 3px double #25683f;
  border-radius: 3px;
  opacity: .92;
  mix-blend-mode: multiply;
  filter: url(#stampwear);
  pointer-events: none;
  white-space: nowrap;
}

.actions { text-align: center; margin: 28px 0 0; }

/* wide screens and print: stub on the right, text reads vertically */
@media (min-width: 760px), print {
  .ticket-shell { max-width: 920px; --stamp: 190px; --stub-w: 350px; }
  .ticket { flex-direction: row; }
  .t-main { flex: 1; padding: 54px 44px 36px; }
  .t-main > .serial { right: auto; left: 40px; }
  .fields { grid-template-columns: repeat(2, 1fr); gap: 14px 30px; }

  .perf {
    height: auto; width: 0; margin: 22px 0;
    border-top: 0; border-left: 3px dashed rgba(59, 42, 26, .55);
  }
  .perf::before, .perf::after { left: -15px; right: auto; }
  .perf::before { top: -37px; }
  .perf::after  { top: auto; bottom: -37px; }

  .roundstamp { right: auto; top: 24%; left: calc(var(--stamp) / -2 + 24px); transform: rotate(-12deg); }

  /* stub text reads vertically, every column starting on the same line at the bottom,
     with "Buon viaggio" as the last column on the far right */
  .stub { width: var(--stub-w); padding: 0; }
  /* the stub is laid out like the ticket (name alone on top, then two columns, label then value)
     and the whole block is turned a quarter turn, so it reads from bottom to top.
     Rows therefore run left to right across the stub, "Buon viaggio" in the last row. */
  .stub-body {                        /* out of the flow, so long text never stretches the ticket */
    position: absolute;
    inset: 12% 30px 34px 34px;        /* long, so each column has room for label and answer on one line */
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 0;
    align-content: center;            /* rows sit together, centred across the stub */
    align-items: start;
  }
  .stub-fields { display: contents; }
  .sf { display: block; line-height: 1.5; min-width: 0; text-align: start; padding-block: 11px; }
  .sf .lab { display: inline; }
  .sf .it { font-size: 1.6rem; }
  .sf .v { display: inline; font-size: 1.05rem; margin-inline-start: .7em; line-height: 1.5; }
  .sf.name { grid-column: 1 / -1; }
  .sf.sep { border-block-end: 1px dashed rgba(59, 42, 26, .5); }   /* thin rule between rows (runs up and down on the stub) */
  .sf.c1 { padding-inline-end: 14px; }
  .sf.c2 { border-inline-start: 1px solid rgba(59, 42, 26, .5); padding-inline-start: 14px; }   /* rule between the two columns */
  .go-btn { grid-column: 1 / -1; display: block; padding: 11px 0 0; border-block-start: 1px dashed rgba(59, 42, 26, .5); }
  .go-btn { transform: translateX(-14px); }   /* the stub block is turned, so this nudges it toward the right edge */
  .go-btn .it { display: inline; font-size: 2.8rem; }
  .stub .serial { top: 26px; bottom: auto; left: auto; right: 42px; text-align: start; }   /* top-right corner of the stub, clear of the border */
  .minstamp { top: 84px; left: 80px; right: auto; transform: rotate(-11deg); }
}

/* ==========================================================
   PAGE 3 - THE MAKER
   ========================================================== */
.maker-page { padding: 30px 14px 44px; }
.card {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  padding: 30px 24px 32px;
  background: var(--grain), #eddcb0;
  border: 3px double var(--ink);
  outline: 1px solid var(--gold);
  outline-offset: -9px;
  border-radius: 4px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, .55), inset 0 0 40px rgba(95, 58, 16, .35);
}
.card h1 { margin: 0 0 4px; font-weight: 400; text-align: center; }
.card h1 .it { display: block; font-size: clamp(2.8rem, 12vw, 3.8rem); }
.card h1 .en { display: block; font-style: italic; font-size: .95rem; }
.setup-note {
  margin: 12px 0 22px;
  padding: 8px 12px;
  text-align: center;
  font-size: .82rem;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.mfield { margin: 0 0 16px; text-align: center; }
.mfield .lab {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 0 8px;
  padding-bottom: 1px; margin-bottom: 4px; border-bottom: 1px solid rgba(59, 42, 26, .6);
}
.mfield .lab .it { font-size: 2rem; }
.mfield .lab .en { font-size: .67rem; }
.mfield .opt { flex-basis: 100%; font-size: .72rem; opacity: .8; text-align: center; }
.mfield .count { text-align: right; font-size: .72rem; margin-top: 2px; opacity: .8; }
.mfield .count.full { font-weight: 700; }
.mfield input[type="text"], .mfield textarea {
  width: 100%;
  font-family: var(--serif);
  font-size: 1rem;
  padding: 10px 12px;
  color: var(--pen);
  background: #fbf3dc;
  border: 1px solid var(--ink);
  border-radius: 3px;
  text-align: center;
}
.mfield textarea { min-height: 84px; resize: vertical; }
.mfield ::placeholder { color: #8a7b6a; opacity: .75; font-style: italic; }
.mfield input:focus, .mfield textarea:focus { outline: 3px solid rgba(79, 132, 166, .45); }

/* stamp picture picker */
.picks { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 6px; }
/* the picker sits inside .mfield, so reset what that label style would add (underline, baseline alignment, wrapping) */
.picks .pick {
  position: relative;
  display: flex;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 0;
  padding: 0;
  margin: 0;
  border: 0;
}                                                      /* fills its grid cell, so every tile in a row is the same height */
.pick input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pick .tile {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 10px 9px;
  background: #fbf3dc;
  border: 1px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
  min-width: 0;
}
.pick img, .pick .noimg { display: block; flex: none; width: 80px; height: 80px; object-fit: contain; margin: 0 auto 4px; }
/* .picks .pick is needed so these win over the ".mfield label .it" rule (1.85rem, no wrapping) */
.picks .pick .it { display: block; font-size: 1.3rem; line-height: 1.15; white-space: normal; overflow-wrap: break-word; max-width: 100%; }
.picks .pick .en { display: block; font-size: .7rem; line-height: 1.3; margin-top: 2px; letter-spacing: 0; overflow-wrap: break-word; max-width: 100%; }
.pick input:checked + .tile { box-shadow: 0 0 0 2px var(--blue), 0 0 0 4px var(--gold); }
.pick input:focus-visible + .tile { outline: 3px solid var(--gold-light); outline-offset: 3px; }

.mform-actions { text-align: center; margin-top: 12px; }
.err { text-align: center; font-size: .85rem; min-height: 1.2em; margin: 0 0 8px; }

.results { margin-top: 26px; display: none; }
.results.show { display: block; }
.link-box {
  margin: 0 0 16px;
  padding: 14px;
  text-align: center;
  background: #fbf3dc;
  border: 1px solid var(--ink);
  border-radius: 4px;
}
.link-box h2 { margin: 0 0 8px; font-weight: 400; }
.link-box h2 .it { display: block; font-size: 1.9rem; }
.link-box h2 .en { display: block; font-size: .8rem; }
.link-box output {
  display: block;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .72rem;
  text-align: left;
  word-break: break-all;
  max-height: 5.6em;
  overflow: auto;
  padding: 8px;
  color: var(--ink);
  background: #efe3c2;
  border-radius: 3px;
  margin-bottom: 12px;
  user-select: all;
}
.link-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: center; }
.copied { font-size: .8rem; min-height: 1.2em; width: 100%; }

/* ==========================================================
   Motion preferences
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; }
  .scroll.cracking .seal, .scroll.cracking .band { display: none; }
}

/* ==========================================================
   Print (the ticket)
   ========================================================== */
@page { size: A4 landscape; margin: 10mm; }
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  :root { --page: #ffffff; }
  body { background: #fff !important; min-height: 0; }
  .actions, .replay, .go-btn svg { display: none !important; }
  .ticket-page { padding: 0; }
  .ticket { box-shadow: none; }
  .perf::before, .perf::after { box-shadow: none; }
}
