:root {
  --paper: #ffffff;
  --ink: #111111;
  --ink-faint: #5c5c5c;
  --c: #2c8aa8;
  --m: #c44470;
  --y: #d4b338;
  --m-text: #b03a63;
  --rule: #e6e6e6;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2,.7,.1,1);
  --spin-ease: cubic-bezier(.3,.6,.15,1);
}
/* Dark mode, from the Common Instruments foundation. Process inks stay the same in both modes. */
[data-mode="dark"] {
  --paper: #1a1a1a;
  --ink: #ffffff;
  --ink-faint: rgba(255, 255, 255, 0.6);
  --m-text: #e07a9f;
  --rule: rgba(255, 255, 255, 0.12);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body { transition: background-color 0.2s ease, color 0.2s ease; }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--c); text-underline-offset: 5px; text-decoration-thickness: 2px; }
a:hover { text-decoration-color: var(--ink); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--c); outline-offset: 3px; }

.page {
  /* --gx (exploded gap, px) and --fx (exploded scale) are set by the script to fit the screen */
  --gx: clamp(18px, 5vw, 88px);
  --fx: 1;
  position: relative;
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column;
  padding: clamp(20px, 4vw, 48px) max(clamp(16px, 5vw, 72px), env(safe-area-inset-right)) max(clamp(20px, 4vw, 48px), env(safe-area-inset-bottom)) max(clamp(16px, 5vw, 72px), env(safe-area-inset-left));
  opacity: 0; transition: opacity 1600ms ease;
}
.page.in { opacity: 1; }

main {
  flex: 1 1 auto; min-height: 600px;
  display: flex; align-items: center; justify-content: center;
  padding-block: clamp(24px, 4vh, 48px); overflow: hidden;
}
.stage { position: relative; display: flex; justify-content: center; max-width: 100%; }

/* Wordmark */
.word {
  --fs: clamp(56px, 15vw, 220px);
  margin: 0; display: flex; align-items: flex-start; justify-content: center; gap: 0;
  font-family: var(--serif); font-weight: 300; font-size: var(--fs); line-height: 1;
  letter-spacing: -0.02em; font-variation-settings: 'opsz' 72; color: var(--ink);
  transition: gap 1100ms var(--ease), font-size 1100ms var(--ease), color 0.2s ease;
}
.ex .word { gap: var(--gx); font-size: calc(var(--fs) * var(--fx)); }

.mark-col {
  display: flex; flex-direction: column; align-items: center;
  margin-left: 0; margin-right: 0.08em;
  transition: margin-left 1100ms var(--ease), margin-right 1100ms var(--ease);
}
.ex .mark-col { margin-left: -0.24em; margin-right: calc(0.02em - var(--gx)); }
.mark {
  position: relative; display: block; width: 0.72em; height: 1em; isolation: isolate;
  transform: rotate(0deg); transform-origin: 0.36em 0.46em;
  transition: transform 1300ms var(--spin-ease);
}
.ex .mark { transform: rotate(360deg); }
.ink {
  position: absolute; left: 0; top: 0; mix-blend-mode: multiply;
  transition: transform 1300ms var(--spin-ease), width 1300ms var(--spin-ease), height 1300ms var(--spin-ease), border-radius 1300ms ease, opacity 600ms ease, background-color 0.2s ease;
}
/* The key plate sits on top unblended: black over the inks in light mode, white in dark */
.ink.k { mix-blend-mode: normal; }

/* Labels hung under each letter (wide screens) */
.letter { position: relative; display: flex; flex-direction: column; align-items: center; }
.lab {
  position: absolute; top: 100%; left: 50%; width: 0; height: 168px;
  display: flex; flex-direction: column; align-items: center; pointer-events: none;
}
.pip { width: 6px; height: 6px; border-radius: 50%; background: var(--m); flex: 0 0 auto; opacity: 0; transition: opacity 400ms ease 0ms; }
.lead { width: 1px; height: 0; background: var(--m); flex: 0 0 auto; transition: height 700ms var(--ease) 0ms; }
.txt { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 8px; white-space: nowrap; opacity: 0; transition: opacity 500ms ease 0ms; }
.ex .pip { opacity: 1; transition-delay: 500ms; }
.ex .lead { height: 28px; transition-delay: 600ms; }
.ex .letter:nth-child(odd) .lead { height: 84px; }
.ex .txt { opacity: 1; transition-delay: 1100ms; }
.part { font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: 0.14em; color: var(--ink-faint); }
.q {
  font-family: var(--serif); font-style: italic; font-weight: 400; font-size: clamp(15px, 1.4vw, 19px); letter-spacing: 0; color: var(--ink);
  padding-inline: 3px;
  background: linear-gradient(transparent 50%, rgba(44,138,168,0.4) 50%, rgba(44,138,168,0.4) 92%, transparent 92%);
}

/* One caption at a time (narrow screens) */
.caption {
  position: absolute; top: calc(100% + 50px); left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  opacity: 0; visibility: hidden; transition: opacity 180ms ease, visibility 0s linear 180ms;
}
.caption .q { font-size: 17px; }
.compact.ex .caption { opacity: 1; visibility: visible; transition: opacity 400ms ease 1100ms, visibility 0s; }
.compact.ex .caption.live { transition: opacity 250ms ease, visibility 0s; }
.compact.ex .caption.swap { opacity: 0; transition: opacity 180ms ease; }
.compact .txt { opacity: 0 !important; }
.compact.ex .letter .lead, .compact.ex .letter:nth-child(odd) .lead { height: 0; transition-duration: 400ms; transition-delay: 0ms; }
.compact.ex .letter.active .lead, .compact.ex .letter.active:nth-child(odd) .lead { height: 36px; }
.compact.ex .pip { opacity: 0.3; }
.compact.ex .letter.active .pip { opacity: 1; }
.word { cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }

/* Footer */
footer {
  --head: clamp(28px, 3.6vw, 48px);
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 24px 48px;
  border-top: 1px solid var(--ink); padding-top: 24px;
  transition: border-color 0.2s ease;
}
/* The two lines move as one block, nudged so the headline's centre sits on the button's centre (button is 44px tall) */
.claim { flex: 999 1 420px; min-width: 0; margin-top: calc((44px - 1.1 * var(--head)) / 2); }
.claim p { margin: 0; font-family: var(--serif); }
.claim .a { margin-bottom: 6px; font-weight: 300; font-size: var(--head); line-height: 1.1; letter-spacing: -0.02em; }
.claim .b { font-style: italic; font-size: clamp(18px, 2vw, 24px); color: var(--m-text); }
.actions { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 14px; margin-left: auto; }
@media (max-width: 640px) {
  .claim { margin-top: 0; }
  .actions { align-items: flex-start; margin-left: 0; }
}
.toggle {
  min-height: 44px; width: 136px; padding: 10px 0; text-align: center;
  background: transparent; color: var(--ink); border: 1px solid var(--ink); border-radius: 2px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 0.2s ease;
}
.toggle:hover { background: var(--ink); color: var(--paper); }
.claim .b, .part, .q, a { transition: color 0.2s ease; }

/* Mode toggle: the Common Instruments celestial scene. A fixed horizon a quarter
   up from the bottom; the sun sets and the crescent moon rises in dark mode. */
.mode-toggle {
  position: absolute; top: clamp(20px, 4vw, 48px); right: max(clamp(16px, 5vw, 72px), env(safe-area-inset-right)); z-index: 5;
  display: inline-block; width: 38px; height: 38px; padding: 0;
  border: 1px solid var(--rule); border-radius: 2px; background: transparent; cursor: pointer; overflow: hidden;
  transition: border-color 0.15s ease;
}
.mode-toggle:hover { border-color: var(--ink-faint); }
.mode-toggle::after {
  content: ''; position: absolute; left: 5px; right: 5px; top: 75%; height: 1px;
  background: var(--ink-faint); pointer-events: none; z-index: 2;
}
/* Set (hidden) positions sit fully below the box edge so nothing peeks over it */
.mode-toggle .sun, .mode-toggle .moon {
  position: absolute; left: 50%; width: 11px; height: 11px; transform: translateX(-50%);
  transition: top 0.4s cubic-bezier(0.5, 0, 0.5, 1); z-index: 1;
}
.mode-toggle .sun { background: var(--y); border-radius: 50%; top: 18%; }
.mode-toggle .moon { background: #fafaf8; border-radius: 50%; top: calc(100% + 2px); }
.mode-toggle .moon::before {
  content: ''; position: absolute; top: -1px; right: -3px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--paper); transition: background 0.2s ease;
}
[data-mode="dark"] .mode-toggle .sun { top: calc(100% + 2px); }
[data-mode="dark"] .mode-toggle .moon { top: 18%; }
.contact { font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; padding-block: 12px; }

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

@media (max-width: 900px) { main { min-height: 420px; } }
@media (prefers-reduced-motion: reduce) {
  .page, .word, .mark-col, .mark, .ink, .pip, .lead, .txt, .caption { transition: none !important; }
}
