/* Meshi door intro. Everything is scoped under .md-root (and .md-lock on <html>). */

.md-lock { overflow: hidden; overscroll-behavior: none; }

.md-root {
  position: fixed;
  /* top/left/width/height (ne inset): index.js je přepisuje podle
     visualViewport — iOS 26 Safari posouvá position:fixed, když
     visualViewport.offsetTop zůstane > 0. */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  overflow: hidden;
  cursor: grab;
  outline: none;
  touch-action: none;           /* drags and swipes push the door instead of scrolling */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  contain: strict;
}
.md-root.is-dragging { cursor: grabbing; }
.md-root[hidden] { display: none; }

/* dark interior seen through the gap (hover crack, first frames of the opening) */
.md-backdrop { position: absolute; inset: 0; background: #140d09; }

.md-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: opacity 0.4s ease;
}
.md-root.is-loading { background: #140d09; }
.md-root.is-loading .md-canvas { opacity: 0; }
.md-root.is-static .md-canvas { transition: none; }

/* film grain + vignette: one cinematic surface over the scene */
.md-grain {
  position: absolute;
  inset: -50%;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  animation: md-grain 0.9s steps(6) infinite;
}
.md-root::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(12, 7, 4, 0.32) 100%);
}
@keyframes md-grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-7%, 4%); }
  40% { transform: translate(5%, -6%); }
  60% { transform: translate(-3%, 8%); }
  80% { transform: translate(8%, 2%); }
  100% { transform: translate(-5%, -4%); }
}
/* phones and modest devices: a blended full-screen layer costs more than it gives */
@media (pointer: coarse) { .md-grain { display: none; } }
.md-root[data-quality='low'] .md-grain { display: none; }

/* welcome line (options.hint): quiet serif, a hairline between the two languages */
.md-hint {
  position: absolute;
  left: 50%;
  bottom: max(32px, 7vh);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  font: italic 400 15px/1 'EB Garamond', Georgia, serif;
  letter-spacing: 0.14em;
  color: rgba(248, 236, 214, 0.86);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
}
.md-hint [lang='ja'] { font: 400 13px/1 'Shippori Mincho', serif; letter-spacing: 0.32em; }
.md-hint i {
  width: 0;
  height: 1px;
  background: rgba(226, 194, 135, 0.8);
  transition: width 1.4s cubic-bezier(0.22, 1, 0.36, 1) 0.4s;
}
.md-root[data-state='closed'].is-lit .md-hint { opacity: 1; transition-delay: 0.6s; }
.md-root[data-state='closed'].is-lit .md-hint i { width: 42px; }
.md-root[data-state='closed']:focus-visible .md-hint { color: #fff; transition-delay: 0s; }

/* cursor: a small point of warm light; the torch on the paper does the rest (mouse only) */
.md-cursor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
  will-change: transform;
}
.md-cursor::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 240, 214, 0.95);
  box-shadow: 0 0 8px 2px rgba(255, 196, 120, 0.55), 0 0 22px 6px rgba(255, 176, 92, 0.18);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
}
@media (pointer: fine) {
  .md-root.has-cursor { cursor: none; }
  .md-root.has-cursor .md-cursor::before { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  .md-root.has-cursor.is-dragging .md-cursor::before { transform: translate(-50%, -50%) scale(1.8, 0.7); }
}

/* rack focus: the room behind is soft through the first crack, sharp once the door is open */
.md-focus {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  -webkit-backdrop-filter: blur(var(--md-focus, 8px));
  backdrop-filter: blur(var(--md-focus, 8px));
}

/* cinema bars: wide screens with a mouse only; they come in with the light and draw back as it opens */
.md-bar {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  display: none;
  height: max(0px, calc((100vh - 100vw / var(--md-letterbox, 2.1)) / 2));
  background: #050302;
  pointer-events: none;
  transform: scaleY(0);
  transition: transform 1.6s cubic-bezier(0.65, 0, 0.35, 1);
}
.md-bar-top { top: 0; transform-origin: top; }
.md-bar-bottom { bottom: 0; transform-origin: bottom; }
@media (pointer: fine) and (min-aspect-ratio: 16/10) { .md-bar { display: block; } }
.md-root.is-lit .md-bar { transform: scaleY(1); }
.md-root[data-state='opening'] .md-bar { transform: scaleY(0); transition-duration: 1.1s; }

/* sound toggle: three small bars, flat when muted */
.md-sound {
  position: absolute;
  top: max(16px, 2.5vh);
  right: max(16px, 2.5vw);
  z-index: 3;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  width: 36px;
  height: 36px;
  padding: 11px 10px;
  border: 1px solid rgba(226, 194, 135, 0.35);
  border-radius: 50%;
  background: rgba(10, 6, 3, 0.25);
  cursor: pointer;
  opacity: 0;
  transition: opacity 1s ease 0.8s, border-color 0.3s ease;
}
.md-root.is-lit .md-sound { opacity: 1; }
.md-sound:hover, .md-sound:focus-visible { border-color: rgba(226, 194, 135, 0.8); outline: none; }
.md-sound i {
  flex: 1;
  height: 100%;
  background: rgba(240, 222, 190, 0.9);
  transform-origin: bottom;
  animation: md-eq 1.1s ease-in-out infinite alternate;
}
.md-sound i:nth-child(2) { animation-delay: -0.4s; }
.md-sound i:nth-child(3) { animation-delay: -0.8s; }
.md-sound.is-muted i { animation: none; transform: scaleY(0.15); }
@keyframes md-eq { from { transform: scaleY(0.3); } to { transform: scaleY(1); } }
.md-root[data-state='opening'] .md-sound { opacity: 0; transition-delay: 0s; }

@media (prefers-reduced-motion: reduce) {
  .md-grain, .md-sound i { animation: none; }
  .md-bar { display: none; }
}
