/* Dolcemangiare · Chi siamo e come lo facciamo
   The panzerotto lives in one fixed WebGL canvas at the centre of the screen.
   The sections scroll up behind it; each one has a cloud or ice edge on top. */

@font-face {
  font-family: "Excon";
  src: url("../fonts/Excon-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --red: #F25246;
  --red-dark: #D63B30;
  --cream: #FFEFDA;
  --sand: #EDCFAD;
  --sky: #D3EDFE;
  --blue: #B7D6F2;
  --blue-light: #D9EAF8;
  --ink: #3A2218;
  --ink-light: #5A3A2C;
  --frost: #2D6CB5;
  --white: #FFFFFF;

  --font: "Excon", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-note: "Protest Riot", "Comic Sans MS", cursive;

  --gutter: 6vw;
  --edge-h: max(130px, 20.8vw);
  color-scheme: light;
}

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

html, body {
  margin: 0;
  background: var(--red);
  color: var(--ink);
  font-family: var(--font);
}

body { overflow-x: hidden; }

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

a:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.sr-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- fixed layers */

#gl {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 5;
  pointer-events: none;
}

/* photographic opening: frames of the real panzerotto opening, scrubbed by the scroll, framed like the 3D one */
#pull {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  width: 160vh;
  height: 90vh;
  opacity: 0;
  pointer-events: none;
  will-change: opacity;
  -webkit-mask-image: radial-gradient(ellipse closest-side at 50% 52%, #000 58%, transparent 100%);
  mask-image: radial-gradient(ellipse closest-side at 50% 52%, #000 58%, transparent 100%);
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--red);
  color: var(--cream);
  transition: opacity .8s;
}
.loader svg { width: min(320px, 70vw); }
.loader__pct {
  margin-top: 10px;
  font-size: 44px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.loader__error {
  max-width: 420px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* ---------- header */

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) 16px max(24px, env(safe-area-inset-left, 0px));
  color: var(--cream);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  transition: color .35s;
}
.site-header.is-dark { color: var(--ink); }
.site-header__logo { height: 24px; width: auto; opacity: 0; transition: opacity .4s, filter .35s; }
.site-header.is-dark .site-header__logo { filter: brightness(.25) sepia(1) hue-rotate(-20deg) saturate(3); }
.site-header nav { display: flex; gap: 22px; }
.site-header a { color: inherit; text-decoration: none; }

/* ---------- sections */

/* every section is its own layer, so the next one slides over the pinned texts of the previous one */
.section {
  position: relative;
  z-index: 1;
  background: var(--bg);
  height: var(--h, 200vh);
}

.edge {
  position: absolute;
  left: 0;
  top: calc(-1 * var(--edge-h) + 2px);
  z-index: 1;
  display: block;
  width: 100%;
  height: var(--edge-h);
  pointer-events: none;
}
.edge--flip { transform: scaleX(-1); }
.edge__back { fill: var(--edge-back); }
.edge__front { fill: var(--edge-front); }

.spark {
  position: absolute;
  z-index: 2;
  fill: var(--white);
  pointer-events: none;
  animation: twinkle 2.4s ease-in-out infinite;
}
.spark:nth-of-type(odd) { animation-delay: -1.1s; }
.spark--1 { left: 30%; top: 120px; width: 30px; height: 30px; }
.spark--2 { left: 60%; top: 230px; width: 52px; height: 52px; }
.spark--3 { left: 78%; top: 90px; width: 18px; height: 18px; }
@keyframes twinkle {
  0%, 100% { transform: scale(.6); opacity: .5; }
  50% { transform: scale(1); opacity: 1; }
}

.pin {
  position: sticky;
  top: 0;
  z-index: 6;
  height: 100vh;
  overflow: hidden;
}
.pin--back { z-index: 4; margin-bottom: -100vh; }

.section--hero { --bg: var(--red); }
.section--impasto { --bg: var(--sand); --edge-back: #FEEEDA; --edge-front: var(--sand); --accent: var(--red); }
.section--sottozero { --bg: var(--sky); --edge-back: var(--blue); --edge-front: var(--sky); --accent: var(--frost); }
.section--ripieno { --bg: var(--red); --edge-back: var(--red-dark); --edge-front: var(--red); --accent: var(--cream); --h: 320vh; color: var(--cream); }
.section--piazza { --bg: var(--blue); --edge-back: var(--blue-light); --edge-front: var(--blue); --accent: var(--white); }
.section--confezione { --bg: var(--red); --edge-back: var(--red-dark); --edge-front: var(--red); --accent: var(--cream); --h: 260vh; color: var(--cream); }
.section--contatti { --bg: var(--ink); --edge-back: var(--ink-light); --edge-front: var(--ink); --h: auto; min-height: 100vh; color: var(--cream); }

.section--ripieno .pin { touch-action: pan-y; }

/* ---------- type */

.block { position: absolute; }

.title {
  margin: 0;
  color: var(--accent);
  font-size: clamp(36px, 4.8vw, 76px);
  font-weight: 900;
  line-height: .9;
  letter-spacing: -.01em;
  text-transform: uppercase;
  text-wrap: balance;
}
.title s { font-weight: 400; text-decoration-thickness: .08em; }

.text {
  max-width: 36ch;
  margin: 18px 0 0;
  font-size: clamp(15px, 1.2vw, 18px);
  font-weight: 400;
  line-height: 1.5;
}

/* handwritten margin notes */
.note {
  position: absolute;
  z-index: 7;
  color: var(--accent);
  font-family: var(--font-note);
  font-size: clamp(18px, 1.7vw, 26px);
  line-height: 1.1;
  white-space: nowrap;
  transform: rotate(-7deg);
}

.card {
  position: absolute;
  width: min(230px, 40vw);
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--cream);
  box-shadow: 0 10px 30px rgba(58, 34, 24, .12);
}
.card b {
  display: block;
  color: var(--red);
  font-size: clamp(24px, 2.8vw, 38px);
  font-weight: 900;
  line-height: 1;
}
.card span {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}
.card--small { width: 200px; }
.card--small b { font-size: 20px; }

.cta {
  display: inline-block;
  padding: 13px 22px;
  border: 2px solid var(--cream);
  border-radius: 40px;
  background: var(--cream);
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  text-align: center;
  text-decoration: none;
}
.cta--ghost { background: transparent; color: var(--cream); }
.cta--white { margin-top: 18px; border-color: var(--white); background: var(--white); color: var(--frost); }
.cta--red { margin-top: 28px; border-color: var(--red); background: var(--red); color: var(--cream); }

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  color: var(--cream);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 3px;
  text-align: center;
  transition: opacity .4s;
}

.reveal { opacity: 0; transform: translateY(40px); }

/* ---------- hero */

.wordmark {
  position: absolute;
  left: 50%;
  top: 12vh;
  width: min(1100px, 92vw);
  height: auto;
  transform: translateX(-50%);
}
.payoff {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  color: var(--cream);
  font-size: clamp(11px, 1.1vw, 15px);
  font-weight: 800;
  letter-spacing: .6em;
  text-align: center;
}
.hero__note { right: 7vw; top: 40vh; --accent: var(--cream); }
.hero__weight { right: var(--gutter); top: 56vh; }
.hero__recipe { right: var(--gutter); top: 70vh; width: 230px; }
.hero__cta { position: absolute; left: 50%; bottom: calc(112px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); white-space: nowrap; }

/* ---------- impasto */

.impasto__copy { left: var(--gutter); top: 15vh; max-width: min(460px, 88vw); }
.impasto__note { left: var(--gutter); top: 52vh; }
.impasto__time { left: var(--gutter); top: 66vh; }
.impasto__ingredients { right: var(--gutter); top: 58vh; }

/* ---------- sottozero */

.sottozero__temp { left: var(--gutter); top: 52vh; background: var(--white); }
.sottozero__temp b { color: var(--frost); font-variant-numeric: tabular-nums; }
.sottozero__copy { right: var(--gutter); top: 14vh; max-width: min(520px, 88vw); text-align: right; }
.sottozero__text { position: absolute; right: var(--gutter); bottom: 13vh; text-align: right; }
.sottozero__note { left: 10vw; top: 38vh; }

/* ---------- ripieno */

.ripieno__copy { left: var(--gutter); top: 14vh; max-width: min(420px, 88vw); }
.ripieno__note { right: 12vw; top: 26vh; }

/* ---------- piazza: the stall is drawn in SVG and placed under the panzerotti from JS */

#stall {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 0;
  overflow: visible;
  opacity: 0;
  pointer-events: none;
}
#stall path {
  fill: none;
  stroke: var(--white);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.piazza__copy { left: 5vw; top: 22vh; max-width: min(460px, 33vw); }
.piazza__copy .text { color: var(--ink); }
.piazza__note { right: 8vw; bottom: 10vh; }

/* ---------- confezione */

.confezione__copy { left: 5vw; top: 14vh; max-width: min(460px, 33vw); }
.piazza__copy .title, .confezione__copy .title { font-size: clamp(34px, 3.8vw, 64px); }
.confezione__ctas { right: var(--gutter); top: 20vh; display: grid; gap: 10px; }
.confezione__note { right: 9vw; bottom: 16vh; }

/* ---------- contatti */

.contact {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 40px;
  padding: 16vh max(var(--gutter), 16px) 8vh;
}
.contact .title { --accent: var(--cream); font-size: clamp(34px, 5vw, 72px); }
.contact__mail { color: var(--cream); font-size: clamp(18px, 1.6vw, 24px); font-weight: 700; text-decoration: none; border-bottom: 2px solid currentColor; }
.contact__legal { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; width: 100%; margin: 30px 0 0; font-size: 12px; opacity: .7; }
.contact__legal a { color: inherit; }

/* ---------- small screens */

@media (max-width: 720px) {
  .site-header nav { display: none; }
  .card { display: none; }
  .sottozero__temp { display: block; left: 20px; top: calc(12vh + 170px); width: min(230px, 60vw); }
  .note { left: 20px; right: auto; top: auto; bottom: calc(15vh + env(safe-area-inset-bottom, 0px)); font-size: 19px; }
  .hero__note { bottom: calc(178px + env(safe-area-inset-bottom, 0px)); }
  .title, .piazza__copy .title, .confezione__copy .title { font-size: clamp(32px, 9.5vw, 44px); }
  .text { max-width: none; font-size: 15px; }
  .block.reveal { left: 20px; right: 20px; top: 12vh; max-width: none; text-align: left; }
  .sottozero__text { display: none; }
  .confezione__ctas { left: 20px; right: 20px; top: auto; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); grid-template-columns: 1fr 1fr; }
  .confezione__ctas .cta { padding: 11px 10px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
  .spark { animation: none; }
}
