/* Tandem — page transition stage styles */

#tx-stage {
  position: fixed;
  inset: 0;
  z-index: 99998;
  pointer-events: none;
  overflow: hidden;
}
#tx-stage.idle > * {
  visibility: hidden;
}

/* Curtain — used by curtain (slides X) and mask (slides Y) */
#tx-stage .tx-curtain {
  position: absolute;
  inset: 0;
  background: #EC2D01;
  transform: translateX(-101%);
  will-change: transform;
}

/* Stack — three vertical bars staggered */
#tx-stage .tx-stack {
  position: absolute;
  inset: 0;
  display: flex;
}
#tx-stage .tx-stack > span {
  flex: 1;
  background: #0E0E0C;
  transform: translateY(101%);
  will-change: transform;
}

/* Cloth — single curved SVG path covering screen */
#tx-stage .tx-cloth {
  position: absolute;
  inset: 0;
  color: #0E0E0C;
}
#tx-stage .tx-cloth svg {
  width: 100%;
  height: 100%;
  display: block;
}
#tx-stage .tx-cloth-path {
  transition: d 0.6s cubic-bezier(.6,0,.2,1);
}

/* Cut — flat ink veil with subtle grain */
#tx-stage .tx-cut {
  position: absolute;
  inset: 0;
  background: #0E0E0C;
  opacity: 0;
}
#tx-stage .tx-cut-grain {
  position: absolute;
  inset: -10%;
  opacity: 0.18;
  mix-blend-mode: overlay;
  background-image:
    radial-gradient(rgba(255,255,255,0.6) 1px, transparent 1.2px),
    radial-gradient(rgba(255,255,255,0.4) 0.6px, transparent 1px);
  background-size: 3px 3px, 5px 5px;
  background-position: 0 0, 1px 2px;
  animation: tx-grain 0.6s steps(6) infinite;
}
@keyframes tx-grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-2%, 1%); }
  40%  { transform: translate(1%, -2%); }
  60%  { transform: translate(-1%, 2%); }
  80%  { transform: translate(2%, -1%); }
  100% { transform: translate(0, 0); }
}

/* Page label readout — appears during transition */
#tx-stage .tx-readout {
  position: absolute;
  bottom: 36px;
  left: 36px;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #F4F1EA;
  mix-blend-mode: difference;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.4s cubic-bezier(.2,.7,.2,1);
  z-index: 2;
}
#tx-stage .tx-readout.show {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.15s;
}
#tx-stage .tx-readout-num { font-weight: 500; }
#tx-stage .tx-readout-sep { opacity: 0.5; }
#tx-stage .tx-readout-name { font-weight: 500; }
#tx-stage .tx-readout-arr { margin-left: 8px; opacity: 0.7; }

/* When the stage is "live" (mid-transition) it should never block clicks
   on the destination page — but visually it covers everything. */
#tx-stage:not(.idle) {
  pointer-events: none;
}

/* Hero line mask wrapper — set by JS, but predefine for first paint
   to prevent flash of un-masked text on transitioned navigation. */
.hero .display-xxl .hero-line,
.hero .display-xl .hero-line {
  display: block;
  overflow: hidden;
}

/* ---------- Modal/overlay system ---------- */
[data-modal] {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
[data-modal].open {
  display: flex;
  animation: tx-modal-bg 0.4s ease forwards;
}
@keyframes tx-modal-bg {
  from { background: rgba(14,14,12,0); }
  to   { background: rgba(14,14,12,0.72); }
}
[data-modal-content] {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  max-width: min(720px, 92vw);
  width: 100%;
  border-radius: 18px;
  padding: 48px;
  box-shadow: 0 30px 90px -20px rgba(0,0,0,0.45);
  transform: translateY(40px) scale(0.96);
  opacity: 0;
  animation: tx-modal-in 0.6s cubic-bezier(.2,.7,.2,1) 0.08s forwards;
}
@keyframes tx-modal-in {
  to { transform: translateY(0) scale(1); opacity: 1; }
}
[data-modal-close] {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: none;
  font-size: 18px;
}

@media (prefers-reduced-motion: reduce) {
  #tx-stage * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .hero .display-xxl .hero-line,
  .hero .display-xl .hero-line { overflow: visible; }
}
