/* ===== PROJECT CARDS — floating image boxes attached to the helix ===== */
.project-stage {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 4;       /* above canvas, below dev panel */
  perspective: 1200px;
}
/* SVG layer that draws connector lines from each card's anchor on the
   shape surface to its floating card position. Sits between canvas (z=1)
   and project-stage (z=4) so the lines render behind the card itself. */
.card-connectors {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 3;
  width: 100%; height: 100%;
  overflow: visible;
}
.card-connectors line {
  stroke: rgba(108, 255, 138, 0.85);
  stroke-width: 1.2;
  stroke-dasharray: 3 4;
  filter: drop-shadow(0 0 3px rgba(0, 255, 65, 0.55));
  animation: card-connector-flow 2s linear infinite;
}
@keyframes card-connector-flow {
  0%   { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -14; }
}
/* During focus mode the project-stage must rise above .focus-overlay (z=5)
   so the focused card isn't dimmed by the overlay's dark radial gradient.
   project-stage has perspective which creates a stacking context, so the
   focused card's own z-index can't escape the parent's value. */
body.focus-mode .project-stage { z-index: 6; }
/* When focus is active, the canvas gets blurred behind the focused card */
body.focus-mode #canvas-blur-target,
body.focus-mode canvas {
  filter: blur(8px) brightness(0.45);
  transition: filter 0.45s ease;
}
body:not(.focus-mode) canvas {
  transition: filter 0.45s ease;
}
body.focus-mode .scene-text .layer:not(.helix-title) { opacity: 0 !important; transition: opacity 0.3s ease; }
body.focus-mode .progress { opacity: 0.18; transition: opacity 0.3s ease; }
/* dim full-screen layer behind the focused content */
.focus-overlay {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, rgba(0, 14, 4, 0.25) 0%, rgba(0, 0, 0, 0.78) 80%);
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 5;
}
body.focus-mode .focus-overlay { opacity: 1; pointer-events: auto; }

/* Register custom properties so they can be transitioned (without this,
   transitioning a CSS variable value is silently ignored). */
@property --card-hover {
  syntax: '<number>';
  inherits: false;
  initial-value: 1;
}
@property --card-base-opacity {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}
@property --card-hover-opacity {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}
@property --card-scale {
  syntax: '<number>';
  inherits: false;
  initial-value: 1;
}

/* Project card — base */
.project-card {
  position: absolute;
  width:  var(--card-w, 220px);
  height: var(--card-h, 140px);
  /* Position + depth-scale + base opacity come from JS via CSS vars (written
     per frame). Hover effects come from CSS-only vars (--card-hover for
     scale, --card-hover-opacity for opacity boost). max() lets hover
     elevate opacity to 1 without being clobbered by inline JS writes. */
  --card-tx: 0px;
  --card-ty: 0px;
  --card-scale: 1;
  --card-base-opacity: 0;
  --card-hover: 1;
  --card-hover-opacity: 0;
  transform: translate(var(--card-tx), var(--card-ty))
             translate(-50%, -50%)
             scale(calc(var(--card-scale) * var(--card-hover)));
  opacity: max(var(--card-base-opacity), var(--card-hover-opacity));
  transform-origin: center center;
  pointer-events: auto;
  cursor: pointer;
  /* Width/height animate when JS swaps --card-w/--card-h after an image
     loads (applyImageAspect resizes the card to match the image's aspect
     ratio). Without this it'd be an invisible instant snap; the transition
     makes the resize legible.
     --card-base-opacity transition (0.35s) animates the binary 0↔1 flip
     on mobile so cards fade in/out instead of snapping. The transition is
     on a single value (cheap), not a per-frame computed gradient (was
     expensive). */
  transition: --card-hover 0.25s ease, --card-hover-opacity 0.18s ease,
              --card-base-opacity 0.35s ease,
              filter 0.3s ease, width 0.4s ease, height 0.4s ease;
  will-change: transform, opacity;
  user-select: none;
}
/* Hover — expand 95% (1.3 × 1.5 ≈ 1.95) and elevate opacity to 1 */
.project-card:hover {
  --card-hover: 1.95;
  --card-hover-opacity: 1;
  z-index: 110 !important;
}
.project-card .card-image {
  position: absolute; inset: 4px;
  /* Gradient ALWAYS shown — acts as fallback when no photo or photo fails. */
  background: var(--card-bg, linear-gradient(135deg, #0d2c14 0%, #07150b 100%));
  overflow: hidden;
}
/* Real photo sits above the gradient. Hidden until loaded so a broken
   image doesn't show a busted icon. Saturation/brightness are tunable so
   photos can be color-matched to the matrix aesthetic. */
.project-card .card-photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.35s ease;
  filter:
    saturate(var(--card-photo-saturate, 0.85))
    brightness(var(--card-photo-brightness, 0.95));
  /* Subtle green-channel push so photos read as part of the matrix world */
  mix-blend-mode: var(--card-photo-blend, normal);
}
.project-card .card-photo.loaded { opacity: 1; }
/* Soft green tint overlay on top of photos */
.project-card[data-has-image="1"] .card-image::before {
  opacity: 0.30;
}
.project-card .card-image::before {
  content: '';
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(135deg,
      rgba(0, 255, 65, 0.10) 0 1px,
      transparent 1px 6px),
    repeating-linear-gradient(45deg,
      rgba(0, 255, 65, 0.06) 0 1px,
      transparent 1px 9px);
  mix-blend-mode: screen;
}
/* Animated scan line travelling top→bottom every ~3s */
.project-card .card-image::after {
  content: '';
  position: absolute; left: 0; right: 0;
  height: 18px;
  top: -18px;
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(108, 255, 138, 0.0) 20%,
    rgba(108, 255, 138, 0.55) 50%,
    rgba(108, 255, 138, 0.0) 80%,
    transparent 100%);
  animation: card-scan 3.6s linear infinite;
  pointer-events: none;
  mix-blend-mode: screen;
}
@keyframes card-scan {
  0%   { top: -18px; }
  100% { top: 100%; }
}
/* Cyberpunk frame — SVG corner brackets + edge ticks */
.project-card .frame {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
  pointer-events: none;
}
.project-card .frame .bracket,
.project-card .frame .edge {
  fill: none;
  stroke: var(--card-frame-color, #6cff8a);
  stroke-width: 1.4;
  filter: drop-shadow(0 0 4px rgba(0, 255, 65, 0.85));
  transition: stroke 0.2s ease, stroke-width 0.2s ease;
}
.project-card .frame .edge { stroke-width: 0.8; opacity: 0.55; }
.project-card:hover .frame .bracket { stroke-width: 2.2; stroke: #c8ffd8; }
.project-card:hover .frame .edge    { opacity: 0.95; }

/* Card text overlay */
.project-card .card-overlay {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 10px 14px 12px 14px;
  font-family: 'Courier New', monospace;
  color: #d8ffe0;
  background: linear-gradient(to top, rgba(0, 14, 4, 0.85) 30%, transparent 100%);
  pointer-events: none;
}
.project-card .card-cat {
  font-size: 9px; letter-spacing: 0.32em;
  color: rgba(160, 255, 180, 0.78);
  margin-bottom: 4px;
}
.project-card .card-title {
  font-size: 16px; letter-spacing: 0.16em;
  color: #f0fff5;
  text-shadow: 0 0 10px rgba(0, 255, 65, 0.85);
  font-weight: 700;
}
.project-card .card-blurb {
  margin-top: 4px;
  font-size: 10px; letter-spacing: 0.06em;
  color: rgba(180, 255, 200, 0.65);
  line-height: 1.4;
  /* Hidden by default, visible on hover */
  max-height: 0; overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}
.project-card:hover .card-blurb {
  max-height: 40px;
  opacity: 1;
}
/* Number badge top-left */
.project-card .card-num {
  position: absolute; top: 8px; left: 12px;
  font-family: 'Courier New', monospace;
  font-size: 9px; letter-spacing: 0.3em;
  color: rgba(160, 255, 180, 0.78);
  background: rgba(0, 14, 4, 0.65);
  padding: 2px 6px;
  border: 1px solid rgba(0, 255, 65, 0.4);
}
/* Glow when not focused */
.project-card:hover {
  filter: drop-shadow(0 0 16px rgba(0, 255, 65, 0.55));
}
/* Focused card — overrides position via JS, locks centered/large */
.project-card.focused {
  z-index: 7;
  cursor: default;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1.0), opacity 0.4s ease;
}
/* Focus mode — image overlays/filters removed so the hero photo reads cleanly */
.project-card.focused .card-photo {
  filter: none !important;
  mix-blend-mode: normal !important;
}
.project-card.focused .card-image::before,
.project-card.focused .card-image::after {
  display: none;
}
.project-card.focused .card-overlay {
  /* Lighter gradient so the focused image isn't half-covered by a dark panel */
  background: linear-gradient(to top, rgba(0, 14, 4, 0.55) 0%, transparent 60%);
}
/* Other cards faded out during focus */
body.focus-mode .project-card:not(.focused) {
  opacity: 0 !important;
  pointer-events: none;
}
