/* pubnyan, live. Editorial, monochrome, calm. */

:root {
  --bg: #fafaf8;
  --fg: #151515;
  --fg-2: #626262;
  --rule: #dededa;
  --surface: #f4f4f0;          /* the mascot stage stays pale in both themes */
  --surface-fg: #151515;
  --surface-rule: #e3e3de;
  --code-bg: #f1f1ec;
  --accent: #151515;
  --accent-fg: #fafaf8;
  --sans: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --max: 1160px;
  --gutter: clamp(20px, 5vw, 56px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151515;
    --fg: #f4f4f0;
    --fg-2: #b4b4ae;
    --rule: #383838;
    --code-bg: #1e1e1e;
    --accent: #f4f4f0;
    --accent-fg: #151515;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
html[data-motion="reduced"] { scroll-behavior: auto; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, canvas, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
code, kbd, pre, .mono { font-family: var(--mono); font-size: 0.86em; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; line-height: 1.08; margin: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

.skip {
  position: absolute; left: 16px; top: -60px; padding: 8px 12px;
  background: var(--accent); color: var(--accent-fg); z-index: 20; border-radius: 6px;
}
.skip:focus { top: 16px; }

.mono { color: var(--fg-2); font-size: 13px; }
.eyebrow {
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--fg-2); margin-bottom: 18px;
}

/* ------------------------------------------------------------- header */

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px var(--gutter);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600;
  letter-spacing: -0.01em;
}
.wordmark img { width: 28px; height: 24px; }
.wordmark em { font-style: normal; color: var(--fg-2); margin-left: 4px; font-weight: 500; }
.top__nav { display: flex; align-items: center; gap: 22px; font-size: 15px; }
.top__nav a { text-decoration: none; color: var(--fg-2); }
.top__nav a:hover { color: var(--fg); }
.motion-toggle {
  white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px;
  border: 1px solid var(--rule); border-radius: 999px; background: transparent; cursor: pointer;
  font-size: 13px; font-family: var(--mono); color: var(--fg-2);
}
.motion-toggle i {
  width: 22px; height: 12px; border-radius: 999px; background: var(--rule); position: relative;
  transition: background 160ms;
}
.motion-toggle i::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--bg); transition: transform 180ms var(--ease-out);
}
.motion-toggle[aria-pressed="true"] i { background: var(--accent); }
.motion-toggle[aria-pressed="true"] i::after { transform: translateX(10px); }

@media (max-width: 720px) {
  .top__nav a:not([href="./_storybook/"]) { display: none; }
}

/* --------------------------------------------------------------- hero */

.hero {
  max-width: var(--max); margin: 0 auto; padding: clamp(48px, 9vw, 120px) var(--gutter) clamp(48px, 7vw, 96px);
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: clamp(32px, 6vw, 80px);
  align-items: center;
}
.hero h1 { font-size: clamp(42px, 6.4vw, 78px); font-weight: 600; letter-spacing: -0.03em; }
.lede { margin-top: 26px; font-size: clamp(17px, 1.6vw, 20px); color: var(--fg-2); max-width: 52ch; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }
.facts {
  display: grid; grid-template-columns: repeat(4, auto); gap: 28px; justify-content: start;
  margin: 44px 0 0; padding-top: 24px; border-top: 1px solid var(--rule);
}
.facts dt { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-2); }
.facts dd { margin: 4px 0 0; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }

.surface {
  background: var(--surface); color: var(--surface-fg);
  border: 1px solid var(--surface-rule); border-radius: 22px;
}
.hero__stage { margin: 0; padding: clamp(18px, 3vw, 36px); }
.hero__stage img { width: 100%; height: auto; aspect-ratio: 406 / 351; }
.hero__stage figcaption { margin-top: 14px; font-size: 13px; color: #626262; font-family: var(--mono); text-align: center; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero__stage { order: -1; max-width: 460px; margin: 0 auto; width: 100%; }
  .facts { gap: 20px; }
}

/* ------------------------------------------------------------ buttons */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 999px; border: 1px solid var(--fg);
  background: transparent; color: var(--fg); text-decoration: none; font-weight: 600; font-size: 15px;
  cursor: pointer; transition: transform 160ms var(--ease-out), background 160ms, color 160ms, opacity 160ms;
}
.button:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.button:active { transform: scale(0.98); }
.button--primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.button--primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--bg)); }
.button--ghost { border-color: var(--rule); color: var(--fg-2); }
.button--small { padding: 7px 14px; font-size: 13px; }
.button:disabled { opacity: 0.55; cursor: default; transform: none; }

/* ----------------------------------------------------------- sections */

.section {
  max-width: var(--max); margin: 0 auto; padding: clamp(56px, 8vw, 112px) var(--gutter);
  border-top: 1px solid var(--rule);
}
.section__head { max-width: 720px; margin-bottom: clamp(32px, 4vw, 52px); }
.section h2 { font-size: clamp(30px, 4.2vw, 48px); }
.section__lede { margin-top: 18px; color: var(--fg-2); font-size: 18px; }

/* -------------------------------------------------------------- stage */

.stage { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr); gap: clamp(24px, 4vw, 48px); align-items: start; }
.stage__canvas { position: relative; padding: clamp(16px, 3vw, 32px); }
.stage__canvas canvas { width: 100%; height: auto; aspect-ratio: 406 / 351; cursor: pointer; }
.stage__poster { position: absolute; inset: clamp(16px, 3vw, 32px); width: auto; height: auto; max-height: calc(100% - 2 * clamp(16px, 3vw, 32px)); margin: auto; aspect-ratio: 406 / 351; }
.stage.is-live .stage__poster { display: none; }
.stage.is-fallback canvas { visibility: hidden; }
.stage__status { margin-top: 12px; font-family: var(--mono); font-size: 13px; color: #626262; text-align: center; min-height: 1.4em; }

.stage__controls { display: grid; gap: 28px; }
.control-group h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; display: flex; gap: 10px; align-items: baseline; }
.control-group h3 small { font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--fg-2); text-transform: uppercase; letter-spacing: 0.05em; }
.control-group--quiet { padding: 18px 20px; border: 1px dashed var(--rule); border-radius: 14px; }
.control-group--quiet h3 { margin-bottom: 6px; }
.control-note { margin-top: 12px; font-size: 14px; color: var(--fg-2); min-height: 1.4em; }
.control-note b { color: var(--fg); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--rule); background: transparent;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background 140ms, border-color 140ms, color 140ms, transform 140ms var(--ease-out);
}
.chip:hover { border-color: var(--fg); }
.chip:active { transform: scale(0.97); }
.chip:disabled { opacity: 0.45; cursor: default; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.chip kbd { font-size: 11px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--rule); color: var(--fg-2); }
.chip--action.is-firing { animation: chip-fire 420ms var(--ease-out); }
@keyframes chip-fire {
  0% { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
  100% { background: transparent; color: inherit; border-color: var(--rule); }
}
html[data-motion="reduced"] .chip--action.is-firing { animation-duration: 1ms; }

@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------ gallery */

.gallery { display: grid; grid-template-columns: minmax(240px, 0.75fr) minmax(0, 1.25fr); gap: clamp(24px, 4vw, 48px); align-items: start; }
.specimens {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 2px;
  max-height: 640px; overflow: auto; padding-right: 6px;
  border-top: 1px solid var(--rule);
}
.specimen-group {
  display: flex; justify-content: space-between; padding: 18px 8px 8px;
  font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-2);
}
.specimen {
  width: 100%; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px;
  padding: 8px 10px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; text-align: left;
  transition: background 140ms;
}
.specimen:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); }
.specimen[aria-selected="true"] { background: color-mix(in srgb, var(--fg) 10%, transparent); }
.specimen img { width: 44px; height: 38px; background: var(--surface); border-radius: 8px; padding: 4px; }
.specimen__name { font-weight: 600; font-size: 15px; }
.specimen__meta { font-family: var(--mono); font-size: 12px; color: var(--fg-2); }

.gallery__preview { margin: 0; padding: clamp(16px, 3vw, 32px); position: sticky; top: 84px; }
.gallery__preview img { width: 100%; height: auto; aspect-ratio: 406 / 351; }
.gallery__preview img[data-rig="starorbit"] { aspect-ratio: 288 / 203; max-width: 70%; margin: 5% auto; }
.gallery__preview figcaption { margin-top: 16px; color: #151515; display: grid; gap: 8px; }
.gallery__caption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.gallery__caption b { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.gallery__caption .mono { color: #626262; }
#gallery-note { color: #626262; font-size: 15px; min-height: 1.4em; }
.gallery__preview .button { justify-self: start; border-color: #151515; color: #151515; }

@media (max-width: 900px) {
  .gallery { grid-template-columns: 1fr; }
  .gallery__preview { position: static; order: -1; }
  .specimens { max-height: 360px; }
}

/* ------------------------------------------------------------ formats */

.formats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: start; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; }
.tab {
  padding: 10px 16px; border: 0; background: transparent; cursor: pointer; font-weight: 600; font-size: 15px;
  color: var(--fg-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--fg); }
.format-frame { padding: clamp(16px, 3vw, 32px); display: grid; place-items: center; min-height: 360px; }
.format-stage { width: 100%; display: grid; place-items: center; transition: width 260ms var(--ease-out); }
.format-media { width: 100%; height: auto; aspect-ratio: 406 / 351; }
.format-frame[data-size="avatar"] .format-stage { width: 48px; }
.format-frame[data-size="avatar"] .format-media { width: 48px; height: auto; border-radius: 50%; }
.formats__foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }

.snippet h3 { font-size: 22px; margin-bottom: 12px; }
.snippet p { color: var(--fg-2); font-size: 16px; }
pre {
  margin: 16px 0 0; padding: 16px 18px; background: var(--code-bg); border: 1px solid var(--rule); border-radius: 12px;
  overflow-x: auto; font-size: 13px; line-height: 1.55;
}
pre code { font-size: inherit; }
.files { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.files a {
  display: inline-block; padding: 6px 12px; border: 1px solid var(--rule); border-radius: 999px;
  font-family: var(--mono); font-size: 13px; text-decoration: none;
}
.files a:hover { border-color: var(--fg); }
.files small { font-family: var(--mono); font-size: 12px; color: var(--fg-2); margin-left: 4px; }
.formats__all { margin-top: 28px; font-size: 14px; color: var(--fg-2); }

@media (max-width: 900px) {
  .formats { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- how */

.how { display: grid; gap: clamp(32px, 5vw, 64px); }
.pipeline {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px;
}
.pipeline li { border-top: 1px solid var(--rule); padding-top: 18px; }
.pipeline__step { font-family: var(--mono); font-size: 12px; color: var(--fg-2); letter-spacing: 0.05em; }
.pipeline h3 { font-size: 20px; margin: 8px 0 10px; }
.pipeline p { font-size: 15px; color: var(--fg-2); }
.code { margin: 0; }
.code figcaption { font-family: var(--mono); font-size: 13px; color: var(--fg-2); margin-bottom: -6px; }

@media (max-width: 900px) {
  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .pipeline { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------- footer */

.foot { max-width: var(--max); margin: 0 auto; padding: clamp(40px, 6vw, 80px) var(--gutter) 48px; border-top: 1px solid var(--rule); }
.foot__grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.6fr); gap: 40px; }
.foot__brand { display: flex; align-items: center; gap: 12px; font-weight: 600; margin-bottom: 16px; }
.foot__brand img { background: var(--surface); border-radius: 10px; padding: 4px; width: 40px; height: 35px; }
.foot__attribution { font-family: var(--mono); font-size: 13px; color: var(--fg-2); max-width: 60ch; margin-bottom: 14px; }
.foot__links { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 15px; }
.foot__links a { text-decoration: none; color: var(--fg-2); }
.foot__links a:hover { color: var(--fg); }
.foot__legal { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--fg-2); }

@media (max-width: 720px) {
  .foot__grid { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before, html[data-motion="reduced"] *::after {
  transition-duration: 1ms !important;
}
