/* ============================================
   BASE.CSS - Foundation & Core Styles
   KlassKit Hub
   ============================================ */

/* ============================================
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */

:root {
  /* --- Color Palette --- */
  --color-pink: #ff4785;
  --color-orange: #ff7e33;
  --color-green: #00d063;
  --color-blue: #1ea7fd;
  --color-dark: #111827;
  --color-chalk: #f8fafc;

  /* --- Semantic Colors (Light Mode) --- */
  --bg-primary: #f8fafc;
  --bg-secondary: rgba(255, 255, 255, 0.85);
  /* For glassmorphism */
  --bg-tertiary: #e2e8f0;

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;

  --border-primary: #334155;
  --border-secondary: #cbd5e1;

  --surface-card: #ffffff;
  --surface-overlay: rgba(255, 255, 255, 0.95);

  /* --- Grid Pattern --- */
  --grid-color: #e2e8f0;
  --grid-size: 32px;
  /* Slightly larger, more breathable */

  /* --- Shadows (Soft Brutalism) --- */
  --shadow-color: var(--border-primary);
  /* Hard block shadows for Soft Brutalism */
  --shadow-sm: 2px 2px 0px var(--shadow-color);
  --shadow-md: 4px 4px 0px var(--shadow-color);
  --shadow-lg: 8px 8px 0px var(--shadow-color);
  --shadow-xl: 12px 12px 0px var(--shadow-color);

  --shadow-hard-sm: 2px 3px 0px var(--shadow-color);
  --shadow-hard-md: 4px 5px 0px var(--shadow-color);

  /* --- Borders --- */
  --border-width-thin: 1.5px;
  --border-width-medium: 2px;
  --border-width-thick: 3px;
  /* Slightly thinner for a cleaner look */

  /* --- Border Radius --- */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-2xl: 2rem;

  /* --- Spacing --- */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* --- Transitions --- */
  --transition-fast: 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-base: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);

  /* --- Z-Index Scale --- */
  --z-background: -1;
  --z-base: 0;
  --z-elevated: 10;
  --z-overlay: 40;
  --z-modal: 50;
  --z-controls: 60;
  --z-tooltip: 70;
}

/* --- Dark Mode Overrides (OLED Modern) --- */
.dark {
  --bg-primary: #020617;
  /* Deep slate, almost black */
  --bg-secondary: rgba(15, 23, 42, 0.75);
  /* Dark glass */
  --bg-tertiary: #1e293b;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  --border-primary: #334155;
  /* Lighter border for contrast */
  --border-secondary: #1e293b;

  --surface-card: #0f172a;
  --surface-overlay: rgba(2, 6, 23, 0.95);

  --grid-color: rgba(255, 255, 255, 0.06);
  /* Make grid more visible in dark mode for better aesthetic */

  --shadow-color: #000000;
  /* Pitch black hard shadows for dark mode */
  --shadow-hard-sm: 2px 3px 0px var(--shadow-color);
  --shadow-hard-md: 4px 5px 0px var(--shadow-color);
}

/* ============================================
   2. BASE STYLES & RESETS
   ============================================ */

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

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-primary);
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  color: var(--text-primary);

  /* Performance optimizations */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;

  /* User experience */
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;

  /* Smooth transitions */
  transition:
    background-color var(--transition-slow),
    color var(--transition-slow);
}

/* Screen reader only content */
.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;
}

/* ============================================
   3. UTILITY CLASSES
   ============================================ */

/* Gradient mask for horizontal scrolling */
.mask-gradient {
  -webkit-mask-image: linear-gradient(to right,
      transparent,
      black 2%,
      black 98%,
      transparent);
  mask-image: linear-gradient(to right,
      transparent,
      black 2%,
      black 98%,
      transparent);
}

/* Focus visible styles (for keyboard navigation) */
.focus-ring:focus-visible {
  outline: 3px solid var(--color-blue);
  outline-offset: 2px;
}

/* Glass panel utility */
.glass-panel {
  background: var(--bg-secondary);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: var(--border-width-medium) solid rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow-md);
}

.dark .glass-panel {
  background: var(--bg-secondary);
  border-color: rgba(255, 255, 255, 0.08);
}

/* Skip to content link (accessibility) */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  padding: 8px;
  background: var(--color-blue);
  color: white;
  z-index: 100;
  text-decoration: none;
  font-weight: bold;
}

.skip-link:focus {
  top: 0;
}

/* ============================================
   4. ANIMATIONS & KEYFRAMES
   ============================================ */

@keyframes slide-down {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }

  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-20px) scale(0.8);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes pop-in {
  0% {
    opacity: 0;
    transform: scale(0.95);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* ============================================
   5. SCROLLBAR CUSTOMIZATION
   ============================================ */

/* Recent list scrollbar */
#recent-list::-webkit-scrollbar {
  height: 10px;
}

#recent-list::-webkit-scrollbar-track {
  background: transparent;
}

#recent-list::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}

#recent-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
  background-clip: content-box;
}

#recent-list {
  scrollbar-width: thin;
  scrollbar-color: var(--border-secondary) transparent;
}

/* Custom scrollbar for info overlay */
.custom-scrollbar::-webkit-scrollbar {
  width: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: var(--radius-sm);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ============================================
   6. ACCESSIBILITY & REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .shape {
    animation: none;
  }
}

/* ============================================
   7. RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
  :root {
    --grid-size: 20px;
  }
}

@media (max-width: 640px) {
  :root {
    --grid-size: 16px;
  }
}

/* ============================================
   8. BROWSER-SPECIFIC FIXES
   ============================================ */

/* Safari iOS bounce fix */
@supports (-webkit-overflow-scrolling: touch) {
  body {
    -webkit-overflow-scrolling: touch;
  }
}

/* Firefox focus outline fix */
@-moz-document url-prefix() {
  .btn-chunky:focus-visible {
    outline-offset: 3px;
  }
}

/* Edge/IE grid background fallback */
@supports not (background-image: linear-gradient(var(--grid-color) 1px, transparent 1px)) {
  body {
    background-image:
      linear-gradient(#E2E8F0 1px, transparent 1px),
      linear-gradient(90deg, #E2E8F0 1px, transparent 1px);
  }
}

/* ============================================
   9. PRINT STYLES
   ============================================ */

@media print {
  body {
    background: white;
    background-image: none;
    color: black;
  }

  .living-bg,
  .floating-stick,
  #sound-btn,
  [data-action="toggleTheme"] {
    display: none;
  }

  .hub-card,
  .btn-chunky {
    box-shadow: none;
    border: 1px solid black;
  }
}