/* =========================================================
   Geno's Birthday
   ========================================================= */

:root {
  --ink: #1d1a16;
  --ink-soft: #4a4239;
  --paper: #fff7e8;
  --red: #e5392b;
  --red-deep: #b8261b;
  --gold: #ffc53d;

  /* Where the photo is anchored when it's cropped to fill the screen.
     Nudge the second value (e.g. 20%, 40%) to keep his face in frame. */
  --photo-position: center 40%;

  --font-display: "Shrikhand", Georgia, serif;
  --font-ticket: "Bungee", Impact, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --notch: 14px;

  color-scheme: dark;
}

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

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--ink);
  color: #fff;
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.is-locked { overflow: hidden; }
body.is-locked .hero { opacity: 0; }

/* ---------- Background photo ---------- */

/* The gradients underneath only show if img/geno.jpg is missing. */
.photo {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    url("img/geno.jpg") var(--photo-position) / cover no-repeat,
    radial-gradient(circle at 18% 22%, #ff9d42 0, transparent 42%),
    radial-gradient(circle at 85% 15%, #e5392b 0, transparent 48%),
    radial-gradient(circle at 65% 95%, #2f6fb5 0, transparent 55%),
    #3b1d14;
  transform-origin: 50% 30%;
  animation: drift 16s ease-out both;
}

@keyframes drift {
  from { transform: scale(1.08); }
  to   { transform: scale(1); }
}

.photo-focus { display: none; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, .35) 0%,
    rgba(0, 0, 0, 0) 22%,
    rgba(0, 0, 0, 0) 42%,
    rgba(0, 0, 0, .55) 72%,
    rgba(0, 0, 0, .85) 100%
  );
}

/* Wide screens: a tall photo cropped to fill a landscape window would put
   his face right behind the headline. Instead, show it whole on the right
   over a blurred copy of itself, with the text on the left. */
@media (min-aspect-ratio: 1/1) and (min-width: 700px) {
  .photo {
    inset: -40px;
    filter: blur(26px) brightness(.5) saturate(1.15);
  }

  .photo-focus {
    display: block;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    width: min(56.25vh, 60vw); /* the photo's own 1152x2048 shape */
    background: url("img/geno.jpg") center top / cover no-repeat;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 22%);
    mask-image: linear-gradient(to right, transparent 0, #000 22%);
    transform-origin: 50% 30%;
    animation: drift 16s ease-out both;
  }

  .scrim {
    background:
      linear-gradient(90deg, rgba(0, 0, 0, .45) 0%, rgba(0, 0, 0, .15) 50%, rgba(0, 0, 0, 0) 70%),
      linear-gradient(180deg, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, .45) 100%);
  }

  h1 { font-size: clamp(2.6rem, min(10vw, 15vh), 7.5rem); }
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  max-width: 1100px;
  transition: opacity .35s ease;
  padding:
    max(1.5rem, env(safe-area-inset-top))
    max(1.25rem, env(safe-area-inset-right))
    max(2.25rem, calc(env(safe-area-inset-bottom) + 1.5rem))
    max(1.25rem, env(safe-area-inset-left));
}

@media (min-width: 768px) {
  .hero {
    padding-left: max(4rem, env(safe-area-inset-left));
    padding-bottom: 4.5rem;
  }
}

.eyebrow {
  margin: 0 0 .9rem;
  padding: .45rem .85rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, .4);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--gold);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.9rem, 12.5vw, 7.5rem);
  line-height: .95;
  text-shadow: 0 4px 24px rgba(0, 0, 0, .45), 0 2px 4px rgba(0, 0, 0, .3);
}

h1 .name {
  display: block;
  color: var(--gold);
}

.lede {
  margin: 1rem 0 1.75rem;
  max-width: 30ch;
  font-size: clamp(1.08rem, 2.6vw, 1.35rem);
  line-height: 1.45;
  color: rgba(255, 255, 255, .92);
  text-shadow: 0 1px 10px rgba(0, 0, 0, .55);
}

/* ---------- The big button ---------- */

.gift-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  padding: 1.05rem 1.7rem 1.05rem 1.3rem;
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font: 700 1.18rem/1 var(--font-body);
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4), inset 0 -3px 0 rgba(0, 0, 0, .12);
  transition: transform .2s ease;
  -webkit-tap-highlight-color: transparent;
}

.gift-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  animation: pulse 2.4s ease-out infinite;
}

.gift-btn:hover { transform: translateY(-2px); }
.gift-btn:active { transform: translateY(1px) scale(.98); }
.gift-btn:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

.gift-icon {
  width: 1.8rem;
  height: 1.8rem;
  flex: none;
  transform-origin: 50% 85%;
  animation: wiggle 3.2s ease-in-out infinite;
}

.gift-btn.is-opening { animation: shake .65s ease-in-out; }
.gift-btn.is-opening .gift-icon { animation: none; }

@keyframes pulse {
  0%        { box-shadow: 0 0 0 0 rgba(255, 197, 61, .55); }
  80%, 100% { box-shadow: 0 0 0 18px rgba(255, 197, 61, 0); }
}

@keyframes wiggle {
  0%, 78%, 100% { transform: rotate(0); }
  82% { transform: rotate(-14deg); }
  86% { transform: rotate(11deg); }
  90% { transform: rotate(-7deg); }
  94% { transform: rotate(3deg); }
}

@keyframes shake {
  0%   { transform: scale(1) rotate(0); }
  15%  { transform: scale(1.06) rotate(-4deg); }
  30%  { transform: scale(1.08) rotate(4deg); }
  45%  { transform: scale(1.1) rotate(-4deg); }
  60%  { transform: scale(1.12) rotate(3deg); }
  80%  { transform: scale(1.14) rotate(-2deg); }
  100% { transform: scale(1.18) rotate(0); opacity: .9; }
}

/* ---------- Reveal ---------- */

.reveal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    max(1.5rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1.75rem, calc(env(safe-area-inset-bottom) + 1rem))
    max(1rem, env(safe-area-inset-left));
  background: rgba(18, 12, 8, .72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity .35s ease;
}

.reveal[hidden] { display: none; }
.reveal.is-open { opacity: 1; }

/* margin:auto centers it but still lets tall content scroll on small phones */
.reveal-inner {
  margin: auto;
  width: 100%;
  max-width: 660px;
}

/* ---------- Ticket ---------- */

.ticket {
  position: relative;
  display: flex;
  margin-top: 8rem; /* room for the snapshot hanging off the top */
  filter: drop-shadow(0 22px 40px rgba(0, 0, 0, .5));
  opacity: 0;
  transform: translateY(48px) rotate(-5deg) scale(.9);
  transition: transform .75s cubic-bezier(.2, 1.35, .35, 1), opacity .3s ease;
}

.is-open .ticket {
  opacity: 1;
  transform: rotate(-1.2deg);
}

.ticket-main {
  flex: 1;
  min-width: 0;
  padding: 1.6rem 1.6rem 1.5rem;
  border-radius: 16px 0 0 16px;
  background:
    radial-gradient(circle at 1px 1px, rgba(29, 26, 22, .07) 1px, transparent 0) 0 0 / 14px 14px,
    var(--paper);
  color: var(--ink);
  /* bite-shaped notches where the ticket tears */
  -webkit-mask:
    radial-gradient(circle var(--notch) at 100% 0, #0000 calc(var(--notch) - .5px), #000 var(--notch)),
    radial-gradient(circle var(--notch) at 100% 100%, #0000 calc(var(--notch) - .5px), #000 var(--notch));
  -webkit-mask-composite: source-in;
  mask:
    radial-gradient(circle var(--notch) at 100% 0, #0000 calc(var(--notch) - .5px), #000 var(--notch)),
    radial-gradient(circle var(--notch) at 100% 100%, #0000 calc(var(--notch) - .5px), #000 var(--notch));
  mask-composite: intersect;
}

.ticket-kicker {
  margin: 0 0 .35rem;
  color: var(--red);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.ticket-main h2 {
  margin: 0;
  font-family: var(--font-ticket);
  font-weight: 400;
  font-size: clamp(1.85rem, 7vw, 2.7rem);
  line-height: 1.02;
  outline: none;
}

.ticket-main h2 .year {
  display: inline-block;
  padding: .12em .38em .08em;
  border-radius: .22em;
  background: var(--ink);
  color: var(--gold);
  font-size: .62em;
  vertical-align: .18em;
}

.ticket-lede {
  margin: .85rem 0 1.15rem;
  color: var(--ink-soft);
  font-size: 1.04rem;
  line-height: 1.45;
}

.ticket-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .95rem 1.2rem;
  margin: 0;
  padding-top: 1.05rem;
  border-top: 2px solid var(--ink);
}

.ticket-details dt {
  margin-bottom: .2rem;
  color: var(--red);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.ticket-details dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

.ticket-details small {
  display: block;
  color: #7a6f63;
  font-size: .85rem;
  font-weight: 500;
}

.ticket-stub {
  flex: none;
  width: 148px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .9rem;
  padding: 1.25rem .75rem;
  border-left: 3px dotted rgba(255, 247, 232, .75);
  border-radius: 0 16px 16px 0;
  background: var(--red);
  color: var(--paper);
  text-align: center;
  -webkit-mask:
    radial-gradient(circle var(--notch) at 0 0, #0000 calc(var(--notch) - .5px), #000 var(--notch)),
    radial-gradient(circle var(--notch) at 0 100%, #0000 calc(var(--notch) - .5px), #000 var(--notch));
  -webkit-mask-composite: source-in;
  mask:
    radial-gradient(circle var(--notch) at 0 0, #0000 calc(var(--notch) - .5px), #000 var(--notch)),
    radial-gradient(circle var(--notch) at 0 100%, #0000 calc(var(--notch) - .5px), #000 var(--notch));
  mask-composite: intersect;
}

.stub-text { display: flex; flex-direction: column; gap: .3rem; }

.stub-admit {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  opacity: .85;
}

.stub-who {
  font-family: var(--font-ticket);
  font-size: 1.35rem;
  line-height: 1.05;
}

.stub-barcode {
  width: 92px;
  height: 46px;
  background: repeating-linear-gradient(
    90deg,
    var(--paper) 0 2px, transparent 2px 4px,
    var(--paper) 4px 7px, transparent 7px 9px,
    var(--paper) 9px 10px, transparent 10px 13px
  );
}

.stub-no {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .16em;
}

/* Frankenstein snapshot taped to the corner of the ticket. It only overlaps
   the ticket's top strip, so it never covers the title. */
.polaroid {
  position: absolute;
  z-index: 2;
  top: -8.6rem;
  right: -.6rem;
  width: 140px;
  margin: 0;
  padding: 8px 8px 0;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .4);
  opacity: 0;
  transform: translateY(-30px) rotate(22deg) scale(1.25);
  transition: transform .55s cubic-bezier(.2, 1.4, .4, 1) .75s, opacity .2s ease .75s;
}

.is-open .polaroid {
  opacity: 1;
  transform: rotate(7deg);
}

/* tape */
.polaroid::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 50%;
  width: 62px;
  height: 22px;
  background: rgba(255, 247, 232, .75);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
  transform: translateX(-50%) rotate(-5deg);
}

.polaroid img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
}

.polaroid figcaption {
  padding: .35rem 0 .45rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1rem;
  text-align: center;
}

/* Phones: stub tears off the bottom instead of the side */
@media (max-width: 600px) {
  .ticket { flex-direction: column; margin-top: 5.5rem; }

  .polaroid {
    top: -5.6rem;
    right: -.25rem;
    width: 100px;
    padding: 6px 6px 0;
  }

  .polaroid figcaption { padding: .25rem 0 .35rem; font-size: .8rem; }

  .ticket-main {
    padding: 1.4rem 1.3rem 1.3rem;
    border-radius: 16px 16px 0 0;
    -webkit-mask:
      radial-gradient(circle var(--notch) at 0 100%, #0000 calc(var(--notch) - .5px), #000 var(--notch)),
      radial-gradient(circle var(--notch) at 100% 100%, #0000 calc(var(--notch) - .5px), #000 var(--notch));
    -webkit-mask-composite: source-in;
    mask:
      radial-gradient(circle var(--notch) at 0 100%, #0000 calc(var(--notch) - .5px), #000 var(--notch)),
      radial-gradient(circle var(--notch) at 100% 100%, #0000 calc(var(--notch) - .5px), #000 var(--notch));
    mask-composite: intersect;
  }

  .ticket-stub {
    width: auto;
    flex-direction: row;
    justify-content: space-between;
    padding: 1rem 1.4rem;
    border-left: 0;
    border-top: 3px dotted rgba(255, 247, 232, .75);
    border-radius: 0 0 16px 16px;
    text-align: left;
    -webkit-mask:
      radial-gradient(circle var(--notch) at 0 0, #0000 calc(var(--notch) - .5px), #000 var(--notch)),
      radial-gradient(circle var(--notch) at 100% 0, #0000 calc(var(--notch) - .5px), #000 var(--notch));
    -webkit-mask-composite: source-in;
    mask:
      radial-gradient(circle var(--notch) at 0 0, #0000 calc(var(--notch) - .5px), #000 var(--notch)),
      radial-gradient(circle var(--notch) at 100% 0, #0000 calc(var(--notch) - .5px), #000 var(--notch));
    mask-composite: intersect;
  }

  .stub-who br { display: none; }
  .stub-who { font-size: 1.15rem; }
  .stub-no { display: none; }
}

@media (max-width: 320px) {
  .ticket-details { grid-template-columns: 1fr; }
}

/* ---------- Below the ticket ---------- */

.fade {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .5s ease, transform .5s ease;
}

.is-open .fade { opacity: 1; transform: none; }
.is-open .iou { transition-delay: .55s; }
.is-open .signoff { transition-delay: .75s; }
.is-open .reveal-actions { transition-delay: .95s; }

.iou {
  max-width: 44ch;
  margin: 1.6rem auto 0;
  color: rgba(255, 255, 255, .9);
  font-size: 1.02rem;
  line-height: 1.5;
  text-align: center;
}

.signoff {
  margin: .7rem 0 0;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  line-height: 1.25;
  text-align: center;
}

.reveal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .75rem;
  margin-top: 1.5rem;
}

.btn {
  padding: .85rem 1.4rem;
  border-radius: 999px;
  font: 700 1rem/1 var(--font-body);
  cursor: pointer;
  transition: transform .2s ease, background-color .2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.btn-primary {
  border: 0;
  background: var(--gold);
  color: var(--ink);
}

.btn-ghost {
  border: 2px solid rgba(255, 255, 255, .55);
  background: transparent;
  color: #fff;
}

.btn-ghost:hover { background: rgba(255, 255, 255, .1); }

/* ---------- The little car ---------- */

.car {
  position: fixed;
  left: 0;
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  z-index: 60;
  width: 130px;
  pointer-events: none;
  transform: translateX(-180px);
}

.car svg { display: block; width: 100%; overflow: visible; }

.car.is-driving { animation: drive 2.6s cubic-bezier(.55, 0, .8, .6) forwards; }
.car.is-driving .wheel { animation: spin .35s linear infinite; }
.car.is-driving .car-body { animation: bounce .3s ease-in-out infinite alternate; }

.wheel { transform-box: fill-box; transform-origin: center; }
.speed-lines { opacity: .8; }

@keyframes drive {
  from { transform: translateX(-180px); }
  to   { transform: translateX(calc(100vw + 60px)); }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce { to { transform: translateY(-1.5px); } }

/* ---------- Confetti ---------- */

.confetti {
  position: fixed;
  inset: 0;
  z-index: 70;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Calm mode ---------- */

@media (prefers-reduced-motion: reduce) {
  .photo, .photo-focus, .gift-icon, .gift-btn::before { animation: none; }
  .ticket, .fade, .reveal { transition: opacity .2s ease; transform: none; }
  .polaroid { transition: opacity .2s ease; transform: rotate(7deg); }
  .car.is-driving { animation-duration: 5s; animation-timing-function: linear; }
  .car.is-driving .car-body { animation: none; }
}

/* ---------- Phones: fit the present on one screen ---------- */

/* Browser toolbars eat a lot of a phone's height, so tighten everything. */
@media (max-width: 600px) {
  .reveal {
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, calc(env(safe-area-inset-bottom) + .75rem));
  }

  .ticket { margin-top: 4.9rem; }

  .polaroid {
    top: -5rem;
    width: 88px;
    padding: 5px 5px 0;
  }

  .polaroid::before { width: 48px; height: 18px; top: -9px; }
  .polaroid figcaption { padding: .2rem 0 .3rem; font-size: .72rem; }

  .ticket-main { padding: 1.15rem 1.2rem 1rem; }
  .ticket-kicker { margin-bottom: .25rem; font-size: .72rem; }
  .ticket-main h2 { font-size: clamp(1.6rem, 7vw, 2.2rem); }
  .ticket-lede { margin: .6rem 0 .85rem; font-size: .98rem; line-height: 1.4; }
  .ticket-details { gap: .7rem 1rem; padding-top: .8rem; }
  .ticket-details dd { font-size: .95rem; }
  .ticket-details small { font-size: .8rem; }

  .ticket-stub { padding: .8rem 1.2rem; }
  .stub-barcode { height: 36px; }

  .iou { margin-top: 1.1rem; font-size: .95rem; line-height: 1.45; }
  .signoff { margin-top: .45rem; font-size: 1.35rem; line-height: 1.2; }
  .reveal-actions { margin-top: 1.1rem; }
  .btn { padding: .75rem 1.2rem; }
}

/* Short screens (small phones, or big browser toolbars): tighter still */
@media (max-width: 600px) and (max-height: 700px) {
  .ticket { margin-top: 4.2rem; }
  .polaroid { top: -4.3rem; width: 76px; }
  .polaroid figcaption { font-size: .66rem; }

  .ticket-main { padding: 1rem 1.1rem .85rem; }
  .ticket-main h2 { font-size: clamp(1.45rem, 6.5vw, 1.9rem); }
  .ticket-lede { margin: .5rem 0 .7rem; font-size: .92rem; }
  .ticket-details { gap: .55rem .9rem; padding-top: .65rem; }
  .ticket-details dt { font-size: .64rem; }
  .ticket-details dd { font-size: .9rem; }
  .ticket-stub { padding: .65rem 1.1rem; }
  .stub-who { font-size: 1.05rem; }
  .stub-barcode { height: 30px; }

  .iou { margin-top: .85rem; font-size: .88rem; }
  .signoff { font-size: 1.2rem; }
  .reveal-actions { margin-top: .85rem; }
  .btn { padding: .65rem 1.1rem; font-size: .95rem; }
}

/* Very short screens (e.g. iPhone SE with browser toolbars) */
@media (max-width: 600px) and (max-height: 600px) {
  .ticket { margin-top: 3.6rem; }
  .polaroid { top: -3.7rem; width: 68px; }
  .polaroid figcaption { font-size: .6rem; }

  .ticket-lede { margin: .4rem 0 .6rem; font-size: .86rem; }
  .iou { margin-top: .7rem; font-size: .82rem; }
  .signoff { font-size: 1.05rem; }
  .signoff br { display: none; }
  .reveal-actions { margin-top: .7rem; }
}

