/* =========================================================
   PluggLAB — Theme
   Void / gothic palette. Cinzel display, Space Grotesk body.
   ========================================================= */

:root {
  /* VOID PALETTE */
  --bg: #060009;
  --bg-deep: #030005;
  --panel: rgba(180, 50, 255, 0.035);
  --panel-mid: rgba(180, 50, 255, 0.07);
  --panel-strong: rgba(180, 50, 255, 0.12);
  --border: rgba(180, 50, 255, 0.11);
  --border-bright: rgba(180, 50, 255, 0.28);
  --text: #e8dff5;
  --text-soft: rgba(232, 223, 245, 0.7);
  --muted: #6b5a80;

  /* ACCENTS */
  --accent: #7c3aed;
  --accent-glow: rgba(124, 58, 237, 0.22);
  --violet: #8b2be2;
  --violet-bright: #a855f7;
  --violet-glow: rgba(139, 43, 226, 0.18);
  --crimson: #c0192f;
  --crimson-bright: #e0263f;
  --crimson-glow: rgba(192, 25, 47, 0.22);
  --ice: #4dc9ff;
  --ice-glow: rgba(77, 201, 255, 0.14);
  --gold: #f6c143;
  --gold-glow: rgba(246, 193, 67, 0.16);
  --soul: #2dff8a;
  --soul-glow: rgba(45, 255, 138, 0.35);

  /* GRADIENTS */
  --gradient-main: linear-gradient(135deg, #e8dff5 0%, #c084fc 40%, #4dc9ff 100%);
  --gradient-ember: linear-gradient(135deg, #f6c143 0%, #e0263f 60%, #8b2be2 100%);
  --gradient-subtle: linear-gradient(135deg, rgba(139, 43, 226, 0.1) 0%, rgba(77, 201, 255, 0.06) 100%);
  --shadow-soft: 0 20px 60px rgba(0, 0, 0, 0.55);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.25);

  /* SHAPE */
  --radius-card: 8px;
  --radius-sm: 6px;
  --radius-btn: 3px;
  --max-width: 1160px;
  --nav-height: 72px;

  /* FONTS */
  --font-display: 'Cinzel', 'Cinzel Decorative', serif;
  --font-body: 'Space Grotesk', 'Inter', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

html, body, button, a, input, textarea, select, summary {
  cursor: url('../images/plugglab_cursor.cur'), auto;
}

body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0.01em;
  font-weight: 400;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 65% 55% at 12% 0%, rgba(139, 43, 226, 0.18) 0%, transparent 58%),
    radial-gradient(ellipse 50% 45% at 88% 5%, rgba(192, 25, 47, 0.12) 0%, transparent 52%),
    radial-gradient(ellipse 45% 55% at 82% 88%, rgba(77, 201, 255, 0.07) 0%, transparent 50%),
    radial-gradient(ellipse 35% 40% at 5% 82%, rgba(139, 43, 226, 0.07) 0%, transparent 48%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(180, 50, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180, 50, 255, 0.022) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(255, 255, 255, 0.28) 0%, transparent 68%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('../images/plugglab_background.png');
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button { cursor: url('../images/plugglab_cursor.cur'), pointer; font: inherit; background: none; border: none; color: inherit; }
ul { list-style: none; }
::selection { background: var(--violet); color: #fff; }

/* Visible keyboard focus everywhere */
:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--panel-strong); border-radius: 8px; border: 2px solid var(--bg-deep); }
::-webkit-scrollbar-thumb:hover { background: var(--violet-glow); }
html { scrollbar-color: rgba(139,43,226,0.35) var(--bg-deep); scrollbar-width: thin; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -60px;
  background: var(--crimson);
  color: #fff;
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 10000;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 1rem; }

.site-shell { position: relative; z-index: 1; }
html::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('../images/grain.png');
  background-size: 180px 180px;
  opacity: 0.05;
  pointer-events: none;
  z-index: 1;
}
.navbar, main, .site-footer { position: relative; z-index: 1; }

/* Ambient soul-drift canvas (signature element) */
#soul-drift {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
}

/* ---------- TYPE UTILITIES ---------- */
body { counter-reset: section-index; }
.section-label {
  counter-increment: section-index;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--violet-bright);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.section-label::before {
  content: "[ " counter(section-index, decimal-leading-zero) " ]";
  color: var(--muted);
  letter-spacing: 0.08em;
  font-weight: 700;
}

.section-heading { max-width: 640px; margin: 0 auto 2.75rem; text-align: left; }
.section-heading h2 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 700;
  margin: 0.6rem 0 0.75rem;
  letter-spacing: -0.01em;
}
.section-copy { color: var(--text-soft); font-size: 1rem; }

.gradient-text {
  background: var(--gradient-main);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- LAYOUT UTILITIES ---------- */
.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 2rem; }
.page-main > section { max-width: var(--max-width); margin: 0 auto; padding: 0 2rem 5.5rem; }
.page-main > section:first-child { padding-top: calc(var(--nav-height) + 2.5rem); }

@media (max-width: 720px) {
  .page-main > section { padding-left: 1.25rem; padding-right: 1.25rem; padding-bottom: 4rem; }
}

/* FADE-UP SCROLL REVEAL */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s var(--ease-spring), transform 0.6s var(--ease-spring);
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }
.reveal-stagger > * { transition-delay: calc(var(--stagger-i, 0) * 60ms); }

/* Section rune divider — signature motif */
.rune-divider {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 2rem;
  color: var(--border-bright);
}
.rune-divider::before,
.rune-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-bright), transparent);
}
.rune-divider svg {
  width: 22px; height: 22px; flex-shrink: 0; opacity: 0.7;
  animation: rune-spin 16s linear infinite;
  transform-origin: center;
}
@keyframes rune-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) { .rune-divider svg { animation: none; } }

@media (max-width: 720px) {
  .rune-divider { padding: 0 1.25rem; }
}

/* =========================================================
   MOTION LAYER — scroll progress, tilt, spotlight, ripple,
   ember trail, text-scramble, magnetic buttons, glow pulses.
   ========================================================= */

/* ---------- SCROLL PROGRESS BAR ---------- */
#scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2.5px;
  width: 0%;
  background: var(--gradient-ember);
  z-index: 10500;
  transition: width 80ms linear;
  box-shadow: 0 0 10px var(--crimson-glow);
}

/* ---------- STAGGERED REVEAL ---------- */
.reveal {
  transition-delay: calc(var(--stagger-i, 0) * 70ms);
}

/* ---------- GRADIENT TEXT SHIMMER ---------- */
.gradient-text,
.hero-title,
.page-hero h1,
.project-hero h1 {
  background-size: 200% auto;
  animation: gradient-shift 7s ease-in-out infinite;
}
@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ---------- TEXT SCRAMBLE-IN ---------- */
.scramble-ready { opacity: 0; }
.scramble-active { opacity: 1; }
.scramble-char { display: inline-block; }
/* While scrambling, use a flat color per-char (gradient-clip only looks right on the final plain text node) */
.hero-title.scramble-active .scramble-char,
.page-hero h1.scramble-active .scramble-char,
.project-hero h1.scramble-active .scramble-char {
  color: var(--violet-bright);
  -webkit-text-fill-color: var(--violet-bright);
}

/* ---------- CARD FRAME — corner brackets replace the old tilt/spotlight ---------- */
.glass-card,
.project-card,
.shortcut-card {
  position: relative;
  transition: transform 0.28s var(--ease-spring), border-color 0.28s ease, box-shadow 0.28s ease;
}
.glass-card::before,
.project-card::before,
.glass-card::after,
.project-card::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid transparent;
  opacity: 0;
  transition: opacity 0.28s ease, width 0.28s ease, height 0.28s ease;
  pointer-events: none;
}
.glass-card::before, .project-card::before {
  top: -1px; left: -1px;
  border-right: none; border-bottom: none;
}
.glass-card::after, .project-card::after {
  bottom: -1px; right: -1px;
  border-left: none; border-top: none;
}
.glass-card:hover,
.project-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-bright);
  box-shadow: var(--shadow-card), 0 0 32px -8px var(--violet-glow), inset 0 1px 0 rgba(255,255,255,0.06);
}
.glass-card:hover::before, .glass-card:hover::after,
.project-card:hover::before, .project-card:hover::after {
  opacity: 1;
  width: 20px;
  height: 20px;
  border-color: var(--violet-bright);
}

@media (hover: none) {
  .glass-card::before, .glass-card::after,
  .project-card::before, .project-card::after { display: none; }
}

/* ---------- BUTTON RIPPLE ---------- */
.btn { position: relative; overflow: hidden; }
.btn-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transform: scale(0);
  pointer-events: none;
  animation: ripple-expand 650ms ease-out forwards;
}
@keyframes ripple-expand {
  to { transform: scale(1); opacity: 0; }
}

/* ---------- MAGNETIC PRIMARY BUTTONS ---------- */
.btn-primary, .nav-cta { will-change: transform; }

/* ---------- EMBER CURSOR TRAIL ---------- */
.ember-particle {
  position: fixed;
  top: 0; left: 0;
  width: 5px; height: 5px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9500;
  background: radial-gradient(circle, rgba(246,193,67,0.9), rgba(224,38,63,0.5) 60%, transparent 70%);
  animation: ember-fade 900ms ease-out forwards;
}
@keyframes ember-fade {
  0% { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.2) translateY(-18px); }
}

/* ---------- EMBER BURST (celebratory) ---------- */
.ember-burst-particle {
  position: fixed;
  width: 6px; height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10600;
  animation: ember-burst-fly 700ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes ember-burst-fly {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--bx), var(--by)) scale(0.3); }
}

/* ---------- NAV LINK UNDERLINE ---------- */
.nav-links a { position: relative; }
.nav-links a::after {
  content: '';
  position: absolute;
  left: 0.75rem; right: 0.75rem;
  bottom: 0.15rem;
  height: 1.5px;
  background: var(--gradient-main);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s var(--ease-spring);
}
.nav-links a:hover::after,
.nav-links a[aria-current="page"]::after { transform: scaleX(1); }

/* ---------- HERO GLOW PARALLAX ---------- */
.hero-glow { transition: transform 0.2s ease-out; }

/* ---------- PULSE-GLOW UTILITY ---------- */
.pulse-glow { animation: pulse-glow 3s ease-in-out infinite; }
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139,43,226,0.0); }
  50% { box-shadow: 0 0 26px 2px var(--violet-glow); }
}

/* ---------- PAGE INTRO ---------- */
body { opacity: 0; }
body.page-ready { opacity: 1; transition: opacity 0.45s ease; }

@media (prefers-reduced-motion: reduce) {
  .gradient-text, .hero-title, .page-hero h1, .project-hero h1 { animation: none; }
  .glass-card::before, .project-card::before { display: none; }
  body { opacity: 1 !important; transition: none !important; }
}

/* ---------- ICON HOVER POP ---------- */
.project-card .project-icon,
.related-card .related-icon {
  transition: transform 0.3s var(--ease-spring), box-shadow 0.3s ease;
}
.project-card:hover .project-icon,
.related-card:hover .related-icon {
  transform: scale(1.08) rotate(-2deg);
  box-shadow: 0 0 18px var(--violet-glow);
}

/* ---------- GLITCH TEXT (404) ---------- */
.glitch-text {
  position: relative;
  display: inline-block;
}
.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  background: var(--bg);
  clip-path: inset(0 0 0 0);
}
.glitch-text::before {
  color: var(--crimson-bright);
  animation: glitch-1 3.2s infinite linear alternate-reverse;
}
.glitch-text::after {
  color: var(--ice);
  animation: glitch-2 2.6s infinite linear alternate-reverse;
}
@keyframes glitch-1 {
  0%, 92%, 100% { clip-path: inset(0 0 100% 0); transform: translate(0, 0); }
  93% { clip-path: inset(10% 0 60% 0); transform: translate(-3px, 1px); }
  95% { clip-path: inset(60% 0 5% 0); transform: translate(3px, -1px); }
  97% { clip-path: inset(30% 0 40% 0); transform: translate(-2px, 0); }
}
@keyframes glitch-2 {
  0%, 90%, 100% { clip-path: inset(0 0 100% 0); transform: translate(0, 0); }
  91% { clip-path: inset(70% 0 5% 0); transform: translate(3px, 0); }
  94% { clip-path: inset(15% 0 55% 0); transform: translate(-3px, 1px); }
  98% { clip-path: inset(45% 0 25% 0); transform: translate(2px, -1px); }
}
@media (prefers-reduced-motion: reduce) {
  .glitch-text::before, .glitch-text::after { display: none; }
}
