.lm-entrance {
  display: none;
}

html.lm-intro-active {
  overflow: hidden;
}

html.lm-intro-active .lm-entrance {
  --lm-intro-duration: 4700ms;
  --lm-book-width: clamp(120px, min(34vw, 34svh), 265px);
  display: grid;
  position: fixed;
  inset: 0;
  z-index: 2147483100;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
  background: #19282b;
}

.lm-entrance-scene {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 50% 45%, #182e2a12 10%, #111a1de0 100%),
    linear-gradient(180deg, #07171997 0%, #07171925 36%, #07171949 68%, #071719ab 100%),
    url('/assets/images/zurich-intro-v1.webp') center 56% / cover no-repeat;
}

.lm-entrance-brand {
  position: absolute;
  top: clamp(18px, 6dvh, 58px);
  left: 50%;
  z-index: 3;
  width: max-content;
  max-width: calc(100% - 36px);
  margin: 0;
  padding: .75em 1.1em;
  border-top: 1px solid #dfbe76;
  border-bottom: 1px solid #dfbe76;
  background: #10211fe8;
  color: #f5e7c8;
  font: 600 clamp(.73rem, 1.75vw, 1rem)/1.2 Georgia, serif;
  text-align: center;
  letter-spacing: .22em;
  transform: translateX(-50%);
}

.lm-entrance-skip {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 4;
  min-height: 44px;
  max-width: calc(100% - 32px);
  padding: 10px 17px;
  border: 1px solid #dfbe76;
  border-radius: 2px;
  background: #17231f;
  color: #fff4d8;
  box-shadow: 0 4px 20px #0b161968;
  font: 600 .875rem/1.3 system-ui, sans-serif;
  cursor: pointer;
}

.lm-entrance-skip:hover {
  background: #2b392e;
}

.lm-entrance-skip:focus-visible {
  outline: 2px solid #fff6db;
  outline-offset: 4px;
}

.lm-entrance-stage {
  position: relative;
  z-index: 1;
  width: var(--lm-book-width);
  aspect-ratio: 2 / 3;
  perspective: 1250px;
}

.lm-entrance-volume {
  position: absolute;
  inset: 0;
  transform: rotateY(-12deg) scale(.87);
  transform-style: preserve-3d;
}

.lm-entrance-face,
.lm-entrance-turn,
.lm-entrance-cover-face,
.lm-entrance-inside {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
}

.lm-entrance-turn {
  transform-origin: left center;
  transform-style: preserve-3d;
}

.lm-entrance-face,
.lm-entrance-cover-face,
.lm-entrance-inside {
  backface-visibility: hidden;
}

.lm-entrance-face {
  display: flex;
  flex-flow: column;
  align-items: center;
  justify-content: center;
  gap: .9em;
  padding: 12%;
  border: 1px solid #e1d4af;
  border-radius: 1px 3px 3px 1px;
  background:
    linear-gradient(90deg, #b8a17362 0%, transparent 12%, transparent 94%, #bdab8253 100%),
    repeating-linear-gradient(0deg, #9c83510a 0 1px, transparent 1px 4px),
    #fff4d5;
  color: #34291b;
  font: 500 clamp(.65rem, calc(var(--lm-book-width) * .088), 1.38rem)/1.3 Georgia, serif;
  text-align: center;
}

.lm-entrance-page-text {
  max-width: 13ch;
  font-style: italic;
}

.lm-entrance-page-title {
  font-weight: 700;
}

.lm-entrance-page-author {
  color: #6c5330;
  font: 600 .57em/1.35 system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .14em;
}

.lm-entrance-last-page {
  box-shadow: 3px 0 #b5a37b, 6px 0 #e1d4b5, 8px 0 #594421, 11px 16px 30px #0715188b;
}

.lm-entrance-leaf {
  transform: translateZ(2px);
}

.lm-entrance-title-leaf {
  transform: translateZ(4px);
}

.lm-entrance-board {
  transform: translateZ(7px);
}

.lm-entrance-cover-face {
  border-radius: 2px 4px 4px 2px;
  background: #25251d;
  box-shadow: 0 10px 24px #06111684;
}

.lm-entrance-cover-face::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #fff6cf28, #18140c4f 3.6%, transparent 7%);
  content: '';
}

.lm-entrance-book {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.lm-entrance-book:not([src]) {
  visibility: hidden;
}

.lm-entrance-inside {
  border: 5px solid #463318;
  border-radius: 4px 2px 2px 4px;
  background: linear-gradient(90deg, #a88a58, #e0cca2 11%, #efe0bd 86%, #a4834d);
}

.lm-entrance-verso {
  transform: rotateY(180deg);
}

.lm-entrance-grille {
  --lm-bar: clamp(5px, 1.03vw, 13px);
  --lm-bars:
    repeating-linear-gradient(90deg,
      transparent 0 calc(16.67% - var(--lm-bar)),
      #453017 calc(16.67% - var(--lm-bar)),
      #ac7b37 calc(16.67% - .77 * var(--lm-bar)),
      #f4d791 calc(16.67% - .53 * var(--lm-bar)),
      #ac7b37 calc(16.67% - .28 * var(--lm-bar)),
      #483019 16.67%);
  --lm-rails:
    linear-gradient(180deg, #55371d, #e5bc6a 23%, #a16d29 62%, #563918 91%);
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  box-sizing: border-box;
  width: 50%;
  border: 1px solid #b98d49;
  background: var(--lm-bars), linear-gradient(90deg, #402c1640, transparent 62%);
  box-shadow: inset 0 0 28px #39270e52;
  pointer-events: none;
}

.lm-entrance-grille::before,
.lm-entrance-grille::after {
  position: absolute;
  right: 0;
  left: 0;
  height: calc(var(--lm-bar) * .78);
  background: var(--lm-rails);
  box-shadow: 0 1px 3px #31201566;
  content: '';
}

.lm-entrance-grille::before { top: 27%; }
.lm-entrance-grille::after { bottom: 21%; }

.lm-entrance-top {
  left: 0;
  transform-origin: left center;
}

.lm-entrance-bottom {
  right: 0;
  border-left-width: var(--lm-bar);
  border-left-color: #9c6d32;
  transform-origin: right center;
}

.lm-entrance-running .lm-entrance-top {
  animation: lm-intro-door-left var(--lm-intro-duration) both;
}

.lm-entrance-running .lm-entrance-bottom {
  animation: lm-intro-door-right var(--lm-intro-duration) both;
}

.lm-entrance-running .lm-entrance-volume {
  animation: lm-intro-volume var(--lm-intro-duration) both;
}

.lm-entrance-running .lm-entrance-board {
  animation: lm-intro-cover var(--lm-intro-duration) both;
}

.lm-entrance-running .lm-entrance-title-leaf {
  animation: lm-intro-first-leaf var(--lm-intro-duration) both;
}

.lm-entrance-running .lm-entrance-leaf {
  animation: lm-intro-second-leaf var(--lm-intro-duration) both;
}

html.lm-intro-active .lm-entrance-running {
  animation: lm-intro-dissolve var(--lm-intro-duration) both;
}

@keyframes lm-intro-door-left {
  0%, 8% { transform: perspective(1100px) translateX(0) rotateY(0); }
  25% { transform: perspective(1100px) translateX(-36%) rotateY(-60deg); }
  43%, 100% { transform: perspective(1100px) translateX(-101%) rotateY(-77deg); }
}

@keyframes lm-intro-door-right {
  0%, 8% { transform: perspective(1100px) translateX(0) rotateY(0); }
  25% { transform: perspective(1100px) translateX(36%) rotateY(60deg); }
  43%, 100% { transform: perspective(1100px) translateX(101%) rotateY(77deg); }
}

@keyframes lm-intro-volume {
  0%, 16% { transform: rotateY(-12deg) scale(.87); opacity: 1; }
  32% { transform: rotateY(-5deg) scale(1.08); }
  56%, 74% { transform: translateX(53%) rotateX(9deg) scale(1.04); opacity: 1; }
  100% { transform: translate(82%, -77vh) rotateX(27deg) rotateZ(18deg) scale(.28); opacity: 0; }
}

@keyframes lm-intro-cover {
  0%, 34% { transform: translateZ(7px) rotateY(0); }
  58%, 100% { transform: translateZ(-4px) rotateY(-177deg); }
}

@keyframes lm-intro-first-leaf {
  0%, 46% { transform: translateZ(4px) rotateY(0); }
  63%, 100% { transform: translateZ(0) rotateY(-174deg); }
}

@keyframes lm-intro-second-leaf {
  0%, 58% { transform: translateZ(2px) rotateY(0); }
  75%, 100% { transform: translateZ(3px) rotateY(-170deg); }
}

@keyframes lm-intro-dissolve {
  0%, 85% { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-width: 600px) {
  html.lm-intro-active .lm-entrance {
    --lm-book-width: clamp(108px, min(38vw, 33svh), 190px);
  }

  .lm-entrance-scene {
    background-position: 58% center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.lm-intro-active { overflow: visible; }
  html.lm-intro-active .lm-entrance { display: none; }
  .lm-entrance, .lm-entrance * { animation: none !important; }
}
