@view-transition {
  navigation: auto;
}

:root {
  color-scheme: light;
  --bg: #fff;
  --fg: #000;
  --pad: clamp(14px, 1.8vw, 28px);
  --ease: cubic-bezier(.16, 1, .3, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000;
  --fg: #fff;
}

* { box-sizing: border-box; }
html {
  min-width: 320px;
  background: var(--bg);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.2;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { border: 0; }
.symbol-use { display: block; max-width: 100%; fill: currentColor; }
::selection { background: var(--fg); color: var(--bg); }

/* Cross-document shared symbol. pageswap and pagereveal assign this class
   only to the one SVG that participates in the current navigation. */
.vt-shared {
  view-transition-name: symbol-shared;
}

/* Keep the logo geometry transition generous while leaving the document
   transition itself to the browser. */
::view-transition-group(root) {
  animation-duration: 360ms;
  animation-timing-function: cubic-bezier(.22, 1, .36, 1);
}
::view-transition-group(symbol-shared) {
  animation-duration: 760ms;
  animation-timing-function: cubic-bezier(.16, 1, .3, 1);
  z-index: 10000;
}
::view-transition-old(symbol-shared),
::view-transition-new(symbol-shared) {
  animation-duration: inherit;
  height: 100%;
  object-fit: contain;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 360ms;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  min-height: 58px;
  padding: 10px var(--pad);
  border-bottom: 1px solid var(--fg);
  background: var(--bg);
}
.brandline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: baseline;
  min-width: 0;
}
.site-title {
  margin: 0;
  font-size: inherit;
  font-weight: 500;
  letter-spacing: -.015em;
}
.site-meta {
  color: var(--fg);
  white-space: nowrap;
  font-size: 12px;
}
.site-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.icon-button,
.search-input {
  height: 34px;
  border: 1px solid var(--fg);
  border-radius: 999px;
  background: var(--bg);
}
.icon-button {
  position: relative;
  width: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .22s var(--ease);
}
.icon-button svg {
  width: 16px;
  height: 16px;
  overflow: visible;
}
.icon-button .bulb-glow {
  opacity: 0;
  transform-origin: 50% 50%;
}
html[data-theme="dark"] .icon-button[data-theme-toggle] .bulb-glow {
  opacity: 1;
}
.icon-button:hover {
  background: var(--fg);
  color: var(--bg);
}
.icon-button:active { transform: scale(.92); }

.search-wrap { position: relative; }
.search-input {
  width: clamp(128px, 14vw, 208px);
  padding: 0 12px;
  outline: none;
  transition: width .3s var(--ease);
}
.search-input:focus {
  width: clamp(180px, 20vw, 260px);
}
.search-input::placeholder {
  color: var(--fg);
  opacity: 1;
}

/* Collection */
.collection {
  padding: 0 var(--pad) var(--pad);
}
.collection-status {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  min-height: 48px;
  align-items: center;
  border-bottom: 1px solid var(--fg);
  color: var(--fg);
  font-size: 12px;
}
.symbol-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-left: 1px solid var(--fg);
}
.symbol-card {
  min-width: 0;
  border-right: 1px solid var(--fg);
  border-bottom: 1px solid var(--fg);
}
.symbol-card[hidden] { display: none; }
.symbol-link {
  display: block;
  min-width: 0;
}
.symbol-art {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--bg);
}
.symbol-art::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 0 solid var(--bg);
  pointer-events: none;
  transition: border-width .42s var(--ease);
}
.symbol-art [data-symbol-image] {
  width: min(50%, 190px);
  height: min(50%, 190px);
  object-fit: contain;
  color: var(--fg);
  fill: currentColor;
  transform: scale(1);
  transition: transform .58s var(--ease);
  will-change: transform;
  scroll-margin-top: 22vh;
}
.symbol-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 16px;
  min-height: 82px;
  padding: 10px 10px 12px;
  align-content: start;
  background: var(--bg);
  border-top: 1px solid var(--fg);
}
.symbol-name {
  font-weight: 500;
  letter-spacing: -.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.symbol-year {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.symbol-designer {
  grid-column: 1 / -1;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}
.symbol-designer strong {
  color: var(--fg);
  font-weight: 500;
}

/* Strong binary hover: pure black/white only */
.symbol-link:hover .symbol-art,
.symbol-link:focus-visible .symbol-art {
  background: var(--fg);
}
.symbol-link:hover .symbol-art [data-symbol-image],
.symbol-link:focus-visible .symbol-art [data-symbol-image] {
  transform: scale(1.15);
  color: var(--bg);
  fill: currentColor;
}
.symbol-link:hover .symbol-art::after,
.symbol-link:focus-visible .symbol-art::after {
  border-width: 7px;
}

.symbol-link:focus-visible,
.icon-button:focus-visible,
.search-input:focus-visible,
.back-link:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: -2px;
}

/* Detail */
.detail-page {
  height: 100svh;
  overflow: hidden;
}
.detail-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px var(--pad);
  pointer-events: none;
}
.detail-header > * { pointer-events: auto; }
.back-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--fg);
  border-radius: 999px;
  background: var(--bg);
}
.back-link svg {
  width: 13px;
  height: 13px;
}
.back-link:hover {
  background: var(--fg);
  color: var(--bg);
}
.detail-scroll {
  height: 100svh;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
}
.detail-scroll::-webkit-scrollbar { display: none; }
.symbol-stage {
  position: relative;
  width: 100%;
  min-height: 100svh;
  display: grid;
  place-items: center;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  background: var(--bg);
  border-bottom: 1px solid var(--fg);
}
.detail-symbol {
  object-fit: contain;
  color: var(--fg);
  fill: currentColor;
}
.detail-symbol--large {
  width: min(52vw, 620px);
  height: min(52vw, 620px);
  min-width: 220px;
  min-height: 220px;
}
.detail-symbol--small {
  width: clamp(54px, 6.6vw, 104px);
  height: clamp(54px, 6.6vw, 104px);
}
.stage-index {
  position: absolute;
  left: var(--pad);
  bottom: var(--pad);
  color: var(--fg);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.scroll-cue {
  position: absolute;
  right: var(--pad);
  bottom: var(--pad);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
  cursor: pointer;
  background: none;
  padding: 0;
  font-size: 12px;
}
.scroll-cue svg {
  width: 13px;
  height: 13px;
  animation: cue 1.8s var(--ease) infinite;
}
@keyframes cue {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(4px); }
}
.detail-meta {
  position: absolute;
  inset: auto 0 0 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(240px, .8fr);
  gap: 16px 28px;
  align-items: baseline;
  padding: 12px var(--pad) 14px;
  border-top: 1px solid var(--fg);
  background: var(--bg);
}
.detail-name {
  margin: 0;
  font-size: inherit;
  font-weight: 500;
  letter-spacing: -.012em;
}
.detail-year {
  color: var(--fg);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.detail-designer {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg);
  font-size: 12px;
}
.detail-designer strong {
  color: var(--fg);
  font-weight: 500;
}

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

@media (max-width: 1050px) {
  .symbol-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-meta { grid-template-columns: minmax(0, 1fr) auto; }
  .detail-designer { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .site-header {
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: start;
    padding-block: 10px;
  }
  .site-actions { width: 100%; }
  .search-wrap { flex: 1; }
  .search-input,
  .search-input:focus { width: 100%; }
  .collection-status span:last-child { display: none; }
  .symbol-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .symbol-info {
    min-height: 80px;
    padding: 9px 8px 11px;
  }
  .symbol-art [data-symbol-image] {
    width: min(48%, 150px);
    height: min(48%, 150px);
  }
  .detail-symbol--large {
    width: min(72vw, 480px);
    height: min(72vw, 480px);
  }
  .detail-meta {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .detail-designer { grid-column: 1 / -1; }
}

@media (max-width: 430px) {
  .brandline { gap: 3px 11px; }
  .site-meta:last-child { display: none; }
  .symbol-info {
    font-size: 12px;
    min-height: 76px;
  }
  .symbol-link:hover .symbol-art [data-symbol-image],
  .symbol-link:focus-visible .symbol-art [data-symbol-image] {
    transform: scale(1.10);
  }
  .detail-symbol--large {
    width: 74vw;
    height: 74vw;
    min-width: 0;
    min-height: 0;
  }
  .detail-meta {
    gap: 6px 14px;
    font-size: 13px;
  }
}

@media (hover: none) {
  .symbol-link:hover .symbol-art {
    background: var(--bg);
  }
  .symbol-link:hover .symbol-art [data-symbol-image] {
    transform: none;
    color: var(--fg);
  fill: currentColor;
  }
  .symbol-link:hover .symbol-art::after {
    border-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(root),
  ::view-transition-group(symbol-shared),
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: 160ms !important; }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
