/**
 * Menu Gate — "the closed case file"
 * ------------------------------------------------------------
 * The first screen. It stands over everything and waits for the
 * first contact, because the browser will not give us sound until
 * the player has touched the page. So we ask them to open a file.
 * The click unlocks audio, starts the theme, and the cover flies
 * away — the studio logo comes up behind it with the music already
 * under it, and the menu plays its own openFile fresh after that.
 *
 * House rules kept:
 *   - keyframes animate transform / opacity only (compositor-safe)
 *   - no animated box-shadow / backdrop-filter
 *   - file:// compatible, zero external resources
 */

/* While the file is shut, the menu does not exist for the renderer,
   so its whole cascade (openFile, slideIn 0.9–1.5s, the stains, the
   cards) starts from zero when the case is finally opened — not
   behind the curtain. */
body.pre-gate #menuSection {
  display: none !important;
}

/* ---------- The ground ---------- */
#menuGate {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #3A3238;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Courier New', Courier, monospace;
  color: #5F5449;
  cursor: pointer;
  perspective: 1200px;
  user-select: none;
  -webkit-user-select: none;
}

/* The same noise as the menu's paper-texture — the gate's ground
   and the menu's ground are one material. */
#menuGate::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('data:image/svg+xml,<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8"/></filter><rect width="100" height="100" filter="url(%23noise)" opacity="0.1"/></svg>');
  opacity: 0.3;
  pointer-events: none;
}

/* A light vignette. Static — never animated. */
#menuGate::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center,
    rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.35) 100%);
  pointer-events: none;
}

/* ---------- The shut folder ---------- */
.gate-folder {
  position: relative;
  width: min(560px, 86vw);
  padding: 3.2rem 2.4rem 4.2rem;
  background: #E3DCCB;                        /* a shade darker than the
                                                 opened file in the menu */
  border: 1px solid #8E7F7F;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); /* static, not in keyframes */
  transform-origin: top center;
  animation: gateFolderIn 0.7s ease-out forwards;
  z-index: 1;
}

@keyframes gateFolderIn {
  from { transform: rotateX(-22deg) translateY(60px); opacity: 0; }
  to   { transform: rotateX(0)      translateY(0);    opacity: 1; }
}

/* The tab */
.gate-folder::before {
  content: '';
  position: absolute;
  top: -18px;
  left: 28px;
  width: 160px;
  height: 18px;
  background: #E3DCCB;
  border: 1px solid #8E7F7F;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}

/* The string clasp on the right — two eyelets and a thread */
.gate-clasp {
  position: absolute;
  top: 50%;
  right: -7px;
  width: 14px;
  height: 14px;
  border: 2px solid #8E7F7F;
  border-radius: 50%;
  background: #E3DCCB;
}
.gate-clasp::before {
  content: '';
  position: absolute;
  top: -46px;
  left: 4px;
  width: 2px;
  height: 44px;
  background: #8E7F7F;
  transform: rotate(14deg);
  transform-origin: bottom center;
}
.gate-clasp::after {
  content: '';
  position: absolute;
  top: -56px;
  left: -1px;
  width: 12px;
  height: 12px;
  border: 2px solid #8E7F7F;
  border-radius: 50%;
  background: #E3DCCB;
}

/* ---------- What's written on the cover ---------- */
.gate-eyebrow {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #8E7F7F;
  text-align: center;
  margin-bottom: 1.6rem;
}

.gate-caseno {
  font-size: 13px;
  color: #5F5449;
  text-align: center;
  margin-bottom: 2.2rem;
}
.gate-caseno .gate-redact {
  background: #3A3238;
  color: #3A3238;            /* the censor got here first */
  padding: 0 6px;
}

/* The stamp — the same language as classification-label in the menu */
.gate-stamp {
  position: absolute;
  top: 18px;
  right: 22px;          /* inside the folder's edge (2026-10-03 — it hung 18px past it) */
  transform: rotate(8deg);
  border: 3px double #8B0000;
  color: #8B0000;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 3px;
  text-transform: uppercase;
  opacity: 0.85;
}

/* The invitation. Blinks like the typewriter caret in the menu. */
.gate-prompt {
  position: absolute;
  bottom: 1.2rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 2px;
  color: #8E7F7F;
  opacity: 0;
  animation: gatePromptIn 0.6s ease-out 0.9s forwards;
}
.gate-prompt::after {
  content: '▮';
  margin-left: 4px;
  color: #8B0000;
  animation: gateCursor 1s step-end infinite;
}
@keyframes gatePromptIn { to { opacity: 1; } }
@keyframes gateCursor {
  0%, 50%   { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* The coffee stain follows us everywhere. It's one house. */
.gate-stain {
  position: absolute;
  width: 90px;
  height: 90px;
  bottom: -26px;
  left: -18px;
  border-radius: 50%;
  background: #8E7F7F;
  opacity: 0.08;
  transform: rotate(20deg);
  pointer-events: none;
}

/* ---------- What waits under the cover ---------- */
/* The gate's own ground is the menu's #3A3238. But when the studio
   logo is next, the thing under the cover is BLACK — so we bring the
   black up as the cover lifts, and the splash mounts into a dark that
   is already there. Opacity only; no colour ever snaps. */
.gate-under {
  position: absolute;
  inset: 0;
  background: #000000;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

/* ---------- Opening the case ---------- */
#menuGate.gate-open {
  pointer-events: none;
}
#menuGate.gate-open .gate-folder {
  animation: gateFolderOpen 0.85s cubic-bezier(0.45, 0, 0.2, 1) forwards;
}
@keyframes gateFolderOpen {
  0%   { transform: rotateX(0)     translateY(0);      opacity: 1; }
  100% { transform: rotateX(74deg) translateY(-120px); opacity: 0; }
}

/* Logo next → go dark. The ground does NOT fade out: it darkens and
   holds, and the splash takes over the black without a seam. */
#menuGate.to-logo.gate-open .gate-under {
  animation: gateGoDark 0.75s ease forwards;
}
@keyframes gateGoDark {
  to { opacity: 1; }
}

/* No logo → the menu is under there, already playing its openFile.
   The ground drains off it; both are #3A3238, so there is nothing to
   see but the file opening. */
#menuGate.to-menu.gate-open {
  animation: gateBackdropOut 0.7s ease 0.25s forwards;
}
@keyframes gateBackdropOut {
  to { opacity: 0; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .gate-folder,
  .gate-prompt,
  .gate-prompt::after {
    animation: none;
    opacity: 1;
    transform: none;
  }
  #menuGate.gate-open,
  #menuGate.gate-open .gate-folder {
    animation: none;
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  #menuGate.to-logo.gate-open .gate-under { animation: none; opacity: 1; }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 480px) {
  .gate-folder { padding: 2.4rem 1.4rem 3.6rem; }
  .gate-stamp  { font-size: 12px; right: 12px; }
}
