/* ==========================================================================
   KG Labs Custom CSS — v1.0.0
   Everything theme.json cannot express:
   - backdrop-filter (glassmorphism)
   - SVG background patterns
   - Keyframe animations
   - Block style variants
   - Utility classes

   Loaded via:
     wp_enqueue_style('kglabs-custom') on the frontend
     add_editor_style('assets/css/kg-custom.css') in the Site Editor
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. GLASSMORPHISM PANEL
   The signature KG Labs effect: frosted glass over patterned backgrounds.
   Requires a semi-transparent rgba() background — opaque colors kill the blur.
   -------------------------------------------------------------------------- */

.kg-glass-panel,
.wp-block-group.is-style-glass-panel {
  background:            rgba(249, 250, 251, 0.1);
  backdrop-filter:       blur(40px);
  -webkit-backdrop-filter: blur(40px); /* Safari 9–14 */
  border:                1px solid rgba(255, 255, 255, 0.2);
  box-shadow:            0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

/* Dark context: denser, darker glass (hero cover, fog-gray backgrounds) */
.has-fog-gray-background-color .kg-glass-panel,
.has-fog-gray-background-color .wp-block-group.is-style-glass-panel,
.kg-hero-cover .kg-glass-panel,
.wp-block-group.is-style-glass-panel-dark {
  background:            rgba(18, 18, 18, 0.75);
  backdrop-filter:       blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border:                1px solid rgba(255, 255, 255, 0.12);
  box-shadow:            0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

/* --------------------------------------------------------------------------
   2. STICKY SITE HEADER
   Glass effect for the navigation bar when scrolled over content.
   -------------------------------------------------------------------------- */

.kg-site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background:             rgba(249, 250, 251, 0.88);
  backdrop-filter:        blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom:          1px solid rgba(0, 196, 140, 0.2);
  transition:             background 0.3s ease, box-shadow 0.3s ease;
}

.kg-site-header:where(:has(+ .kg-front-page)) {
  /* Slightly more transparent on the front page hero */
  background: rgba(249, 250, 251, 0.6);
}

/* --------------------------------------------------------------------------
   3. BUTTON STYLE VARIANTS
   Registered via register_block_style() in functions.php.
   WordPress writes inline style="" on .wp-block-button__link, so
   !important is required to override those inline declarations.
   -------------------------------------------------------------------------- */

/* Accent Gradient — Neural Violet → Deep Alatau Blue */
.wp-block-button.is-style-accent-gradient .wp-block-button__link {
  background:  linear-gradient(135deg, #7B61FF 0%, #004E92 100%) !important;
  color:       #ffffff !important;
  border:      none !important;
  box-shadow:  0 4px 16px rgba(123, 97, 255, 0.4);
  transition:  box-shadow 0.3s ease, transform 0.2s ease;
}
.wp-block-button.is-style-accent-gradient .wp-block-button__link:hover {
  box-shadow: 0 8px 32px rgba(123, 97, 255, 0.6);
  transform:  translateY(-2px);
}

/* Horizon Gradient — Steppe Yellow-Green → Tien Shan Green */
.wp-block-button.is-style-horizon-gradient .wp-block-button__link {
  background: linear-gradient(90deg, #F0F9A6 0%, #00C48C 100%) !important;
  color:      #1E1E1E !important;
  border:     none !important;
}
.wp-block-button.is-style-horizon-gradient .wp-block-button__link:hover {
  box-shadow: 0 4px 16px rgba(0, 196, 140, 0.4);
  transform:  translateY(-1px);
}

/* Ghost — transparent with border, for dark backgrounds */
.wp-block-button.is-style-ghost .wp-block-button__link {
  background: transparent !important;
  border:     2px solid var(--kg-deep-alatau-blue) !important;
  color:      var(--kg-glass-white) !important;
  transition: background 0.2s ease, color 0.2s ease;
}
.wp-block-button.is-style-ghost .wp-block-button__link:hover {
  background: var(--kg-deep-alatau-blue) !important;
  color:      #ffffff !important;
}

/* Glass — for use on cover blocks with image/pattern backgrounds */
.wp-block-button.is-style-glass .wp-block-button__link {
  background:            rgba(249, 250, 251, 0.15) !important;
  backdrop-filter:       blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border:                1px solid rgba(255, 255, 255, 0.3) !important;
  color:                 #ffffff !important;
  transition:            background 0.2s ease;
}
.wp-block-button.is-style-glass .wp-block-button__link:hover {
  background: rgba(249, 250, 251, 0.25) !important;
}

/* --------------------------------------------------------------------------
   4. RUNA SYMBOL UTILITIES
   Applied to core/image blocks containing runa SVG files.
   -------------------------------------------------------------------------- */

.wp-block-image.is-style-runa-glow img,
.kg-runa-icon {
  filter:     drop-shadow(0 0 8px rgba(123, 97, 255, 0.5));
  transition: filter 0.3s ease, transform 0.3s ease;
}

.wp-block-image.is-style-runa-glow:hover img,
.kg-runa-icon:hover {
  filter:    drop-shadow(0 0 16px rgba(123, 97, 255, 0.8));
  transform: scale(1.05);
}

/* Floating runa decorations (absolute-positioned in hero cover) */
.kg-runa-float {
  position:       absolute;
  opacity:        0.3;
  pointer-events: none;
  animation:      kg-runa-pulse 4s ease-in-out infinite;
}

.kg-runa-float--top-left  { top: 80px;    left:  80px; }
.kg-runa-float--top-right { top: 80px;    right: 80px; animation-delay: 1s;   }
.kg-runa-float--bot-left  { bottom: 80px; left:  80px; animation-delay: 2s;   }
.kg-runa-float--bot-right { bottom: 80px; right: 80px; animation-delay: 0.5s; }

/* --------------------------------------------------------------------------
   5. KEYFRAME ANIMATIONS
   -------------------------------------------------------------------------- */

@keyframes kg-runa-pulse {
  0%, 100% { opacity: 0.3; transform: scale(1);    }
  50%       { opacity: 0.6; transform: scale(1.05); }
}

@keyframes kg-network-pulse {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 1;   }
}

@keyframes kg-branch-grow {
  from { stroke-dashoffset: 100; }
  to   { stroke-dashoffset: 0;   }
}

@keyframes kg-node-appear {
  from { opacity: 0; transform: scale(0); }
  to   { opacity: 1; transform: scale(1); }
}

/* Classes applied to SVG elements in animated logos */
.kg-network-line {
  animation: kg-network-pulse 3s ease-in-out infinite;
}

.kg-branch-line {
  stroke-dasharray: 100;
  animation: kg-branch-grow 2s ease-out forwards;
}

/* --------------------------------------------------------------------------
   6. KNOWLEDGE NODE GLOW
   -------------------------------------------------------------------------- */

.kg-node {
  position:   relative;
  transition: transform 0.3s ease;
}

.kg-node:hover {
  transform: scale(1.1);
}

.kg-node::after {
  content:       '';
  position:      absolute;
  inset:         0;
  border-radius: 50%;
  background:    radial-gradient(circle, #7B61FF 0%, transparent 70%);
  opacity:       0;
  transition:    opacity 0.3s ease;
  pointer-events: none;
}

.kg-node:hover::after {
  opacity: 0.6;
}

/* --------------------------------------------------------------------------
   7. SVG BACKGROUND PATTERNS (CSS tile backgrounds)
   Applied to section wrappers as utility classes.
   -------------------------------------------------------------------------- */

.kg-bg-network-field {
  background-image:    url('../images/pattern-network-field.svg');
  background-size:     100px 100px;
  background-repeat:   repeat;
  background-position: center;
}

.kg-bg-axis-grid {
  background-image:    url('../images/pattern-axis-grid.svg');
  background-size:     100px 100px;
  background-repeat:   repeat;
  background-position: center;
}

/* --------------------------------------------------------------------------
   8. HERO SECTION
   -------------------------------------------------------------------------- */

.kg-hero-cover {
  position: relative;
  overflow: hidden;
}

.kg-hero-panel {
  position:   relative;
  z-index:    2;
  text-align: center;
  max-width:  720px;
  margin:     0 auto;
}

.kg-hero-logo {
  filter:    drop-shadow(0 0 20px rgba(0, 196, 140, 0.4));
  animation: kg-runa-pulse 4s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   9. ARCHIVE HEADER
   -------------------------------------------------------------------------- */

.kg-archive-header {
  background-color:  var(--kg-glass-white);
  background-image:  url('../images/pattern-network-field.svg');
  background-size:   100px 100px;
  background-repeat: repeat;
  position:          relative;
}

/* --------------------------------------------------------------------------
   10. QUOTE BLOCK — RUNA CALLOUT STYLE
   -------------------------------------------------------------------------- */

.wp-block-quote.is-style-runa-callout {
  border-left:   4px solid var(--kg-neural-violet);
  padding-left:  var(--kg-space-md);
  background:    rgba(123, 97, 255, 0.05);
  border-radius: 0 12px 12px 0;
  margin-left:   0;
}

.wp-block-quote.is-style-runa-callout cite {
  font-family: var(--kg-font-mono);
  font-size:   0.875rem;
  color:       var(--kg-muted-fg);
}

/* --------------------------------------------------------------------------
   11. POST CONTENT TYPOGRAPHY ENHANCEMENTS
   -------------------------------------------------------------------------- */

.entry-content code,
.wp-block-code code {
  font-family:      var(--kg-font-mono);
  background-color: var(--kg-fog-gray);
  color:            var(--kg-tien-shan-green);
  padding:          2px 6px;
  border-radius:    4px;
  font-size:        0.875em;
}

/* Inline code (not inside code block) */
.entry-content p code,
.entry-content li code {
  background-color: rgba(0, 196, 140, 0.1);
  color:            var(--kg-deep-alatau-blue);
}

/* --------------------------------------------------------------------------
   12. FOOTER LINKS
   -------------------------------------------------------------------------- */

.kg-footer-links {
  list-style: none;
  padding:    0;
  margin:     0;
}

.kg-footer-links a {
  color:       rgba(249, 250, 251, 0.7);
  text-decoration: none;
  transition:  color 0.2s ease;
  font-size:   var(--wp--preset--font-size--sm);
}

.kg-footer-links a:hover {
  color: var(--kg-tien-shan-green);
}

/* --------------------------------------------------------------------------
   13. NAVIGATION ENHANCEMENTS
   -------------------------------------------------------------------------- */

/* Active nav item styling */
.wp-block-navigation-item.current-menu-item > a {
  background:    linear-gradient(135deg, #7B61FF 0%, #004E92 100%);
  color:         #ffffff !important;
  border-radius: var(--kg-radius-pill);
  padding:       6px 16px;
}

/* Nav hover state */
.wp-block-navigation-item > a:hover {
  color: var(--kg-tien-shan-green) !important;
}

/* --------------------------------------------------------------------------
   14. FEATURE CARDS GRID
   -------------------------------------------------------------------------- */

.wp-block-columns.is-style-feature-cards > .wp-block-column {
  background:    rgba(249, 250, 251, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border:        1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--kg-radius-lg);
  padding:       var(--kg-space-md);
  box-shadow:    0 4px 16px rgba(0, 78, 146, 0.1);
  transition:    transform 0.3s ease, box-shadow 0.3s ease;
}

.wp-block-columns.is-style-feature-cards > .wp-block-column:hover {
  transform:  translateY(-4px);
  box-shadow: 0 8px 32px rgba(0, 78, 146, 0.15);
}

/* --------------------------------------------------------------------------
   15. DARK MODE (system preference)
   Activates independently of the WordPress style variation.
   -------------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  .kg-glass-panel,
  .wp-block-group.is-style-glass-panel {
    background:  rgba(18, 18, 18, 0.75);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .kg-site-header {
    background:  rgba(18, 18, 18, 0.9);
    border-bottom-color: rgba(0, 196, 140, 0.3);
  }

  .wp-block-columns.is-style-feature-cards > .wp-block-column {
    background:  rgba(18, 18, 18, 0.6);
    border-color: rgba(255, 255, 255, 0.1);
  }
}

/* --------------------------------------------------------------------------
   16. REDUCED MOTION
   Respects user's OS accessibility preference.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .kg-runa-float,
  .kg-network-line,
  .kg-branch-line,
  .kg-node,
  .kg-hero-logo,
  .wp-block-button.is-style-accent-gradient .wp-block-button__link,
  .wp-block-button.is-style-horizon-gradient .wp-block-button__link,
  .wp-block-columns.is-style-feature-cards > .wp-block-column {
    animation:  none !important;
    transition: none !important;
    transform:  none !important;
  }
}

/* --------------------------------------------------------------------------
   17. PRINT
   Make glass panels printable — backdrop-filter doesn't print.
   -------------------------------------------------------------------------- */

@media print {
  .kg-glass-panel,
  .wp-block-group.is-style-glass-panel {
    background:  rgba(249, 250, 251, 0.9) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow:  none !important;
    border:      1px solid #E5E7EB !important;
  }

  .kg-site-header {
    position: static !important;
    backdrop-filter: none !important;
  }

  .kg-runa-float {
    display: none !important;
  }
}
