/* RESET */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Inter", sans-serif;
  background: radial-gradient(circle at top, #020617 0, #000 60%);
  overflow: hidden;
  color: #f9fafb;
}

/* BACKGROUND NOISE */

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.23;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='noStitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

/* LAYOUT */

.desktop {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 3vh 3vw;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* TERMINAL WINDOW */

.terminal-window {
  position: relative;
  width: min(960px, 100%);
  max-height: 85vh;
  background: radial-gradient(circle at top left, #020617 0, #020617 40%, #000 100%);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(18px) saturate(140%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Behind-glass factory silhouette */

.factory-silhouette {
  position: absolute;
  inset: 48px 0 44px 0;
  background-image:
    linear-gradient(
      to right,
      rgba(15, 23, 42, 0.9) 0,
      rgba(15, 23, 42, 0.9) 12%,
      transparent 12%,
      transparent 18%,
      rgba(15, 23, 42, 0.9) 18%,
      rgba(15, 23, 42, 0.9) 24%,
      transparent 24%,
      transparent 30%
    );
  opacity: 0.13;
  pointer-events: none;
  mix-blend-mode: screen;
  animation: beltsMove 8s linear infinite;
  filter: blur(2px);
}

@keyframes beltsMove {
  0% {
    background-position-x: 0;
  }
  100% {
    background-position-x: 200px;
  }
}

/* HEADER (macOS) */

.terminal-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  padding: 8px 14px;
  background: linear-gradient(
    90deg,
    rgba(15, 23, 42, 0.97),
    rgba(30, 64, 175, 0.4)
  );
  border-bottom: 1px solid rgba(148, 163, 184, 0.4);
  font-size: 12px;
  color: #e5e7eb;
}

.traffic-lights {
  display: flex;
  gap: 6px;
  margin-right: 12px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.7);
}

.dot-close {
  background: #ef4444;
}

.dot-min {
  background: #facc15;
}

.dot-max {
  background: #22c55e;
}

.terminal-title {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}

.ca-badge {
  margin-left: auto;
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  white-space: nowrap;
}

/* BODY */

.terminal-body {
  position: relative;
  z-index: 1;
  padding: 18px 18px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 13px;
  color: #e5e7eb;
}

.ascii-factory {
  font-size: 11px;
  line-height: 1.3;
  color: #f97373;
  text-shadow:
    0 0 10px rgba(248, 113, 113, 0.8),
    0 0 28px rgba(248, 113, 113, 0.4);
  white-space: pre;
  margin-bottom: 4px;
}

/* LOG WINDOW */

.log-window {
  background: radial-gradient(circle at top left, #020617 0, #020617 60%, #000 100%);
  border-radius: 10px;
  border: 1px solid rgba(30, 64, 175, 0.6);
  padding: 10px;
  height: 200px;
  overflow-y: auto;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.8);
}

.log-window::-webkit-scrollbar {
  width: 5px;
}

.log-window::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.6);
  border-radius: 999px;
}

/* Log lines */

.log-line {
  margin-bottom: 2px;
  white-space: nowrap;
}

.log-prefix {
  color: #6b7280;
  margin-right: 4px;
}

.log-message {
  color: #e5e7eb;
}

.log-ok .log-message {
  color: #22c55e;
}

.log-warn .log-message {
  color: #facc15;
}

.log-error .log-message {
  color: #fca5a5;
}

/* BELT DISPLAY */

.belt-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #9ca3af;
  margin-top: 4px;
}

.belt-display {
  margin-top: 2px;
  background: radial-gradient(circle at top, #111827 0, #020617 70%);
  border-radius: 10px;
  border: 1px solid rgba(248, 250, 252, 0.08);
  padding: 6px 10px 7px;
  color: #f3f4f6;
  font-size: 11px;
  line-height: 1.35;
  white-space: pre;
  overflow: hidden;
  box-shadow:
    0 0 18px rgba(239, 68, 68, 0.4),
    inset 0 0 0 1px rgba(15, 23, 42, 0.9);
}

/* INPUT ROW */

.input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
}

.prompt {
  color: #22c55e;
}

.typed-command {
  color: #e5e7eb;
  min-height: 1em;
}

.cursor {
  width: 7px;
  height: 14px;
  background: #f9fafb;
  display: inline-block;
  animation: cursorBlink 1s steps(2, start) infinite;
}

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

/* CONTROLS */

.controls {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.controls button {
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border: 1px solid rgba(248, 250, 252, 0.16);
  background: radial-gradient(circle at top left, #ef4444 0, #991b1b 40%, #020617 100%);
  color: #fee2e2;
  cursor: pointer;
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  box-shadow:
    0 0 16px rgba(248, 113, 113, 0.6),
    0 0 36px rgba(127, 29, 29, 0.7);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

#btn-start {
  background: radial-gradient(circle at top left, #22c55e 0, #166534 40%, #020617 100%);
  border-color: rgba(74, 222, 128, 0.9);
  color: #dcfce7;
  box-shadow:
    0 0 16px rgba(34, 197, 94, 0.65),
    0 0 36px rgba(21, 128, 61, 0.7);
}

#btn-purge {
  background: radial-gradient(circle at top left, #facc15 0, #854d0e 40%, #020617 100%);
  border-color: rgba(250, 204, 21, 0.85);
  color: #fef9c3;
  box-shadow:
    0 0 16px rgba(250, 204, 21, 0.65),
    0 0 36px rgba(161, 98, 7, 0.7);
}

.controls button:hover {
  transform: translateY(-1px);
  box-shadow:
    0 0 22px rgba(248, 250, 252, 0.4),
    0 0 40px rgba(248, 113, 113, 0.7);
}

.controls button:active {
  transform: translateY(0);
  box-shadow:
    0 0 10px rgba(248, 250, 252, 0.25),
    0 0 26px rgba(15, 23, 42, 0.9);
}

/* FOOTER */

.terminal-footer {
  position: relative;
  z-index: 1;
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 10px;
  color: #9ca3af;
  border-top: 1px solid rgba(148, 163, 184, 0.4);
  background: linear-gradient(
    90deg,
    rgba(15, 23, 42, 0.96),
    rgba(127, 29, 29, 0.65)
  );
}

.footer-status {
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

/* ALARM STATE */

.terminal-window.alarm {
  box-shadow:
    0 0 40px rgba(239, 68, 68, 0.9),
    0 0 0 1px rgba(248, 113, 113, 0.9);
  animation: alarmShake 0.25s ease-in-out 0s 10;
}

@keyframes alarmShake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-2px);
  }
  50% {
    transform: translateX(2px);
  }
  75% {
    transform: translateX(-2px);
  }
  100% {
    transform: translateX(0);
  }
}

/* RESPONSIVE */

@media (max-width: 768px) {
  .desktop {
    padding: 1.8vh 1.8vw;
  }

  .terminal-window {
    max-height: 92vh;
  }

  .ascii-factory {
    font-size: 9px;
  }

  .terminal-header {
    padding-inline: 10px;
  }

  .ca-badge {
    display: none;
  }

  .terminal-footer {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }
}

/* LOADING SCREEN */

.loading-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #020617 0, #000 80%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  max-width: 500px;
  width: 90%;
}

.loading-logo {
  margin-bottom: 30px;
}

.loading-ascii {
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;
  font-size: 16px;
  line-height: 1.2;
  color: #ef4444;
  text-shadow:
    0 0 20px rgba(248, 113, 113, 1),
    0 0 40px rgba(248, 113, 113, 0.6),
    0 0 60px rgba(248, 113, 113, 0.3);
  animation: logoGlow 2s ease-in-out infinite;
}

@keyframes logoGlow {
  0%, 100% {
    text-shadow:
      0 0 20px rgba(248, 113, 113, 1),
      0 0 40px rgba(248, 113, 113, 0.6),
      0 0 60px rgba(248, 113, 113, 0.3);
  }
  50% {
    text-shadow:
      0 0 30px rgba(248, 113, 113, 1),
      0 0 60px rgba(248, 113, 113, 0.8),
      0 0 90px rgba(248, 113, 113, 0.5);
  }
}

.loading-text {
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #e5e7eb;
  margin-bottom: 20px;
  animation: textPulse 1.5s ease-in-out infinite;
}

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

.loading-bar-container {
  margin-bottom: 16px;
}

.loading-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    #ef4444 0%,
    #f97316 50%,
    #ef4444 100%
  );
  background-size: 200% 100%;
  border-radius: 999px;
  box-shadow:
    0 0 20px rgba(239, 68, 68, 0.8),
    0 0 40px rgba(239, 68, 68, 0.4);
  transition: width 0.3s ease;
  animation: barShimmer 2s linear infinite;
}

@keyframes barShimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.loading-percentage {
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;
  font-size: 18px;
  font-weight: 600;
  color: #ef4444;
  margin-top: 10px;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.loading-status {
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 12px;
  letter-spacing: 0.05em;
}

/* FLOATING TOYS BACKGROUND */

.floating-toys {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.toy {
  position: absolute;
  opacity: 0.15;
  animation: toyFloat linear infinite;
  filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.3));
}

.toy img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes toyFloat {
  0% {
    transform: translateY(-100px) rotate(0deg);
  }
  100% {
    transform: translateY(calc(100vh + 100px)) rotate(360deg);
  }
}

.toy:nth-child(odd) {
  animation-direction: reverse;
}

.toy:nth-child(3n) {
  opacity: 0.1;
}

.toy:nth-child(4n) {
  opacity: 0.2;
}
