/* =====================================================
   Factory 1 (factory1.wizuslabs.com): one small stylesheet.
   Type, spacing, radius and motion tokens are the main site's
   (wizuslabs-site-source/docs/design/design-system.md §2). The
   colours are its always-dark bands: near-black ground, copper
   hairlines and ember light, links and focus in the dark-theme
   oxblood. The site is dark in both OS themes, like the art.
   ===================================================== */

:root {
  color-scheme: dark;

  /* Colour */
  --ground: #0E1013;
  --surface: #1A1715;
  --line: #3A302A;          /* decorative hairlines */
  --line-strong: #8C7B6E;   /* control boundaries: 4.4:1 on --surface */
  --fg: #F4F1EA;
  --fg-muted: #CDC9C0;
  --fg-subtle: #A39E95;     /* 6.7:1 on --surface */
  --accent: #D89A93;        /* links and focus ring, 7.6:1 on --surface */
  --copper: #D9935C;        /* labels and numerals, 7.0:1 on --surface */
  --ember: #E39A62;         /* the primary action; --ground on it is 8.2:1 */
  --ember-hover: #EDAA74;
  --alert: #F2A49A;         /* 9.0:1 on --surface */

  /* Typography */
  --font-serif: "Source Serif 4", Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --size-00: 0.6875rem;
  --size-01: 0.75rem;
  --size-02: 0.875rem;
  --size-03: 1rem;
  --size-04: 1.125rem;
  --size-05: 1.35rem;
  --size-06: 1.62rem;
  --size-07: 1.94rem;
  --size-08: 2.33rem;
  --size-09: 2.8rem;
  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-normal: 1.55;
  --lh-relaxed: 1.7;
  --tracking-tight: -0.01em;
  --tracking-mono: 0.02em;
  --tracking-wide: 0.06em;

  /* Spacing (4px base) */
  --space-0: 4px;
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  --space-7: 64px;
  --space-8: 96px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;

  /* Motion */
  --duration-micro: 160ms;
  --duration-content: 320ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --idle-period: 4.8s;

  --opacity-busy: 0.72;
  --z-top: 100;

  /* Ember light, as in the main site's landing hero */
  --ember-glow: rgb(255 170 96 / 0.2);
  --ember-glow-soft: rgb(232 112 44 / 0.07);
}

/* =====================================================
   Base
   ===================================================== */

/* Same files and Latin range as the main site; the mono face is a static
   400, so its semibold labels are synthesized there too. */
@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4.woff2") format("woff2-variations"),
       url("../fonts/source-serif-4.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-024F, U+0300-036F, U+2000-206F, U+2070-209F, U+20A0-20CF, U+2100-214F, U+2200-22FF;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-024F, U+0300-036F, U+2000-206F, U+2070-209F, U+20A0-20CF, U+2100-214F, U+2200-22FF;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  hanging-punctuation: first last;
}

body {
  display: flex;
  flex-direction: column;
  min-block-size: 100vh;
  margin: 0;
  background: var(--ground);
  color: var(--fg);
  font-family: var(--font-serif);
  font-size: var(--size-03);
  font-weight: var(--weight-regular);
  line-height: var(--lh-normal);
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "onum" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
@supports (min-block-size: 100svh) {
  body { min-block-size: 100svh; }
}

main { flex: 1; }

img { display: block; max-inline-size: 100%; block-size: auto; }

h1, h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: var(--weight-regular);
  line-height: var(--lh-snug);
  text-wrap: pretty;
}

p { margin: 0 0 var(--space-3); }

a { color: var(--accent); }

::selection { background: #3A2A20; color: var(--fg); }

:focus { outline: 2px solid var(--accent); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.skip-link {
  position: fixed;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  z-index: var(--z-top);
  padding: var(--space-2) var(--space-3);
  background: var(--ground);
  color: var(--accent);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: var(--size-02);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transform: translateY(calc(-100% - var(--space-3)));
}
.skip-link:focus-visible { transform: none; }

.container {
  inline-size: 100%;
  max-inline-size: 1200px;
  margin-inline: auto;
  padding-inline: var(--space-4);
}
@media (min-width: 48em) {
  .container { padding-inline: var(--space-5); }
}

.u-caps {
  font-family: var(--font-mono);
  font-size: var(--size-01);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

/* Link (§7.3): no underline at rest, a 1px rule drawn on hover and focus. */
.link {
  color: var(--accent);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0 1px;
  background-position: 0 calc(100% - 1px);
  background-repeat: no-repeat;
}
.link:hover, .link:focus-visible { background-size: 100% 1px; }

/* Button (§7.4), in ember: the one action on each page. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-block-size: 48px;
  min-inline-size: 44px;
  padding: var(--space-2) var(--space-4);
  background: var(--ember);
  color: var(--ground);
  border: 1px solid var(--ember);
  border-radius: var(--radius-sm);
  font-family: var(--font-serif);
  font-size: var(--size-03);
  font-weight: var(--weight-medium);
  line-height: var(--lh-snug);
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--ember-hover); border-color: var(--ember-hover); }
.button:active { transform: translateY(1px); }
.button[aria-disabled="true"] { opacity: var(--opacity-busy); cursor: progress; }

@media (prefers-reduced-motion: no-preference) {
  .link { transition: background-size var(--duration-micro) var(--ease-out); }
  .button {
    transition: background-color var(--duration-micro) var(--ease-out),
                border-color var(--duration-micro) var(--ease-out),
                transform var(--duration-micro) var(--ease-out);
  }
}

/* =====================================================
   Masthead and colophon
   ===================================================== */

.masthead { border-block-end: 1px solid var(--line); }
.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-block-size: 64px;
}
.masthead__label { margin: 0; color: var(--copper); }

/* Wordmark (§11), as on wizuslabs.com in its dark theme. */
.wordmark {
  display: inline-block;
  font-size: var(--size-04);
  letter-spacing: -0.015em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.wordmark__first {
  color: var(--fg);
  border-block-end: 1.5px solid var(--accent);
  padding-block-end: 2px;
}
.wordmark__second { color: var(--accent); }

.colophon {
  border-block-start: 1px solid var(--line);
  padding-block: var(--space-4);
}
.colophon__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
}
.colophon__inner p { margin: 0; }
.colophon__mark { color: var(--fg-subtle); }
.colophon__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
}
/* 24px floor for text links (§9.9, WCAG 2.5.8). */
.colophon__links .link {
  display: inline-flex;
  align-items: center;
  min-block-size: 24px;
}

/* =====================================================
   The guide: framed art over ember light, idling
   ===================================================== */

/* guide.webp is 640x960 on a transparent ground, its ember floor included. */
.guide {
  position: relative;
  isolation: isolate;
  margin: 0;
  inline-size: min(46vw, 180px);
}
.guide__img {
  inline-size: 100%;
  aspect-ratio: 2 / 3;
  object-fit: contain;
}
/* Ember light behind the guide's chest. */
.guide::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 -25% 10%;
  background: radial-gradient(closest-side, var(--ember-glow), var(--ember-glow-soft) 55%, transparent);
}
.guide--small { inline-size: 96px; }

/* Idle: the guide sways from its feet, so its floor stays put, and its
   light breathes. Still at rest and under reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .guide__img {
    transform-origin: 50% 90%;
    animation: guide-sway var(--idle-period) ease-in-out infinite;
  }
  .guide::before { animation: guide-breathe var(--idle-period) ease-in-out infinite; }
}
@keyframes guide-sway {
  25% { rotate: -1.2deg; scale: 1.01; }
  75% { rotate: 1.2deg; scale: 1.01; }
}
@keyframes guide-breathe { 50% { opacity: 0.6; } }

/* =====================================================
   Speech bubble: what the guide says
   ===================================================== */

.bubble {
  position: relative;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
@media (min-width: 30em) {
  .bubble { padding: var(--space-4); }
}
/* The tail points up at the guide on phones and left from 64em. */
.bubble::before {
  content: "";
  position: absolute;
  inset-block-start: -9px;
  inset-inline-start: calc(50% - 8px);
  inline-size: 16px;
  block-size: 16px;
  background: var(--surface);
  border-block-start: 1px solid var(--line);
  border-inline-start: 1px solid var(--line);
  rotate: 45deg;
}
.bubble__eyebrow { margin-block-end: var(--space-2); color: var(--copper); }
.bubble__title {
  margin-block-end: var(--space-3);
  font-size: var(--size-07);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}
.bubble p:last-child { margin-block-end: 0; }
.bubble__text { color: var(--fg-muted); }

/* The tour, one line per step, numbered 01-03 in copper mono. */
.steps {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding-inline-start: 2.75em;
  list-style: decimal-leading-zero;
  color: var(--fg-muted);
}
.steps li { padding-inline-start: var(--space-0); }
.steps li::marker {
  color: var(--copper);
  font-family: var(--font-mono);
  font-size: var(--size-02);
  letter-spacing: var(--tracking-mono);
}
.steps strong { color: var(--fg); font-weight: var(--weight-medium); }

/* =====================================================
   Front door
   ===================================================== */

/* The guide speaks in two bubbles, then hands over the ticket. Phones put
   the greeting beside the guide, so the ticket comes up sooner; from 64em the
   guide stands left of the whole conversation. */
.door { padding-block: var(--space-4) var(--space-6); }
.door__inner {
  display: grid;
  grid-template-columns: clamp(88px, 30%, 128px) minmax(0, 1fr);
  grid-template-areas:
    "guide hello"
    "tour tour"
    "ticket ticket";
  align-items: center;
  gap: var(--space-2);
  max-inline-size: 40rem;
}
.door .guide { grid-area: guide; inline-size: 100%; }
.door__hello { grid-area: hello; }
.door__tour { grid-area: tour; }
.door__ticket { grid-area: ticket; }
.door .steps { gap: var(--space-1); }
/* 21.6px on a 320px phone, 25.9px from 405px. */
.door .bubble__title { font-size: clamp(var(--size-05), 6.4vw, var(--size-06)); }
.door__hello .bubble__title { margin-block-end: 0; }
/* One tail, pointing left at the guide: from the greeting beside it on
   phones, from the tour from 64em, where the centred guide's mouth is level
   with the tour's middle. */
.door__hello::before,
.door__tour::before {
  inset-block-start: calc(50% - 8px);
  inset-inline-start: -9px;
  rotate: -45deg;
}
.door__tour::before { display: none; }

@media (min-width: 30em) {
  .door__inner { grid-template-columns: 136px minmax(0, 1fr); }
  .door .bubble__title { font-size: var(--size-07); }
}
@media (min-width: 48em) {
  .door { padding-block: var(--space-7) var(--space-8); }
  .door__inner { grid-template-columns: 180px minmax(0, 1fr); gap: var(--space-3) var(--space-4); }
  .door .steps { gap: var(--space-2); }
}
@media (min-width: 64em) {
  .door__inner {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    grid-template-areas:
      "guide hello"
      "guide tour"
      "guide ticket";
    column-gap: var(--space-7);
    max-inline-size: 1200px;
  }
  .door .guide { inline-size: min(100%, 340px); justify-self: end; }
  .door__hello,
  .door__tour,
  .door__ticket { max-inline-size: 36rem; }
  .door .bubble__title { font-size: var(--size-08); }
  .door__hello::before { display: none; }
  .door__tour::before { display: block; }
}

/* The ticket: a stub with a perforation, then the form. */
.ticket {
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
@media (min-width: 30em) {
  .ticket { padding: var(--space-4); }
}
.ticket__stub {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  margin: 0 0 var(--space-3);
  padding-block-end: var(--space-2);
  border-block-end: 1px dashed var(--line-strong);
  color: var(--copper);
}
.ticket__label {
  display: block;
  margin-block-end: var(--space-1);
  font-size: var(--size-04);
  font-weight: var(--weight-medium);
}
/* One feedback line under the label: the hint, or whatever replaces it. */
.ticket__hint,
.ticket__status,
.ticket__fallback {
  margin: 0 0 var(--space-2);
  font-size: var(--size-02);
}
.ticket__hint { color: var(--fg-subtle); }
.ticket__status { color: var(--fg-muted); }
.ticket__status:empty { margin: 0; }
.ticket__status[data-tone="error"],
.ticket__fallback { color: var(--alert); }
/* No-JS fallbacks: a failed plain post lands on /?error=…#<id>. */
.ticket__fallback { display: none; scroll-margin-block-start: 10rem; }
.ticket__fallback:target:not([data-dismissed]) { display: block; }
.ticket__status:not(:empty) ~ .ticket__hint,
.ticket__fallback:target:not([data-dismissed]) ~ .ticket__hint { display: none; }

.ticket__row {
  display: grid;
  gap: var(--space-2);
}
@media (min-width: 30em) {
  .ticket__row { grid-template-columns: minmax(0, 1fr) auto; }
}
.ticket__input {
  inline-size: 100%;
  min-block-size: 48px;
  margin: 0;
  padding: 0 var(--space-3);
  background: var(--ground);
  color: var(--fg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--size-04); /* 18px: no zoom-on-focus on iOS */
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ticket__input:focus-visible { border-color: var(--ember); outline-offset: 2px; }
.ticket__input[aria-invalid="true"] { border-color: var(--alert); }

/* Arrival: the guide's two bubbles and the ticket rise in once, in turn. */
@media (prefers-reduced-motion: no-preference) {
  .door__hello,
  .door__tour,
  .door__ticket { animation: rise var(--duration-content) var(--ease-out) both; }
  .door__tour { animation-delay: 120ms; }
  .door__ticket { animation-delay: 240ms; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* =====================================================
   The lab
   ===================================================== */

.lab-head { padding-block: var(--space-6) var(--space-4); }
.lab-head__eyebrow { margin-block-end: var(--space-2); color: var(--copper); }
.lab-head__title {
  margin-block-end: var(--space-3);
  font-size: var(--size-08);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
}
.lab-head__lead {
  max-inline-size: 52ch;
  margin: 0;
  font-size: var(--size-04);
  line-height: var(--lh-relaxed);
  color: var(--fg-muted);
}
@media (min-width: 48em) {
  .lab-head { padding-block: var(--space-7) var(--space-5); }
  .lab-head__title { font-size: var(--size-09); }
}

/* The picture, as large as the page allows: edge to edge on phones, then in
   a copper hairline frame. */
.lab-figure { margin: 0; }
.lab-figure__frame {
  overflow: hidden;
  margin-inline: calc(-1 * var(--space-4));
  background: #070707;
  border-block: 1px solid var(--line);
}
@media (min-width: 48em) {
  .lab-figure__frame {
    margin-inline: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: 0 24px 64px rgb(0 0 0 / 0.5), 0 0 0 1px rgb(217 147 92 / 0.06);
  }
}
.lab-figure__img {
  inline-size: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}
.lab-figure__caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-1) var(--space-4);
  margin-block-start: var(--space-3);
  font-size: var(--size-02);
  color: var(--fg-muted);
}
.lab-figure__caption p { max-inline-size: 68ch; margin: 0; }
.lab-figure__caption .link {
  display: inline-flex;
  align-items: center;
  min-block-size: 24px;
  white-space: nowrap;
}

.farewell { padding-block: var(--space-6) var(--space-7); }
.farewell__inner {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  max-inline-size: 44rem;
  margin-inline: auto;
}
.farewell .bubble { inline-size: 100%; }
.farewell .bubble__title { font-size: var(--size-06); }
@media (min-width: 40em) {
  .farewell__inner {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: var(--space-5);
  }
  .farewell .bubble::before {
    inset-block-start: calc(50% - 8px);
    inset-inline-start: -9px;
    rotate: -45deg;
  }
}
.farewell__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0 0;
}
.farewell__links .link {
  display: inline-flex;
  align-items: center;
  min-block-size: 24px;
}

/* =====================================================
   404
   ===================================================== */

.lost { padding-block: var(--space-7) var(--space-8); }
.lost__inner { display: grid; justify-items: center; gap: var(--space-4); }
.lost .bubble { max-inline-size: 32rem; }
.lost .bubble__title { font-size: var(--size-06); }
