/* Past Five Studio
   One section on white. A centred bold-sans headline with inline App Store style icon
   chips (tap one to change its icon), one sentence, one email link, a shelf of icons rising
   from the fold, and a logo that throws confetti and fireworks when pressed.
   Near-black ink for type; vermilion (the colour of the "5" icon) as the only accent.
   Colour is OKLCH. */

:root {
  --paper: oklch(0.998 0.002 85);
  --ink: oklch(0.17 0.008 60);
  --ink-soft: oklch(0.48 0.008 60);
  --sun: oklch(0.64 0.21 36);

  --display: "Host Grotesk", ui-sans-serif, "Helvetica Neue", Arial, sans-serif;
  --text: "Host Grotesk", ui-sans-serif, "Helvetica Neue", Arial, sans-serif;

  --margin: clamp(1.25rem, 3.2vw, 2.75rem);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Headline size. The widest line ("staying [icon] late") measures about 5.9em,
     so on phones the type is sized from the width; from tablet up it is also limited by height
     so the whole composition stays inside one screen. */
  --h-w: calc((100vw - 2 * var(--margin)) / 6.95);
  --h-svh: 17svh;
  --h: clamp(2.25rem, min(var(--h-w), var(--h-svh)), 11rem);

  /* Icon shelf */
  --shelf: clamp(3.75rem, 17vw, 5.5rem);

  color-scheme: light;
}

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

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

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

::selection {
  background: var(--ink);
  color: var(--paper);
}

p,
h1,
ul {
  margin: 0;
}

img {
  display: block;
}

/* ───────── Hero ───────── */

.hero {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  padding: var(--margin) var(--margin) calc(var(--shelf) * 0.72 + 1rem);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: clip;
}

/* Wordmark: the "5" tile and the studio name. Not navigation; press it for a celebration. */
.mark {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  padding: 0.25rem 0.5rem 0.25rem 0;
  border: 0;
  background: none;
  color: inherit;
  font: 650 clamp(1.0625rem, 1.3vw, 1.25rem) / 1 var(--display);
  letter-spacing: -0.02em;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mark__tile {
  position: relative;
  display: block;
  width: 1.9em;
  height: 1.9em;
  transition: transform 0.5s var(--ease-out);
}

.mark__icon {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0.08em 0.12em oklch(0.2 0.03 270 / 0.22));
}

/* A ring that pulses out of the tile on press. */
.mark__tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 24%;
  opacity: 0;
  pointer-events: none;
}

@media (hover: hover) {
  .mark:hover .mark__tile {
    transform: rotate(-8deg) scale(1.08);
  }
}

.mark:active .mark__tile {
  transform: scale(0.88);
}

.mark.is-celebrating .mark__tile {
  transform: scale(1.1);
}

.mark:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 0.2rem;
  border-radius: 0.5rem;
}

.stage {
  align-self: center;
  justify-self: center;
  width: 100%;
  padding-block: clamp(1.5rem, 4svh, 3rem);
  text-align: center;
}

/* Headline */
.headline {
  font: 650 var(--h) / 1 var(--display);
  letter-spacing: -0.032em;
  text-wrap: wrap;
}

.line {
  display: block;
  white-space: nowrap;
}

/* Each word sits in its own mask so the load-in can rise through it.
   The padding and negative margin keep descenders (p, y, g) unclipped. */
.w {
  display: inline-block;
  vertical-align: top;
  overflow: hidden;
  padding: 0.06em 0.04em 0.2em;
  margin: -0.06em -0.04em -0.2em;
}

.w > span {
  display: inline-block;
}

.headline__sun {
  font-style: normal;
  color: var(--sun);
}

/* Icon chips. The wrapper (.slot) owns the size and sits on the text baseline, like any inline box;
   the button (.slot__btn) fills it and holds a stack of icons. Pressing it shows the next icon.
   Without the script only the first icon shows.

   Two WebKit rules learned the hard way (Safari 26, iOS and macOS):
   - Never put blur() in a filter on these images, and never animate a filter: WebKit paints an
     opaque white box where the icon's transparency should be (blank squares).
   - Never make the button itself the inline-block: WebKit gives buttons a different baseline,
     so the chips hang below the line and spread the lines apart. */
.slot {
  position: relative;
  display: inline-block;
  width: 0.84em;
  height: 0.84em;
  margin: 0 0.1em;
  vertical-align: -0.075em;
}

.slot--last {
  margin-right: 0.02em;
}

.slot__btn {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  /* The button holds no text (its name is the aria-label). Zero metrics stop WebKit painting
     a grey tab for the empty text line under the icon. */
  font-size: 0;
  line-height: 0;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.slot__btn img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transform: scale(0.82);
  filter: drop-shadow(0 0.035em 0.07em oklch(0.2 0.03 270 / 0.24));
  pointer-events: none;
  z-index: 0;
  /* Leaving: stay exactly as it is, under the incoming icon, and drop out only after the
     incoming icon is fully opaque. Two half-transparent icons cross-fading would thin out in the middle. */
  transition: opacity 0.01s linear 0.5s, transform 0s linear 0.5s;
}

.slot__btn:not(.is-live) img:first-child,
.slot__btn img.is-on {
  z-index: 1;
  opacity: 1;
  transform: none;
  /* Arriving: fades and scales in, on top. */
  transition: opacity 0.45s var(--ease-out), transform 0.6s var(--ease-out);
}

.slot__btn:active {
  transform: scale(0.93);
}

.slot__btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 0.06em;
  border-radius: 24%;
}

/* The confetti and fireworks canvas, created on demand by app.js. */
.fx {
  position: fixed;
  inset: 0;
  z-index: 50;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Lede */
.lede {
  max-width: 33em;
  margin: clamp(1.25rem, 3.4svh, 2rem) auto 0;
  font: 400 clamp(1.0625rem, 1.5vw, 1.375rem) / 1.4 var(--text);
  letter-spacing: -0.01em;
  color: var(--ink-soft);
  text-wrap: balance;
}

/* Contact */
.contact {
  margin-top: clamp(1.25rem, 3.4svh, 2rem);
}

.contact__label {
  display: block;
  margin-bottom: 1.1rem;
  font: 500 0.75rem / 1 var(--text);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.contact__link {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  font: 600 clamp(1.5rem, 2.3vw, 2.25rem) / 1.1 var(--display);
  letter-spacing: -0.035em;
  color: var(--ink);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  /* A 44px-plus touch target (the text alone is about 31px on a phone) that leaves the layout untouched. */
  padding-block: 0.32em;
  margin-block: -0.32em;
}

.contact__text {
  padding-bottom: 0.1em;
  background: linear-gradient(var(--sun), var(--sun)) 0 100% / 100% 0.055em no-repeat;
  transition: background-size 0.5s var(--ease-out), color 0.3s ease;
}

.contact__arrow {
  width: 0.62em;
  height: 0.62em;
  flex: none;
  align-self: center;
  color: var(--sun);
  transition: transform 0.5s var(--ease-out);
}

@media (hover: hover) {
  .contact__link:hover .contact__text {
    background-size: 100% 0.11em;
  }

  .contact__link:hover .contact__arrow {
    transform: translate(0.14em, -0.14em);
  }
}

.contact__link:active .contact__text {
  color: var(--sun);
}

.contact__link:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 0.08em;
  border-radius: 2px;
}

/* ───────── Icon shelf ───────── */

.shelf {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 0;
  display: flex;
  align-items: flex-end;
  gap: calc(var(--shelf) * 0.17);
  padding: 0;
  list-style: none;
  translate: -50% calc(var(--shelf) * 0.34);
  pointer-events: none;
}

.shelf li {
  width: var(--shelf);
  height: var(--shelf);
  flex: none;
  /* a shallow arc: the middle icon sits highest */
  translate: 0 calc(var(--shelf) * 0.1 * var(--o));
}

.shelf img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0.14em 0.22em oklch(0.2 0.03 270 / 0.2));
}

/* Phones show five icons. */
@media (max-width: 639px) {
  .shelf li:nth-child(1),
  .shelf li:nth-child(7) {
    display: none;
  }
}

/* ───────── Motion ───────── */

@media (prefers-reduced-motion: no-preference) {
  @keyframes rise {
    from { transform: translateY(112%); }
    to   { transform: none; }
  }

  @keyframes pop {
    from { opacity: 0; transform: scale(0.45) rotate(-10deg); }
    to   { opacity: 1; transform: none; }
  }

  @keyframes lift {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
  }

  @keyframes up {
    from { opacity: 0; transform: translateY(70%); }
    to   { opacity: 1; transform: none; }
  }

  /* The logo tile on press: dip, spin a full turn while swelling, settle. */
  @keyframes logo-pop {
    0%   { transform: scale(1) rotate(0deg); }
    16%  { transform: scale(0.78) rotate(-14deg); }
    50%  { transform: scale(1.34) rotate(210deg); }
    78%  { transform: scale(0.96) rotate(350deg); }
    100% { transform: scale(1) rotate(360deg); }
  }

  @keyframes ring {
    0%   { opacity: 0.9; box-shadow: 0 0 0 0 oklch(0.64 0.21 36 / 0.55); }
    100% { opacity: 0;   box-shadow: 0 0 0 1.1em oklch(0.64 0.21 36 / 0); }
  }

  .w > span {
    animation: rise 1.2s var(--ease-out) both;
    animation-delay: calc(0.12s + var(--i) * 0.09s);
  }

  .slot {
    animation: pop 1.1s var(--ease-out) backwards;
    animation-delay: var(--d);
  }

  .mark.is-celebrating .mark__tile {
    animation: logo-pop 1s var(--ease-out);
  }

  .mark.is-celebrating .mark__tile::after {
    animation: ring 0.95s var(--ease-out);
  }

  .mark {
    animation: lift 1s var(--ease-out) 0.2s both;
  }

  .lede {
    animation: lift 1.1s var(--ease-out) 0.95s both;
  }

  .contact {
    animation: lift 1.1s var(--ease-out) 1.1s both;
  }

  .shelf img {
    animation: up 1.3s var(--ease-out) both;
    animation-delay: calc(1.15s + var(--o) * 0.08s);
  }

  /* With JS, the entrance waits for the web fonts so the headline never flashes in a fallback. */
  .js:not(.ready) .w > span,
  .js:not(.ready) .slot,
  .js:not(.ready) .mark,
  .js:not(.ready) .lede,
  .js:not(.ready) .contact,
  .js:not(.ready) .shelf img {
    animation-play-state: paused;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slot__btn img,
  .slot__btn img.is-on {
    transition: none;
  }
}

/* ───────── Larger screens ───────── */

@media (min-width: 640px) {
  :root {
    --h-w: calc((100vw - 2 * var(--margin)) / 7.1);
    --shelf: clamp(4.5rem, min(10vw, 17svh), 10.5rem);
  }
}

@media (min-width: 900px) {
  :root {
    --h-w: 9.8vw;
    /* Measured: the largest size that fits one screen is about 0.2467 x height - 81px
       (worst case, 1920 wide); this keeps about 8px to spare for other browsers' text rounding. */
    --h-svh: calc(0.2467 * 100svh - 89px);
    --shelf: clamp(5rem, min(10.5vw, 17svh), 10.5rem);
  }
}

/* Short windows (a 13-inch laptop's browser viewport, a phone on its side): shrink the type's
   height budget and tighten the vertical rhythm so everything stays on one screen. */
@media (max-height: 700px) {
  :root {
    /* Measured on short windows: about 0.27 x height - 73px at most; about 8px to spare. */
    --h-svh: calc(0.27 * 100svh - 81px);
  }

  .stage {
    padding-block: 0.5rem;
  }

  .contact__label {
    display: none;
  }
}
