/**
 * StackSift Core Styles
 * Main entry point for all design system styles
 *
 * Import this file in your HTML templates:
 * <link rel="stylesheet" href="/static/styles/core.css">
 */

/* ====================================
   DESIGN SYSTEM IMPORTS
   ==================================== */

/* Design tokens - CSS variables and keyframes */
@import url('design-system/tokens.css');

/* Component styles - Reusable component patterns */
@import url('design-system/components.css');

/* Utility classes - Helper classes for common patterns */
@import url('design-system/utilities.css');

/* ====================================
   GLOBAL BASE STYLES
   ==================================== */

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

body {
  font-family: var(--font-ui);
  background-color: var(--bg-deep);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* ====================================
   BACKGROUND EFFECTS
   ==================================== */

/* Hexagonal grid pattern - fades in diagonally from top-left to bottom-right */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-background-grid);
  pointer-events: none;
  /* Hexagonal honeycomb SVG pattern */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cpath d='M28 66L0 50L0 16L28 0L56 16L56 50L28 66L28 100' fill='none' stroke='rgba(123,147,184,0.04)' stroke-width='1'/%3E%3Cpath d='M28 0L28 34L0 50L0 84L28 100L56 84L56 50L28 34' fill='none' stroke='rgba(123,147,184,0.04)' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 56px 100px;
  /* Smooth diagonal fade: invisible top-left, visible bottom-right */
  mask-image: linear-gradient(
    135deg,
    transparent 0%,
    transparent 15%,
    rgba(0, 0, 0, 0.02) 25%,
    rgba(0, 0, 0, 0.05) 35%,
    rgba(0, 0, 0, 0.1) 45%,
    rgba(0, 0, 0, 0.2) 55%,
    rgba(0, 0, 0, 0.35) 65%,
    rgba(0, 0, 0, 0.55) 75%,
    rgba(0, 0, 0, 0.75) 85%,
    rgba(0, 0, 0, 1) 100%
  );
  -webkit-mask-image: linear-gradient(
    135deg,
    transparent 0%,
    transparent 15%,
    rgba(0, 0, 0, 0.02) 25%,
    rgba(0, 0, 0, 0.05) 35%,
    rgba(0, 0, 0, 0.1) 45%,
    rgba(0, 0, 0, 0.2) 55%,
    rgba(0, 0, 0, 0.35) 65%,
    rgba(0, 0, 0, 0.55) 75%,
    rgba(0, 0, 0, 0.75) 85%,
    rgba(0, 0, 0, 1) 100%
  );
}

/* Ambient glow effect */
body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 600px 400px at 15% 20%, rgba(109, 150, 232, 0.12) 0%, transparent 100%),
    radial-gradient(ellipse 500px 500px at 85% 60%, rgba(183, 148, 246, 0.10) 0%, transparent 100%),
    radial-gradient(ellipse 400px 300px at 50% 85%, rgba(245, 166, 35, 0.06) 0%, transparent 100%);
  filter: blur(40px);
}

/* Optional: Cosmic background layer (if image exists) */
#bg-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('/static/assets/cosmic-bg.webp');
  background-size: cover;
  background-position: center;
  opacity: 0.05;
  z-index: var(--z-background);
  pointer-events: none;
}

/* SVG Noise Texture Overlay - Adds subtle depth */
.noise-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  mix-blend-mode: overlay;
}

/* Reduce noise on mobile for performance */
@media (max-width: 768px) {
  .noise-overlay {
    opacity: 0.02;
  }
}

/* Respect reduced motion - hide noise animation if present */
@media (prefers-reduced-motion: reduce) {
  .noise-overlay {
    animation: none;
  }
}

/* ====================================
   GLOBAL LINK STYLES
   ==================================== */

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-default);
}

a:hover {
  color: var(--accent-primary-hover);
}

/* ====================================
   SELECTION STYLES
   ==================================== */

::selection {
  background: rgba(109, 150, 232, 0.3);
  color: var(--text-main);
}

::-moz-selection {
  background: rgba(109, 150, 232, 0.3);
  color: var(--text-main);
}

/* ====================================
   FOCUS STYLES
   ==================================== */

:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ====================================
   COMMON ELEMENTS
   ==================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
}

p {
  line-height: 1.6;
}

img {
  max-width: 100%;
  height: auto;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, textarea, select {
  font-family: inherit;
}

/* ====================================
   LOADING STATES
   ==================================== */

.loading-spinner {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}

.loading-spinner::after {
  content: "...";
  animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
  0%, 20% { content: "."; }
  40% { content: ".."; }
  60%, 100% { content: "..."; }
}

/* ====================================
   RESPONSIVE BREAKPOINTS
   ==================================== */

/* Mobile-first approach */
@media (max-width: 480px) {
  body {
    font-size: 14px;
  }
}

@media (max-width: 768px) {
  /* Tablet adjustments */
  :root {
    --sidebar-width: 200px;
  }
}

@media (max-width: 1200px) {
  /* Desktop adjustments */
  :root {
    --max-content-width: 1200px;
  }
}
