/* Anybody, variable (width 50–150%, weight 100–900), self-hosted. "block": the words wait for it (preloaded,
   so a moment at most) instead of showing in a fallback font and then changing. */
@font-face {
  font-family: "Anybody";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 50% 150%;
  font-display: block;
  src: url("../assets/fonts/anybody-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Anybody";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 50% 150%;
  font-display: block;
  src: url("../assets/fonts/anybody-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* dapoitaly.com coming soon: one screen, lights off, laid out as a poster. COMING across the top, SOON across
   the bottom, the site's 3D dapo (js/hero3d.js) glowing in front of the words, a star sticker that changes
   its print, and one line for the email. Palette and type as the site's UV night (mockup/css/tokens.css). */

:root {
  --ink: oklch(23.5% 0.075 292);
  --acid: oklch(91.5% 0.2 124);
  --pink: oklch(69% 0.235 356);
  --night: oklch(14.5% 0.045 296);
  --night-2: oklch(19% 0.06 296);
  --night-ink: oklch(95% 0.035 118);
  --glow: oklch(85% 0.25 135 / 0.4);

  --font: "Anybody", "Arial Narrow", system-ui, sans-serif;
  --gutter: clamp(1rem, 0.4rem + 3vw, 3rem);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  overflow-x: clip;
  background:
    radial-gradient(55% 50% at 50% 46%, oklch(25% 0.1 300 / 0.95), transparent 72%),
    var(--night);
  color: var(--night-ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  font-weight: 450;
}

h1,
p {
  margin: 0;
}

img,
canvas,
svg {
  display: block;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--acid);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ================= HEADER ================= */

.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(0.9rem, env(safe-area-inset-top)) var(--gutter) 0.9rem;
  pointer-events: none;
}

.top > * {
  pointer-events: auto;
}

.logo {
  width: 5.25rem;
  aspect-ratio: 178.9 / 96.8;
  background: currentColor;
  mask: url("../assets/brand/main-logo.svg") center / contain no-repeat;
  -webkit-mask: url("../assets/brand/main-logo.svg") center / contain no-repeat;
}

.lang {
  display: flex;
  padding: 3px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.lang button {
  min-width: 2.75rem;
  min-height: 2.25rem;
  padding: 0 0.6rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 800;
  font-variation-settings: "wdth" 120;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.lang button[aria-pressed="true"] {
  background: var(--night-ink);
  color: var(--night);
}

/* ================= THE POSTER ================= */

.cs {
  height: 100svh;
  min-height: 34rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* the column is the screen, whatever the words' natural width */
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(0.75rem, 2svh, 1.5rem);
  padding: 5.5rem var(--gutter) max(1.25rem, env(safe-area-inset-bottom));
}

/* the words and the dapo share one cell: the words at its edges, the dapo in its middle */
.cs__stage {
  position: relative;
  display: grid;
  min-height: 0;
  container-type: size;
}

.cs__title {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* COMING is 2.5em wide in Anybody: phones, it spans 90% of the stage (36cqw), within 27% of its height */
  font-size: min(36cqw, 27cqh);
  font-weight: 900;
  font-variation-settings: "wdth" 55;
  line-height: 0.76;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
  opacity: 0; /* shown by js/cs.js once the font is in */
  transition: opacity 400ms var(--ease-out);
}

.cs__title.is-fit {
  opacity: 1;
}

.cs__w1 {
  align-self: flex-start;
}

.cs__w2 {
  align-self: flex-end;
  color: var(--acid);
}

/* ---------- the dapo (the site's hero, js/hero3d.js) ---------- */

.cs__dapo {
  grid-area: 1 / 1;
  place-self: center;
  position: relative;
  z-index: 2;
}

.dapo {
  --bleed: 10%; /* the canvas overhangs the photo's box: the domed dapo matches the flat photo, a flip has room */
  position: relative;
  width: min(80cqw, 64cqh);
  aspect-ratio: 1;
  filter: drop-shadow(0 0 2.4rem var(--glow)); /* the blacklight halo */
  -webkit-user-select: none;
  user-select: none;
}

.dapo__img,
.dapo__canvas {
  position: absolute;
  transition: opacity 700ms var(--ease-out);
}

.dapo__img {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: saturate(1.6) contrast(1.15) brightness(1.08); /* the photo under UV, until the 3D one (its shader glows) */
}

.dapo__canvas {
  top: calc(var(--bleed) * -1);
  left: calc(var(--bleed) * -1);
  width: calc(100% + 2 * var(--bleed));
  height: calc(100% + 2 * var(--bleed));
  max-width: none;
  opacity: 0;
  cursor: grab;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

.dapo__canvas.is-grabbing {
  cursor: grabbing;
}

.dapo.is-live .dapo__canvas {
  opacity: 1;
}

.dapo.is-live .dapo__img {
  opacity: 0;
}

/* the print's name, a tag hanging under the dapo */
.dapo__name {
  position: absolute;
  left: 50%;
  bottom: 2%;
  z-index: 3;
  padding: 0.35rem 0.8rem;
  border: 1.5px solid color-mix(in oklch, var(--night-ink) 45%, transparent);
  border-radius: 999px;
  background: var(--night);
  font-size: 0.75rem;
  font-weight: 800;
  font-variation-settings: "wdth" 125;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%) rotate(-3deg);
  pointer-events: none; /* a label: a finger on it is on the dapo (a long name covers a good part of it) */
}

/* ---------- "Cambia stampa": the star sticker on the dapo's shoulder, slowly turning ---------- */

.sticker {
  --size: clamp(5.5rem, 4rem + 4vw, 8rem);
  position: absolute;
  top: 1%;
  right: -3%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: var(--size);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: none;
  color: var(--night);
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  transition: transform 220ms var(--ease-out);
  animation: star-turn 22s linear infinite;
}

/* the dapo's star: a square and a diamond */
.sticker::before,
.sticker::after {
  content: "";
  position: absolute;
  inset: 14.6%;
  z-index: -1;
  border-radius: 12%;
  background: var(--acid);
  transition: background-color 220ms var(--ease-out);
}

.sticker::after {
  transform: rotate(45deg);
}

.sticker__in {
  display: grid;
  gap: 0.2rem;
  justify-items: center;
  width: 64%;
  font-size: clamp(0.625rem, 0.5rem + 0.35vw, 0.8125rem);
  font-weight: 900;
  font-variation-settings: "wdth" 110;
  letter-spacing: 0.06em;
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
  animation: star-turn 22s linear infinite reverse; /* the words stay upright while the star turns */
}

.sticker svg {
  width: 1.5em;
  height: 1.5em;
  transition: transform 700ms var(--ease-out);
}

.sticker:hover {
  transform: scale(1.07);
}

.sticker:hover::before,
.sticker:hover::after {
  background: var(--night-ink);
}

.sticker:hover svg {
  transform: rotate(-200deg);
}

.sticker:active {
  transform: scale(0.95);
}

.sticker[disabled] {
  cursor: progress;
}

@keyframes star-turn {
  to {
    rotate: 360deg;
  }
}

/* ================= THE EMAIL, ONE LINE ================= */

.notify {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem 1.5rem;
}

.notify__label {
  max-width: 34ch;
  font-size: 0.8125rem;
  font-weight: 350;
  line-height: 1.4;
  text-wrap: pretty;
}

/* input and button in one pill */
.notify__field {
  display: flex;
  flex: 0 1 26rem;
  min-width: 0;
  padding: 4px;
  border: 2px solid var(--night-ink);
  border-radius: 999px;
  transition: border-color 280ms var(--ease-out);
}

.notify__field:focus-within {
  border-color: var(--acid);
}

.notify input {
  flex: 1;
  min-width: 0;
  padding: 0 0.9rem;
  border: 0;
  background: transparent;
  outline: none;
}

.notify input::placeholder {
  color: color-mix(in oklch, var(--night-ink) 55%, transparent);
}

.notify button {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0 1.1rem;
  border: 0;
  border-radius: 999px;
  background: var(--acid);
  color: var(--night);
  font-size: 0.9375rem;
  font-weight: 800;
  font-variation-settings: "wdth" 118;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 220ms var(--ease-out);
}

.notify button:hover {
  background: var(--night-ink);
}

.notify button[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.notify button svg {
  width: 1.15em;
  height: 1.15em;
}

.notify__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.notify__msg {
  flex-basis: 100%;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 700;
}

.notify__msg.is-ok {
  color: var(--acid);
}

.notify__msg:empty {
  display: none;
}

/* ================= WIDE SCREENS: as the site's hero, the words on the left, the dapo big on the right ================= */

@media (min-width: 48rem) and (min-aspect-ratio: 1/1) {
  .cs__title {
    justify-content: center;
    font-size: min(24.8cqw, 50cqh); /* COMING takes 62% of the width, within half the height */
    line-height: 0.8;
  }

  .cs__w2 {
    align-self: flex-start;
  }

  .cs__dapo {
    place-self: center end;
    margin-right: 2cqw;
  }

  .dapo {
    width: min(50cqw, 86cqh);
  }

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

/* phones: all on one screen; the sentence in two light lines, left, above the pill */
@media (max-width: 40rem) {
  .cs {
    gap: 0.5rem;
  }

  /* SOON sits right on the sentence */
  .cs__w2 {
    translate: 0 0.07em;
  }

  .notify {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .notify__label {
    max-width: 32ch;
    font-size: 0.9375rem;
    line-height: 1.35;
  }

  /* the print's name leans against the dapo's lower-left point */
  .dapo__name {
    left: 1%;
    bottom: 13%;
    transform: rotate(-8deg);
  }

  /* smaller header */
  .logo {
    width: 4.25rem;
  }

  .lang {
    padding: 2px;
    border-width: 1.5px;
  }

  .lang button {
    min-width: 2.25rem;
    min-height: 1.85rem;
    padding: 0 0.45rem;
    font-size: 0.6875rem;
  }

  /* a slimmer email pill (the input stays 16px: below that iOS zooms in on focus) */
  .notify__field {
    padding: 3px;
    border-width: 1.5px;
  }

  .notify input {
    padding: 0 0.75rem;
    font-size: 1rem;
  }

  .notify button {
    min-height: 2.25rem;
    padding: 0 0.85rem;
    gap: 0.4rem;
    font-size: 0.8125rem;
  }

  .notify__field {
    flex: none;
    width: 100%;
  }

  .dapo {
    width: min(90cqw, 70cqh); /* its canvas overhangs by --bleed: the page clips that (html overflow-x) */
  }
}

/* touch screens: the page is fixed to the screen, it never scrolls or bounces (everything fits in it) */
@media (pointer: coarse) {
  html,
  body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* a long press or a double tap (spinning the dapo, "Cambia stampa") must not start iOS's text selection
     loupe or its callout menu: nothing here is for copying, only the email field stays selectable */
  body {
    position: fixed;
    inset: 0;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  input {
    -webkit-user-select: text;
    user-select: text;
  }

  button {
    touch-action: manipulation;
  }

  .cs {
    /* the screen with Safari's bars out: a fixed page never hides them, and unlike 100dvh it does not move while
       they settle on the first load (the title is sized on this height: it came up big, then shrank) */
    height: 100svh;
    min-height: 0;
  }

  .dapo__canvas {
    touch-action: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sticker,
  .sticker__in {
    animation: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
