/* Archive case overlay */
.archive-case-overlay {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3dvh, 28px) clamp(14px, 2.6vw, 26px);
  background: rgba(8, 8, 10, 0.72);
  backdrop-filter: blur(8px);
  opacity: 1;
  transition: opacity 0.38s ease;
}

.archive-case-overlay.is-closing {
  opacity: 0;
}

.archive-case-stage {
  min-height: 100dvh;
  width: 100%;
  display: grid;
  place-items: center;
  perspective: 1700px;
  perspective-origin: 50% 38%;
}

.archive-case-shell {
  --archive-case-gap: clamp(18px, 3dvh, 34px);
  --archive-case-control-height: clamp(54px, 8dvh, 76px);
  position: relative;
  display: grid;
  justify-items: center;
  gap: var(--archive-case-gap);
  width: min(68vw, 580px, calc((100dvh - 190px) / 1.4142));
  max-width: 100%;
}

.archive-case-rig {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.4142;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  opacity: 0;
  pointer-events: none;
}

.archive-case-rig.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.archive-case-rig.is-flying {
  animation: archive-case-arrive 1.65s cubic-bezier(0.2, 0.9, 0.18, 1) forwards;
}

.archive-case-rig.is-exiting {
  animation: archive-case-depart 0.72s cubic-bezier(0.22, 0.8, 0.3, 1) forwards;
}

.archive-case-rig.is-settled {
  transform: rotateX(9deg) rotateY(-8deg) rotateZ(-3.5deg) translateZ(0);
}

.archive-case-shadow {
  position: absolute;
  inset: auto 10% 5%;
  height: 13%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.48) 0%, rgba(0, 0, 0, 0) 72%);
  filter: blur(24px);
  transform: translateZ(-130px) scale(0.84);
  opacity: 0;
}

.archive-case-rig.is-flying .archive-case-shadow {
  animation: archive-case-shadow-arrive 1.65s cubic-bezier(0.2, 0.9, 0.18, 1) forwards;
}

.archive-case-rig.is-exiting .archive-case-shadow {
  animation: archive-case-shadow-depart 0.72s cubic-bezier(0.22, 0.8, 0.3, 1) forwards;
}

.archive-case-folder {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 12%),
    linear-gradient(145deg, #d7c39d 0%, #cbb790 34%, #baa27e 100%);
  border: 1px solid rgba(88, 64, 32, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -18px 40px rgba(111, 88, 51, 0.16),
    0 38px 80px rgba(0, 0, 0, 0.42);
  overflow: visible;
  transform-style: preserve-3d;
}

.archive-case-folder::before {
  content: "";
  position: absolute;
  top: 7%;
  right: -24px;
  width: 34px;
  height: 116px;
  border-radius: 0 10px 10px 0;
  background: linear-gradient(90deg, #d8c39b 0%, #bca37d 100%);
  border: 1px solid rgba(88, 64, 32, 0.16);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transform: translateZ(-12px);
  transform-origin: left center;
}

.archive-case-folder::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 255, 255, 0.08), transparent 24%),
    radial-gradient(circle at 86% 78%, rgba(92, 62, 19, 0.08), transparent 28%),
    repeating-linear-gradient(0deg, transparent 0 26px, rgba(92, 62, 19, 0.025) 26px 27px);
  opacity: 0.9;
  pointer-events: none;
}

.archive-case-paper {
  --archive-case-content-scale: 1;
  position: absolute;
  inset: 34px 32px 26px 28px;
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 10%),
    linear-gradient(180deg, #f2e8d2 0%, #ede2ca 100%);
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
  transform: translateZ(24px) rotateZ(0.8deg);
  padding: 36px 34px;
  overflow: hidden;
}

.archive-case-page-body {
  position: relative;
  z-index: 1;
  width: calc(100% / var(--archive-case-content-scale));
  transform-origin: top left;
  transform: scale(var(--archive-case-content-scale));
}

.archive-case-embed-host {
  width: 100%;
  height: 100%;
}

.archive-case-embed-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: transparent;
}

.archive-case-paper.archive-case-paper-embed-mode {
  inset: 26px 24px 22px 24px;
  padding: 0;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
  transform: translateZ(24px) rotateZ(0deg);
}

.archive-case-paper.archive-case-paper-embed-mode::before,
.archive-case-paper.archive-case-paper-embed-mode::after {
  display: none;
}

.archive-case-paper.archive-case-paper-embed-mode .archive-case-page-body {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: none;
}

.archive-case-paper.is-turning {
  animation: archive-case-page-shift 0.38s ease;
}

.archive-case-paper::before {
  content: "";
  position: absolute;
  top: 24px;
  left: 34px;
  right: 34px;
  height: 1px;
  background: rgba(67, 47, 19, 0.2);
  box-shadow: 0 13px 0 rgba(96, 72, 34, 0.16), 0 72px 0 rgba(96, 72, 34, 0.16), 0 130px 0 rgba(96, 72, 34, 0.16);
}

.archive-case-paper::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(123, 85, 42, 0.07), transparent 18%),
    radial-gradient(circle at 78% 34%, rgba(123, 85, 42, 0.06), transparent 20%),
    radial-gradient(circle at 62% 82%, rgba(123, 85, 42, 0.05), transparent 16%);
  pointer-events: none;
}

.archive-case-stamp {
  position: absolute;
  top: 28px;
  right: 34px;
  padding: 8px 14px;
  border: 2px solid rgba(141, 33, 26, 0.52);
  color: rgba(141, 33, 26, 0.74);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transform: rotate(9deg);
  opacity: 0.86;
}

.archive-case-content {
  color: #33281d;
  display: grid;
  align-content: start;
  gap: 18px;
}

.archive-case-header {
  display: grid;
  gap: 6px;
}

.archive-case-label {
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(51, 40, 29, 0.64);
}

.archive-case-title {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #33281d;
}

.archive-case-copy {
  max-width: 35ch;
  margin: 0;
  font-size: clamp(14px, 1.5vw, 17px);
  line-height: 1.6;
  color: rgba(51, 40, 29, 0.76);
}

.archive-case-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  margin-top: 10px;
}

.archive-case-meta-card {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(81, 60, 28, 0.12);
  background: rgba(255, 255, 255, 0.24);
}

.archive-case-meta-key {
  display: block;
  margin-bottom: 7px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(51, 40, 29, 0.56);
}

.archive-case-meta-value {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #33281d;
}

.archive-case-control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(100%, 470px);
  min-height: var(--archive-case-control-height);
  padding: 12px 16px;
  margin-bottom: clamp(8px, 1.8dvh, 18px);
  border: 1px solid rgba(209, 177, 125, 0.18);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(11, 15, 21, 0.9), rgba(17, 22, 30, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 18px 34px rgba(0, 0, 0, 0.3);
}

.archive-case-nav-panel {
  display: flex;
  align-items: center;
  gap: 16px;
}

.archive-case-control-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.archive-case-page-indicator {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(241, 226, 191, 0.7);
}

.archive-case-actions {
  display: flex;
  gap: 10px;
}

.archive-case-actions.is-hidden {
  display: none;
}

.archive-case-page-button {
  appearance: none;
  border: 1px solid rgba(209, 177, 125, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #f3dfba;
  padding: 9px 14px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.archive-case-page-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
}

.archive-case-page-button:disabled {
  opacity: 0.42;
  cursor: default;
}

.archive-case-zoom-button {
  min-width: 98px;
}

.archive-case-close {
  flex: 0 0 auto;
  min-width: 118px;
  min-height: 42px;
  border: 1px solid rgba(209, 177, 125, 0.34);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(25, 31, 42, 0.94), rgba(12, 16, 22, 0.96));
  color: #f3dfba;
  font-family: "IBM Plex Mono", "Courier New", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 24px rgba(0, 0, 0, 0.22);
}

.archive-case-close:hover {
  border-color: rgba(236, 201, 133, 0.68);
  background:
    linear-gradient(180deg, rgba(47, 58, 78, 0.96), rgba(20, 27, 37, 0.98));
}

.archive-case-overlay.is-zoomed .archive-case-stage {
  perspective: none;
}

.archive-case-overlay.is-zoomed .archive-case-shell {
  width: min(90vw, 760px, calc((100dvh - 146px) / 1.4142));
  gap: clamp(12px, 2dvh, 18px);
}

.archive-case-overlay.is-zoomed .archive-case-rig,
.archive-case-overlay.is-zoomed .archive-case-rig.is-settled,
.archive-case-overlay.is-zoomed .archive-case-rig.is-flying,
.archive-case-overlay.is-zoomed .archive-case-rig.is-exiting {
  animation: none !important;
  transform: none !important;
  opacity: 1;
}

.archive-case-overlay.is-zoomed .archive-case-shadow,
.archive-case-overlay.is-zoomed .archive-case-folder::before,
.archive-case-overlay.is-zoomed .archive-case-folder::after {
  display: none;
}

.archive-case-overlay.is-zoomed .archive-case-folder {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.archive-case-overlay.is-zoomed .archive-case-paper {
  inset: 0;
  transform: none !important;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

@keyframes archive-case-arrive {
  0% {
    opacity: 0;
    transform:
      translate3d(48vw, -58vh, -260px)
      rotateX(72deg)
      rotateY(-26deg)
      rotateZ(18deg)
      scale(0.72);
  }
  18% {
    opacity: 1;
  }
  64% {
    opacity: 1;
    transform:
      translate3d(-2vw, 3vh, 42px)
      rotateX(4deg)
      rotateY(-10deg)
      rotateZ(-5deg)
      scale(1.02);
  }
  100% {
    opacity: 1;
    transform:
      translate3d(0, 0, 0)
      rotateX(9deg)
      rotateY(-8deg)
      rotateZ(-3.5deg)
      scale(1);
  }
}

@keyframes archive-case-shadow-arrive {
  0% {
    opacity: 0;
    transform: translateZ(-130px) scale(0.3);
  }
  55% {
    opacity: 0.5;
    transform: translateZ(-130px) scale(0.94);
  }
  100% {
    opacity: 0.78;
    transform: translateZ(-130px) scale(1);
  }
}

@keyframes archive-case-depart {
  0% {
    opacity: 1;
    transform:
      translate3d(0, 0, 0)
      rotateX(9deg)
      rotateY(-8deg)
      rotateZ(-3.5deg)
      scale(1);
  }
  100% {
    opacity: 0;
    transform:
      translate3d(-78vw, 92vh, -260px)
      rotateX(20deg)
      rotateY(-16deg)
      rotateZ(-10deg)
      scale(0.68);
  }
}

@keyframes archive-case-shadow-depart {
  0% {
    opacity: 0.78;
    transform: translateZ(-130px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateZ(-130px) scale(0.52);
  }
}

@keyframes archive-case-page-shift {
  0% {
    transform: translateZ(24px) rotateZ(0.8deg) translateX(0);
  }
  40% {
    transform: translateZ(24px) rotateZ(0.8deg) translateX(12px);
  }
  100% {
    transform: translateZ(24px) rotateZ(0.8deg) translateX(0);
  }
}

@media (max-width: 560px) {
  .archive-case-overlay {
    padding: 12px;
  }

  .archive-case-shell {
    width: min(78vw, 520px, calc((100dvh - 166px) / 1.4142));
    gap: 16px;
  }

  .archive-case-paper {
    inset: 24px 22px 18px 18px;
    padding: 28px 24px;
  }

  .archive-case-meta-grid {
    grid-template-columns: 1fr;
  }

  .archive-case-control-panel {
    width: min(100%, 380px);
    margin-bottom: 10px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .archive-case-nav-panel {
    flex-wrap: wrap;
    justify-content: center;
  }

  .archive-case-control-actions {
    width: 100%;
    justify-content: center;
  }
}
