body, html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.envelope-container {
  position: relative;
  width: 300px;
  height: 500px;
}

/* perspective for 3D flap folding */
.envelope-container {
  perspective: 1200px;
  perspective-origin: center top;
}

.envelope {
  position: relative;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(0,0,0,0) 40%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.04) 0 2px, rgba(0,0,0,0.02) 2px 4px),
    #D4B67C; /* Kraft paper */
  /* square top corners, slight rounding on bottom corners */
  border-radius: 0 0 4px 4px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.18), inset 0 0 0 1px rgba(0,0,0,0.05);
  /* allow the folded flap to remain visible outside the envelope top */
  overflow: visible;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  z-index: 1;
  transition: transform 1s ease-in-out;
  filter: saturate(0.95);
}

.flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  /* make the flap noticeably shorter so it's not an obvious trapezoid */
  height: 12%;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.08), rgba(255,255,255,0) 40%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.05) 0 3px, rgba(0,0,0,0.03) 3px 6px),
    #c9a86e;
  /* soften the taper so the flap reads more like a short lid than a big trapezoid */
  /* swap long/short edges: make the long edge the top and the short edge the bottom */
  clip-path: polygon(0% 0%, 100% 0%, 96% 100%, 4% 100%);
  /* no rounding on the long/top edge */
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.12);
  /* hinge should be along the top edge so the flap lifts upward */
  transform-origin: top center;
  /* keep 3D transforms visible and ensure the flap sits above the envelope */
  transform-style: preserve-3d;
  /* show the back face (user prefers visible underside) */
  backface-visibility: visible;
  z-index: 4; /* always on top */
  /* create its own compositing layer to avoid subpixel shifts */
  transform: translateZ(0);
  /* very smooth, fluid opening with longer transition */
  transition: transform 600ms cubic-bezier(.2,.9,.2,1), box-shadow 180ms ease-in-out;
  will-change: transform, box-shadow;
  cursor: pointer;
}

/* Slight flap movement on hover */
.flap:hover {
  /* baseline closed hover: gentle, not too sensitive */
  transform: rotateX(-25deg);
  transition: transform 160ms ease-in-out, box-shadow 160ms ease-in-out;
  box-shadow: 0 8px 14px rgba(0,0,0,0.12);
  pointer-events: auto;
}

/* Flap open animation */
.open-flap {
  /* final open angle: keep front face visible */
  transform: rotateX(-140deg) translateZ(2px);
  box-shadow: 0 12px 20px rgba(0,0,0,0.16);
}

/* When flap is already open, hovering should hint closing (rotate toward 0deg) */
.open-flap:hover {
  /* when open, hover should suggest reclosing: tilt toward closed (reduce magnitude) */
  transform: rotateX(-100deg) translateZ(1px);
  box-shadow: 0 8px 14px rgba(0,0,0,0.12);
}

/* When the envelope is open (pulled), make the hover hint subtler so it suggests reclosing
   without looking like a forced undo—reduce angle and shadow while hovered in this state. */
.envelope.pull-envelope .flap:hover {
  /* when envelope fully pulled, hover should be subtle (don't undo too strongly) */
  transform: rotateX(-140deg) translateZ(1px);
  box-shadow: 0 6px 10px rgba(0,0,0,0.08);
  transition: transform 120ms ease-in-out, box-shadow 120ms ease-in-out;
}

/* more obvious hover when the user is in the opening phase */
.envelope.opening .flap:hover {
  /* hover should go further open (more negative angle) to show opening progress */
  transform: rotateX(-170deg) translateZ(12px) !important;
  box-shadow: 0 40px 80px rgba(0,0,0,0.32) !important;
  transition: transform 80ms cubic-bezier(.2,.9,.2,1), box-shadow 80ms ease-in-out !important;
}

/* subtler hover during reclosing phase */
.envelope.reclosing .flap:hover {
  /* slightly stronger hint when reclosing: move noticeably toward closed */
  transform: rotateX(-100deg) translateZ(2px);
  box-shadow: 0 8px 14px rgba(0,0,0,0.10);
  transition: transform 120ms ease-in-out, box-shadow 120ms ease-in-out;
}

@keyframes flapOpen {
  0% { transform: rotateX(0deg); }
  /* rotate so the flap lifts up but doesn't fully flip its front face */
  100% { transform: rotateX(-150deg) translateZ(2px); }
}

.card {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%) translateY(40%) translateZ(-20px);
  width: 80%;
  height: 90%;
  background: #C8AD7F; /* Card color */
  border-radius: 2px;
  z-index: 0;
  opacity: 0;
  transition: transform 1s ease-in-out, opacity 1s ease-in-out;
  overflow: hidden;

  /* Flex layout to pin title at top and center horizontally */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.envelope.reclosing .card {
  transition: transform 600ms ease-in-out, opacity 600ms ease-in-out;
}

.card-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 2px;
  z-index: 1;
}

@media (max-width: 900px) {
  body:not(.home-page) .card-image {
    transform: scale(1.25);
    transform-origin: center;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  .card {
    width: 90%;
    height: 85%;
  }

  .card-handle,
  .card-handle-secondary,
  .card-handle-tertiary,
  .card-handle-quaternary,
  .card-handle-quinary {
    left: 12%;
    right: 12%;
    transform: translateY(-50%) rotate(0deg);
    text-align: left;
    max-width: 76%;
    word-break: break-word;
  }

  .card-handle-secondary { top: 42%; }
  .card-handle-tertiary { top: 50%; }
  .card-handle-quaternary { top: 58%; }
  .card-handle-quinary { top: 66%; }
  .card-handle { top: 78%; font-size: 18px; }
}

.card-handle {
  position: absolute;
  top: 50%;
  left: 24%;
  transform: translate(-50%, -50%) translateX(-24px) rotate(90deg);
  font-family: 'Special Elite', "Courier New", Courier, "Lucida Console", monospace;
  font-size: 20px;
  color: #000;
  z-index: 6;
  opacity: 0;
  transition: opacity 300ms ease-in-out;
  text-align: center;
  pointer-events: none;
}

.card-handle-link {
  pointer-events: auto;
  text-decoration: none;
  color: inherit;
}

.card-category-link {
  pointer-events: auto;
  text-decoration: none;
  color: inherit;
}

/* Category pages */
.category-page {
  margin: 0;
  min-height: 100vh;
  background: #fff;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-family: 'Special Elite', "Courier New", Courier, "Lucida Console", monospace;
}

.category-page::before {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: 120vmax;
  height: 120vmax;
  background: url('big screen page texture.png') center/cover no-repeat;
  transform: translate(-50%, -50%) rotate(-90deg);
  z-index: 0;
}

@media (max-width: 2899px) {
  .category-page::before {
    background: url('small screen page texture.png') center/cover no-repeat;
  }
}

.category-page .page-title {
  position: relative;
  z-index: 1;
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 56px;
  color: #000;
  margin-top: 48px;
  margin-bottom: 48px;
}

@media (max-width: 900px) {
  .category-page .page-title {
    font-size: 40px;
    margin-top: 32px;
    margin-bottom: 40px;
    padding: 0 16px;
    text-align: center;
    max-width: 90vw;
    line-height: 1.1;
    word-break: break-word;
  }
}

@media (max-width: 480px) {
  .category-page .page-title {
    font-size: 32px;
    margin-top: 24px;
    margin-bottom: 32px;
    max-width: 94vw;
  }
}

/* Music page layout */
.music-page {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding-bottom: 48px;
}

.music-page .page-title {
  margin-bottom: 48px;
}

.music-grid {
  position: relative;
  z-index: 1;
  width: min(1400px, 100%);
  padding: 0 48px;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  gap: 48px;
}

.music-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.music-art {
  width: 350px;
  height: 350px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.music-art--placeholder {
  background: transparent;
}

.music-envelope-container {
  width: 230px;
  height: 350px;
}

.music-envelope-container .envelope {
  width: 100%;
  height: 100%;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(0,0,0,0) 40%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.04) 0 2px, rgba(0,0,0,0.02) 2px 4px),
    #C3A26A;
  box-shadow: 0 10px 26px rgba(0,0,0,0.22), inset 0 0 0 1px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.06);
}

.music-envelope-container .flap {
  width: 100%;
  left: 0;
  box-sizing: border-box;
  clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
  border-left: 1px solid rgba(0,0,0,0.06);
  border-right: 1px solid rgba(0,0,0,0.06);
  border-top: 1px solid rgba(0,0,0,0.06);
}

.music-envelope-container .card {
  opacity: 0;
}

.seal-text {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Old Rubber Stamp', 'Cinzel', "Times New Roman", serif;
  font-size: 21px;
  font-weight: normal;
  color: #dc143c;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  z-index: 6;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(0,0,0,0.25);
  padding: 8px 22px 6px;
  border: 4px solid #dc143c;
  border-radius: 8px 10px 9px 12px;
  background:
    radial-gradient(circle at 20% 30%, rgba(220, 20, 60, 0.1), transparent 50%),
    radial-gradient(circle at 75% 70%, rgba(220, 20, 60, 0.12), transparent 52%),
    rgba(220, 20, 60, 0.06);
  box-shadow: 1px 1px 0 rgba(220, 20, 60, 0.35), inset 0 0 0 1px rgba(220, 20, 60, 0.2);
}

.seal-text--flap {
  top: 100%;
  clip-path: inset(0 0 50% 0);
  opacity: 1;
  transition: opacity 200ms ease;
}

.seal-text--body {
  top: 12%;
  clip-path: inset(50% 0 0 0);
}

.music-envelope-container.is-openable .seal-text {
  transform: translate(-50%, -50%) rotate(-3deg) skewX(-1deg);
}

.music-envelope-container:not(.is-openable) .seal-text {
  transform: translate(-50%, -50%) rotate(2deg) skewX(1deg);
}

.music-envelope-container.is-openable .seal-text::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 3px solid rgba(220, 20, 60, 0.6);
  border-radius: 8px 10px 9px 12px;
  filter: blur(1px);
  opacity: 0.55;
  background: repeating-linear-gradient(90deg, rgba(220,20,60,0.25) 0 4px, rgba(220,20,60,0) 4px 14px);
  pointer-events: none;
}

.music-envelope-container .flap {
  cursor: default;
}

.wax-seal {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translate(-50%, -50%);
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: transform 320ms ease, opacity 320ms ease;
}

.wax-text {
  font-family: 'Special Elite', "Courier New", Courier, "Lucida Console", monospace;
  font-size: 20px;
  color: #dc143c;
  letter-spacing: 2px;
  text-transform: uppercase;
  z-index: 1;
  text-shadow: 0 1px 0 rgba(0,0,0,0.15);
}

.music-envelope-container.is-openable:hover .flap {
  transform: rotateX(-140deg) translateZ(2px);
  box-shadow: 0 12px 20px rgba(0,0,0,0.16);
}

.music-envelope-container.is-openable:hover .seal-text--flap {
  opacity: 0;
}

.music-envelope-container:not(.is-openable) .flap:hover {
  transform: rotateX(-8deg);
  box-shadow: 0 6px 10px rgba(0,0,0,0.08);
}

.music-envelope-container.is-openable:hover .wax-seal {
  transform: translate(-50%, -50%) rotate(-18deg) translateY(10px) scale(0.92);
  opacity: 0.25;
}

.music-envelope-container:hover .wax-seal--june {
  transform: translate(-50%, -50%) rotate(-3deg) translateY(1px);
}

.redacted-x {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.redacted-x::before,
.redacted-x::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 140%;
  background: #dc143c;
}

.redacted-x::before {
  transform: rotate(45deg);
}

.redacted-x::after {
  transform: rotate(-45deg);
}

.redacted-label {
  position: relative;
  z-index: 1;
  color: #dc143c;
  font-size: 32px;
  letter-spacing: 2px;
}

.bandcamp-embed {
  width: 100%;
  height: 100%;
  border: 0;
}

.music-links {
  width: 350px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.music-links a {
  flex: 1 1 0;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  color: #000;
  border: 2px solid #dc143c;
  padding: 8px 6px;
  font-size: 15px;
  background: rgba(220, 20, 60, 0.18);
}

.music-links a:hover {
  background: #dc143c;
  color: #fff;
}

.music-links.is-disabled a {
  pointer-events: none;
  opacity: 0.6;
}

.music-links.is-disabled a:hover {
  background: rgba(220, 20, 60, 0.18);
  color: #000;
}


@media (max-width: 1200px) {
  .music-grid {
    gap: 32px;
    justify-content: center;
  }
}

@media (max-width: 1100px) {
  .music-grid {
    flex-wrap: wrap;
  }
}

@media (max-width: 420px) {
  .music-art,
  .music-links {
    width: 300px;
  }

  .music-art {
    height: 300px;
  }

  .music-envelope-container {
    width: 200px;
    height: 300px;
  }
}

.card-handle-quaternary {
  position: absolute;
  top: 50%;
  left: 24%;
  transform: translate(-50%, -50%) translateX(60px) translateY(40px) rotate(90deg);
  font-family: 'Special Elite', "Courier New", Courier, "Lucida Console", monospace;
  font-size: 18px;
  color: #000;
  z-index: 6;
  opacity: 0;
  transition: opacity 300ms ease-in-out;
  text-align: center;
  pointer-events: none;
}

.card-handle-quinary {
  position: absolute;
  top: 50%;
  left: 24%;
  transform: translate(-50%, -50%) translateX(60px) translateY(130px) rotate(90deg);
  font-family: 'Special Elite', "Courier New", Courier, "Lucida Console", monospace;
  font-size: 18px;
  color: #000;
  z-index: 6;
  opacity: 0;
  transition: opacity 300ms ease-in-out;
  text-align: center;
  pointer-events: none;
}

.card-handle-secondary {
  position: absolute;
  top: 50%;
  left: 24%;
  transform: translate(-50%, -50%) translateX(60px) translateY(-140px) rotate(90deg);
  font-family: 'Special Elite', "Courier New", Courier, "Lucida Console", monospace;
  font-size: 18px;
  color: #000;
  z-index: 6;
  opacity: 0;
  transition: opacity 300ms ease-in-out;
  text-align: center;
  pointer-events: none;
}

.card-handle-tertiary {
  position: absolute;
  top: 50%;
  left: 24%;
  transform: translate(-50%, -50%) translateX(60px) translateY(-50px) rotate(90deg);
  font-family: 'Special Elite', "Courier New", Courier, "Lucida Console", monospace;
  font-size: 18px;
  color: #000;
  z-index: 6;
  opacity: 0;
  transition: opacity 300ms ease-in-out;
  text-align: center;
  pointer-events: none;
}


/* Show categories when the card is pulled out (no position jumping) */
.envelope.pull-envelope .card .card-handle,
.envelope.pull-envelope .card .card-handle-secondary,
.envelope.pull-envelope .card .card-handle-tertiary,
.envelope.pull-envelope .card .card-handle-quaternary,
.envelope.pull-envelope .card .card-handle-quinary {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

.envelope.pull-envelope .card .card-category-link {
  pointer-events: auto;
  cursor: pointer;
  display: inline-block;
}

.envelope.pull-envelope .card {
  transform: translateX(-50%) translateY(0) translateZ(20px) translateY(-120%);
  opacity: 1;
  z-index: 5;
}

.envelope.pull-envelope .card.rotated {
  transform: translateX(-50%) translateY(-135%) translateZ(20px) rotateZ(-90deg) scale(1.55);
  transition: transform 800ms ease-in-out;
}

@media (max-width: 900px) {
  .envelope.pull-envelope .card.rotated {
    transform: translateX(-50%) translateY(-120%) translateZ(20px) rotateZ(0deg) scale(1);
  }
}

.pull-envelope {
  transform: translateY(120%);
}

@keyframes envelopeDown {
  0% { transform: translateY(0); }
  100% { transform: translateY(120%); }
}

/* Import Special Elite font */
@import url('https://fonts.googleapis.com/css2?family=Special+Elite&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&display=swap');

@font-face {
  font-family: 'Old Rubber Stamp';
  src: url('Old_Rubber_Stamp.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@supports (-webkit-touch-callout: none) {
  body,
  .category-page,
  .page-title,
  .card-handle,
  .card-handle-secondary,
  .card-handle-tertiary,
  .card-handle-quaternary,
  .card-handle-quinary,
  .music-placeholder {
    font-family: 'Special Elite', Menlo, "Courier New", Courier, "Lucida Console", monospace;
  }
}
