:root {
  color-scheme: dark;
  --ink: #101310;
  --bone: #e5e6da;
  --acid: #c6f56b;
  --line: rgba(229, 230, 218, 0.2);
  --muted: rgba(229, 230, 218, 0.58);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--ink);
  color: var(--bone);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--ink);
}

html.embedded, html.embedded body { min-height: 0; min-width: 0; }
html.embedded .exhibit { min-height: 0; }

body {
  min-width: 320px;
  overflow-x: hidden;
}

button {
  color: inherit;
  font: inherit;
}

.exhibit {
  width: min(1180px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(22px, 4vw, 54px) clamp(18px, 5vw, 66px) 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(24px, 4vw, 54px);
}

.masthead,
footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 32px;
}

.eyebrow,
.roman,
.counter,
.interaction-hint,
footer {
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--acid);
  font-size: 10px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(42px, 6.4vw, 84px);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: -0.065em;
}

.intro {
  width: min(330px, 42vw);
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.gallery {
  align-self: center;
  display: grid;
  grid-template-columns: minmax(250px, 0.88fr) minmax(310px, 1.12fr);
  align-items: center;
  gap: clamp(42px, 8vw, 120px);
}

.card-column {
  width: min(100%, 420px);
  justify-self: end;
}

.card-viewport {
  position: relative;
  width: min(100%, 390px);
  aspect-ratio: 2 / 3;
  margin: 0 auto;
  perspective: 1200px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  filter: drop-shadow(0 28px 32px rgba(0, 0, 0, 0.38));
}

.card-viewport[data-dragging="true"] {
  cursor: grabbing;
}

.tilt-shell,
.card-flipper,
.card-face,
.foil-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tilt-shell {
  transform-style: preserve-3d;
  transition: transform 380ms cubic-bezier(0.2, 0.75, 0.2, 1);
  will-change: transform;
}

.card-viewport[data-dragging="true"] .tilt-shell {
  transition-duration: 70ms;
}

.card-flipper {
  transform-style: preserve-3d;
  transition: transform 700ms cubic-bezier(0.2, 0.76, 0.18, 1);
  will-change: transform;
}

.card-flipper.is-flipped {
  transform: rotateY(180deg);
}

.card-face {
  overflow: hidden;
  border: 1px solid rgba(229, 230, 218, 0.28);
  border-radius: clamp(13px, 2.2vw, 22px);
  background: #070907;
  backface-visibility: hidden;
  transform: translateZ(0.01px);
}

.card-back {
  transform: rotateY(180deg) translateZ(0.01px);
}

.foil-canvas {
  display: block;
  opacity: 0;
  transition: opacity 220ms ease;
}

.foil-canvas.ready {
  opacity: 1;
}

.loading {
  position: absolute;
  inset: auto 18px 18px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: rgba(229, 230, 218, 0.72);
  font-size: 10px;
  letter-spacing: 0.08em;
  transition: opacity 200ms ease;
  pointer-events: none;
}

.loading.is-ready {
  opacity: 0;
}

.loading span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 12px var(--acid);
  animation: pulse 900ms ease-in-out infinite alternate;
}

@keyframes pulse {
  to { opacity: 0.25; transform: scale(0.6); }
}

.interaction-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 390px);
  margin: 15px auto 0;
  color: var(--muted);
  font-size: 9px;
}

.hint-line {
  width: 32px;
  height: 1px;
  background: var(--acid);
}

.caption-column {
  min-width: 0;
  padding-right: clamp(0px, 3vw, 34px);
}

.counter {
  display: flex;
  gap: 7px;
  margin-bottom: clamp(26px, 5vw, 60px);
  color: var(--muted);
  font-size: 11px;
}

.counter #index {
  color: var(--acid);
}

.roman {
  margin: 0 0 14px;
  color: var(--acid);
  font-size: 10px;
  font-weight: 700;
}

h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(54px, 8vw, 106px);
  font-weight: 400;
  line-height: 0.93;
  letter-spacing: -0.06em;
}

.keywords {
  margin: 22px 0 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(16px, 2vw, 22px);
}

.material {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: clamp(28px, 5vw, 58px);
}

.controls button,
.card-thumb {
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.controls button:focus-visible,
.card-thumb:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 3px;
}

.circle-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 18px;
  transition: border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.circle-button:hover {
  border-color: var(--acid);
  color: var(--acid);
  transform: translateY(-2px);
}

.flip-button {
  min-width: 120px;
  height: 44px;
  padding: 0 17px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 28px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--acid) !important;
  border-color: var(--acid) !important;
  font-size: 12px;
  font-weight: 700;
}

.flip-mark {
  font-size: 17px;
  transition: transform 500ms ease;
}

.flip-button[aria-pressed="true"] .flip-mark {
  transform: rotate(180deg);
}

.card-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(34px, 1fr));
  gap: clamp(6px, 1vw, 10px);
  margin-top: clamp(28px, 5vw, 54px);
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.card-thumb {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  border-radius: 5px;
  opacity: 0.42;
  transition: opacity 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.card-thumb:hover,
.card-thumb.is-active {
  opacity: 1;
  border-color: var(--acid);
  transform: translateY(-4px);
}

footer {
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: rgba(229, 230, 218, 0.42);
  font-size: 8px;
}

footer p {
  margin: 0;
}

@media (max-width: 760px) {
  .exhibit {
    gap: 30px;
  }

  .masthead {
    align-items: flex-start;
  }

  .intro {
    width: min(260px, 48vw);
  }

  .gallery {
    grid-template-columns: minmax(190px, 0.92fr) minmax(210px, 1.08fr);
    gap: clamp(20px, 5vw, 44px);
  }

  .counter {
    margin-bottom: 25px;
  }

  .controls {
    margin-top: 28px;
  }

  .flip-button {
    min-width: 96px;
    gap: 10px;
  }
}

@media (max-width: 560px) {
  .exhibit {
    display: block;
    padding: 22px 18px 18px;
  }

  .masthead {
    display: block;
  }

  .intro {
    width: auto;
    margin-top: 16px;
  }

  .gallery {
    display: block;
    margin-top: 30px;
  }

  .card-column {
    width: min(74vw, 330px);
    margin: 0 auto;
  }

  .caption-column {
    margin-top: 28px;
    padding: 0;
  }

  .caption-copy {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 3px 14px;
  }

  .counter {
    margin-bottom: 16px;
  }

  .roman,
  h2 {
    grid-column: 1;
  }

  h2 {
    font-size: clamp(48px, 17vw, 82px);
  }

  .keywords,
  .material {
    grid-column: 2;
    text-align: right;
  }

  .keywords {
    margin: 0;
    font-size: 14px;
  }

  .material {
    max-width: 150px;
  }

  .controls {
    justify-content: center;
  }

  .card-strip {
    margin-top: 24px;
  }

  footer {
    margin-top: 30px;
  }
}

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