/* ==========================================================================
   1. GLOBAL RESET & BODY SETUP
   ========================================================================== */
:root {
  --caution: #eaa352;
  --caution-rgb: 234, 163, 82;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: black; /* Fills screen background */
}

/* ==========================================================================
   2. WRAPPER & LAYOUT SETUP
   ========================================================================== */
#wrapper {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  display: flex; /* Flex alignment eliminates layout whitespace gaps */
  flex-direction: column;
  background-color: transparent;
  position: relative;
}

/* ==========================================================================
   2b. FULL-SCREEN CRT / VHS DESKTOP BACKGROUND
   ========================================================================== */
.desktop-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background-color: black;
}

.desktop-bg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: contrast(1.22) saturate(0.72) brightness(0.54) hue-rotate(-8deg);
}

.crt-scanlines,
.crt-vignette,
.crt-vhs {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.crt-scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.28) 3px,
    rgba(0, 0, 0, 0.28) 3px
  );
  background-size: 100% 4px;
  animation: crtScan 0.12s linear infinite;
  opacity: 0.7;
}

.crt-vignette {
  background:
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0.04) 40%, rgba(0, 0, 0, 0.66) 100%),
    linear-gradient(90deg, rgba(255, 0, 70, 0.06), transparent 18%, transparent 82%, rgba(0, 220, 255, 0.06));
  box-shadow: inset 0 0 120px 40px rgba(0, 0, 0, 0.55);
}

.crt-vhs {
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.04) 0%,
    transparent 8%,
    transparent 92%,
    rgba(0, 0, 0, 0.2) 100%
  );
  mix-blend-mode: overlay;
  animation: vhsFlicker 4.5s steps(2, end) infinite;
}

@keyframes crtScan {
  from { background-position: 0 0; }
  to { background-position: 0 4px; }
}

@keyframes vhsFlicker {
  0%, 87%, 100% { opacity: 0.55; }
  88% { opacity: 0.2; }
  90% { opacity: 0.7; }
  92% { opacity: 0.35; }
  94% { opacity: 0.6; }
}

@media (prefers-reduced-motion: reduce) {
  .crt-scanlines,
  .crt-vhs {
    animation: none;
  }
}

/* ==========================================================================
   3. TYPOGRAPHY
   ========================================================================== */
@font-face {
    font-family: 'ibm_3270regular';
    src: url('fonts/3270-regular-webfont.woff2') format('woff2'),
         url('fonts/3270-regular-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

/* ==========================================================================
   4. STRUCTURAL ELEMENTS (Fixed Display & Conflict Rules)
   ========================================================================== */
header, main, footer {
  display: block; /* Native block display removes inline-block margin conflicts */
  margin: 0;
  padding: 0;
  width: 100%;
  text-align: center;
  font-family: 'ibm_3270regular', monospace;
  background-color: transparent;
}

header {
  height: 50px; /* Increased to provide a vertical gap beneath browser frames */
}

main {
  flex: 1; /* Instructs main layout container to fill remaining monitor space */
  padding: 20px 0;
}

footer {
  height: 0px;
}

/* ==========================================================================
   5. DATE & TIME ELEMENTS
   ========================================================================== */
date {
  display: block;
  margin: 20px auto;
  font-family: 'ibm_3270regular', monospace;
  color: white;
  font-size: 28px;
  text-shadow: 0 0 8px black, 1px 1px 2px black;
}

/* ==========================================================================
   6. MEDIA CONTAINERS
   ========================================================================== */
.globe-well {
  margin: 0 auto;
  width: 25%;
  min-width: 300px;
  background: none;
}

.video-container {
  margin: 0 auto;
  display: block;
  width: 100%;
  min-width: 0; 
  background-color: transparent;
}

.video-container video {
  width: 100%;
  height: auto;
  display: block;
  background: transparent;
}

/* ==========================================================================
   7. GRID DESKTOP ICONS (Main Screen Workspace Configuration)
   ========================================================================== */
.folder, .txt-doc {
  display: inline-block; 
  vertical-align: top;
  width: 150px;
  text-align: center;
  cursor: pointer;
  padding: 10px;
  border-radius: 4px;
  font-family: 'ibm_3270regular', monospace;
  margin: 10px;
}

/* Interactive focus / click highlight selections */
.folder:focus, .folder:active, .txt-doc:focus, .txt-doc:active {
  background-color: rgba(255, 255, 255, 0.2);
  outline: 1px dotted rgba(255, 255, 255, 0.5);
}

.folder-icon, .txt-icon {
  font-size: 120px;
  margin-bottom: 5px;
}

/* High-priority hardware graphic mapping layer for complex Unicode characters */
.emoji {
  display: inline-block;
  position: relative;
  z-index: 9999; /* Forces graphic output onto the absolute top layout layer */
  color: initial; 
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
}

.folder-name, .doc-name {
  color: white;
  font-size: 12px;
  text-shadow: 1px 1px 2px black, 0 0 8px black;
  word-break: break-word;
}

/* ==========================================================================
   8. RETRO POPUP WINDOW SYSTEM
   ========================================================================== */
.window-overlay {
  display: none; /* Keeps containers hidden until triggered via DOM events */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7); /* Dims viewport environment backgrounds */
  z-index: 100000; /* Forces open system frames to stack directly ABOVE emojis */
  
  /* Locks application boxes dead center on the user monitor screen */
  justify-content: center;
  align-items: center;
}

.window-box {
  background-color: black;
  border: 2px solid white;
  width: 400px;
  max-width: 90%;
  box-sizing: border-box;
  font-family: 'ibm_3270regular', monospace;
  color: white;
  box-shadow: 0px 0px 15px rgba(255, 255, 255, 0.3);
}

.window-header {
  background-color: white;
  color: black;
  padding: 5px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
}

.close-btn {
  background: none;
  border: none;
  color: black;
  font-size: 20px;
  cursor: pointer;
  font-weight: bold;
  line-height: 1;
}

.close-btn:hover {
  color: red;
}

.window-body {
  padding: 20px;
  text-align: left;
  font-size: 16px;
  line-height: 1.4;
  box-sizing: border-box;
  width: 100%;
}

/* ==========================================================================
   9. RETRO INPUT & FORM LAYOUT STYLES
   ========================================================================== */
.mail-window {
  width: 450px; 
}

.form-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  text-align: left;
}

.form-group label {
  color: white;
  font-family: 'ibm_3270regular', monospace;
  font-size: 14px;
  margin-bottom: 5px;
}

.form-group input {
  background-color: black;
  border: 1px solid white;
  color: var(--caution);
  padding: 8px 10px;
  font-family: 'ibm_3270regular', monospace;
  font-size: 16px;
  outline: none;
}

.form-group input:focus {
  border-color: var(--caution);
  box-shadow: 0 0 5px rgba(var(--caution-rgb), 0.5);
}

.terminal-submit-btn {
  background-color: white;
  color: black;
  border: 2px solid white;
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  font-family: 'ibm_3270regular', monospace;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.terminal-submit-btn:hover {
  background-color: black;
  color: white;
  border-color: white;
}

.terminal-submit-btn:active {
  background-color: #222;
}

/* ==========================================================================
   10. DYNAMIC FILE EXPLORER WINDOW LAYOUT
   ========================================================================== */
.filesystem-window {
  width: 550px !important; /* Slightly wider frame block allocation for paths */
  max-width: 95%;
}

.explorer-toolbar {
  background-color: #111;
  border-bottom: 1px solid white;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 15px;
  text-align: left;
}

#explorer-back-btn {
  background: none;
  border: 1px solid white;
  color: white;
  padding: 2px 8px;
  cursor: pointer;
  font-family: 'ibm_3270regular', monospace;
  font-size: 12px;
}

#explorer-back-btn:hover:not(:disabled) {
  background-color: white;
  color: black;
}

#explorer-back-btn:disabled {
  color: #444;
  border-color: #444;
  cursor: not-allowed;
}

#explorer-path {
  color: var(--caution);
  font-size: 14px;
  word-break: break-all;
}

.explorer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  max-height: 300px;
  overflow-y: auto; /* Activates internal scrolling if a directory overflows */
  padding-top: 5px;
}

.explorer-item {
  width: 90px;
  text-align: center;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
}

.explorer-item:focus {
  background-color: rgba(255, 255, 255, 0.2);
  outline: 1px dotted rgba(255, 255, 255, 0.5);
}

.explorer-icon {
  font-size: 50px;
  margin-bottom: 2px;
}

.explorer-name {
  display: block;
  color: white;
  font-size: 11px;
  word-break: break-all;
}

.explorer-timestamp {
  display: block;
  color: var(--caution);
  font-size: 9px;
  margin-top: 4px;
  line-height: 1.3;
  word-break: break-word;
}

.media-player-window {
  width: 520px;
}

.media-timestamp {
  color: var(--caution);
  font-size: 12px;
  margin: 0 0 12px 0;
  letter-spacing: 0.5px;
}

#media-stage video,
#media-stage audio,
#media-stage img {
  width: 100%;
  display: block;
  background: #000;
}

#media-stage audio {
  background: transparent;
}

/* ==========================================================================
   11. MOBILE RESPONSIVENESS MEDIA QUERIES (Devices under 768px wide)
   ========================================================================== */
@media screen and (max-width: 768px) {
  
  date {
    font-size: 18px;
    margin: 10px auto;
  }

  .globe-well {
    width: 50%;
    min-width: 200px;
  }

  .folder, .txt-doc {
    width: 90px;
    margin: 5px;
    padding: 5px;
  }

  .folder-icon, .txt-icon {
    font-size: 60px;
    margin-bottom: 2px;
  }

  .folder-name, .doc-name {
    font-size: 11px;
  }

  .window-box, .mail-window, .filesystem-window {
    width: 90% !important;
    max-width: 340px;
  }
  
  .window-body {
    padding: 12px;
    font-size: 14px;
  }

  .form-group input {
    padding: 6px;
    font-size: 14px;
  }

  .explorer-icon {
    font-size: 40px;
  }
}

/* ==========================================================================
   12. THEMATIC AGENT BADGE RENDER SYSTEM (Streamlined Text Matrix)
   ========================================================================== */
#form-success-msg {
  width: 100%;
  box-sizing: border-box;
}

.agent-badge {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background-color: #0a0400;
  border: 1px solid var(--caution);
  padding: 15px;
  position: relative;
  font-family: 'ibm_3270regular', monospace;
  color: var(--caution);
  box-shadow: 0 0 20px rgba(var(--caution-rgb), 0.15);
}

/* Branding Header Integration Group */
.badge-brand-header {
  display: flex;
  align-items: center;
  gap: 20px; /* Increased padding gap slightly to compensate for larger image asset */
  border-bottom: 1px solid var(--caution);
  padding-bottom: 12px;
  margin-bottom: 15px;
}

/* Upgraded Static Graphic Logo Sizing Rules */
.badge-mini-logo {
  width: 35px; /* Keeps the PNG icon sized perfectly in line with text rows */
  height: auto;
  display: block;
  flex-shrink: 0;
}


.badge-header-title {
  flex: 1;
  text-align: left;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 1px;
  line-height: 1.2;
}


/* Horizontal alignment rule matching status light to name header */
.header-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* Integrated Pulsing Status LED Node */
.header-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 1px;
  background-color: rgba(var(--caution-rgb), 0.12);
  border: 1px solid var(--caution);
  padding: 2px 6px;
  border-radius: 2px;
}

.status-led {
  width: 6px;
  height: 6px;
  background-color: var(--caution);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px var(--caution);
  animation: ledPulse 1.5s infinite alternate;
}

@keyframes ledPulse {
  0% { opacity: 0.3; box-shadow: 0 0 2px var(--caution); }
  100% { opacity: 1; box-shadow: 0 0 8px var(--caution); }
}

/* Full Width Data Box (Avatar Frame Removed) */
.badge-data-full {
  text-align: left;
  width: 100%;
}

.badge-data-full p {
  margin: 6px 0;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.badge-data-full strong {
  color: rgba(var(--caution-rgb), 0.5);
}

.badge-footer {
  margin-top: 15px;
  padding-top: 8px;
  border-top: 1px solid var(--caution);
  font-size: 10px;
  text-align: center;
  opacity: 0.7;
}

@media screen and (max-width: 768px) {
  .badge-brand-header {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
  .badge-header-title {
    text-align: center;
  }
  .header-status-row {
    justify-content: center;
  }
}

/* Upgraded Vector Logo Bounds (Shrunk from 55px to 35px for clean proportions) */
.badge-logo-vector {
  width: 35px; /* Downsized footprint locks it cleanly inline with text rows */
  height: 35px;
  display: block;
  flex-shrink: 0;
}
