:root {
  --ink: #111;
  --rule: #888;
  --bg: #fff;
  --header-h: 57.5px;
  --ticker-speed: 45s;
  /* fallback only: script.js sets the real speed (TICKER_SPEED) */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

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

.ticker {
  position: absolute;
  /* sits at the top of the page and scrolls away with it */
  inset: 0 0 auto 0;
  height: calc(var(--header-h) * 1.2);
  background: var(--bg);
  border-bottom: 1px solid #000;
  overflow: hidden;
  z-index: 10;
}

.ticker__track {
  display: flex;
  width: max-content;
  height: 100%;
  animation: ticker var(--ticker-speed) linear infinite;
  will-change: transform;
  /* keep it on the GPU, iOS Safari likes this */
}

.ticker__group {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.ticker__group span {
  font-style: normal;
  font-size: 24px;
  white-space: nowrap;
  padding: 0;
  margin-right: 15vw;
  /* fallback only: script.js sizes this gap */
}

/* script.js running: it moves each phrase itself (smoother than sliding the
   whole strip), so the strip stays still and the phrases stack at the left */
.ticker.is-js .ticker__track {
  animation: none;
  position: relative;
  width: auto;
}

.ticker.is-js .ticker__group[aria-hidden] {
  display: none;
}

.ticker.is-js .ticker__group span {
  position: absolute;
  left: 0;
  top: 50%;
  margin: 0;
  will-change: transform;
}

@keyframes ticker {
  from {
    transform: translate3d(0, 0, 0);
  }

  to {
    transform: translate3d(-50%, 0, 0);
  }
}

/* Reduce Motion (common on iPhones): keep the ticker, just make it gentler */
@media (prefers-reduced-motion: reduce) {
  .ticker__track {
    animation-duration: calc(var(--ticker-speed) * 2);
  }
}

/* ---------- column ---------- */

.column {
  --col-w: min(64.35vw, 812px);
  width: var(--col-w);
  margin: 0 auto;
  /* set to "0 0 0 40px" to pin the column to the left edge */
  padding: var(--header-h) 0 64px;
  text-align: left;
}

/* mat sits vertically centred on the first screen with the text right under
   it. 0.6038 is the mat image's height/width (1094 / 1812). */
.mat {
  --mat-w: min(33.333vw, 640px, var(--col-w));
  /* mat stays its original size */
  --mat-h: calc(var(--mat-w) * 0.6038);
  margin: 0 0 50px;
  /* gap between mat and text */
  /* centred on the full screen height (the column already pads by the header) */
  padding-top: max(16px, calc((100vh - var(--mat-h)) / 2 - var(--header-h)));
  padding-top: max(16px, calc((100svh - var(--mat-h)) / 2 - var(--header-h)));
}

.mat img {
  display: block;
  width: var(--mat-w);
  height: auto;
  margin: 0 auto;
}

/* line drawings between paragraphs */
.art {
  --art-w: min(33.333vw, 640px, var(--col-w));
  /* same size as the mat */
  margin: 4em 0;
}

.art img {
  display: block;
  width: var(--art-w);
  height: auto;
  margin: 0 auto;
}

.art--tall img {
  width: calc(var(--art-w) * 0.7);
}

/* the gate register scan: full width of the text column */
.art--wide img {
  width: calc(var(--art-w) * 1.465);
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
}

/* the name tag: 15% smaller than the mat */
.art--nametag img {
  width: calc(var(--art-w) * 0.85);
}

/* the sms screenshot: 10% smaller than the mat */
.art--sms img {
  width: calc(var(--art-w) * 0.9);
}

/* the QR drawing: a bit smaller than the tall drawings */
.art--qr img {
  width: calc(var(--art-w) * 0.616);
}

/* the Ahmer card drawing: 5% smaller than the mat */
.art--ahmer img {
  width: calc(var(--art-w) * 0.95);
}

/* the party sign: 30% bigger than the mat, still narrower than the text */
.art--sign img {
  width: min(calc(var(--art-w) * 1.3), calc(var(--col-w) * 0.8));
}

/* phones: drawings already fill the column, so wide drawings stay within it */
@media (max-width: 900px) {

  .art--wide img,
  .art--sign img {
    width: var(--art-w);
  }
}

@media (max-width: 900px) {
  .art {
    --art-w: var(--col-w);
  }
}

p {
  font-size: 24px;
  line-height: 1.22;
  margin: 0 0 1.22em;
}

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

.jump {
  margin-top: 150vh;
  /* "way below" the text */
  scroll-margin-top: 32px;
  /* clear the fixed ticker */
}

.jump h2 {
  font-size: 24px;
  font-weight: 400;
  margin: 0 0 1.22em;
}

/* ---------- links ---------- */

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
  text-decoration-skip-ink: none;
  /* solid line straight through descenders */
}

/* thickness also sets the size of the wiggles and dots */
/* the wave is a repeating drawing under the word (not a text-decoration),
   so it can flow left to right on hover */
a.wavy {
  text-decoration: none;
  /* one wave = 12px long; stroke-width is the line thickness. The path runs
     past both tile edges so neighbouring tiles overlap with no seam */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M-6,3.5 Q-3,6.5 0,3.5 T6,3.5 T12,3.5 T18,3.5' fill='none' stroke='%23111' stroke-width='2'/%3E%3C/svg%3E") repeat-x 0 100% / 12px 7px;
  padding-bottom: 3.5px;
  /* gap between the word and the wave */
}

@media (max-width: 900px) {

  /* phones: same wave drawn with a thinner line (1.3 instead of 2) */
  a.wavy {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M-6,3.5 Q-3,6.5 0,3.5 T6,3.5 T12,3.5 T18,3.5' fill='none' stroke='%23111' stroke-width='1.365'/%3E%3C/svg%3E");
    padding-bottom: 3px;
  }
}

/* the wave flows left to right all the time */
@media (prefers-reduced-motion: no-preference) {
  a.wavy {
    animation: wavy-flow 1s linear infinite;
  }
}

@keyframes wavy-flow {
  to {
    background-position-x: 12px;
    /* one whole wave, so the loop is seamless */
  }
}

/* jump links: class is still "dotted" but they now get a plain solid line */
a.dotted {
  text-decoration: none;
  /* a row of round dots (one every 6px), drawn under the word like the wave */
  background: radial-gradient(circle, #111 1.4px, transparent 1.8px) repeat-x 0 100% / 6px 4px;
  padding-bottom: 1px;
}

/* phones: smaller, lighter dots */
@media (max-width: 900px) {
  a.dotted {
    background-image: radial-gradient(circle, #111 0.9px, transparent 1.25px);
    background-size: 6px 3px;
  }
}

/* the dots march left to right all the time */
@media (prefers-reduced-motion: no-preference) {
  a.dotted {
    animation: dots-flow 0.6s linear infinite;
  }
}

@keyframes dots-flow {
  to {
    background-position-x: 6px;
    /* one dot step, so the loop is seamless */
  }
}

/* phones: smaller text, so the underline is a touch thinner and tighter */
@media (max-width: 900px) {
  a {
    text-decoration-thickness: 1.5px;
    text-underline-offset: 2px;
  }
}

/* ---------- product popup ---------- */

.popup {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  /* script.js lines the box up with the clicked word */
  padding: 16px;
  background: transparent;
  /* page behind stays exactly as it is */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.8s ease, visibility 0.8s;
  /* slow fade out */
}

/* hover popups (desktop): the mouse passes through to the word underneath,
   so moving off the word is what closes it; player embeds stay clickable */
.popup.is-hover {
  pointer-events: none;
}

.popup.is-hover .popup__yt:not([hidden]) {
  pointer-events: auto;
}

.popup.is-open {
  opacity: 1;
  visibility: visible;
  transition-duration: 0.2s;
  /* quick fade in */
}

.popup__box {
  position: relative;
  max-width: 100%;
  isolation: isolate;
}

/* one drop shadow behind the image, centred so the glow is even on every side.
   Colour = the link's data-glow. Tweak the look here:
     --shadow-blur:   how soft the edge is (like "Blur Radius")
     --shadow-spread: how far the solid colour reaches past the image before
                      it starts to fade (bigger = a wider glow)
     opacity:         1 = full colour, 0.5 = half, 0 = no shadow */
.popup__box::before {
  --shadow-blur: 175px;
  --shadow-spread: 70px;
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: 0 0 var(--shadow-blur) var(--shadow-spread) var(--glow, #22ff22);
  opacity: 1;
  z-index: -1;
}

.popup__img {
  /* every link image is scaled by this (0.95 = 5% smaller) */
  --img-scale: 0.95;
  display: block;
  max-width: min(calc(85vw * var(--img-scale)), calc(820px * var(--img-scale)));
  /* leave room around it for the glow */
  max-height: calc(85vh * var(--img-scale));
  max-height: calc(85svh * var(--img-scale));
  width: auto;
  height: auto;
}

/* portrait screenshots: 10% smaller */
.popup__img.is-tall {
  max-width: min(calc(76.5vw * var(--img-scale)), calc(738px * var(--img-scale)));
  max-height: calc(76.5vh * var(--img-scale));
  max-height: calc(76.5svh * var(--img-scale));
}

/* links marked data-small: 20% smaller again */
.popup__img.is-small {
  max-width: min(calc(61vw * var(--img-scale)), calc(590px * var(--img-scale)));
  max-height: calc(61vh * var(--img-scale));
  max-height: calc(61svh * var(--img-scale));
}

/* data-small="more": smaller still (the map screenshot) */
.popup__img.is-smaller {
  max-width: min(calc(52vw * var(--img-scale)), calc(500px * var(--img-scale)));
  max-height: calc(52vh * var(--img-scale));
  max-height: calc(52svh * var(--img-scale));
}

/* data-small="less": 5% bigger than data-small (the rosebuds) */
.popup__img.is-small-less {
  max-width: min(calc(64vw * var(--img-scale)), calc(620px * var(--img-scale)));
  max-height: calc(64vh * var(--img-scale));
  max-height: calc(64svh * var(--img-scale));
}

/* data-small="bit": a little smaller than data-small (the karaoke photo) */
.popup__img.is-small-bit {
  max-width: min(calc(57.75vw * var(--img-scale)), calc(556px * var(--img-scale)));
  max-height: calc(57.75vh * var(--img-scale));
  max-height: calc(57.75svh * var(--img-scale));
}

/* data-size="0.79" etc: an exact fraction of the full popup size (the cake) */
.popup__img.is-sized {
  max-width: min(calc(85vw * var(--size) * var(--img-scale)), calc(820px * var(--size) * var(--img-scale)));
  max-height: calc(85vh * var(--size) * var(--img-scale));
  max-height: calc(85svh * var(--size) * var(--img-scale));
}

.popup__img[hidden] {
  display: none;
}

/* videos are square: as big as the screen allows */
.popup__video {
  /* sized from the video's own shape, so a portrait video gets a portrait
     box (and the glow hugs the video, not empty space beside it) */
  width: auto;
  height: auto;
  max-width: min(85vw, 820px);
  max-height: 85vh;
  max-height: 85svh;
}

/* YouTube: 16:9 box sized to the screen */
.popup__yt {
  width: min(85vw, 960px, calc(85svh * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #000;
}

.popup__yt iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Spotify: the compact player strip (152px tall is Spotify's own size) */
.popup__yt.is-spotify {
  width: min(85vw, 420px);
  height: 152px;
  aspect-ratio: auto;
  background: transparent;
}

.popup__yt.is-spotify me {
  border-radius: 12px;
}

/* Spotify: a tighter glow with the player's rounded corners, so it hugs the strip */
.popup__box:has(.popup__yt.is-spotify:not([hidden]))::before {
  --shadow-blur: 90px;
  --shadow-spread: 20px;
  border-radius: 12px;
}

/* products marked data-bw: black & white with a black border */
.popup__img.is-bw {
  filter: grayscale(1);
}

/* ---------- greyscale side images ---------- */

body {
  position: relative;
}

.side-art {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.side-art img {
  position: absolute;
  height: auto;
}

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

@media (max-width: 900px) {
  .column {
    --col-w: calc(100vw - 32px);
    margin: 0 16px;
  }

  .mat {
    --mat-w: var(--col-w);
    margin-bottom: 25px;
  }

  /* phones: images peek in from the edges only while scrolling,
     then fade out (script.js removes .is-scrolling 400ms after it stops) */
  .side-art {
    z-index: 5;
    opacity: 0;
    transition: opacity 0.8s ease;
  }

  .side-art.is-scrolling {
    opacity: 1;
    transition-duration: 0.25s;
  }

  /* a gif that has already been seen fades out with the layer, for good */
  .side-art img {
    transition: opacity 0.8s ease;
  }

  .side-art img.is-seen {
    opacity: 0;
  }

  p,
  .ticker__group span {
    font-size: 18px;
  }

  .ticker__group span {
    margin-right: 15vw;
  }
}

/* ---------- day headings ---------- */

.day {
  font-size: 24px;
  font-weight: 400;
  text-align: center;
  margin: 2.5em 0 1.22em;
}

/* phones: every heading matches the 18px body text */
@media (max-width: 900px) {

  .day,
  .jump h2 {
    font-size: 18px;
  }
}

/* footer ticker: same bar at the very end of the page, line on top instead */
.ticker--foot {
  position: relative;
  inset: auto;
  border-bottom: 0;
  border-top: 2px solid #000;
}

@media (max-width: 900px) {
  .ticker {
    border-bottom-width: 1px;
  }

  .ticker--foot {
    border-top-width: 1px;
  }
}

/* ---------- credits ---------- */

.credits {
  margin-top: 25vh;
}

.credits__logo {
  display: block;
  width: 100px;
  height: auto;
  margin-top: 1em;
}

@media (max-width: 900px) {
  .credits__logo {
    width: 77px;
  }
}

/* jump targets inside the story clear the fixed ticker */
.day[id],
p[id],
span[id] {
  scroll-margin-top: 32px;
}

/* double gap between one delivery person's story and the next person */
p+p.visit {
  margin-top: 2.44em;
}

/* ---------- drawn banner headings (The Gate Register, The Party, Credits) ---------- */

.banner svg {
  display: block;
  width: var(--banner-w);
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  overflow: visible;
}

.banner path {
  fill: var(--bg);
  stroke: #555;
  stroke-width: 1.5px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.banner text {
  fill: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  text-anchor: middle;
  dominant-baseline: middle;
}

.banner--gate {
  --banner-w: 280px;
}

#the-gate-register {
  margin-top: 10em;
}

#day-1 {
  margin-top: 1px;
}

.banner--party {
  --banner-w: 440px;
}

#the-party {
  margin-top: 4em;
}

.banner--heart {
  --banner-w: 187px;
}

/* banner text is sized (in index.html) to be exactly 24px at these widths,
   like the paragraphs; phones use 75% of each width, so it's 18px there */
@media (max-width: 900px) {
  .banner--gate {
    --banner-w: 210px;
  }

  #the-gate-register {
    margin-top: 6em;
  }

  .banner--party {
    --banner-w: 330px;
  }

  .banner--heart {
    --banner-w: 140.25px;
  }
}

/* heading text for screen readers; the drawing carries it visually */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* EXPERIMENT: grey highlight for a link. Add class="wavy try-grey" to use it. */
a.wavy.try-grey {
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding-left: 2px;
  padding-right: 2px;
}

/* 1st link: a grey highlighter behind the words */
a.wavy.try-grey {
  background-color: #ebebeb;
}

/* Hand-drawn arrow before the first link (Tara's pick, 4 Nov:
   arrow 12, size 0.75, rotate -163deg, up/down -0.05, space left 0.05,
   space right 0.20, flipped left-right + upside down) */
.link-arrow {
  display: inline-block;
  height: 0.75em;
  width: auto;
  margin-left: 0.05em;
  margin-right: 0.2em;
  /* centred on the text; the negative margins stop the arrow
     pushing the lines apart */
  vertical-align: middle;
  margin-top: calc((0.8em - 0.75em) / 2);
  margin-bottom: calc((0.8em - 0.75em) / 2);
  transform: translateY(-0.05em) rotate(-163deg) scale(-1, -1);
}

/* keep the arrow on the same line as the first word of its link: no
   line break is allowed between the arrow and the link, but the link's
   own words can still wrap normally */
.arrow-keep {
  white-space: nowrap;
}

.arrow-keep > a {
  white-space: normal;
}
