/* =========================================================
   SECRET LAYER — hidden terminal + recovered artifact
   Purely additive. Nothing here touches the existing world.
   ========================================================= */

/* --- the discovery: a small terminal-style access point, low right --- */
#sigil {
  position: fixed;
  right: 3.2vmin;
  bottom: 3.4vmin;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid rgba(178, 140, 255, 0.16);
  background: linear-gradient(rgba(12, 8, 22, 0.32), rgba(6, 4, 12, 0.42));
  cursor: none;
  z-index: 40;
  font-family: "Jost", system-ui, sans-serif;
  font-size: 8.5px;
  font-weight: 200;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(226, 216, 255, 0.42);
  opacity: 0;
  animation:
    sigilReveal 6s var(--ease-soft, ease) 7s forwards,
    sigilBreathe 7.5s ease-in-out 13s infinite;
  transition:
    color 0.9s ease,
    border-color 0.9s ease,
    box-shadow 0.9s ease,
    transform 0.5s ease;
  -webkit-tap-highlight-color: transparent;
}

@keyframes sigilReveal {
  to {
    opacity: 0.6;
  }
}

@keyframes sigilBreathe {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.74;
  }
}

.sigil__b {
  color: rgba(178, 140, 255, 0.5);
}

.sigil__dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(210, 180, 255, 0.85);
  box-shadow: 0 0 8px 2px rgba(150, 110, 235, 0.4);
  animation: sigilPulse 3.4s ease-in-out infinite;
}

@keyframes sigilPulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

#sigil:hover,
#sigil:focus-visible {
  outline: none;
  color: rgba(240, 234, 255, 0.9);
  border-color: rgba(178, 140, 255, 0.42);
  box-shadow:
    0 0 22px rgba(130, 90, 210, 0.22),
    inset 0 0 16px rgba(130, 90, 210, 0.12);
  animation-play-state: paused;
  opacity: 1;
}

#sigil:hover .sigil__t {
  animation: sigilJitter 0.45s steps(2) infinite;
}

@keyframes sigilJitter {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(0.6px) skewX(-4deg);
  }
}

/* --- the clue: an acrostic that surfaces only for the patient --- */
#whisper {
  position: fixed;
  left: 4vmin;
  top: 50%;
  transform: translateY(-50%);
  z-index: 35;
  display: grid;
  gap: 7px;
  font-family: "Jost", system-ui, sans-serif;
  font-size: 9px;
  font-weight: 200;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(226, 216, 255, 0.5);
  opacity: 0;
  pointer-events: none;
  filter: blur(2px);
  transition:
    opacity 2.6s ease,
    filter 2.6s ease;
}

#whisper.is-on {
  opacity: 0.42;
  filter: blur(0.2px);
}

#whisper span:first-letter {
  color: rgba(200, 168, 255, 0.95);
}

/* --- custom cursor: a small analog ring --- */
#cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 1px solid rgba(200, 170, 255, 0.4);
  border-radius: 50%;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  box-shadow:
    0 0 12px rgba(140, 100, 225, 0.22),
    inset 0 0 8px rgba(140, 100, 225, 0.12);
  transition:
    opacity 0.6s ease,
    width 0.35s ease,
    height 0.35s ease,
    margin 0.35s ease,
    border-color 0.4s ease;
  mix-blend-mode: screen;
}

#cursor.is-on {
  opacity: 1;
}

#cursor.is-hot {
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-color: rgba(214, 190, 255, 0.75);
}

#cursor i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 2px;
  margin: -1px 0 0 -1px;
  border-radius: 50%;
  background: rgba(236, 230, 255, 0.85);
  animation: cursorFlick 2.6s steps(2) infinite;
}

@keyframes cursorFlick {
  0%,
  92%,
  100% {
    opacity: 0.9;
  }
  94% {
    opacity: 0.35;
  }
}

/* --- overlay: the world stays visible behind it --- */
#secret {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 50%, rgba(4, 4, 4, 0.42), rgba(4, 4, 4, 0.78));
  transition: opacity 1.1s ease;
}

#secret.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* --- terminal --- */
#terminal {
  width: min(78vw, 320px);
  padding: 22px 20px 18px;
  background: linear-gradient(rgba(9, 6, 16, 0.9), rgba(6, 4, 11, 0.94));
  border: 1px solid rgba(178, 140, 255, 0.28);
  box-shadow:
    0 0 0 1px rgba(4, 4, 4, 0.6),
    0 0 42px rgba(120, 80, 200, 0.14),
    inset 0 0 30px rgba(120, 80, 200, 0.07);
  font-family: "Jost", system-ui, sans-serif;
  transform: translateY(6px);
  transition: transform 1.2s var(--ease-soft, ease);
}

#secret.is-open #terminal {
  transform: translateY(0);
}

#terminal p {
  margin: 0 0 14px;
  font-size: 10px;
  font-weight: 200;
  letter-spacing: 0.44em;
  text-transform: uppercase;
  color: rgba(226, 216, 255, 0.6);
}

.term-line {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(178, 140, 255, 0.2);
  padding-bottom: 6px;
}

.term-line span {
  font-size: 11px;
  color: rgba(178, 140, 255, 0.75);
  letter-spacing: 0.2em;
}

#pw {
  flex: 1;
  background: none;
  border: 0;
  outline: none;
  color: rgba(238, 232, 255, 0.9);
  font-family: inherit;
  font-size: 12px;
  font-weight: 200;
  letter-spacing: 0.38em;
  caret-color: rgba(178, 140, 255, 0.9);
}

#caret {
  width: 6px;
  height: 12px;
  background: rgba(200, 170, 255, 0.75);
  animation: caretBlink 1.15s steps(1) infinite;
}

@keyframes caretBlink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

#terminal.is-wrong {
  animation: termShake 0.5s ease;
  border-color: rgba(178, 140, 255, 0.5);
}

@keyframes termShake {
  20% {
    transform: translate3d(-2px, 0, 0);
  }
  50% {
    transform: translate3d(2px, 0, 0) skewX(0.6deg);
  }
  80% {
    transform: translate3d(-1px, 0, 0);
  }
}

/* --- the analog transition --- */
#tracking {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  background:
    repeating-linear-gradient(rgba(226, 216, 255, 0.05) 0 1px, rgba(0, 0, 0, 0) 1px 3px),
    linear-gradient(rgba(178, 140, 255, 0.14), rgba(0, 0, 0, 0) 40%);
}

body.is-glitching #tracking {
  animation: trackRoll 1.05s steps(9) 1;
}

body.is-glitching #world {
  animation: worldSlip 1.05s steps(11) 1;
}

@keyframes trackRoll {
  0% {
    opacity: 0.85;
    transform: translateY(-14%);
  }
  40% {
    opacity: 0.5;
  }
  70% {
    opacity: 0.9;
    transform: translateY(9%);
  }
  100% {
    opacity: 0;
    transform: translateY(0);
  }
}

@keyframes worldSlip {
  0%,
  100% {
    filter: none;
  }
  20% {
    filter: brightness(1.25) saturate(1.2);
    transform: translateX(6px);
  }
  45% {
    transform: translateX(-9px);
  }
  60% {
    filter: brightness(1.4);
    transform: translateX(3px);
  }
  85% {
    transform: translateX(-2px);
  }
}

/* --- the recovered window --- */
#artifact {
  position: fixed;
  z-index: 70;
  left: 50%;
  top: 50%;
  width: min(84vw, 306px);
  transform: translate(-50%, -50%) scale(0.985);
  background: rgba(7, 5, 12, 0.96);
  border: 1px solid rgba(178, 140, 255, 0.3);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 22px 60px rgba(0, 0, 0, 0.6),
    0 0 48px rgba(120, 80, 200, 0.12);
  font-family: "Jost", system-ui, sans-serif;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.7s ease,
    transform 0.7s var(--ease-soft, ease);
}

#artifact.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
  animation: winFlicker 7s steps(1) infinite;
}

@keyframes winFlicker {
  0%,
  96%,
  100% {
    opacity: 1;
  }
  97% {
    opacity: 0.82;
  }
  98% {
    opacity: 0.95;
  }
}

.win__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 5px 4px 8px;
  background: linear-gradient(rgba(70, 50, 110, 0.8), rgba(34, 24, 56, 0.9));
  border-bottom: 1px solid rgba(178, 140, 255, 0.22);
}

.win__bar b {
  font-size: 9px;
  font-weight: 300;
  letter-spacing: 0.22em;
  color: rgba(232, 226, 255, 0.8);
}

#pw,
.win__close,
#secret,
#artifact {
  cursor: none;
}

.win__close {
  width: 15px;
  height: 14px;
  line-height: 1;
  font-size: 9px;
  color: rgba(232, 226, 255, 0.85);
  background: rgba(40, 30, 60, 0.9);
  border: 1px solid rgba(178, 140, 255, 0.35);
  cursor: none;
  font-family: inherit;
}

.win__close:hover {
  background: rgba(70, 50, 110, 0.95);
}

.win__body {
  padding: 7px;
}

/* image frame — the recovered VHS still */
.frame {
  position: relative;
  overflow: hidden;
  background: #050408;
  aspect-ratio: 4 / 3;
}

.frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: grayscale(0.28) brightness(0.6) contrast(0.82) saturate(1.15) blur(0.5px)
    sepia(0.08) hue-rotate(-14deg);
  animation: tapeBrightness 5.5s ease-in-out infinite;
}

/* chromatic aberration ghosts */
.frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background: inherit;
  pointer-events: none;
}

.frame__ghost {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.2;
}

.frame__ghost img {
  filter: brightness(0.5) saturate(2.4) hue-rotate(-30deg) blur(1.1px);
  animation: none;
}

.frame__ghost--b {
  opacity: 0.14;
  transform: translateX(-1.5px);
}

.frame__ghost--b img {
  filter: brightness(0.45) saturate(2.6) hue-rotate(150deg) blur(1.3px);
}

.frame__ghost--a {
  transform: translateX(1.5px);
}

/* scanlines + grain + tint */
.frame__scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(rgba(0, 0, 0, 0.32) 0 1px, rgba(0, 0, 0, 0) 1px 3px),
    linear-gradient(rgba(60, 40, 110, 0.3), rgba(10, 14, 40, 0.42));
  mix-blend-mode: multiply;
}

.frame__noise {
  position: absolute;
  inset: -60%;
  pointer-events: none;
  opacity: 0.22;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  animation: grainShift 0.7s steps(3) infinite;
}

/* horizontal tracking tear, passing now and then */
.frame__tear {
  position: absolute;
  left: -10%;
  width: 120%;
  height: 9%;
  pointer-events: none;
  background: linear-gradient(rgba(226, 216, 255, 0.09), rgba(226, 216, 255, 0));
  backdrop-filter: blur(1px) brightness(1.15);
  animation: tear 9s ease-in-out infinite;
}

@keyframes tear {
  0%,
  62% {
    opacity: 0;
    top: 84%;
  }
  66% {
    opacity: 0.9;
    top: 52%;
  }
  70% {
    opacity: 0.5;
    top: 34%;
  }
  74%,
  100% {
    opacity: 0;
    top: 10%;
  }
}

@keyframes tapeBrightness {
  0%,
  100% {
    filter: grayscale(0.28) brightness(0.58) contrast(0.8) saturate(1.15) blur(0.5px) sepia(0.08)
      hue-rotate(-14deg);
  }
  43% {
    filter: grayscale(0.24) brightness(0.68) contrast(0.86) saturate(1.2) blur(0.4px) sepia(0.08)
      hue-rotate(-14deg);
  }
}

.win__meta {
  display: flex;
  justify-content: space-between;
  padding: 8px 2px 2px;
  font-size: 8.5px;
  font-weight: 200;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(200, 186, 240, 0.5);
}
