/* =====================================================================
   CONTENT-DRIVEN SCENES (electrical theme) — see js/scenes.js
   ===================================================================== */

/* ---------- 1. Hero circuit board canvas ---------- */
.hero-section { position: relative; }
.hero-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  animation: sceneFadeIn 1.6s ease 0.3s forwards;
}
.hero-section .hero-layout { position: relative; z-index: 2; }
.hero-photo-credit { z-index: 3; }
@keyframes sceneFadeIn { to { opacity: 0.9; } }

/* ---------- 2. Three-phase waveform dividers ---------- */
.phase-divider {
  position: relative;
  height: 56px;
  overflow: hidden;
  background: var(--bg-page);
  border-block: 1px solid var(--border-color);
}
.phase-track {
  position: absolute;
  inset: 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.phase-track svg {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 2400px;
  animation: phaseRun 9s linear infinite;
  animation-play-state: paused;
}
.phase-divider.is-live .phase-track svg { animation-play-state: running; }
@keyframes phaseRun { to { transform: translateX(-1200px); } }

.phase-track .ph { fill: none; stroke-width: 1.8; stroke-linecap: round; }
.phase-track .ph1 { stroke: #1f4d8c; }
.phase-track .ph2 { stroke: #4a86dc; opacity: 0.8; }
.phase-track .ph3 { stroke: #8fb4f0; opacity: 0.75; }
.phase-track .ph-axis { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 6; }
[data-theme="dark"] .phase-track .ph1 { stroke: #8fb4f0; }
[data-theme="dark"] .phase-track .ph2 { stroke: #4a86dc; }
[data-theme="dark"] .phase-track .ph3 { stroke: #cfe0f8; opacity: 0.5; }

.phase-labels {
  position: absolute;
  inset-inline-start: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: flex;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  direction: ltr;
}
.phase-labels span {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
}
.phase-labels .l1 { color: #1f4d8c; }
.phase-labels .l2 { color: #4a86dc; }
.phase-labels .l3 { color: #6f93c2; }
[data-theme="dark"] .phase-labels .l1 { color: #8fb4f0; }

/* ---------- 3. Living icons ---------- */
/* strokes are drawn by "current" when they first come into view */
.ico-pending svg :is(path, line, polyline, polygon, circle, rect):not([fill="currentColor"]) {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.ico-drawn svg :is(path, line, polyline, polygon, circle, rect):not([fill="currentColor"]),
.ico-replay svg :is(path, line, polyline, polygon, circle, rect):not([fill="currentColor"]) {
  stroke-dasharray: 1;
  animation: icoDraw 1.3s cubic-bezier(0.65, 0, 0.35, 1) both;
}
.ico-replay svg :is(path, line, polyline, polygon, circle, rect):not([fill="currentColor"]) { animation-duration: 0.9s; }
@keyframes icoDraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.ico-drawn svg { animation: icoGlow 1.6s ease-out both; }
@keyframes icoGlow {
  0%, 60% { filter: drop-shadow(0 0 6px rgba(74, 134, 220, 0.7)); }
  100% { filter: drop-shadow(0 0 0 transparent); }
}

/* motors & gears turn */
svg[data-ico="refresh-cw"], svg[data-ico="settings"], svg[data-ico="disc"] { transform-origin: 50% 50%; }
.division-card:hover svg[data-ico="refresh-cw"],
.tool-card:hover svg[data-ico="settings"],
.tool-tab:hover svg[data-ico="settings"],
.sim-test:hover svg[data-ico="disc"],
.sim-equip-btn:hover svg[data-ico="settings"] { animation: icoSpin 1.6s cubic-bezier(0.45, 0, 0.2, 1) infinite; }
@keyframes icoSpin { to { transform: rotate(360deg); } }
html[dir="rtl"] .division-card:hover svg[data-ico="refresh-cw"] { animation-direction: reverse; }

/* gauge needle swing (whole icon sways like a needle settling) */
svg[data-ico="gauge"] { transform-origin: 50% 70%; }
.division-card:hover svg[data-ico="gauge"],
.sim-test:hover svg[data-ico="gauge"],
.hero-pillar-chip:hover svg[data-ico="gauge"] { animation: icoNeedle 1.1s ease-in-out; }
@keyframes icoNeedle {
  0% { transform: rotate(0); }
  30% { transform: rotate(-24deg); }
  55% { transform: rotate(14deg); }
  75% { transform: rotate(-6deg); }
  100% { transform: rotate(0); }
}

/* bolts flicker like an arc */
.sim-test:hover svg[data-ico="zap"], .tool-tab:hover svg[data-ico="zap"] { animation: icoArc 0.7s steps(1) 1; }
@keyframes icoArc {
  0% { opacity: 1; } 15% { opacity: 0.2; } 30% { opacity: 1; } 45% { opacity: 0.4; } 60%, 100% { opacity: 1; filter: drop-shadow(0 0 6px #4a86dc); }
}

/* heartbeat / signal re-traces itself */
.tool-card:hover svg[data-ico="activity"] :is(polyline, path),
.tool-tab:hover svg[data-ico="activity"] :is(polyline, path) {
  stroke-dasharray: 1;
  animation: icoDraw 0.9s cubic-bezier(0.65, 0, 0.35, 1) both;
}

/* simulator "play" pulses */
.tool-card:hover svg[data-ico="play"], .tool-tab:hover svg[data-ico="play"] { animation: icoBeat 0.9s ease-in-out infinite; }
@keyframes icoBeat { 50% { transform: scale(1.18); } }

/* sliders, calculator, factory: a small mechanical nudge */
.tool-card:hover svg[data-ico="sliders"], .division-card:hover svg[data-ico="sliders"] { animation: icoNudge 0.8s ease-in-out; }
.tool-card:hover svg[data-ico="calculator"] { animation: icoNudge 0.6s ease-in-out; }
.division-card:hover svg[data-ico="factory"] { animation: icoRise 0.9s ease-in-out; }
@keyframes icoNudge { 25% { transform: translateY(-3px); } 50% { transform: translateY(2px); } 75% { transform: translateY(-1px); } }
@keyframes icoRise { 40% { transform: translateY(-4px) scale(1.06); } }

/* shield gets a quick "verified" shine */
.tool-card:hover svg[data-ico="shield-check"], .hero-pillar-chip:hover svg[data-ico="shield-check"] {
  animation: icoGlow 1.2s ease-out both;
}

/* hero highlight icons idle gently so the hero never feels static */
.hero-pillar-icon svg[data-ico="refresh-cw"] { animation: icoSpin 7s linear infinite; }

/* ---------- 4. Thermal camera view on gallery photos ---------- */
.thermal-hud {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s var(--m-ease, ease);
}
.gallery-item:hover .thermal-hud,
.gallery-item:focus-visible .thermal-hud { opacity: 1; }
.gallery-item:hover img { filter: grayscale(1) contrast(1.15) brightness(1.05); }
.gallery-item img { transition: transform 0.9s var(--m-out, ease), filter 0.5s ease !important; }

.thermal-tint {
  position: absolute;
  inset: 0;
  mix-blend-mode: color;
  background:
    radial-gradient(220px circle at var(--tx, 55%) var(--ty, 45%), #fff7a1 0%, #ffb020 22%, #ff4d2e 42%, transparent 62%),
    linear-gradient(160deg, #2a0a5e 0%, #7b1fa2 35%, #d81b60 60%, #ff7043 85%, #ffd54f 100%);
}
.thermal-reticle {
  position: absolute;
  left: var(--tx, 55%);
  top: var(--ty, 45%);
  width: 46px;
  height: 46px;
  transform: translate(-50%, -50%);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.thermal-reticle::before,
.thermal-reticle::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
}
.thermal-reticle::before { left: 50%; top: -10px; bottom: -10px; width: 1.5px; transform: translateX(-50%); }
.thermal-reticle::after { top: 50%; left: -10px; right: -10px; height: 1.5px; transform: translateY(-50%); }
.thermal-reticle i {
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px #fff;
}
.thermal-badge {
  position: absolute;
  top: 14px;
  inset-inline-start: 14px;
  padding: 3px 9px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  direction: ltr;
}
.thermal-badge::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-inline-end: 6px;
  border-radius: 50%;
  background: #ff3d3d;
  animation: recBlink 1s steps(1) infinite;
}
@keyframes recBlink { 50% { opacity: 0; } }
.thermal-scale {
  position: absolute;
  top: 14px;
  bottom: 70px;
  inset-inline-end: 14px;
  width: 8px;
  border-radius: 4px;
  background: linear-gradient(180deg, #ffd54f, #ff7043, #d81b60, #7b1fa2, #2a0a5e);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}
.thermal-scale b {
  position: absolute;
  inset-inline-end: 12px;
  font: 700 0.6rem/1 var(--font-mono);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.thermal-scale b:first-of-type { top: 0; }
.thermal-scale b:last-of-type { bottom: 0; }
.thermal-scanline {
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 30%;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.14), transparent);
  animation: thermalScan 2.4s linear infinite;
}
@keyframes thermalScan { from { transform: translateY(-100%); } to { transform: translateY(340%); } }
/* captions stay readable above the thermal layer */
.gallery-caption { z-index: 2; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .hero-canvas { opacity: 0.9; animation: none; }
  .phase-track svg, .thermal-scanline, .thermal-badge::before { animation: none !important; }
  .ico-pending svg :is(path, line, polyline, polygon, circle, rect) { stroke-dashoffset: 0; }
}

/* keep the headline crisp: circuit fades out behind the text column */
.hero-canvas {
  -webkit-mask-image: linear-gradient(to right, #000 0%, #000 40%, rgba(0, 0, 0, 0.28) 75%, rgba(0, 0, 0, 0.28) 100%);
  mask-image: linear-gradient(to right, #000 0%, #000 40%, rgba(0, 0, 0, 0.28) 75%, rgba(0, 0, 0, 0.28) 100%);
}
html[dir="ltr"] .hero-canvas {
  -webkit-mask-image: linear-gradient(to left, #000 0%, #000 40%, rgba(0, 0, 0, 0.28) 75%, rgba(0, 0, 0, 0.28) 100%);
  mask-image: linear-gradient(to left, #000 0%, #000 40%, rgba(0, 0, 0, 0.28) 75%, rgba(0, 0, 0, 0.28) 100%);
}
@media (max-width: 1080px) {
  .hero-canvas, html[dir="ltr"] .hero-canvas {
    -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35) 60%, #000 100%);
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35) 60%, #000 100%);
  }
}
