/* === Intro Overlay === */

#intro-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  height: 100vh; /* fallback */
  background: #000;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

@supports (height: 100dvh) {
  #intro-overlay { height: 100dvh; }
}

#intro-overlay.hidden {
  display: none;
}

#intro-content {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#intro-prompt {
  position: absolute;
  bottom: env(safe-area-inset-bottom, 20px);
  bottom: 15%;
  left: 50%;
  transform: translateX(-50%);
  color: #008f11;
  font-family: 'VT323', monospace;
  font-size: 18px;
  letter-spacing: 2px;
  animation: blink 1.5s infinite;
  white-space: nowrap;
  width: 90%;
  text-align: center;
  z-index: 10001;
}

#intro-prompt.hidden {
  display: none;
}

#intro-skip {
  position: absolute;
  bottom: 15%;
  right: 20px;
  color: #008f11;
  font-family: 'VT323', monospace;
  font-size: 18px;
  letter-spacing: 2px;
  cursor: pointer;
  z-index: 10003;
  padding: 8px 16px;
  border: 1px solid #008f11;
  transition: all 0.2s;
}

#intro-skip:hover {
  color: #ffb000;
  border-color: #ffb000;
}

#intro-skip.corner {
  bottom: auto;
  top: 15px;
  right: 15px;
  font-size: 14px;
  border: none;
  padding: 4px 8px;
  opacity: 0.6;
}

#intro-skip.corner:hover {
  opacity: 1;
}

#intro-open-device {
  position: absolute;
  bottom: 15%;
  left: 50%;
  transform: translateX(-50%);
  color: #00ff41;
  font-family: 'VT323', monospace;
  font-size: 20px;
  letter-spacing: 2px;
  cursor: pointer;
  padding: 10px 24px;
  border: 1px solid #00ff41;
  z-index: 10003;
  animation: blink 2s infinite;
  transition: all 0.2s;
  white-space: nowrap;
}

#intro-open-device:hover {
  color: #ffb000;
  border-color: #ffb000;
  animation: none;
  text-shadow: 0 0 10px rgba(255, 176, 0, 0.5);
}

/* === Document Cards === */

.intro-doc {
  position: absolute;
  width: 320px;
  padding: 25px 30px;
  background: #1a1508;
  border: 1px solid #3a2f1a;
  font-family: 'VT323', monospace;
  opacity: 0;
  transform: rotate(0deg) scale(0.8);
  transition: none;
  box-shadow: 0 0 30px rgba(0,0,0,0.8);
}

.intro-doc.visible {
  animation: docAppear 1.5s ease-out forwards;
}

.intro-doc.fade-out {
  animation: docFade 0.8s ease-in forwards;
}

@keyframes docAppear {
  0% { opacity: 0; transform: rotate(var(--rot, 0deg)) scale(0.8) translateY(20px); }
  100% { opacity: 1; transform: rotate(var(--rot, 0deg)) scale(1) translateY(0); }
}

@keyframes docFade {
  0% { opacity: 1; }
  100% { opacity: 0; transform: scale(0.9) translateY(-10px); }
}

/* Document styling - aged paper look */
.intro-doc::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 28px,
    rgba(58, 47, 26, 0.3) 28px,
    rgba(58, 47, 26, 0.3) 29px
  );
  pointer-events: none;
}

.doc-header {
  font-size: 12px;
  color: #5a4a2a;
  margin-bottom: 10px;
  letter-spacing: 2px;
}

.doc-stamp {
  display: inline-block;
  padding: 3px 12px;
  border: 2px solid #ff0000;
  color: #ff0000;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 4px;
  transform: rotate(-5deg);
  margin-bottom: 12px;
}

.doc-stamp.classified {
  border-color: #ffb000;
  color: #ffb000;
}

.doc-body {
  font-size: 16px;
  color: #8a7a5a;
  line-height: 1.6;
}

.doc-redacted {
  background: #5a4a2a;
  color: transparent;
  padding: 0 4px;
  user-select: none;
}

.doc-keyword {
  color: #00ff41;
  font-weight: bold;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.5);
}

.doc-crossed {
  text-decoration: line-through;
  color: #5a4a2a;
}

/* === Static/Noise Effect === */

.intro-static {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10002;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  animation: staticShift 0.1s steps(5) infinite;
}

@keyframes staticShift {
  0% { background-position: 0 0; }
  20% { background-position: -50px -30px; }
  40% { background-position: 30px -50px; }
  60% { background-position: -30px 50px; }
  80% { background-position: 50px 30px; }
  100% { background-position: 0 0; }
}

/* === Boot Sequence === */

.intro-boot {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

.intro-boot.visible {
  animation: fadeIn 0.5s ease-in forwards;
}

.boot-text {
  color: #00ff41;
  font-family: 'VT323', monospace;
  font-size: 18px;
  text-align: center;
  line-height: 2;
}

.boot-text .boot-line {
  opacity: 0;
  animation: fadeIn 0.3s ease-in forwards;
}

/* === Glitch Transition === */

.intro-glitch {
  animation: introGlitch 0.5s steps(3) forwards;
}

@keyframes introGlitch {
  0% { transform: translate(0); filter: none; }
  20% { transform: translate(-5px, 3px); filter: hue-rotate(90deg); }
  40% { transform: translate(3px, -5px); filter: hue-rotate(180deg); }
  60% { transform: translate(-3px, -2px); filter: hue-rotate(270deg); }
  80% { transform: translate(5px, 2px); filter: hue-rotate(360deg); }
  100% { transform: translate(0); opacity: 0; }
}

/* === Responsive === */

@media (max-width: 400px) {
  .intro-doc { width: calc(100vw - 60px); padding: 18px 20px; }
  .doc-stamp { font-size: 14px; letter-spacing: 2px; }
  .doc-body { font-size: 14px; }
  .doc-header { font-size: 10px; }
  #intro-prompt { font-size: 16px; letter-spacing: 1px; bottom: 40px; }
  .boot-text { font-size: 15px; padding: 0 15px; }
  #intro-open-device { font-size: 18px; letter-spacing: 1px; padding: 8px 16px; bottom: 50px; }
  #intro-skip { font-size: 14px; padding: 6px 12px; }
}

@media (min-width: 361px) and (max-width: 480px) {
  .intro-doc { width: 280px; }
}

@media (min-width: 769px) {
  .intro-doc { width: 400px; padding: 30px 35px; }
  .doc-stamp { font-size: 22px; }
  .doc-body { font-size: 18px; }
  .boot-text { font-size: 22px; }
  #intro-open-device { font-size: 28px; }
}
