html.front-door-active { overflow: hidden; }

.front-door {
  --door-ink: #53372c;
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--door-ink);
  background: #f6e5c8 url("../assets/cotton-paper.svg");
  font-family: Georgia, serif;
}

.front-door::backdrop { background: #f6e5c8; }

.front-door-scene {
  position: relative;
  container-type: size;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: #f4d9ad url("../assets/cotton-paper.svg");
}

.front-door-heading {
  position: absolute;
  z-index: 1;
  top: max(clamp(16px, 3vh, 34px), env(safe-area-inset-top));
  left: 50%;
  width: min(92%, 650px);
  transform: translateX(-50%);
  text-align: center;
  padding: 8px 0 12px;
  pointer-events: none;
  background: radial-gradient(ellipse, #fff1d9ee 20%, #fff0d900 74%);
}

.front-door-heading p {
  margin: 0 0 4px;
  font: 600 clamp(.58rem, 1.5vw, .72rem)/1.35 system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .19em;
}

.front-door-heading h1 {
  margin: 0;
  color: inherit;
  font: italic 500 clamp(1.8rem, 5vw, 4rem)/1.05 Georgia, serif;
}

.front-door-art {
  --painting: url("splash-landscape.jpg");
  --art-ratio: 1.5;
  --art-width: 150cqh;
  --door-left: 37.63%;
  --door-right: 61.98%;
  --door-top: 21.92%;
  --door-bottom: 78.67%;
  --door-mask: polygon(37.63% 78.67%, 37.63% 40.12%, 38.15% 35.42%, 39.32% 30.92%, 41.15% 27.40%, 43.88% 24.27%, 46.88% 22.50%, 49.87% 21.92%, 52.86% 22.50%, 55.99% 24.46%, 58.72% 28.18%, 60.68% 32.49%, 61.59% 37.18%, 61.98% 41.29%, 61.85% 78.67%);
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(var(--art-width), min(100cqw, calc(var(--art-width) * 1.22)));
  aspect-ratio: var(--art-ratio);
  transform: translate(-50%, -50%);
  background: var(--painting) center / 100% 100% no-repeat;
  perspective: 1000px;
}

.front-door-view, .front-door-leaf {
  position: absolute;
  inset: 0;
  clip-path: var(--door-mask);
  visibility: hidden;
}

.front-door-opening .front-door-view, .front-door-opening .front-door-leaf {
  visibility: visible;
}

.front-door-media, .front-door-open {
  position: absolute;
  left: var(--door-left);
  right: calc(100% - var(--door-right));
  top: var(--door-top);
  bottom: calc(100% - var(--door-bottom));
}

.front-door-media { background: #c89470; }
.front-door-view img, .front-door-view video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.front-door-view img:not([src]), .front-door-view video:not(.front-door-playing) { visibility: hidden; }

.front-door-leaf {
  background: var(--painting) center / 100% 100% no-repeat;
  transform-origin: var(--door-right) center;
  pointer-events: none;
}

.front-door-opening .front-door-leaf { animation: front-door-swing .95s ease-in-out both; }

@keyframes front-door-swing {
  70% { opacity: 1; }
  to { transform: rotateY(83deg); opacity: 0; }
}

.front-door-open {
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 48% 48% 3% 3% / 28% 28% 2% 2%;
}

.front-door-open span {
  position: absolute;
  bottom: 13%;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  white-space: nowrap;
  padding: 10px 16px;
  border: 1px solid #b99973;
  border-radius: 46% 39% 42% 33% / 19% 18% 22% 18%;
  background: #fff0d3 url("../assets/cotton-paper.svg");
  box-shadow: 1px 3px 8px #26393f55;
  color: var(--door-ink);
  font: italic 600 clamp(.85rem, 2.6vw, 1.08rem)/1.2 Georgia, serif;
}
.front-door-open:hover span { background-color: #fff8e6; }
.front-door-open:focus-visible span, .front-door-skip:focus-visible, .front-door-replay:focus-visible {
  outline: 3px solid #623b49;
  outline-offset: 4px;
}

.front-door-skip {
  position: absolute;
  z-index: 1;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  border: 1px solid #bc9676;
  border-radius: 18px;
  min-height: 44px;
  padding: 6px 18px;
  background: #fff1da;
  color: var(--door-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  font: 500 .87rem Georgia, serif;
  cursor: pointer;
}

.front-door-opening .front-door-view { cursor: pointer; }
.front-door-petal {
  display: none;
  position: absolute;
  top: 30%;
  left: 43%;
  width: 11px;
  height: 7px;
  border-radius: 75% 15% 65% 30%;
  background: radial-gradient(at 30% 35%, #f5bcab, #c96278);
  opacity: 0;
}
.front-door-opening .front-door-petal { display: block; animation: door-petal 4.5s .25s ease-in-out both; }
.front-door-petal:nth-of-type(2) { left: 52%; animation-delay: .65s; width: 7px; }
.front-door-petal:nth-of-type(3) { left: 57%; animation-delay: 1.1s; background: #edab81; }
@keyframes door-petal {
  18%, 78% { opacity: .68; }
  50% { transform: translate(-16px, 22dvh) rotate(145deg); }
  100% { transform: translate(36px, 57dvh) rotate(380deg); opacity: 0; }
}

.front-door-replay {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.front-door-replay img { display: block; object-fit: contain; }
.hibiki-door-card .front-door-replay { grid-row: span 3; }
@media (max-aspect-ratio: 4/5) {
  .front-door-art {
    --painting: url("splash-portrait.jpg");
    --art-ratio: .666667;
    --art-width: 66.6667cqh;
    --door-left: 31.05%;
    --door-right: 67.77%;
    --door-top: 26.43%;
    --door-bottom: 73.70%;
    --door-mask: polygon(31.05% 73.70%, 31.05% 40.10%, 31.64% 36.33%, 33.20% 32.94%, 35.94% 30.21%, 39.84% 28.12%, 44.73% 26.82%, 49.61% 26.43%, 54.30% 26.82%, 58.98% 28.12%, 63.09% 30.21%, 66.21% 33.20%, 67.38% 36.59%, 67.77% 40.36%, 67.58% 73.70%);
  }
  .front-door-heading { top: max(7%, env(safe-area-inset-top)); }
}

@media (max-aspect-ratio: 3/5) {
  .front-door-art { left: calc(50% + min(27px, 7vw)); }
}

@media (max-height: 460px) and (orientation: landscape) {
  .front-door-heading { top: 6px; }
  .front-door-heading h1 { font-size: 1.5rem; }
  .front-door-skip { bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .front-door-opening .front-door-leaf, .front-door-opening .front-door-petal { display: none; }
}
