/* ============================================================
   REBOOT MUSEUM v2 — BASE.CSS
   Design Tokens, Reset, CRT Effects, Base Styles
   ============================================================ */

/* ── Custom Properties (Design Tokens) ── */
:root {
  /* Core Brand Colors */
  --color-bg:               #0a0a0a;
  --color-terminal:         #00ff41;
  --color-terminal-dim:     #00cc33;
  --color-terminal-bright:  #33ff66;
  --color-amber:            #ffb000;
  --color-amber-dim:        #cc8c00;
  --color-red:              #ff4040;
  --color-blue:             #4080ff;

  /* Text */
  --color-text:             #e0e0e0;
  --color-text-dim:         #808080;
  --color-text-muted:       #555555;
  --color-text-inverse:     #0a0a0a;

  /* Surfaces */
  --color-surface:          #141414;
  --color-surface-hover:    #1a1a1a;
  --color-surface-raised:   #1e1e1e;
  --color-surface-overlay:  rgba(10, 10, 10, 0.92);

  /* Borders */
  --color-border:           #222222;
  --color-border-bright:    #333333;
  --color-border-terminal:  rgba(0, 255, 65, 0.3);
  --color-border-active:    rgba(0, 255, 65, 0.7);

  /* Typography */
  --font-display:           'VT323', 'Courier New', monospace;
  --font-body:              'IBM Plex Mono', 'Courier New', monospace;

  /* Type Scale (clamp-based fluid) */
  --text-xs:    clamp(0.65rem, 1vw, 0.75rem);
  --text-sm:    clamp(0.75rem, 1.2vw, 0.875rem);
  --text-base:  clamp(0.875rem, 1.5vw, 1rem);
  --text-md:    clamp(1rem, 2vw, 1.125rem);
  --text-lg:    clamp(1.125rem, 2.5vw, 1.375rem);
  --text-xl:    clamp(1.5rem, 3vw, 2rem);
  --text-2xl:   clamp(2rem, 4vw, 3rem);
  --text-3xl:   clamp(2.5rem, 6vw, 4.5rem);
  --text-hero:  clamp(3rem, 8vw, 7rem);

  /* VT323 Scale (display font runs large — calibrated sizes) */
  --text-vt-sm:   clamp(1rem, 2vw, 1.25rem);
  --text-vt-md:   clamp(1.25rem, 2.5vw, 1.75rem);
  --text-vt-lg:   clamp(1.75rem, 3vw, 2.5rem);
  --text-vt-xl:   clamp(2.5rem, 5vw, 4rem);
  --text-vt-hero: clamp(3.5rem, 9vw, 8rem);

  /* Spacing (4px base) */
  --space-1:    4px;
  --space-2:    8px;
  --space-3:    12px;
  --space-4:    16px;
  --space-5:    20px;
  --space-6:    24px;
  --space-8:    32px;
  --space-10:   40px;
  --space-12:   48px;
  --space-16:   64px;
  --space-20:   80px;
  --space-24:   96px;
  --space-32:   128px;

  /* Layout */
  --max-width:       1400px;
  --nav-height:      56px;
  --search-height:   44px;
  --sidebar-width:   240px;

  /* Border Radius */
  --radius-sm:   2px;
  --radius-md:   4px;
  --radius-lg:   8px;

  /* Shadows */
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.6);
  --shadow-md:  0 2px 12px rgba(0,0,0,0.8);
  --shadow-lg:  0 4px 32px rgba(0,0,0,0.9);
  --glow-sm:    0 0 8px rgba(0, 255, 65, 0.3);
  --glow-md:    0 0 20px rgba(0, 255, 65, 0.4);
  --glow-lg:    0 0 40px rgba(0, 255, 65, 0.5);
  --glow-amber: 0 0 16px rgba(255, 176, 0, 0.4);

  /* Transitions */
  --transition-fast:    120ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-base:    180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow:    320ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-layout:  400ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Z-Index Scale */
  --z-base:     1;
  --z-raised:   10;
  --z-overlay:  100;
  --z-nav:      200;
  --z-modal:    300;
  --z-toast:    400;
  --z-tooltip:  500;
  --z-crt:      600;
  --z-boot:     700;
  --z-lightbox: 800;
}

/* ── CSS Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ── CRT Phosphor Scanline Overlay ── */
.crt-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-crt);
  pointer-events: none;
  background:
    /* Scanlines */
    repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 2px,
      rgba(0, 0, 0, 0.08) 2px,
      rgba(0, 0, 0, 0.08) 4px
    );
  mix-blend-mode: multiply;
}

/* Vignette effect */
.crt-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.5) 100%
  );
}

/* CRT flicker */
.crt-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 255, 65, 0.012);
  animation: crt-flicker 0.15s infinite;
}

@keyframes crt-flicker {
  0%, 19.999%, 22%, 62.999%, 64%, 64.999%, 70%, 100% { opacity: 1; }
  20%, 21.999%, 63%, 63.999%, 65%, 69.999% { opacity: 0.85; }
}

/* ── Typography Base ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--color-terminal);
}

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--color-terminal);
  text-decoration: none;
  transition: color var(--transition-fast), text-shadow var(--transition-fast);
}
a:hover {
  color: var(--color-terminal-bright);
  text-shadow: var(--glow-sm);
}
a:focus-visible {
  outline: 1px solid var(--color-terminal);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Terminal Text Utilities ── */
.terminal-green { color: var(--color-terminal); }
.terminal-dim   { color: var(--color-terminal-dim); }
.terminal-bright { color: var(--color-terminal-bright); }
.terminal-amber  { color: var(--color-amber); }
.terminal-red    { color: var(--color-red); }
.text-dim        { color: var(--color-text-dim); }
.text-muted      { color: var(--color-text-muted); }

/* ── Blink Animation ── */
.blink {
  animation: blink 1.1s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Cursor ── */
.cursor::after {
  content: '█';
  animation: blink 1.1s step-end infinite;
  color: var(--color-terminal);
  margin-left: 2px;
}

/* ── Scanline Text (phosphor effect on text) ── */
.phosphor {
  text-shadow:
    0 0 4px currentColor,
    0 0 10px rgba(0, 255, 65, 0.4);
}

/* ── Scrollbar Styling ── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-terminal-dim) var(--color-surface);
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-surface); }
::-webkit-scrollbar-thumb {
  background: var(--color-terminal-dim);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-terminal);
}

/* ── Selection ── */
::selection {
  background: var(--color-terminal);
  color: var(--color-bg);
}

/* ── Images & Media ── */
img, video, canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  object-fit: cover;
}

/* Image loading skeleton */
img.loading {
  background: var(--color-surface);
  position: relative;
  overflow: hidden;
}
img.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 255, 65, 0.05) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── Form Resets ── */
button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-terminal);
  box-shadow: var(--glow-sm);
}

/* ── List Resets ── */
ul, ol { list-style: none; }

/* ── Hidden Utility ── */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Table Reset ── */
table { border-collapse: collapse; width: 100%; }

/* ── Container ── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ── Responsive Breakpoints ── */
/* xs:  0-479   */
/* sm:  480-767 */
/* md:  768-1023 */
/* lg:  1024-1279 */
/* xl:  1280+   */

/* ── Boot Screen ── */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-boot);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
}

.boot-screen.fade-out {
  animation: bootFadeOut 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes bootFadeOut {
  0%   { opacity: 1; transform: scale(1); filter: brightness(1); }
  50%  { opacity: 1; transform: scale(1.01); filter: brightness(1.5); }
  100% { opacity: 0; transform: scale(0.98); filter: brightness(0); pointer-events: none; }
}

.boot-content {
  width: min(480px, 90vw);
  padding: var(--space-8);
}

.boot-logo {
  margin-bottom: var(--space-8);
  text-align: center;
}
.boot-logo svg {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  filter: drop-shadow(0 0 20px rgba(0, 255, 65, 0.5));
}

.boot-terminal {
  border: 1px solid var(--color-border-terminal);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  background: rgba(0, 255, 65, 0.02);
  min-height: 140px;
}

.boot-line {
  font-size: var(--text-sm);
  color: var(--color-terminal);
  min-height: 1.6em;
  font-family: var(--font-body);
}
.boot-line::before {
  content: '> ';
  color: var(--color-terminal-dim);
}
.boot-line.ok .status { color: var(--color-terminal-bright); }
.boot-line.error .status { color: var(--color-red); }
.boot-line.warn .status { color: var(--color-amber); }

.boot-progress {
  height: 2px;
  background: var(--color-border);
  overflow: hidden;
}
.boot-progress-bar {
  height: 100%;
  background: var(--color-terminal);
  width: 0%;
  transition: width 0.1s linear;
  box-shadow: var(--glow-sm);
}

/* ── Glow Keyframe ── */
@keyframes glowPulse {
  0%, 100% { box-shadow: var(--glow-sm); }
  50%       { box-shadow: var(--glow-md); }
}

/* ── Slide In ── */
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes scanIn {
  from { opacity: 0; clip-path: inset(0 100% 0 0); }
  to   { opacity: 1; clip-path: inset(0 0% 0 0); }
}

/* ── Noise texture overlay ── */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-crt) - 1;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* ── Terminal Box Component ── */
.terminal-box {
  border: 1px solid var(--color-border-terminal);
  background: rgba(0, 255, 65, 0.02);
  padding: var(--space-6);
  position: relative;
}
.terminal-box::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 8px;
  width: 40px;
  height: 1px;
  background: var(--color-bg);
}

.terminal-box-label {
  position: absolute;
  top: -9px;
  left: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-terminal-dim);
  background: var(--color-bg);
  padding: 0 var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ── Chip / Tag ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  padding: 2px var(--space-2);
  border: 1px solid var(--color-border-terminal);
  color: var(--color-terminal);
  background: rgba(0, 255, 65, 0.06);
  border-radius: var(--radius-sm);
  cursor: default;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.chip-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: var(--text-base);
  line-height: 1;
  transition: opacity var(--transition-fast);
}
.chip-remove:hover { opacity: 1; }

/* ── Button System ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-height: 36px;
}
.btn:focus-visible {
  outline: 1px solid var(--color-terminal);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-terminal);
  color: var(--color-bg);
  border-color: var(--color-terminal);
}
.btn-primary:hover {
  background: var(--color-terminal-bright);
  border-color: var(--color-terminal-bright);
  box-shadow: var(--glow-md);
}

.btn-secondary {
  background: transparent;
  color: var(--color-terminal);
  border-color: var(--color-border-terminal);
}
.btn-secondary:hover {
  background: rgba(0, 255, 65, 0.08);
  border-color: var(--color-terminal);
  box-shadow: var(--glow-sm);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-dim);
  border-color: var(--color-border);
}
.btn-ghost:hover {
  color: var(--color-text);
  border-color: var(--color-border-bright);
  background: var(--color-surface-hover);
}

.btn-amber {
  background: var(--color-amber);
  color: var(--color-bg);
  border-color: var(--color-amber);
}
.btn-amber:hover {
  background: #ffc430;
  box-shadow: var(--glow-amber);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-sm {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
  min-height: 28px;
}

/* ── Responsive Typography ── */
@media (max-width: 768px) {
  body { font-size: var(--text-sm); }
}

/* ── Lightbox ── */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-lightbox);
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease;
}
.lightbox-overlay.hidden {
  display: none;
}
.lightbox-img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border: 1px solid var(--color-border-terminal);
  box-shadow: 0 0 40px rgba(0, 255, 65, 0.15);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  background: none;
  border: 1px solid var(--color-border-terminal);
  color: var(--color-terminal);
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s, box-shadow 0.15s;
}
.lightbox-close:hover {
  background: rgba(0, 255, 65, 0.1);
  box-shadow: var(--glow-sm);
}
