:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  color: #f8e9d2;
  background: #160c11;
}

body {
  margin: 0;
  min-height: 100svh;
  background: radial-gradient(ellipse at 50% 32%, #47202c 0%, #251019 49%, #10090d 90%);
}

.record-shell {
  --gutter: clamp(.5rem, 2.4vw, 2rem);
  width: min(calc(100% - 2 * var(--gutter)), 85rem);
  margin-inline: auto;
  padding: .75rem 0 1.25rem;
}

.record-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  margin-bottom: .75rem;
}

.record-number,
.record-status {
  margin: 0;
  color: #d7b790;
  font-size: .75rem;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.record-status {
  padding: .85rem .1rem 0;
  text-align: right;
}

.record-status span {
  margin-right: .25rem;
  color: #d1a167;
}

.record-back,
.record-close {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  min-height: 44px;
  padding-inline: .9rem;
  border: 1px solid #ae8b66;
  background: #39141e;
  color: inherit;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 650;
  text-decoration: none;
}

.record-close {
  cursor: pointer;
}

.record-back:hover,
.record-close:hover {
  background: #5a202c;
}

.record-back:focus-visible,
.record-close:focus-visible {
  outline: 2px solid #ffdda8;
  outline-offset: -2px;
}

.record-heading {
  margin: .25rem .1rem .9rem;
  font: 500 clamp(1.15rem, 4.2vw, 2rem)/1.12 Georgia, serif;
}

.record-heading > span {
  display: block;
  margin-bottom: .3rem;
  color: #d7b790;
  font: 650 .67rem/1.2 system-ui, sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.record-view {
  border: 1px solid #986a58;
  box-shadow: 0 1.2rem 4rem #0a040ab3, 0 0 2.8rem #9f463429;
  perspective: 85rem;
}

.record-sheet {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
}

.record-artwork {
  display: block;
  width: 100%;
  height: auto;
}

.record-sheet::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  content: "";
  background: radial-gradient(ellipse at 50% 46%, transparent 50%, #220c1780 100%);
  box-shadow: inset 0 0 0 1px #f9d7a129;
}

.record-name-letter {
  position: absolute;
  top: 82.51%;
  height: 2.37%;
  overflow: hidden;
  pointer-events: none;
}

.record-name-letter img {
  position: absolute;
  top: calc(-698 / var(--sheet-width) * 100cqw);
  left: var(--glyph-x);
  width: var(--glyph-width);
  height: calc(846 / var(--sheet-width) * 100cqw);
  max-width: none;
}

/* Each photo covers the printed opening while leaving its frame and pin visible. */
.record-photo {
  position: absolute;
  top: 40.78%;
  left: var(--frame-left);
  width: var(--frame-width);
  height: 25.95%;
  display: block;
  overflow: hidden;
  isolation: isolate;
}

.record-photo-dance {
  --crop: 41% 50%;
  --grade: contrast(1.13) saturate(1.2);
}

.record-photo-sketch {
  --crop: 50% 56%;
  --grade: grayscale(.85) contrast(1.22) brightness(1.09);
}

.record-photo-read {
  --crop: 50% 27%;
  --grade: contrast(1.13) saturate(1.22);
}

.record-photo-edit {
  --crop: 38% 52%;
  --grade: contrast(1.14) saturate(1.18) brightness(1.1);
}

.record-photo > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--crop, center);
  filter: var(--grade, none);
}

.record-photo-placeholder {
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: saturate(.6) sepia(.28);
}

.record-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(145deg, #ffc47f40, transparent 38% 65%, #621d3f42);
  box-shadow: inset 0 0 1rem #2d111e33;
}

.record-photo {
  cursor: zoom-in;
}

.record-photo:hover,
.record-photo:focus-visible {
  outline: 2px solid #ffdda8;
  outline-offset: -2px;
}

@media (min-width: 48rem) {
  .record-heading {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (min-width: 48rem) and (min-height: 36rem) {
  .record-shell {
    max-width: calc((100svh - 6.75rem) * 1.6);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .record-sheet {
    animation: record-arrival .5s cubic-bezier(.22, .8, .28, 1) both;
  }

  .record-sheet::before {
    position: absolute;
    z-index: 3;
    top: 15.7%;
    left: 7.8%;
    width: 84.8%;
    height: 79.5%;
    pointer-events: none;
    content: "";
    transform-origin: center top;
    border-radius: 1.7%;
    background: linear-gradient(145deg, #fae9c7, #d1a27c);
    box-shadow: 0 .85rem 2rem #2e081d70, inset 0 0 0 1px #fff2cd8c;
    animation: open-folder .55s .12s cubic-bezier(.48, .14, .56, 1) both;
  }

  .record-photo::before {
    position: absolute;
    z-index: 1;
    inset: 0;
    pointer-events: none;
    content: "";
    background: linear-gradient(115deg, #fef0cf, #c59277 75%, #8f4660);
    animation: reveal-photo .38s cubic-bezier(.22, .8, .28, 1) both;
    animation-delay: calc(.38s + var(--slot) * .075s);
  }

  a.record-photo > img {
    transition: filter .2s ease;
  }
}

a.record-photo:hover > img,
a.record-photo:focus-visible > img {
  filter: var(--grade, none) brightness(1.08);
}

@keyframes record-arrival {
  from { opacity: 0; transform: translateY(1rem) rotateX(7deg); }
  to { opacity: 1; transform: none; }
}

@keyframes open-folder {
  from { opacity: 1; transform: perspective(58rem) rotateX(0); }
  to { opacity: 0; transform: perspective(58rem) rotateX(87deg); }
}

@keyframes reveal-photo {
  from { opacity: .95; clip-path: inset(0); }
  to { opacity: 0; clip-path: inset(0 0 0 100%); }
}

.record-photo-dialog {
  box-sizing: border-box;
  min-width: min(16rem, calc(100% - 1.5rem));
  max-width: min(62rem, calc(100% - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  padding: .75rem;
  border: 1px solid #ae8b66;
  background: #231016;
  color: #f8e9d2;
  overflow: visible;
}

.record-photo-dialog::backdrop {
  background: #10060aed;
}

@media (prefers-reduced-motion: no-preference) {
  .record-photo-dialog[open] {
    animation: photo-dialog-arrival .26s ease-out both;
  }

  .record-photo-dialog[open]::backdrop {
    animation: photo-backdrop-arrival .26s ease-out both;
  }

  @keyframes photo-dialog-arrival {
    from { background-color: transparent; border-color: transparent; }
  }

  @keyframes photo-backdrop-arrival {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}

.record-photo-header {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .65rem;
  margin-bottom: .75rem;
}

.record-photo-controls {
  display: flex;
  align-items: center;
  gap: .25rem;
  margin-inline-end: auto;
}

.record-photo-controls[hidden] {
  display: none;
}

.record-photo-arrow {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #ae8b66;
  background: #39141e;
  color: #ffdda8;
  font: 1.35rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.record-photo-arrow:hover {
  background: #5a202c;
}

.record-photo-arrow:focus-visible {
  outline: 2px solid #ffdda8;
  outline-offset: -2px;
}

.record-photo-position {
  min-width: 2.7rem;
  text-align: center;
  white-space: nowrap;
  color: #d7b790;
  font: 500 .75rem/1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

.record-photo-full {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 7rem);
  margin-inline: auto;
  object-fit: contain;
}

.record-photo-preview {
  position: relative;
  width: min(32rem, calc(100vw - 3.125rem), calc((100dvh - 7rem) * 230 / 219));
  aspect-ratio: 230 / 219;
  overflow: hidden;
  margin-inline: auto;
}

.record-photo-preview > img {
  position: absolute;
  top: calc(-345 / 219 * 100%);
  left: calc(-429 / 230 * 100%);
  width: var(--artwork-width);
  max-width: none;
}

.record-photo-full[hidden],
.record-photo-preview[hidden] {
  display: none;
}
