/**
 * Peripheral System Styles
 * 
 * Creates a depth effect with peripherals appearing on a desk/table surface
 * alongside the terminal monitor. Peripherals "poke out" from the sides of
 * the CRT, positioned as if on the same desk surface but further away.
 */

/* ============================================
   PERIPHERAL BACKDROP - Background layer
   ============================================ */
.peripheral-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  
  /* Dark ambient background */
  background: linear-gradient(
    180deg,
    #0a0a0f 0%,
    #0d0d14 30%,
    #12121a 60%,
    #0a0a0f 100%
  );
  
  /* Subtle vignette for depth */
  box-shadow: inset 0 0 200px 100px rgba(0, 0, 0, 0.5);
}

/* Scan line overlay for retro feel */
.peripheral-backdrop::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.15) 3px,
    rgba(0, 0, 0, 0.15) 4px
  );
  pointer-events: none;
  animation: backdrop-scan 30s linear infinite;
}

@keyframes backdrop-scan {
  0% { background-position: 0 0; }
  100% { background-position: 0 400px; }
}

/* Ambient light glow from terminal */
.peripheral-backdrop::after {
  content: '';
  position: absolute;
  top: 20%;
  left: 50%;
  width: 80%;
  height: 60%;
  transform: translateX(-50%);
  background: radial-gradient(
    ellipse at center top,
    rgba(0, 255, 100, 0.03) 0%,
    transparent 70%
  );
  pointer-events: none;
}

/* ============================================
   PERIPHERAL BAY - Container for devices
   ============================================ */
#peripheral-bay {
  position: fixed;
  /* Position to the right side of the viewport */
  top: 50%;
  right: 2%;
  transform: translateY(-50%);
  z-index: 5; /* Between backdrop (0) and CRT (10) */
  
  /* Depth scaling - smaller = farther away */
  --peripheral-scale: 0.55;
  
  /* Atmospheric perspective effects - peripherals are "further back" */
  filter: 
    blur(0.4px)
    saturate(0.80)
    brightness(0.55)
    contrast(0.92);
  
  /* Vertical stack for multiple peripherals */
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: flex-end;
  
  /* No background - peripherals sit directly on the "desk" */
  padding: 0;
  
  /* Transition for smooth appearance */
  transition: 
    opacity 0.3s ease,
    filter 0.3s ease;
}

/* Subtle shadow underneath peripheral bay for grounding */
#peripheral-bay::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 120%;
  height: 30px;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.4) 0%,
    transparent 70%
  );
  pointer-events: none;
  z-index: -1;
}

/* Individual peripheral slots */
.peripheral-slot {
  position: relative;
  transform: scale(var(--peripheral-scale, 0.55));
  transform-origin: right center;
  
  /* Add subtle shadow underneath each peripheral */
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
  
  /* Smooth transitions */
  transition: 
    transform 0.3s ease,
    filter 0.2s ease;
}

/* Hover effect - peripheral comes "closer" */
.peripheral-slot:hover {
  --peripheral-scale: 0.6;
  filter: 
    drop-shadow(0 12px 24px rgba(0, 0, 0, 0.6))
    brightness(1.1);
}

/* ============================================
   PRINTER PERIPHERAL - Okidata ML-320
   ============================================ */
.printer-peripheral {
  --printer-body-color: #d8d4c8;
  --printer-accent-color: #2a2a2a;
  --printer-paper-color: #f5f5f0;
  --printer-led-color: #00ff00;
}

.printer-peripheral .printer-body {
  width: 500px;
  background: var(--printer-body-color);
  border-radius: 8px;
  box-shadow: 
    0 4px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* Printer Top Panel */
.printer-peripheral .printer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: linear-gradient(
    180deg,
    #e8e4d8 0%,
    #d0ccc0 100%
  );
  border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.printer-peripheral .printer-logo {
  font-family: 'Arial', sans-serif;
  font-size: 14px;
  font-weight: bold;
  color: #333;
  letter-spacing: 1px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* LED Indicators */
.printer-peripheral .printer-leds {
  display: flex;
  gap: 12px;
}

.printer-peripheral .led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #333;
  box-shadow: 
    inset 0 1px 2px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.15s ease;
}

.printer-peripheral .led.on {
  background: var(--printer-led-color);
  box-shadow: 
    0 0 4px var(--printer-led-color),
    0 0 8px var(--printer-led-color),
    inset 0 -1px 2px rgba(0, 0, 0, 0.3);
}

.printer-peripheral .led.flash {
  animation: led-flash 0.1s ease;
}

@keyframes led-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.printer-peripheral .led-power.on {
  --printer-led-color: #00ff00;
}

.printer-peripheral .led-online.on {
  --printer-led-color: #00cc00;
}

.printer-peripheral .led-paper.on {
  --printer-led-color: #ffcc00;
}

/* Paper Bay */
.printer-peripheral .printer-paper-bay {
  display: flex;
  height: 150px;
  background: #1a1a1a;
  padding: 10px;
  gap: 0;
}

/* Tractor Feed Mechanisms */
.printer-peripheral .tractor-feed {
  width: 30px;
  background: linear-gradient(
    90deg,
    #444 0%,
    #555 50%,
    #444 100%
  );
  border-radius: 4px;
  position: relative;
}

.printer-peripheral .tractor-feed::before {
  content: '';
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 50%;
  width: 12px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(
    0deg,
    #333 0px,
    #333 8px,
    #222 8px,
    #222 16px
  );
  border-radius: 2px;
}

/* Paper Guide and Paper */
.printer-peripheral .paper-guide {
  flex: 1;
  background: #0a0a0a;
  overflow: hidden;
  position: relative;
}

.printer-peripheral .paper {
  position: absolute;
  top: -20px;
  left: 10px;
  right: 10px;
  bottom: -30px;
  background: var(--printer-paper-color);
  box-shadow: 
    0 0 10px rgba(0, 0, 0, 0.5),
    inset 0 0 20px rgba(0, 0, 0, 0.05);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Perforation holes on paper sides */
.printer-peripheral .paper::before,
.printer-peripheral .paper::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12px;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 6px,
    rgba(0, 0, 0, 0.1) 6px,
    rgba(0, 0, 0, 0.1) 8px
  );
}

.printer-peripheral .paper::before {
  left: 0;
}

.printer-peripheral .paper::after {
  right: 0;
}

.printer-peripheral .paper-content {
  padding: 20px 24px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.4;
  color: #111;
  white-space: pre;
  min-height: 100%;
}

/* Print Mechanism */
.printer-peripheral .printer-mechanism {
  height: 30px;
  background: linear-gradient(
    180deg,
    #333 0%,
    #222 100%
  );
  position: relative;
  overflow: hidden;
}

/* Print Head Rail */
.printer-peripheral .print-head-rail {
  position: absolute;
  top: 50%;
  left: 30px;
  right: 30px;
  height: 6px;
  transform: translateY(-50%);
  background: linear-gradient(
    180deg,
    #555 0%,
    #444 50%,
    #333 100%
  );
  border-radius: 3px;
  box-shadow: 
    inset 0 1px 2px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Print Head */
.printer-peripheral .print-head {
  position: absolute;
  top: 50%;
  left: 40px;
  width: 40px;
  height: 20px;
  transform: translateY(-50%);
  background: linear-gradient(
    180deg,
    #666 0%,
    #444 50%,
    #333 100%
  );
  border-radius: 4px;
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.05s linear;
}

/* Print Head Needle Indicator */
.printer-peripheral .print-head::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  width: 8px;
  height: 4px;
  transform: translateX(-50%);
  background: #222;
  border-radius: 0 0 2px 2px;
}

/* Ribbon Cartridge */
.printer-peripheral .ribbon-cartridge {
  position: absolute;
  top: 4px;
  right: 40px;
  width: 60px;
  height: 22px;
  background: #111;
  border-radius: 4px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Printer Bottom */
.printer-peripheral .printer-bottom {
  height: 20px;
  background: linear-gradient(
    180deg,
    #c8c4b8 0%,
    #b8b4a8 100%
  );
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.printer-peripheral .printer-feet {
  display: flex;
  justify-content: space-between;
  padding: 0 40px;
}

.printer-peripheral .printer-feet::before,
.printer-peripheral .printer-feet::after {
  content: '';
  width: 40px;
  height: 8px;
  background: #333;
  border-radius: 0 0 4px 4px;
  margin-top: -1px;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 1400px) {
  #peripheral-bay {
    --peripheral-scale: 0.45;
    right: 1%;
  }
}

@media (max-width: 1200px) {
  #peripheral-bay {
    --peripheral-scale: 0.40;
    right: 0;
  }
}

@media (max-width: 1000px) {
  /* On smaller screens, move peripherals below the CRT */
  #peripheral-bay {
    top: auto;
    bottom: 2%;
    right: 50%;
    transform: translateX(50%);
    flex-direction: row;
    align-items: flex-end;
    --peripheral-scale: 0.35;
  }
  
  .peripheral-slot {
    transform-origin: center bottom;
  }
}

@media (max-width: 768px) {
  #peripheral-bay {
    --peripheral-scale: 0.30;
    gap: 10px;
  }
}

@media (max-width: 600px) {
  #peripheral-bay {
    display: none; /* Hide on mobile */
  }
}

/* ============================================
   CRT MONITOR Z-INDEX FIX
   ============================================ */
.crt-monitor {
  position: relative;
  z-index: 10;
}

/* ============================================
   ANIMATIONS
   ============================================ */

/* Paper feed animation */
@keyframes paper-feed {
  0% { transform: translateY(0); }
  100% { transform: translateY(-16px); }
}

.printer-peripheral.printing .paper-content {
  animation: paper-feed 0.1s ease-out;
}

/* Print head return */
@keyframes carriage-return {
  0% { transform: translateY(-50%) translateX(var(--head-position)); }
  100% { transform: translateY(-50%) translateX(0); }
}
