:root {
  --ink: #000;
  --ink-soft: #343434;
  --muted: #6e6e6e;
  --faint: #d4d4d4;
  --bg: #fff;
  --gutter: 16px;
  --header-h: 64px;
  --cols: 6;
  --font: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 24px;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  color: inherit;
  text-transform: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }

button:disabled,
[aria-disabled="true"] { cursor: default; }

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

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 var(--gutter);
  background: var(--bg);
}

.icon-btn {
  width: 32px;
  height: 32px;
  margin: -8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.header-left { justify-self: start; }
.header-right { justify-self: end; }

.filters { display: flex; gap: 16px; }
.filters[hidden] { display: flex; visibility: hidden; }

.filter-btn { color: var(--ink-soft); transition: opacity 0.2s; }
.filter-btn[aria-pressed="false"] { opacity: 0.2; }
.filter-btn[aria-pressed="false"]:not(:disabled):hover { opacity: 0.5; }

/* ---------- view transitions ---------- */

.view { flex: 1; animation: fade-in 0.35s var(--ease); }
@keyframes fade-in { from { opacity: 0; } }

::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.3s; }
::view-transition-group(*) { animation-duration: 0.45s; animation-timing-function: var(--ease); }

/* ---------- grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  column-gap: 13px;
  row-gap: 14px;
  padding: 0 var(--gutter);
}
.grid.zoomed { --cols: 3; column-gap: 24px; row-gap: 24px; }

.tile { display: block; text-align: center; }

.tile-media {
  position: relative;
  aspect-ratio: 1;
  display: block;
}
.tile-media > svg,
.tile-media > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile-label { display: block; margin-top: -4px; }

@media (hover: hover) {
  .tile-media { transition: opacity 0.2s; }
  body:not(.locked) .grid:has(.tile:hover) .tile:not(:hover) .tile-media { opacity: 0.35; }
}

.empty {
  padding: 120px var(--gutter);
  text-align: center;
  color: var(--muted);
}

/* ---------- detail ---------- */

.detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 var(--gutter) 96px;
}

.stage {
  position: relative;
  width: 100%;
  height: min(66vh, 720px);
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
}

.stage-media {
  width: min(100%, 44vh, 480px);
  aspect-ratio: 1;
  position: relative;
}
.stage-media > svg,
.stage-media > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 0.3s;
}

.arrow {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
}
.arrow-prev { left: 13%; }
.arrow-next { right: 13%; }

.dots {
  display: flex;
  gap: 6px;
  height: 24px;
  align-items: center;
  margin-top: 8px;
}
.dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--faint);
  padding: 0;
  position: relative;
}
.dot::after { content: ""; position: absolute; inset: -6px; }
.dot[aria-current="true"] { background: var(--ink); }

.meta {
  width: min(100%, 520px);
  margin-top: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 14px;
  line-height: 16px;
}
.meta-code { color: var(--muted); }
.meta-year { margin-top: 31px; }
.meta-toggle { margin-top: 18px; }

.panel { display: none; width: 100%; flex-direction: column; align-items: center; }
.meta.open .panel { display: flex; }
.meta.open .meta-closed { display: none; }

.panel-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.panel-row > :first-child { justify-self: start; }
.panel-row > :last-child { justify-self: end; }

.panel-title { font-weight: 500; text-align: center; }
.panel-year { margin-top: 31px; }

.panel-tags {
  width: 100%;
  margin-top: 31px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.panel-tags > span:nth-child(1) { justify-self: start; }
.panel-tags > span:nth-child(2) { justify-self: center; }
.panel-tags > span:nth-child(3) { justify-self: end; }

.panel-role { margin-top: 31px; color: var(--muted); }

.panel-links { margin-top: 31px; display: flex; gap: 32px; }
.panel-links a { border-bottom: 1px solid var(--ink); padding-bottom: 2px; }

.info-toggle { margin-top: 31px; font-weight: 500; }

.about {
  display: none;
  margin: 24px 0 0;
  max-width: 440px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 20px;
  text-transform: none;
}
.meta.about-open .about { display: block; }

/* ---------- info ---------- */

.info {
  max-width: 520px;
  margin: 0 auto;
  padding: 96px var(--gutter) 0;
  text-align: center;
}
.info p { margin: 0; min-height: 24px; }
.info dl {
  margin: 72px 0 0;
  display: grid;
  gap: 24px;
  font-size: 14px;
  line-height: 16px;
}
.info dt { color: var(--muted); }
.info dd { margin: 4px 0 0; }

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

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 32px;
  padding: 200px var(--gutter) 220px;
  font-size: 14px;
  line-height: 16px;
  color: var(--muted);
}
.footer a { transition: color 0.2s; }
.footer a:hover { color: var(--ink); }
.footer.hidden { display: none; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  :root { --cols: 4; }
  .grid.zoomed { --cols: 2; }
}

@media (max-width: 600px) {
  :root { --cols: 3; --header-h: 56px; }
  .grid { column-gap: 8px; row-gap: 12px; }
  .grid.zoomed { --cols: 1; row-gap: 32px; }
  .tile-label { font-size: 14px; }
  .stage { height: auto; min-height: 0; padding: 24px 0 0; }
  .stage-media { width: 78%; }
  .arrow-prev { left: -4px; }
  .arrow-next { right: -4px; }
  .meta { margin-top: 40px; }
  .footer { padding: 140px var(--gutter) 120px; gap: 12px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

.grid.zoomed .tile-media > svg,
.grid.zoomed .tile-media > img { inset: 6%; width: 88%; height: 88%; }
