/* =================================================================
   SECTION 1: THE ATMOSPHERE (Merged Variables)
   ================================================================= */
:root {
  --bg-dark: #050a0f;
  --bg-radial: radial-gradient(circle at top, #1b2b3a, #050a0f);
  --term-glass: rgba(8, 12, 16, 0.92);
  --term-border: #2f4f6f;
  --text-main: #e6f1ff;
  --text-dim: #526f85;
  --highlight: #66b3ff;
  --alert: #ff6b6b;
  --scanline: rgba(18, 16, 16, 0.1);

  --card-dim: #b3b7c4;
  --card-edge: rgba(255,255,255,0.12);
  --foil: linear-gradient(120deg,#ff4d4d,#ffcc33,#33ff99,#33ccff,#9966ff,#ff4dd2);
}

* { box-sizing: border-box; }

body {
  margin: 0; height: 100dvh; width: 100vw;
  background: var(--bg-radial); color: var(--text-main);
  font-family: "Courier New", monospace;
  display: flex; justify-content: center; align-items: center;
  overflow: hidden; position: relative; perspective: 1800px; 
}

body::after {
  content: " "; display: block; position: absolute; inset: 0;
  background: linear-gradient(to bottom, var(--scanline) 50%, rgba(0, 0, 0, 0) 50%);
  background-size: 100% 4px; z-index: 1000; pointer-events: none; opacity: 0.3;
}

/* =================================================================
   SECTION 2: THE BACKGROUND (ASCII Physics)
   ================================================================= */
#ascii-canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0;
  /* Replaced fixed 10px with a fluid min() clamp */
  font-family: 'Consolas', monospace; font-size: min(10px, 1.4vw); line-height: min(10px, 1.4vw);
  white-space: pre; color: #3f6885; font-weight: bold; text-align: center;
  display: flex; justify-content: center; align-items: center;
  opacity: 0.5; pointer-events: none;
  transition: all 4s cubic-bezier(0.25, 1, 0.5, 1);
}

.state-locked #ascii-canvas { color: var(--highlight); opacity: 0.15; filter: blur(1px); }
.state-panic #ascii-canvas { color: var(--alert); opacity: 0.3; animation: shake 0.5s infinite; }

@keyframes shake {
  0% { transform: translate(1px, 1px) rotate(0deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  100% { transform: translate(1px, -2px) rotate(-1deg); }
}

/* =================================================================
   SECTION 3: THE TERMINAL (Foreground Interface)
   ================================================================= */
.terminal-container {
  width: 90%; max-width: 868px; height: calc(100dvh - 88px); 
  background: var(--term-glass); backdrop-filter: blur(6px);
  border: 1px solid var(--term-border); border-radius: 12px;    
  padding: 25px; box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column;
  transition: opacity 1s ease, transform 1s ease; margin: 0; 
}

.terminal-container.dormant { opacity: 0; pointer-events: none; transform: scale(0.95); }

.terminal-log {
  flex: 1; overflow-y: auto; white-space: pre-wrap; line-height: 1.6;
  padding-right: 10px; display: flex; flex-direction: column; font-size: 14px;
  
  /* THE WRAPPER ENGINE: Tells children to measure against this box, not the screen */
  container-type: inline-size; 
}
.terminal-log::-webkit-scrollbar { width: 6px; }
.terminal-log::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }
.terminal-log::-webkit-scrollbar-thumb { background: var(--term-border); border-radius: 3px; }

.terminal-msg { max-width: 95%; padding: 4px 8px; margin: 6px 0; word-wrap: break-word; }
.msg-sys-boot { color: var(--text-dim); font-size: 12px; margin: 2px 0; }
.msg-sys-err  { color: var(--alert); text-shadow: 0 0 8px rgba(255, 107, 107, 0.4); }
.msg-sys-main { 
  border-left: 2px solid var(--highlight); padding-left: 12px; 
  color: #bde0ff; text-shadow: 0 0 5px rgba(102, 179, 255, 0.3);
  margin-top: 15px; margin-bottom: 15px;
}
.msg-user { 
  border-right: 2px solid #9fd4ff; padding-right: 12px; align-self: flex-end; 
  text-align: right; margin-left: auto; color: #ffffff;
}

.terminal-input-row { margin-top: 20px; position: relative; opacity: 0; transition: opacity 0.5s ease; }
.terminal-input-row.visible { opacity: 1; }

.terminal-input {
  width: 100%; padding: 12px 14px;
  background: rgba(10, 15, 20, 0.8); border: 1px solid var(--term-border);
  border-left: 3px solid var(--term-border); color: var(--text-main);
  border-radius: 0; font-size: 15px; transition: all 0.3s ease;
}
.terminal-input:focus {
  outline: none; border-color: var(--highlight); border-left-color: var(--highlight);
  box-shadow: -5px 0 15px rgba(102, 179, 255, 0.15);
}

/* =================================================================
   SECTION 4: THE ARTIFACT CARD (OmniCard Integration)
   ================================================================= */
#artifact-wrapper {
  /* Define true genetic dimensions */
  --card-base-w: 320px;
  --card-base-h: 460px;
  --card-scale: 1.15; /* Dramatic terminal scale */

  width: calc(var(--card-base-w) * var(--card-scale));
  height: calc(var(--card-base-h) * var(--card-scale));

  position: fixed; 
  top: -800px; 
  left: 50%; 
  transform: translateX(-50%);
  z-index: 100; 
  pointer-events: none; 
  transition: top 3.5s cubic-bezier(0.19, 1, 0.22, 1);
}

#artifact-wrapper.descend { 
  top: 50%; 
  /* Automatically centers perfectly based on the math */
  margin-top: calc((var(--card-base-h) * var(--card-scale)) / -2); 
  pointer-events: auto; 
}

#artifact-wrapper .omni-card {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0 !important;
  transform-origin: top left !important;
  transform: scale(var(--card-scale)) !important;
}

/* =================================================================
   SECTION 5: TERMINAL VOLTAGE & CRT ATMOSPHERE
   ================================================================= */

/* 1. CRT Overlays */
.crt-shell { position: fixed; inset: 0; pointer-events: none; z-index: 99; overflow: hidden; }

.scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.2) 2px, rgba(0,0,0,0.2) 4px);
  animation: scanShift 10s linear infinite;
}
@keyframes scanShift { from { background-position: 0 0; } to { background-position: 0 100px; } }

.vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.7) 100%);
}

.flicker {
  position: absolute; inset: 0; background: rgba(102, 179, 255, 0.02);
  animation: crt-flicker 0.15s infinite;
}

@keyframes crt-flicker {
  0% { opacity: 1; } 92% { opacity: 1; } 93% { opacity: 0.5; } 
  95% { opacity: 1; } 97% { opacity: 0.8; } 100% { opacity: 1; }
}

/* 2. Ghost & Terminal Styling */
.terminal-msg.msg-sys-ascii {
  color: var(--highlight); 
  
  /* The standard desktop size you currently have */
  font-size: 13px; 
  
  line-height: 1.1; 
  white-space: pre; 
  margin: 0; 
  padding: 0 8px; 
  text-shadow: 0 0 8px rgba(102, 179, 255, 0.4);
}

/* Add this to the very bottom of landing.css */
@media (max-width: 480px) {
  .terminal-msg.msg-sys-ascii {
    /* Shrinks dynamically on mobile to prevent breaking the terminal bounds */
    font-size: 2.2vw; 
  }
}

/* Add a 20px gap ONLY to the final line of the ASCII logo to separate it from the boot text */
.terminal-msg.msg-sys-ascii:nth-of-type(6) {
  margin-bottom: 20px;
}

/* 3. Input Fix (Restoring flex layout from monolith) */
.terminal-input-row { 
  margin-top: 20px; position: relative; 
  opacity: 0; transition: opacity 0.5s ease; 
  display: flex; align-items: center;
}
.terminal-input-row.visible { opacity: 1; }

/* =================================================================
   SECTION 6: THE OVERLAY & CURSOR (Restoring Stacking Order)
   ================================================================= */
.terminal-overlay {
    position: absolute; 
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200; /* Force it above the terminal container */
    color: var(--highlight);
    text-shadow: 0 0 10px rgba(102, 179, 255, 0.5);
    cursor: pointer;
    transition: opacity 0.5s ease;
}

.terminal-overlay.state-fade-out {
    opacity: 0;
    pointer-events: none;
}

.cursor-blink {
    animation: blink 4s step-end infinite;
}

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