@font-face { font-family: 'Saint'; src: url('../fonts/saint.otf') format('opentype'); font-display: swap; }
@font-face { font-family: 'Copy Dept'; src: url('../fonts/copy-dept-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Copy Dept'; src: url('../fonts/copy-dept-bleed.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --cr: #050505;      /* GMK CR, as black as it reads on the cap */
  --ws1: #F7F2EA;     /* GMK WS1 */
  --rubine: #CE0058;  /* Pantone Rubine Red C */
  --slot: #0e0e0e;    /* an empty image box, one step off the ground */
  --gutter: clamp(16px, 3vw, 40px);
  --display: 'Saint', 'Copy Dept', serif;
  --text: 'Copy Dept', ui-serif, Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { background: var(--cr); }
body { margin: 0; color: var(--ws1); font: 400 17px/1.55 var(--text); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
::selection { background: var(--rubine); color: var(--ws1); }
:focus-visible { outline: 2px solid var(--rubine); outline-offset: 3px; }
.defs { position: absolute; width: 0; height: 0; }
.skip { position: fixed; left: var(--gutter); top: -60px; z-index: 30; padding: 10px 16px; background: var(--ws1); color: var(--cr); text-decoration: none; }
.skip:focus { top: 12px; }

.wrap { width: min(100% - 2 * var(--gutter), 1440px); margin-inline: auto; }
.display { font-family: var(--display); font-weight: 400; letter-spacing: .01em; line-height: .9; }
.title { font: 400 clamp(44px, 6.4vw, 104px)/.95 var(--display); margin: 0 0 32px; letter-spacing: .01em; }
p { margin: 0 0 18px; max-width: 58ch; }
h3 { font: 700 17px/1.4 var(--text); margin: 0 0 6px; }

/* the loader: the mark, faint, with a Rubine line running round it, while the stages are set up */
.loader { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .5s ease, visibility 0s .5s; }
html.boot .loader { opacity: 1; visibility: visible; transition: opacity .3s ease .25s; }
.loader svg { width: 96px; height: 96px; overflow: visible; }
.loader path { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.loader__ghost { stroke: var(--ws1); stroke-width: .5; opacity: .28; }
.loader__run { stroke: var(--rubine); stroke-width: 1; stroke-dasharray: .22 .78; filter: drop-shadow(0 0 2px var(--rubine)) drop-shadow(0 0 5px var(--rubine)); }
html.boot .loader__run { animation: run 1.6s linear infinite; }
@keyframes run { to { stroke-dashoffset: -1; } }

/* the menu: a small star in the corner. Pointed at, tapped or focused, it draws out the list of sections. */
.menu { position: fixed; top: 6px; right: calc(var(--gutter) - 12px); z-index: 6; transition: opacity .7s ease; }
html.boot .menu { opacity: 0; }
.menu__btn { display: grid; place-items: center; width: 44px; height: 44px; margin-left: auto; padding: 0; border: 0; background: none; cursor: pointer; }
.menu__star, .menu__list a[aria-current]::before { background: var(--ws1);
  clip-path: polygon(50% 0, 57% 43%, 100% 50%, 57% 57%, 50% 100%, 43% 57%, 0 50%, 43% 43%); }
.menu__star { width: 22px; height: 22px; transition: rotate .7s cubic-bezier(.2, .7, .1, 1), scale .7s cubic-bezier(.2, .7, .1, 1); }
.menu.is-open .menu__star { rotate: 45deg; scale: 1.2; }
.menu__list { position: absolute; top: 44px; right: 0; margin: 0; padding: 4px 12px 14px 30px; list-style: none; text-align: right; white-space: nowrap;
  font: 400 clamp(21px, 1.9vw, 29px)/1 var(--display); letter-spacing: .04em;
  background: var(--cr); box-shadow: 0 0 34px 30px var(--cr);          /* a feathered patch of the ground, so the names read over anything */
  visibility: hidden; opacity: 0; transition: opacity .3s ease, visibility 0s .3s; }
.menu.is-open .menu__list { visibility: visible; opacity: 1; transition: opacity .2s ease; }
.menu__list a { position: relative; display: block; padding: 10px 0; color: var(--ws1); text-decoration: none; transition: translate .4s cubic-bezier(.2, .7, .1, 1); }
.menu__list a:hover, .menu__list a:focus-visible { translate: -10px 0; }
.menu__list a[aria-current]::before { content: ''; position: absolute; right: calc(100% + 12px); top: 50%; width: .42em; height: .42em; margin-top: -.21em; }
/* without script the list simply shows on hover or focus */
@media (hover: hover) { .menu:not(.js):hover .menu__list, .menu:not(.js):focus-within .menu__list { visibility: visible; opacity: 1; } }
/* its names are drawn in Rubine and settle to WS1, the way the sigils grow */
.trace--menu .trace__line { stroke: var(--rubine); stroke-width: 1.3; filter: drop-shadow(0 0 3px var(--rubine)) drop-shadow(0 0 7px var(--rubine)); }
.trace--menu .trace__wet--wide { opacity: .75; }

/* sound: four small bars beside the menu star, moving while the music plays, level while it does not */
.sound { position: fixed; top: 6px; right: calc(var(--gutter) - 12px + 44px); z-index: 6; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; transition: opacity .7s ease; }
html.boot .sound { opacity: 0; }
.sound__bars { display: flex; align-items: center; gap: 3px; height: 16px; }
.sound__bars i { width: 2px; height: 16px; background: var(--ws1); transform: scaleY(.14); transition: transform .5s ease; }
.sound.is-on i { animation: bars 1.1s ease-in-out infinite alternate; }
.sound.is-on i:nth-child(2) { animation-duration: .8s; animation-delay: -.3s; }
.sound.is-on i:nth-child(3) { animation-duration: 1.4s; animation-delay: -.6s; }
.sound.is-on i:nth-child(4) { animation-duration: .95s; animation-delay: -.15s; }
@keyframes bars { from { transform: scaleY(.2); } to { transform: scaleY(1); } }

/* held back while the stages are set up (index.html adds .boot before first paint) */
.portal { transition: opacity .7s ease; }
html.boot .portal { opacity: 0; }

/* rooms: a plain stacked page without script or with reduced motion */
.room { position: relative; min-height: 100vh; display: grid; align-items: center; padding: 56px 0; }

/* the portal: rooms on the z axis, the scroll drives the camera */
html.z, html.z body { overflow: hidden; height: 100%; overscroll-behavior: none; }
html.z .portal { position: fixed; inset: 0; overflow: hidden; }
html.z .room { position: absolute; inset: 0; min-height: 0; padding: 40px 0; will-change: transform, opacity; }
/* words fall away first as the camera pushes into a sigil */
html.z .room :is(h3, p:not(.display), dl, .boxes, .frame > .tear, .hero__line) { opacity: var(--words, 1); }
/* names leave with the words, but arrive by being drawn */
html.z .room :is(h2, .display--under, .display--over) { opacity: var(--heads, 1); }

/* art: a bitmap of each sigil, its race outlines over it, and its life drawn on a canvas above */
[data-art] { position: relative; }
[data-art] > img, [data-art] > .race-svg, .race-layer > .race-svg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; }
.art-img { transition: opacity .9s ease; }
.art-img.undrawn { opacity: 0; }
.race-svg { overflow: visible; pointer-events: none; }
/* neon: while it runs, the Rubine line carries a bloom of its own colour */
.is-racing .race-svg { filter: drop-shadow(0 0 3px var(--rubine)) drop-shadow(0 0 9px var(--rubine)); }
.race path { fill: none; stroke: var(--rubine); stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: 0; }
.race .head { stroke-width: 2.2; stroke-dasharray: .04 .96; stroke-dashoffset: 1; }
.race .trail { stroke-width: 3.6; stroke-dasharray: .26 .74; stroke-dashoffset: 1.22; }
.is-racing .head { animation: race 6.4s cubic-bezier(.45, 0, .4, 1) forwards; }
.is-racing .trail { animation: trail 6.4s cubic-bezier(.45, 0, .4, 1) forwards; }
@keyframes race { 0% { stroke-dashoffset: 1; opacity: 0; } 10%, 82% { opacity: .95; } 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes trail { 0% { stroke-dashoffset: 1.22; opacity: 0; } 10%, 82% { opacity: .24; } 100% { stroke-dashoffset: .22; opacity: 0; } }
.life { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; }

/* headings traced in: the real glyphs wait transparent under the pen */
.is-tracing, .pending { color: transparent; }
.trace { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.trace__line { fill: none; stroke: var(--ws1); stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }
.trace__fill { fill: var(--ws1); fill-opacity: 0; }
.trace__nib { transition: opacity .25s; filter: drop-shadow(0 0 3px var(--rubine)) drop-shadow(0 0 9px var(--rubine)); }
.trace__wet { fill: none; stroke-linecap: round; }
.trace__wet--wide { stroke: var(--rubine); stroke-width: 4; opacity: .8; }
.trace__wet--thin { stroke: var(--ws1); stroke-width: 2.2; opacity: 1; }
.trace__bead { fill: var(--rubine); opacity: .6; }
.trace__point { fill: var(--ws1); }

/* landing */
.hero { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: var(--gutter); align-items: end; height: 100%; }
.hero__art { grid-column: 2; grid-row: 1; height: min(80vh, 920px); align-self: center; }
.hero__copy { grid-column: 1; grid-row: 1; padding-bottom: 4vh; }
.hero h1 { margin: 0 0 24px; font-weight: 400; }
.hero h1 .display { display: block; font-size: clamp(64px, 13.5vw, 230px); margin-left: -.04em; }
.hero__line { display: block; font: 400 clamp(20px, 2vw, 28px)/1.3 var(--text); margin-top: 32px; max-width: 26ch; }

/* concept */
.split { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: calc(var(--gutter) * 2); align-items: center; }
.split__art { height: min(80vh, 900px); }

/* kits and renders: empty boxes with torn edges, filled by the images later */
.room--render { place-items: center; }
.render__title { position: absolute; left: var(--gutter); top: 40px; z-index: 2; margin: 0; }
.tear { position: relative; overflow: hidden; width: 100%; height: 100%; background: var(--slot);
  -webkit-mask: url('../assets/tear-a.svg') center / 100% 100% no-repeat; mask: url('../assets/tear-a.svg') center / 100% 100% no-repeat; }
.tear img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .8s ease; }
.tear.is-loaded img { opacity: 1; }
/* skeleton: while its image loads, a soft band of light crosses the box; a box with no image yet stays still */
.tear::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(100deg, transparent 30%, rgba(247, 242, 234, .07) 50%, transparent 70%); animation: sweep 1.9s ease-in-out infinite; }
.tear.is-loaded::after, .tear.is-empty::after { animation: none; opacity: 0; transition: opacity .4s; }
@keyframes sweep { to { transform: translateX(100%); } }
.tear--b { -webkit-mask-image: url('../assets/tear-b.svg'); mask-image: url('../assets/tear-b.svg'); }
.tear--big { width: min(92vw, 1500px); height: min(74vh, 860px); }
.boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 4vh 9vw; width: min(92vw, 1500px); height: min(72vh, 840px); margin-top: 8vh; }

/* kits: one sigil stands in the cross between the four boxes and binds them */
.room--render { position: relative; }
.bind { position: absolute; left: 50%; top: 50%; height: 92vh; width: 56vh; margin: -42vh 0 0 -28vh; z-index: 2; cursor: crosshair; }
/* renders: a sigil clasped over a corner of each frame, breaking out past the torn edge */
.frame { position: relative; display: grid; place-items: center; }
.clasp { position: absolute; height: 70vh; width: 42vh; z-index: 2; cursor: crosshair; }
.clasp--tl { left: -3vw; top: -12vh; }
.clasp--br { right: -3vw; bottom: -14vh; }
.clasp--tr { right: -2vw; top: -14vh; }

/* information: the words down the left, the cathedral standing on the right, the name burned across its foot */
.info { position: relative; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); grid-template-rows: auto auto 1fr auto;
  column-gap: calc(var(--gutter) * 2); height: 100%; padding-top: 4vh; }
.info .title { grid-column: 1; grid-row: 1; position: relative; z-index: 2; margin-bottom: 28px; }
.specs { grid-column: 1; grid-row: 2; display: grid; grid-template-columns: auto 1fr; gap: 6px 24px; margin: 0 0 28px; position: relative; z-index: 2; }
.specs div { display: contents; }
.specs dd { margin: 0; }
.info__notes { grid-column: 1; grid-row: 3; align-self: start; position: relative; z-index: 2; max-width: 46ch; }
.info__notes p { font-size: 16px; }
.info__art { position: absolute; right: 9%; top: 8vh; height: 78vh; width: 44vh; z-index: 0; cursor: crosshair; }
.info__close { grid-column: 1 / -1; grid-row: 4; position: relative; z-index: 2; font-size: clamp(64px, 15vw, 260px); margin: 0; text-align: right; line-height: .9; mix-blend-mode: difference; pointer-events: none; }

/* composed rooms (wider screens): the sigil is the centre of the room and the type is set into it */
@media (min-width: 861px) {
  .hero, .split { position: relative; display: block; height: 100%; }
  .hero__art, .split__art { position: absolute; top: 50%; height: 94vh; width: 62vh; transform: translateY(-50%); cursor: crosshair; }
  .hero__art { left: 50%; margin-left: -31vh; }
  .split__art { right: 15%; }
  /* the word burns through the sigil where they cross */
  .split .title { mix-blend-mode: difference; position: relative; z-index: 2; pointer-events: none; }
  /* the name is woven through the saint: one copy under the art, a second over it showing only some letters and parts of letters */
  .hero__art { z-index: 1; }
  .hero__copy { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
  .hero h1 { margin: 0; }
  .hero h1 .display--under, .info .display--under, .display--over { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; font-size: clamp(80px, 17vw, 300px); margin: 0; line-height: .9; }
  .display--over { z-index: 2; pointer-events: none; color: transparent; }
  .display--over span { -webkit-text-stroke: 4px var(--cr); paint-order: stroke fill; }
  .display--over .w { color: var(--ws1); }
  .display--over .t { color: var(--ws1); clip-path: inset(0 0 52% 0); }
  .display--over .b { color: var(--ws1); clip-path: inset(48% 0 0 0); }
  .display--over .r { color: var(--ws1); clip-path: inset(0 0 0 50%); }
  .display--over .n { -webkit-text-stroke: 0; }
  .display--over span { transition: opacity .7s ease; }
  .display--over.waiting span { opacity: 0; }
  /* the last room closes the way the first opens: the name woven through its sigil, the facts at the corners */
  .info { display: block; padding-top: 0; }
  .info .title { margin-bottom: 24px; }
  .info__notes { position: absolute; left: 0; bottom: 3vh; }
  .info__art { left: 50%; right: auto; top: 50%; height: 94vh; width: 62vh; margin-left: -31vh; transform: translateY(-50%); z-index: 1; }
  .info .display--under { z-index: 0; mix-blend-mode: normal; }
  .info .display--under, .info .display--over { top: 57%; }
  .hero__line { position: absolute; left: 0; bottom: 9vh; margin: 0; }
  .hero__fact { position: absolute; left: 0; bottom: 3vh; margin: 0; }
  .split__text { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; justify-content: center; pointer-events: none; }
  .split .title { font-size: clamp(56px, 8.6vw, 150px); max-width: none; margin-bottom: 40px; }
  .split__text p { max-width: 46ch; }
  /* the blood runs on its own layer above the type, so the inverted word never turns it green */
  .race-layer { z-index: 3; pointer-events: none; cursor: auto; }
}

/* phone */
@media (max-width: 860px) {
  .info { display: flex; flex-direction: column; padding-top: 0; }
  .info .title { margin-bottom: 16px; }
  .specs { margin-bottom: 16px; }
  .info__art { position: relative; right: auto; top: auto; flex: 1 1 auto; min-height: 0; width: 100%; height: auto; }
  .info__close { font-size: 22vw; text-align: center; margin-top: -10vh; }
  body { font-size: 16px; }
  .hero, .split { grid-template-columns: 1fr; gap: 20px; }
  .hero { align-content: end; }
  .hero__art { grid-column: 1; height: 46vh; align-self: start; }
  .hero__copy { grid-column: 1; grid-row: 2; padding-bottom: 0; }
  .hero__line { margin-top: 18px; }
  .split__art { height: 34vh; order: -1; }

  .title { margin-bottom: 18px; }
  p { margin-bottom: 12px; }
  .tear--big { width: 100vw; height: 62vh; }
  .boxes { width: 100vw; height: 66vh; margin-top: 6vh; grid-template-columns: 1fr; grid-template-rows: repeat(4, 1fr); }
  .display--over { display: none; }
  .bind { height: 70vh; width: 42vh; margin: -30vh 0 0 -21vh; }
  .boxes { gap: 2vh; }
  .clasp { height: 40vh; width: 24vh; }
  .room, html.z .room { padding: 32px 0 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .sound.is-on i { animation: none; transform: scaleY(.7); }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* halation: the display type bleeds a little light, like bright film. It follows the text's own colour, so a
   name that is still waiting to be drawn has none. */
.display--under, h2.title, .menu__list a { text-shadow: 0 0 .12em color-mix(in srgb, currentColor 30%, transparent), 0 0 .45em color-mix(in srgb, currentColor 14%, transparent); }
.trace { filter: drop-shadow(0 0 6px rgba(247, 242, 234, .25)); }

/* each letter keeps its own box, so the line never reflows */
.word { white-space: nowrap; }
.ch { display: inline-block; text-align: center; white-space: pre; }
