/* ============================================
   Theme keyhole — grow on hover, split on tap
   Footprint matches the E logo (3360 × 3401).
   ============================================ */

.theme-door {
  --theme-door-size: var(--home-mark-size, var(--nav-control-height, 2rem));
  --theme-door-ease: cubic-bezier(0.33, 1, 0.68, 1);
  --theme-door-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Solid glyph — not a page punch-through */
  --theme-door-lock: #FFFCFA;
  box-sizing: border-box;
  display: block;
  height: var(--theme-door-size);
  width: auto;
  aspect-ratio: 3360 / 3401;
  flex-shrink: 0;
  color: inherit;
  line-height: 0;
}

.theme-door__stage {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #ffffff;
}

.theme-door__fill {
  position: absolute;
  inset: 0;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: center center;
  transition: transform 0.55s var(--theme-door-ease);
  pointer-events: none;
  z-index: 1;
}

.theme-door__panel {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50.2%;
  background: currentColor;
  transition: transform 0.5s var(--theme-door-ease);
  will-change: transform;
  z-index: 2;
}

.theme-door__panel--left {
  left: 0;
  transform: translate3d(0, 0, 0);
}

.theme-door__panel--right {
  right: 0;
  transform: translate3d(0, 0, 0);
}

.theme-door__lock {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: 80%;
  height: 94%;
  color: var(--theme-door-lock);
  opacity: 1;
  transform: translate3d(-50%, -50%, 0) scale(1);
  transform-origin: center center;
  transition: transform 0.32s var(--theme-door-ease);
  pointer-events: none;
}

.theme-door__lock svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Dark: solid ink keyhole on the light door — not page-colored */
[data-theme="dark"] .theme-door {
  --theme-door-lock: #1A1410;
}

.home__topbar .theme-door {
  --theme-door-lock: #FFFCFA;
}

[data-theme="dark"] .home__topbar .theme-door {
  --theme-door-lock: #1A1410;
}

/* ——— Hover: only grow the keyhole, doors stay shut ——— */
@media (hover: hover) and (pointer: fine) {
  .home__theme:not(.is-animating):hover .theme-door__lock,
  .nav__theme:not(.is-animating):hover .theme-door__lock {
    transform: translate3d(-50%, -50%, 0) scale(1.22);
  }
}

.home__theme:not(.is-animating):focus-visible .theme-door__lock,
.nav__theme:not(.is-animating):focus-visible .theme-door__lock {
  transform: translate3d(-50%, -50%, 0) scale(1.22);
}

/* ——— Tap: doors open, white, fill, keyhole springs back ——— */

.theme-door__stage.is-open .theme-door__panel--left {
  transform: translate3d(-100%, 0, 0);
  transition-duration: 0.55s;
}

.theme-door__stage.is-open .theme-door__panel--right {
  transform: translate3d(100%, 0, 0);
  transition-duration: 0.55s;
}

.theme-door__stage.is-open .theme-door__lock {
  opacity: 0;
  transform: translate3d(-50%, -50%, 0) scale(0.4);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}

.theme-door__stage.is-filling .theme-door__fill {
  transform: scaleX(1);
}

.theme-door__stage.is-reset .theme-door__panel {
  transition: none;
  transform: translate3d(0, 0, 0);
}

.theme-door__stage.is-reset .theme-door__fill {
  transition: none;
  transform: scaleX(0);
}

.theme-door__stage.is-lock-in .theme-door__lock {
  opacity: 1;
  transform: translate3d(-50%, -50%, 0) scale(1);
  transition:
    opacity 0.18s ease,
    transform 0.58s var(--theme-door-spring);
}

.home__theme:active,
.nav__theme:active,
.home__theme:active .theme-door,
.nav__theme:active .theme-door {
  transform: none;
}

.home__theme:focus-visible,
.nav__theme:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .theme-door__panel,
  .theme-door__lock,
  .theme-door__fill {
    transition: none !important;
  }
}
