@media (prefers-reduced-motion: reduce) {
  .will-animate { transition: none !important; }
}
:focus-visible { outline: 2px solid #22d3ee; outline-offset: 3px; }
.reveal { opacity: 0; transform: translateY(16px); }
:root {
  /* header height is set dynamically by JS; fallback to 7rem */
  --header-height: 7rem;
  --cursor-glow-size: 150px;
  scroll-padding-top: var(--header-height);
}

/* global box-sizing and responsive images to avoid accidental overflow */
*, *::before, *::after { box-sizing: border-box; }
img, svg, video { max-width: 100%; height: auto; display: block; }

/* Cursor glow effect */
#cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--cursor-glow-size);
  height: var(--cursor-glow-size);
  margin-left: calc(var(--cursor-glow-size) * -0.5);
  margin-top: calc(var(--cursor-glow-size) * -0.5);
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15,118,110,0.25) 0%, rgba(15,118,110,0) 60%);
  mix-blend-mode: screen;
  z-index: 9999;
  transform: translate3d(0,0,0);
}

/* Hide the cursor glow on coarse/touch-only devices so it doesn't linger unattractively. */
@media (pointer: coarse), (hover: none) {
  #cursor-glow { display: none !important; }
}
.logo-hover {
  transition: filter 0.3s;
}

.logo-hover:hover {
  filter: brightness(1.3) drop-shadow(0 0 6px #0f766e);
}
.nav-glow {
  transition: color 0.3s, text-shadow 0.3s;
}

.nav-glow:hover {
  color: #0f766e; /* teal accent */
  text-shadow: 0 0 8px #0f766e, 0 0 16px #0f766e;
}

p, h1, h2, h3, h4, h5, h6, span {
  user-select: none; /* optional: prevents text from being highlighted */
}

/* Mobile header / nav fixes */
@media (max-width: 1023px) {
  /* Prevent any accidental horizontal overflow on small screens */
  html, body { overflow-x: hidden; }
  /* Position mobileNav below the header so the header remains visible */
  /* Mobile nav: collapsed state by default, animate to .open */
  #mobileNav {
  position: fixed;
  /* header height is set via --header-height so it adapts to layout changes */
  top: var(--header-height);
    left: 0;
    width: 100%;
    z-index: 30; /* below header (header z-40) so header stays visible */
    background: rgba(24,24,27,0.96);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    /* start collapsed so it doesn't show until opened */
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-6px);
    visibility: hidden;
    pointer-events: none;
    transition: max-height 360ms cubic-bezier(.2,.9,.2,1), opacity 240ms ease, transform 240ms ease;
  }

  /* Open state: allow scrolling and full height beneath header */
  #mobileNav.open {
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
  }

  /* Dim overlay behind the mobile nav to focus attention */
  #menuOverlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.45);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 240ms ease, visibility 240ms ease;
    z-index: 25; /* below mobileNav (30) but above page content */
  }

  #menuOverlay.visible {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
  }

  /* Center the list and make links comfortably tappable */
  #mobileNav ul {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    margin: 0;
    list-style: none;
  }

      #mobileNav a {
        width: 100%;
        max-width: 420px;
        display: inline-block;
        text-align: center;
        padding: 0.85rem 1rem;
        border-radius: 0.5rem;
        /* remove the default mobile tap highlight */
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        color: inherit;
        transition: transform 120ms ease, color 160ms ease, text-shadow 160ms ease;
        /* allow ripple to be positioned inside the link */
        position: relative;
        overflow: hidden;
      }

  /* subtle press feedback */
  #mobileNav a:active {
    transform: translateY(1px) scale(0.997);
    opacity: 0.98;
  }

  /* hovering / keyboard focus keeps the soft text glow */
  #mobileNav a:focus-visible,
  #mobileNav a:hover {
    text-shadow: 0 0 8px rgba(15,118,110,0.9);
    color: #a7f3eb;
  }

  /* Ripple element created dynamically on tap/pointer down */
  #mobileNav a .ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    background: rgba(167,243,235,0.18); /* subtle cyan */
    pointer-events: none;
    will-change: transform, opacity;
    animation: ripple 560ms cubic-bezier(.22,.98,.52,.99);
    mix-blend-mode: screen;
  }

  @keyframes ripple {
    to {
      transform: scale(3);
      opacity: 0;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    #mobileNav a .ripple { animation: none; opacity: 0; }
  }
      /* keep keyboard focus outlines, but suppress focus styling on touch devices */
      #mobileNav a:focus { outline: none; }

      /* mark the link for the current section */
      #mobileNav a.is-current,
      nav[aria-label="Primary"] a.is-current {
        text-shadow: 0 0 10px rgba(15,118,110,0.95);
        color: #a7f3eb;
      }
}

/* On coarse pointers, avoid leaving focus outlines visible after touch */
@media (pointer: coarse) {
  header a:focus {
    outline: none;
    box-shadow: none;
  }

  /* ensure header background never pushes page wider than viewport */
  header { overflow-x: hidden; }
}

/* Glitch effect for Playground link */
.glitch {
  position: relative;
  display: inline-block;
  color: inherit;
  text-decoration: none;
}
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  overflow: hidden;
  clip-path: inset(0 0 0 0);
  pointer-events: none;
}
.glitch::before {
  color: #a7f3eb; /* cyan-ish */
  z-index: -1;
  transform: translate3d(-2px, -1px, 0);
  mix-blend-mode: screen;
  text-shadow: -2px 0 8px rgba(167,243,235,0.8);
}
.glitch::after {
  color: #fca5a5; /* pink-ish */
  z-index: -2;
  transform: translate3d(2px, 1px, 0);
  mix-blend-mode: screen;
  text-shadow: 2px 0 8px rgba(252,165,165,0.85);
}

/* animated slices */
@keyframes glitch-slice-1 {
  0% { clip-path: inset(0 0 80% 0); transform: translate3d(-2px, -1px, 0); }
  50% { clip-path: inset(30% 0 45% 0); transform: translate3d(3px, -2px, 0); }
  100% { clip-path: inset(0 0 80% 0); transform: translate3d(-2px, -1px, 0); }
}
@keyframes glitch-slice-2 {
  0% { clip-path: inset(60% 0 0 0); transform: translate3d(2px, 1px, 0); }
  50% { clip-path: inset(35% 0 25% 0); transform: translate3d(-3px, 2px, 0); }
  100% { clip-path: inset(60% 0 0 0); transform: translate3d(2px, 1px, 0); }
}

/* Trigger subtle ambient animation; more intense on hover/focus */
.glitch {
  will-change: transform;
}
.glitch::before { animation: glitch-slice-1 2.5s infinite linear; opacity: 0.9; }
.glitch::after { animation: glitch-slice-2 3s infinite linear; opacity: 0.9; }

.glitch:hover::before,
.glitch:focus::before,
.glitch:hover::after,
.glitch:focus::after {
  animation-duration: 0.9s;
}

@media (prefers-reduced-motion: reduce) {
  .glitch::before, .glitch::after { animation: none; transform: none; text-shadow: none; }
}
