/* The Corpus: royal blue and white, nothing else. */

:root {
  --royal: #2340C8;
  --deep: #14257A;
  --white: #FFFFFF;
  --hair: rgba(255, 255, 255, 0.26);
  --hair-royal: rgba(35, 64, 200, 0.26);
  --serif: 'Instrument Serif', 'Iowan Old Style', 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --gutter: 16px;
  --slow: cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

html {
  background: var(--royal);
  color: var(--white);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--royal);
  color: var(--white);
  font: 400 19px/1.38 var(--serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--white);
  color: var(--royal);
}

h1,
h2,
p {
  margin: 0;
  font-weight: 400;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Chrome ---------- */

.logo {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid currentColor;
  color: var(--white);
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.06em;
}

.loading {
  display: none;
}

.js .loading {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: var(--deep);
  color: var(--white);
  font: 400 12px/1 var(--mono);
  letter-spacing: 0.28em;
  transition: opacity 0.9s var(--slow), visibility 0s linear 0.9s;
  /* If the scripts never arrive, step aside anyway. */
  animation: loading-out 0.9s var(--slow) 6s forwards;
}

.loading span {
  animation: breathe 1.8s ease-in-out infinite alternate;
}

.is-ready .loading {
  opacity: 0;
  visibility: hidden;
}

@keyframes loading-out {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

@keyframes breathe {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

/* ---------- Type ---------- */

.label {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 500 11px/1.2 var(--mono);
  letter-spacing: 0.16em;
}

.label::before {
  content: '';
  width: 24px;
  height: 1px;
  background: currentColor;
  opacity: 0.7;
}

.headline {
  font-size: clamp(32px, 3.6vw, 60px);
  line-height: 1.04;
  letter-spacing: -0.01em;
}

.chapter--open .headline {
  max-width: 12.5em;
  font-size: clamp(40px, 6vw, 96px);
  line-height: 1.02;
}

.copy__body {
  display: grid;
  gap: 12px;
  max-width: 30em;
}

.scroll-hint {
  font: 400 11px/1 var(--mono);
  letter-spacing: 0.28em;
}

/* ---------- Stacked layout (reduced motion, fallback, no JS) ---------- */

.chapter {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  min-height: 100vh;
  min-height: 100svh;
  padding: 112px var(--gutter) 96px;
}

.chapter--open {
  text-align: center;
}

.chapter--open .scroll-hint {
  position: absolute;
  right: 0;
  bottom: 32px;
  left: 0;
}

.copy {
  display: grid;
  gap: 20px;
  width: 100%;
  max-width: 520px;
}

.copy__head {
  display: grid;
  gap: 18px;
}

.chapter--turn {
  background: var(--white);
  color: var(--royal);
}

.art {
  position: relative;
  flex: none;
  width: min(64vw, 300px);
  aspect-ratio: 1;
  border: 1px solid var(--hair);
}

.chapter--turn .art {
  border-color: var(--hair-royal);
}

.art:empty {
  display: none;
}

.drawing {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.drawing path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.star {
  position: absolute;
  width: 13px;
  height: 13px;
  fill: currentColor;
  transform: translate(-50%, -50%);
}

.art .star--tl { top: -0.5px; left: -0.5px; }
.art .star--tr { top: -0.5px; left: calc(100% + 0.5px); }
.art .star--bl { top: calc(100% + 0.5px); left: -0.5px; }
.art .star--br { top: calc(100% + 0.5px); left: calc(100% + 0.5px); }

@media (min-width: 900px) {
  .chapter:not(.chapter--open):not(.chapter--end) {
    flex-direction: row;
    gap: 80px;
  }

  .chapter .art {
    width: 320px;
  }

  .chapter .copy {
    max-width: 440px;
  }
}

.is-stacked .chapter > * {
  opacity: 0;
  transition: opacity 1.2s var(--slow);
}

.is-stacked .chapter.is-visible > * {
  opacity: 1;
}

/* ---------- The end box ---------- */

.box {
  position: relative;
  width: min(520px, 100%);
  color: var(--white);
}

.box__frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.box__frame rect {
  fill: none;
  stroke: var(--white);
  stroke-width: 2;
}

.box__fill {
  position: absolute;
  inset: 0;
  background: var(--deep);
}

.box__inner {
  position: relative;
  z-index: 2;
  padding: 44px 40px 36px;
}

.box__headline,
.box__done {
  font-size: clamp(30px, 3vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.box__headline {
  margin-bottom: 32px;
}

.box__done {
  outline: none;
  animation: fade-in 1.2s var(--slow) both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.waitlist-form {
  display: grid;
  gap: 12px;
}

.waitlist-form input,
.waitlist-form button {
  height: 52px;
  border-radius: 0;
  font-family: var(--mono);
  -webkit-appearance: none;
  appearance: none;
}

.waitlist-form input {
  width: 100%;
  min-width: 0;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: var(--deep);
  color: var(--white);
  font-size: 16px;
  transition: border-color 0.4s var(--slow);
}

.waitlist-form input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.waitlist-form input:focus {
  border-color: var(--white);
  outline: none;
}

.waitlist-form input[aria-invalid='true'] {
  border-color: var(--white);
}

.waitlist-form button {
  padding: 0 22px;
  border: 1px solid var(--white);
  background: var(--white);
  color: var(--royal);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.4s var(--slow), color 0.4s var(--slow);
}

.waitlist-form button:hover {
  background: transparent;
  color: var(--white);
}

.waitlist-form button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.waitlist-form :focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 3px;
}

.form__error {
  min-height: 1.4em;
  font: 400 13px/1.4 var(--mono);
}

@media (min-width: 560px) {
  .waitlist-form {
    grid-template-columns: 1fr auto;
  }

  .form__error {
    grid-column: 1 / -1;
  }
}

/* ---------- Phones ---------- */

@media (max-width: 600px) {
  body {
    font-size: 18px;
  }

  .logo {
    top: 16px;
    left: 16px;
    font-size: 12px;
  }

  .label,
  .scroll-hint {
    font-size: 12px;
  }

  .box__inner {
    padding: 32px 22px 24px;
  }
}

/* ---------- The film (motion allowed, GSAP present) ---------- */

.is-film {
  --edge: max(40px, 5vw);
}

.is-film .stage {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.is-film .scene {
  position: absolute;
  inset: 0;
}

.is-film .scene--dark {
  z-index: 1;
  background: var(--royal);
  color: var(--white);
}

.is-film .scene--light {
  --hair: var(--hair-royal);
  z-index: 2;
  background: var(--white);
  color: var(--royal);
  visibility: hidden;
}

.is-film .scene .logo {
  color: inherit;
}

.is-film .chapter {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: block;
  min-height: 0;
  padding: 0;
  pointer-events: none;
}

.is-film .art {
  display: none;
}

/* Hairlines frame the centre square, then close in on the end box. */
.hair {
  position: absolute;
  background: var(--hair);
}

.hair--l,
.hair--r {
  top: 0;
  bottom: 0;
  width: 1px;
}

.hair--t,
.hair--b {
  right: 0;
  left: 0;
  height: 1px;
}

.hair--l { left: var(--fx); }
.hair--r { left: calc(var(--fx) + var(--fw) - 1px); }
.hair--t { top: var(--fy); }
.hair--b { top: calc(var(--fy) + var(--fh) - 1px); }

.grid .star--tl { top: calc(var(--fy) + 0.5px); left: calc(var(--fx) + 0.5px); }
.grid .star--tr { top: calc(var(--fy) + 0.5px); left: calc(var(--fx) + var(--fw) - 0.5px); }
.grid .star--bl { top: calc(var(--fy) + var(--fh) - 0.5px); left: calc(var(--fx) + 0.5px); }
.grid .star--br { top: calc(var(--fy) + var(--fh) - 0.5px); left: calc(var(--fx) + var(--fw) - 0.5px); }

.object {
  position: absolute;
  top: var(--sy);
  left: var(--sx);
  width: var(--ss);
  height: var(--ss);
  overflow: visible;
}

.object path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.is-film .chapter--open {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 calc(var(--edge) + 24px);
}

.is-film .chapter--open .scroll-hint {
  bottom: 104px;
}

.is-film .scroll-hint::after {
  content: '';
  display: block;
  width: 1px;
  height: 28px;
  margin: 14px auto 0;
  background: currentColor;
  transform-origin: top;
  animation: hint 2.8s var(--slow) infinite;
}

@keyframes hint {
  0% { transform: scaleY(0); opacity: 1; }
  55% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}

.is-film .chapter--turn {
  background: none;
}

.is-film .chapter--end .box {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(520px, calc(100% - 2 * var(--gutter)));
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

/* Wide screens: label and headline to the left of the object, the lines to its right. */
@media (min-width: 1000px) and (orientation: landscape) {
  .is-film .copy {
    position: absolute;
    inset: 0;
    display: block;
    max-width: none;
  }

  .is-film .copy__head,
  .is-film .copy__body {
    position: absolute;
    bottom: calc(100% - var(--sy) - var(--ss) + 28px);
  }

  .is-film .copy__head {
    left: var(--edge);
    width: calc(var(--sx) - var(--edge) - 48px);
  }

  .is-film .copy__body {
    left: calc(var(--sx) + var(--ss) + 48px);
    width: min(340px, calc(100% - var(--sx) - var(--ss) - 48px - var(--edge)));
    font-size: clamp(17px, 1.5vw, 20px);
  }
}

/* Everything else: the object up top, the text underneath it. */
@media not all and (min-width: 1000px) and (orientation: landscape) {
  .is-film .copy {
    position: absolute;
    top: calc(var(--sy) + var(--ss) + 32px);
    right: var(--gutter);
    left: var(--gutter);
    gap: 14px;
    max-width: 560px;
    margin: 0 auto;
  }

  .is-film .copy__head {
    gap: 14px;
  }

  .is-film .headline {
    font-size: clamp(28px, 8.2vw, 44px);
  }

  .is-film {
    --edge: var(--gutter);
  }

  .is-film .chapter--open .headline {
    font-size: clamp(38px, 10.6vw, 72px);
  }
}
