@layer base, layout, components, utilities;

@layer base {
  :root {
    /* OKLCH Colors - Modern & Vibrant */
    --bg-base: oklch(15% 0.02 240);
    --text-primary: oklch(98% 0.01 240);
    --text-secondary: oklch(80% 0.02 240);
    --accent-blue: oklch(65% 0.15 250);
    --accent-up: oklch(60% 0.2 15);    /* Warm red for rising */
    --accent-down: oklch(65% 0.15 220); /* Cool blue/cyan for falling */
    
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  }

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

  body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
  }
}

@layer layout {
  #app {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    container-type: inline-size;
  }

  /* Background Effects */
  .background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
  }

  .noise-texture {
    position: absolute;
    inset: 0;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  }

  .gradient-blob {
    position: absolute;
    width: 60vmax;
    height: 60vmax;
    filter: blur(80px);
    opacity: 0.15;
    border-radius: 50%;
  }

  .gradient-blob.top-left {
    top: -20%;
    left: -20%;
    background: radial-gradient(circle, var(--accent-blue) 0%, transparent 70%);
  }

  .gradient-blob.bottom-right {
    bottom: -20%;
    right: -20%;
    background: radial-gradient(circle, var(--accent-up) 0%, transparent 70%);
  }
}

@layer components {
  /* Web Components will use these shared styles via inheritance or :host */
  .glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease, border-color 0.3s ease;
  }

  .glass-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.2);
  }

  /* Primary Card Enhancement */
  .primary-card .card {
    border: 1px solid rgba(104, 153, 255, 0.2);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
  }

  .primary-card .name {
    color: var(--accent-blue);
    font-size: 1.25rem;
  }

  /* Search Bar Styles */
  .search-container {
    margin: 2rem 0;
    position: relative;
    max-width: 600px;
    margin-inline: auto;
  }

  .search-input {
    width: 100%;
    padding: 1rem 1.5rem;
    padding-left: 3.5rem;
    border-radius: 100px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    backdrop-filter: blur(8px);
    outline: none;
    transition: all 0.3s ease;
  }

  .search-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(104, 153, 255, 0.1);
  }

  .search-icon {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
  }

  /* Category Styles */
  .category-container {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
  }

  .category-btn {
    padding: 0.6rem 1.25rem;
    border-radius: 100px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
  }

  .category-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
  }

  .category-btn.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
  }

  /* Section Title */
  .section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, var(--glass-border), transparent);
  }
}

@layer utilities {
  .text-up { color: var(--accent-up); }
  .text-down { color: var(--accent-down); }
}
