@font-face {
  font-family: "Index Serif";
  src: url("/fonts/instrument-serif.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Index Mono";
  src: url("/fonts/ibm-plex-mono-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Index Mono";
  src: url("/fonts/ibm-plex-mono-semibold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #efe9d8;
  --paper-bright: #f7f3e7;
  --ink: #171b18;
  --muted: #6f7066;
  --rule: rgba(23, 27, 24, 0.2);
  --red: #c6332f;
  --green: #386443;
  --amber: #aa751e;
  --failed: #8e2825;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Index Mono", ui-monospace, monospace;
  background:
    linear-gradient(rgba(23, 27, 24, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 27, 24, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 83% 9%, rgba(198, 51, 47, 0.08), transparent 27rem),
    var(--paper);
  background-size: 24px 24px, 24px 24px, auto, auto;
}

body.viewer-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 4px;
}

.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;
}

.masthead,
main,
footer {
  width: min(1540px, calc(100% - 40px));
  margin-inline: auto;
}

.masthead {
  padding: 42px 0 28px;
  border-bottom: 1px solid var(--ink);
}

.eyebrow,
.progress-copy,
.live-readout,
.viewer-number {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 20px;
  color: var(--red);
  font-weight: 600;
}

.title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 30px;
}

h1 {
  max-width: 11ch;
  margin: 0;
  font-family: "Index Serif", Georgia, serif;
  font-size: clamp(4.4rem, 10vw, 10rem);
  font-weight: 400;
  line-height: 0.72;
  letter-spacing: -0.055em;
}

.live-readout {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-bottom: 8px;
  color: var(--green);
  font-weight: 600;
}

.live-light {
  width: 10px;
  height: 10px;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(56, 100, 67, 0.14);
  animation: pulse 1.8s steps(2, end) infinite;
}

.progress-line {
  height: 8px;
  margin-top: 48px;
  background: rgba(23, 27, 24, 0.13);
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--red);
  transition: width 480ms cubic-bezier(0.16, 1, 0.3, 1);
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 11px;
  color: var(--muted);
}

.progress-copy strong {
  color: var(--ink);
  font-size: 1rem;
}

main {
  padding: 30px 0 70px;
}

.controls {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: 1fr minmax(250px, 360px) auto;
  align-items: end;
  gap: 28px;
  padding: 14px 0 16px;
  background: rgba(239, 233, 216, 0.94);
  border-bottom: 1px solid var(--ink);
  backdrop-filter: blur(8px);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
}

.filter,
.error-state button,
.empty-state button,
.viewer-close {
  padding: 4px 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.filter:hover,
.filter.is-active {
  color: var(--ink);
  border-bottom-color: var(--red);
}

.filter span {
  margin-left: 4px;
  color: var(--red);
}

.search-label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
}

.search-label input {
  width: 100%;
  padding: 7px 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
}

.search-label input::placeholder {
  color: rgba(23, 27, 24, 0.42);
}

.archive-link,
.viewer-download {
  color: var(--paper-bright);
  background: var(--ink);
  padding: 10px 12px;
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.is-hidden {
  display: none !important;
}

.error-state,
.empty-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  min-height: 130px;
  border-bottom: 1px solid var(--ink);
}

.error-state strong {
  color: var(--failed);
}

.not-found {
  min-height: 100vh;
}

.error-state button,
.empty-state button {
  color: var(--ink);
  border-bottom-color: var(--red);
}

.sprite-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 54px 28px;
  padding-top: 38px;
}

.specimen {
  min-width: 0;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
}

.specimen-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
}

.specimen-number {
  color: var(--red);
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.specimen-status {
  color: var(--muted);
  font-size: 0.58rem;
  letter-spacing: 0.09em;
}

.specimen.is-ready .specimen-status {
  color: var(--green);
}

.specimen.is-failed .specimen-status {
  color: var(--failed);
}

.specimen h2 {
  margin: 1px 0 12px;
  font-family: "Index Serif", Georgia, serif;
  font-size: clamp(1.45rem, 2.3vw, 2rem);
  font-weight: 400;
  line-height: 1;
}

.sprite-stage {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  background-color: rgba(247, 243, 231, 0.72);
  background-image:
    linear-gradient(45deg, rgba(23, 27, 24, 0.045) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(23, 27, 24, 0.045) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(23, 27, 24, 0.045) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(23, 27, 24, 0.045) 75%);
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  background-size: 18px 18px;
}

button.sprite-stage {
  padding: 0;
  border: 0;
  cursor: zoom-in;
}

.sprite-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  transition: transform 160ms steps(2, end);
}

.sprite-stage:hover img {
  transform: scale(1.025);
}

.waiting-mark {
  color: rgba(23, 27, 24, 0.18);
  font-family: "Index Serif", Georgia, serif;
  font-size: clamp(4rem, 10vw, 7.5rem);
  line-height: 1;
}

.scanline {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 35%, rgba(198, 51, 47, 0.12) 50%, transparent 65%);
  animation: scan 2.6s linear infinite;
}

.specimen-actions {
  display: flex;
  justify-content: space-between;
  min-height: 26px;
  margin-top: 9px;
  font-size: 0.59rem;
  letter-spacing: 0.07em;
}

.specimen-actions a {
  color: var(--ink);
  text-underline-offset: 4px;
}

.specimen-note {
  color: var(--muted);
}

.skeleton {
  animation: skeleton 1.25s ease-in-out infinite alternate;
}

.skeleton-line {
  width: 62%;
  height: 18px;
  margin: 9px 0 16px;
  background: rgba(23, 27, 24, 0.12);
}

.skeleton-stage {
  aspect-ratio: 1;
  background: rgba(23, 27, 24, 0.08);
}

footer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 30px;
  padding: 28px 0 48px;
  border-top: 1px solid var(--ink);
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.6;
}

footer p {
  max-width: 62ch;
  margin: 0;
}

.viewer {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 28px;
  color: var(--paper-bright);
  background: rgba(12, 15, 13, 0.97);
  border: 0;
}

.viewer::backdrop {
  background: rgba(12, 15, 13, 0.84);
}

.viewer-close {
  position: fixed;
  z-index: 2;
  top: 22px;
  right: 28px;
  color: var(--paper-bright);
  border-bottom-color: var(--red);
}

.viewer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 390px);
  align-items: center;
  gap: clamp(30px, 7vw, 110px);
  width: min(1400px, 100%);
  min-height: calc(100vh - 56px);
  margin-inline: auto;
}

.viewer-animation-wrap {
  position: relative;
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  background-image:
    linear-gradient(45deg, #202521 25%, transparent 25%),
    linear-gradient(-45deg, #202521 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #202521 75%),
    linear-gradient(-45deg, transparent 75%, #202521 75%);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}

.viewer-animation-wrap img {
  width: min(100%, 720px);
  height: min(100%, 720px);
  object-fit: contain;
  image-rendering: pixelated;
}

.viewer-animation-pending {
  display: grid;
  max-width: 34rem;
  place-items: center;
  padding: 30px;
  text-align: center;
}

.viewer-animation-pending span {
  color: var(--red);
  font-size: clamp(2rem, 6vw, 5rem);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.viewer-animation-pending p {
  max-width: 35ch;
  color: #b8b9ae;
  font-size: 0.72rem;
  line-height: 1.7;
}

.viewer-animation-toggle {
  position: absolute;
  right: 16px;
  bottom: 16px;
  padding: 5px 0;
  color: var(--paper-bright);
  background: none;
  border: 0;
  border-bottom: 2px solid var(--red);
  cursor: pointer;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.viewer-copy h2 {
  margin: 8px 0 20px;
  font-family: "Index Serif", Georgia, serif;
  font-size: clamp(3.5rem, 7vw, 7rem);
  font-weight: 400;
  line-height: 0.85;
}

.viewer-copy p {
  color: #b8b9ae;
  font-size: 0.72rem;
  line-height: 1.6;
}

.viewer-copy .viewer-status {
  color: #f0b34b;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pose-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 24px;
  margin: 24px 0 34px;
  padding: 18px 0 18px 2.2rem;
  border-block: 1px solid rgba(247, 243, 231, 0.23);
  color: #d5d3c8;
  font-size: 0.66rem;
}

.viewer-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.viewer-save-gif {
  border: 0;
  cursor: pointer;
}

.viewer-save-hint {
  max-width: 52ch;
  margin-top: 12px;
}

.viewer-download.is-disabled {
  color: #8b8e85;
  background: #292d29;
  cursor: wait;
  pointer-events: none;
}

.viewer-atlas {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: end;
  gap: 14px;
  margin: 30px 0 0;
  padding-top: 16px;
  border-top: 1px solid rgba(247, 243, 231, 0.23);
}

.viewer-atlas img {
  width: 92px;
  aspect-ratio: 1;
  object-fit: contain;
  image-rendering: pixelated;
}

.viewer-atlas figcaption {
  color: #b8b9ae;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
}

@keyframes pulse {
  50% { opacity: 0.28; }
}

@keyframes scan {
  from { transform: translateY(-60%); }
  to { transform: translateY(60%); }
}

@keyframes skeleton {
  from { opacity: 0.42; }
  to { opacity: 0.9; }
}

@media (max-width: 860px) {
  .masthead,
  main,
  footer {
    width: min(100% - 26px, 1540px);
  }

  .title-row,
  .controls,
  .viewer-layout {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: clamp(4.1rem, 21vw, 7.5rem);
  }

  .live-readout {
    padding-top: 12px;
  }

  .controls {
    gap: 15px;
  }

  .archive-link {
    justify-self: start;
  }

  .sprite-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 38px 18px;
  }

  .viewer {
    overflow-y: auto;
    padding: 70px 18px 28px;
  }

  .viewer-layout {
    min-height: auto;
  }

  .viewer-animation-wrap {
    min-height: min(82vw, 560px);
  }

  footer {
    grid-template-columns: 1fr;
  }
}

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

  .progress-copy {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
