/* Punica — chrome and typography. The world itself is drawn in WebGL. */

:root {
  --lapis: #1633c9;
  --lapis-hi: #5a86f4;
  --paper: #f0e7d6;
  --ink: #0f1420;
  --gold: #d8a63c;
  --crimson: #b8232f;
  --night: #08102a;

  --fg: #fff;
  --fg-dim: rgba(255, 255, 255, 0.84);
  --rule: rgba(255, 255, 255, 0.22);

  --gutter: max(28px, env(safe-area-inset-left), env(safe-area-inset-right));
  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

body[data-theme='paper'] .display { text-shadow: none; }
body[data-theme='paper'] { --fg: #22190c; --fg-dim: rgba(34, 25, 12, 0.86); --rule: rgba(34, 25, 12, 0.2); }
body[data-theme='dark'], body[data-theme='night'] { --fg: #fff; --fg-dim: rgba(255, 255, 255, 0.82); --rule: rgba(255, 255, 255, 0.18); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: #050914;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.skip {
  position: fixed; top: 8px; left: 8px; z-index: 90; padding: 10px 14px;
  background: #fff; color: #111; font: 500 12px/1 var(--mono); letter-spacing: .08em;
  transform: translateY(-160%); transition: transform .2s;
}
.skip:focus { transform: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* --------------------------------------------------------------- the film */

/* A canvas is a replaced element, so inset:0 alone leaves it at its intrinsic
   300x150 — it needs an explicit size. But a percentage height on a fixed
   element resolves against a viewport that excludes the dynamic toolbar on
   iOS, so the canvas ended short of the fold and the body showed through as a
   hard band at the foot of the film. dvh tracks the toolbar; % is the fallback. */
#film {
  position: fixed; inset: 0; width: 100%; height: 100%;
  height: 100dvh;
  display: block; z-index: 0; background: #050914;
}

/* drafting hairlines over the whole picture */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background:
    repeating-linear-gradient(to right, var(--rule) 0 1px, transparent 1px calc(100% / 6)),
    linear-gradient(to bottom, transparent calc(50% - .5px), var(--rule) calc(50% - .5px), var(--rule) calc(50% + .5px), transparent calc(50% + .5px));
  opacity: .5; mix-blend-mode: normal;
  transition: opacity .6s;
}
body.still::before, .no-js body::before { display: none; }

.spacer { height: calc(11 * 270vh); height: calc(11 * 270svh); pointer-events: none; }

#main {
  position: fixed; inset: 0; z-index: 3; pointer-events: none;
}
.act { position: absolute; inset: 0; }
.beat {
  position: absolute; inset: 0; padding: var(--gutter);
  display: flex; flex-direction: column; justify-content: center;
  opacity: 0; will-change: transform, opacity;
  transform-origin: 50% 50%;
}
/* Secondary copy is translucent over a moving painting, so give it a shadow of
   its own: the scrim handles the block, this handles the individual word that
   lands on a lit column. */
.body, .lede, .qa dd, .terms li p, .colophon { text-shadow: 0 1px 3px rgba(3, 8, 26, .5); }
body[data-theme='paper'] :is(.body, .lede, .qa dd, .terms li p) { text-shadow: 0 1px 3px rgba(252, 248, 238, .7); }
:is(.still, .no-js) :is(.body, .lede, .qa dd, .terms li p, .colophon) { text-shadow: none; }

/* unpainted, but still readable by assistive technology */
.beat.is-off > * { pointer-events: none; }
.beat.is-off::before { display: none; }
.beat > * { pointer-events: auto; position: relative; }
/* a soft scrim so type stays readable over a busy painting */
/* --scrim is set every frame from the film's own brightness (see Stage.sampleBrightness).
   Over the blue acts the type has 8:1 of contrast already and the scrim stays light;
   over the court's lit marble it more than doubles, which is where white body copy
   was measuring 2.5:1 against the paving. */
.beat::before {
  content: ''; position: absolute; inset: -14%; z-index: -1; pointer-events: none;
  opacity: calc(.62 + var(--scrim, 0) * .38);
}
.beat--center::before { background: radial-gradient(88% 68% at 50% 50%, rgba(4, 10, 30, .7), rgba(4, 10, 30, .38) 60%, transparent 90%); }
.beat--tl::before { background: radial-gradient(78% 66% at 16% 34%, rgba(4, 10, 30, .66), rgba(4, 10, 30, .32) 62%, transparent 86%); }
.beat--bl::before { background: radial-gradient(76% 64% at 18% 76%, rgba(4, 10, 30, .68), rgba(4, 10, 30, .34) 62%, transparent 86%); }
.beat--tr::before { background: radial-gradient(96% 84% at 74% 34%, rgba(4, 10, 30, .8), rgba(4, 10, 30, .48) 58%, transparent 94%); }
.beat--top::before { background: linear-gradient(to bottom, rgba(4, 10, 30, .72), rgba(4, 10, 30, .46) 58%, rgba(4, 10, 30, .28)); }
.beat--card::before { background: radial-gradient(74% 74% at 78% 50%, rgba(3, 7, 24, .7), rgba(3, 7, 24, .34) 62%, transparent 86%); }
.beat--page::before { background: none; }
/* on a light ground the scrim inverts rather than disappearing */
body[data-theme='paper'] .beat::before { background: radial-gradient(78% 68% at 50% 50%, rgba(250, 246, 236, .8), rgba(250, 246, 236, .4) 64%, transparent 88%); }
body[data-theme='paper'] .beat--page::before { background: none; }

.beat--center { align-items: center; text-align: center; }
.beat--hero { align-items: flex-start; justify-content: center; padding-left: max(var(--gutter), 6vw); }
.beat--hero > * { max-width: 22ch; }
.beat--hero .lede { max-width: 30ch; }
.beat--hero::before { background: radial-gradient(74% 68% at 26% 50%, rgba(4, 10, 30, .6), rgba(4, 10, 30, .3) 62%, transparent 86%); }
.beat--center > * { max-width: 60ch; }
.beat--tl { align-items: flex-start; justify-content: flex-start; padding-top: 22vh; }
.beat--tl > * { max-width: 42ch; }
.beat--bl { align-items: flex-start; justify-content: flex-end; padding-bottom: 16vh; }
.beat--bl > * { max-width: 40ch; }
.beat--tr { align-items: flex-end; justify-content: flex-start; padding-top: 20vh; text-align: right; }
.beat--tr > * { max-width: 40ch; }
.beat--top { align-items: center; justify-content: flex-start; padding-top: 15vh; text-align: center; }
.beat--page { align-items: center; justify-content: center; }
.beat--card { align-items: flex-end; justify-content: center; }

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

.mono { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow { color: var(--fg-dim); margin: 0 0 1.4rem; }
.display {
  font-family: var(--serif); font-weight: 400; letter-spacing: -.015em;
  text-shadow: 0 2px 40px rgba(3, 8, 26, .45);
  line-height: .96; margin: 0;
  font-size: clamp(3.2rem, 10.5vw, 9.5rem);
  text-wrap: balance;
}
.display--md { font-size: clamp(2.1rem, 5.2vw, 5rem); line-height: 1.02; }
.lede {
  font-family: var(--serif); font-size: clamp(1.15rem, 2vw, 1.9rem);
  line-height: 1.32; margin: 1.5rem 0 0; color: var(--fg);
  text-wrap: pretty;
}
.lede--sm { font-size: clamp(1rem, 1.4vw, 1.25rem); color: var(--fg-dim); }
.body {
  margin: 1.1rem 0 0; font-size: clamp(.95rem, 1.05vw, 1.05rem);
  line-height: 1.62; color: var(--fg-dim); max-width: 40ch; text-wrap: pretty;
}
.beat--tr .body { margin-left: auto; }
.cue { margin: 3.2rem 0 0; color: var(--fg-dim); animation: cue 2.6s ease-in-out infinite; }
@keyframes cue { 0%, 100% { opacity: .4; transform: translateY(0); } 50% { opacity: 1; transform: translateY(4px); } }

/* ------------------------------------------------------------ components */

.terms {
  list-style: none; margin: 2rem 0 0; padding: 0; counter-reset: t;
  display: grid; gap: 1.1rem; max-width: 58ch;
}
.terms li { display: grid; grid-template-columns: 3.2rem 1fr; align-items: baseline; }
.terms li span { color: #6b4c07; }
.terms li p { margin: 0; font-size: .98rem; line-height: 1.6; color: var(--fg-dim); }
.beat--page > * { max-width: none; }
/* the terms sit on a laid-in leaf of clean vellum */
.beat--page .page-card {
  max-width: min(52ch, 44vw); margin: 0 auto; padding: clamp(1.3rem, 2.4vw, 2.2rem);
  background: rgba(246, 238, 219, .93);
  box-shadow: 0 24px 60px rgba(40, 26, 8, .3), 0 1px 0 rgba(255, 255, 255, .7) inset;
  border: 1px solid rgba(120, 92, 44, .35);
}
.beat--page .display { text-align: left; font-size: clamp(1.5rem, 2.6vw, 2.5rem); }
.beat--page .terms li p { font-size: .88rem; }
@media (max-width: 900px) { .beat--page .page-card { max-width: 86vw; } }

.qa { margin: 2.2rem auto 0; padding: 0; max-width: 74ch; text-align: left; display: grid; gap: 1.4rem; }
.qa div { border-top: 1px solid var(--rule); padding-top: .9rem; }
.qa dt { font-family: var(--serif); font-size: clamp(1.05rem, 1.7vw, 1.5rem); line-height: 1.2; }
.qa dd { margin: .5rem 0 0; color: var(--fg-dim); font-size: .95rem; line-height: 1.6; }

.beat--card { padding-right: max(var(--gutter), 5vw); }
.beat--card > * { max-width: min(44ch, 86vw); width: 100%; }
.form {
  margin: 1.6rem 0 0; padding: 1.6rem; display: grid; gap: 1rem;
  background: rgba(10, 18, 44, 0.42);
  border: 1px solid var(--rule);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-radius: 2px;
}
.field { margin: 0; display: grid; gap: .4rem; }
.field label { color: var(--fg-dim); }
.field__input {
  width: 100%; padding: .6rem .1rem; color: var(--fg);
  background: transparent; border: 0; border-bottom: 1px solid var(--rule);
  font: 400 1rem/1.4 var(--sans); border-radius: 0;
}
.field__input:focus { border-bottom-color: var(--gold); }
.field__input:focus:not(:focus-visible) { outline: none; }
textarea.field__input { resize: vertical; }
.btn {
  justify-self: start; margin-top: .4rem; padding: .8rem 1.4rem;
  font: 500 11px/1 var(--mono); letter-spacing: .14em;
  color: #0d1424; background: var(--paper); border: 0; cursor: pointer;
  transition: background .2s, transform .2s;
}
.btn:hover { background: #fff; transform: translateY(-1px); }
.form__status { color: var(--fg-dim); }

.wordmark {
  font-family: var(--serif); font-size: clamp(4rem, 17vw, 15rem);
  line-height: .82; margin: 0; letter-spacing: -.03em;
}
.wordmark__dot { color: var(--crimson); }
.colophon { margin: 2.2rem 0 0; color: var(--fg-dim); max-width: 60ch; line-height: 1.85; }

/* ---------------------------------------------------------------- chrome */

.chrome {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  /* the page is viewport-fit=cover, so the notch is ours to clear */
  padding: calc(var(--gutter) * .7 + env(safe-area-inset-top)) var(--gutter) calc(var(--gutter) * .7);
  mix-blend-mode: normal;
}
.brand { color: var(--fg); text-decoration: none; }
.menu-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: none; border: 0; cursor: pointer; color: var(--fg);
}
.menu-btn__bars { display: grid; gap: 5px; width: 22px; }
.menu-btn__bars i { height: 1px; background: currentColor; transition: transform .3s; }
body.menu-open .menu-btn__bars i:first-child { transform: translateY(3px) rotate(45deg); }
body.menu-open .menu-btn__bars i:last-child { transform: translateY(-3px) rotate(-45deg); }

.menu {
  position: fixed; inset: 0; z-index: 39; background: rgba(6, 12, 32, .92);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  display: grid; place-items: center;
  /* eleven links do not fit a phone held sideways; let them scroll */
  overflow-y: auto; overscroll-behavior: contain;
  padding: calc(4rem + env(safe-area-inset-top)) var(--gutter) calc(2rem + env(safe-area-inset-bottom));
  opacity: 0; visibility: hidden;
  /* visibility flips at once on open and only after the fade on close, so the
     first link is focusable the moment the menu opens */
  transition: opacity .45s, visibility 0s .45s;
}
body.menu-open .menu { opacity: 1; visibility: visible; transition: opacity .45s, visibility 0s 0s; }
.menu__list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.menu__list a {
  display: flex; gap: 1.2rem; align-items: baseline; text-decoration: none; color: #fff;
  font-family: var(--serif); font-size: clamp(1.8rem, 5vw, 3.4rem); line-height: 1.15;
  opacity: .86; transition: opacity .2s, transform .2s;
}
.menu__list a:hover, .menu__list a:focus-visible { opacity: 1; transform: translateX(6px); }
.menu__list .mono { color: var(--gold); }

.rail {
  position: fixed; left: var(--gutter); top: 50%; transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl; z-index: 30; color: var(--fg-dim);
  display: flex; gap: 1.4rem; align-items: center; pointer-events: none;
}
.bar { position: fixed; left: 0; right: 0; bottom: env(safe-area-inset-bottom); height: 2px; z-index: 30; background: var(--rule); }
.bar i { display: block; height: 100%; background: var(--gold); transform-origin: 0 50%; transform: scaleX(0); }

#loader {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: #050914; transition: opacity .3s;
}
.loader__mark {
  font-family: var(--serif); font-size: clamp(2rem, 6vw, 4rem); color: #fff;
  opacity: .5; animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .28; } 50% { opacity: .7; } }
body.booting { overflow: hidden; }

/* ------------------------------------------------- the still edition */

.still #film, .no-js #film,
.still #loader, .no-js #loader,
.still .spacer, .no-js .spacer,
.still .rail, .no-js .rail,
.still .bar, .no-js .bar,
.still .cue, .no-js .cue { display: none !important; }

.still, .no-js body { background: var(--lapis); }
/* the still edition has no artwork behind the type, so it can afford more contrast */
.still, .no-js body { --fg-dim: rgba(255, 255, 255, 0.82); }
.no-js .menu-btn, .no-js .menu, .no-js .skip { display: none !important; }
/* the chrome stays fixed while the page scrolls under it, so give it a ground */
:is(.still, .no-js) .chrome {
  background: linear-gradient(to bottom, var(--lapis) 42%, rgba(11, 26, 92, 0));
  padding-bottom: calc(var(--gutter) * 1.1);
}

:is(.still, .no-js) #main {
  position: static; pointer-events: auto; max-width: 1180px; margin: 0 auto;
  /* the chrome stays fixed over the top of the page, so leave it a lane */
  padding: calc(3.4rem + env(safe-area-inset-top)) var(--gutter) 0;
}
:is(.still, .no-js) .act {
  position: relative; inset: auto; min-height: 82vh;
  /* three beats share the graft act: stack them, or flex lays them out as
     columns and they clip against each other on a phone */
  display: flex; flex-direction: column; align-items: stretch; justify-content: center;
  border-top: 1px solid var(--rule); background-repeat: no-repeat;
  background-position: right center; background-size: contain;
}
:is(.still, .no-js) .act:first-child { border-top: 0; min-height: 92vh; }
:is(.still, .no-js) .beat {
  position: relative; inset: auto; opacity: 1 !important; visibility: visible !important;
  transform: none !important; padding: 6rem 0; align-items: flex-start; text-align: left;
}
:is(.still, .no-js) .beat--tr { text-align: left; }
:is(.still, .no-js) .beat--tr .body { margin-left: 0; }
:is(.still, .no-js) .beat > * { max-width: 58ch; }
/* background-color, not the shorthand: the shorthand resets the
   background-repeat above and tiles the seal across the whole act */
:is(.still, .no-js) .act--terms { background-color: var(--paper); color: #22190c; }
:is(.still, .no-js) .act--terms :is(.body, .display, .terms li p) { color: rgba(34, 25, 12, .78); }
:is(.still, .no-js) .act--terms .terms li span { color: #7a5a0e; }
:is(.still, .no-js) .act[data-art='curtain'] { background-image: url(../assets/img/hero-figure-s.webp); }
:is(.still, .no-js) .act[data-art='sky'] { background-image: url(../assets/img/plate-s.webp); }
:is(.still, .no-js) .act[data-art='graft'] { background-image: url(../assets/img/pom-held-s.webp); }
:is(.still, .no-js) .act[data-art='colossus'] { background-image: url(../assets/img/pom-s.webp); }
:is(.still, .no-js) .act[data-art='terms'] { background-image: url(../assets/img/seal-s.webp); background-size: 120px auto; }
:is(.still, .no-js) .act[data-art='roster'] { background-image: url(../assets/img/proserpine-s.webp); }
:is(.still, .no-js) .act[data-art='canopy'] { background-image: url(../assets/img/bough-1-s.webp); }
:is(.still, .no-js) .act[data-art='stars'] { background-image: url(../assets/img/pleiades-s.webp); }
:is(.still, .no-js) .act[data-art='studio'] { background-image: url(../assets/img/pom-split-s.webp); }
@media (max-width: 860px) {
  :is(.still, .no-js) .act { background-image: none !important; }
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .beat--hero { padding-left: var(--gutter); }
  :root { --gutter: max(20px, env(safe-area-inset-left), env(safe-area-inset-right)); }
  .rail { display: none; }
  .beat--tl, .beat--tr { padding-top: 18vh; }
  .beat--tr { align-items: flex-start; text-align: left; }
  .beat--tr .body { margin-left: 0; }
  .beat--card { align-items: stretch; justify-content: flex-end; padding-bottom: 12vh; }
  .beat--bl { padding-bottom: 12vh; }
  /* The type is full-bleed here, so a radial scrim runs out of alpha exactly
     where the last words of each line are. Use vertical gradients instead:
     they cover the whole width and fade only where there is nothing to read. */
  .beat--tl::before, .beat--tr::before {
    background: linear-gradient(to bottom, rgba(4, 10, 30, .86) 4%, rgba(4, 10, 30, .66) 46%, rgba(4, 10, 30, .3) 74%, transparent);
  }
  /* the questions run the whole height of the frame, so the scrim has to as well */
  .beat--top::before {
    background: linear-gradient(to bottom, rgba(4, 10, 30, .86) 4%, rgba(4, 10, 30, .74) 46%, rgba(4, 10, 30, .6) 80%, rgba(4, 10, 30, .42));
  }
  .beat--bl::before {
    background: linear-gradient(to top, rgba(4, 10, 30, .86) 4%, rgba(4, 10, 30, .66) 46%, rgba(4, 10, 30, .3) 74%, transparent);
  }
  .beat--card::before {
    background: linear-gradient(to top, rgba(3, 7, 24, .84) 6%, rgba(3, 7, 24, .62) 52%, rgba(3, 7, 24, .28) 80%, transparent);
  }
  .beat--hero::before, .beat--center::before {
    background: radial-gradient(130% 78% at 42% 50%, rgba(4, 10, 30, .78), rgba(4, 10, 30, .46) 62%, rgba(4, 10, 30, .18) 88%);
  }
  body[data-theme='paper'] :is(.beat--tl, .beat--tr, .beat--top)::before {
    background: linear-gradient(to bottom, rgba(250, 246, 236, .92) 4%, rgba(250, 246, 236, .84) 50%, rgba(250, 246, 236, .44) 80%, transparent);
  }
  body[data-theme='paper'] .beat--page::before { background: none; }
  .qa { gap: 1rem; }
  .terms li { grid-template-columns: 2.4rem 1fr; }
}
@media (hover: none) {
  .field__input { font-size: 16px; }
}

/* a phone held sideways: the film still runs, the type just tightens up */
@media (max-height: 560px) {
  .beat { padding: max(12px, var(--gutter)); }
  .beat--tl, .beat--tr, .beat--top { padding-top: 12vh; }
  .beat--bl { padding-bottom: 8vh; }
  .display { font-size: clamp(2rem, 7vw, 4rem); }
  .display--md { font-size: clamp(1.4rem, 4vw, 2.6rem); }
  .lede { font-size: clamp(.95rem, 1.6vw, 1.3rem); margin-top: .8rem; }
  .body, .qa dd { font-size: .82rem; line-height: 1.45; }
  .qa { gap: .55rem; margin-top: 1rem; }
  .qa dt { font-size: 1rem; }
  .terms { gap: .6rem; margin-top: 1rem; }
  .cue { display: none; }
  /* Measured at 852x393 and 740x360: the application and the colophon ran 60px
     and 100px taller than the viewport, so a centred beat lost its headline off
     the top. Anchor them to the top and take the type down to fit. */
  .beat--card, .beat--center { justify-content: flex-start; padding-top: 5vh; }
  .beat--card::before { background: radial-gradient(120% 70% at 50% 26%, rgba(3, 7, 24, .76), rgba(3, 7, 24, .4) 58%, transparent 94%); }
  .form { padding: .7rem 0 0; gap: .35rem; }
  .form .field__input { font-size: .82rem; padding: .3rem 0; }
  .form textarea.field__input { min-height: 2.1rem; }
  .form label { font-size: .58rem; }
  .wordmark { font-size: clamp(2rem, 8vw, 3.4rem); }
  .lede--sm { font-size: .82rem; }
  .colophon { margin-top: .9rem; font-size: .52rem; line-height: 1.5; }
}

/* the shortest phones held sideways need one more notch */
@media (max-height: 400px) {
  .beat--tl, .beat--tr, .beat--top { padding-top: 7vh; }
  .qa { gap: .38rem; margin-top: .7rem; }
  .qa dt { font-size: .92rem; }
  .qa dd { font-size: .74rem; line-height: 1.36; }
  .form .field__input { font-size: .78rem; }
  .colophon { font-size: .48rem; line-height: 1.42; }
  .lede--sm { font-size: .76rem; }
}

/* the colophon is a long block of mono: it overruns a short phone in portrait too */
@media (max-height: 720px) and (orientation: portrait) {
  .colophon { margin-top: 1.4rem; font-size: .58rem; line-height: 1.6; }
}

@media print {
  #film, #loader, .chrome, .menu, .rail, .bar, .spacer { display: none !important; }
  #main { position: static; }
  .act { position: static; page-break-inside: avoid; }
  .beat { position: static; opacity: 1 !important; visibility: visible !important; transform: none !important; }
  body { background: #fff; color: #000; }
}
