/* ============================================================
   core.kzick.dev — reactor console
   Built on K-Zick design system v2.1.3 tokens.
   Cyan only. No orange.
   ============================================================ */

html {
  /* inherited kzick tokens */
  --bg: #000000;
  --text-primary: #ffffff;
  --text-tertiary: rgba(235, 235, 245, 0.3);
  --accent: #06b6d4;
  --accent-rgb: 6, 182, 212;

  /* core.kzick extensions: cyan depth ramp.
     Single-hue palettes go flat fast. These give the reactor a
     temperature gradient from cold dead metal to white-hot center
     without introducing a second accent hue. */
  --cy-substrate: #041b20;
  --cy-deep:      #0a3d47;
  --cy-hot:       #7ff3ff;
  --cy-white:     #e8feff;

  /* not pure black — a hair of blue keeps the bloom from clipping */
  --field: #04070a;

  --sf: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  font-family: var(--sf);
  color: var(--text-primary);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--field);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* ══ ATMOSPHERE — three stacked field layers ══ */

.field-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(var(--accent-rgb), 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.055) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 65% 55% at 50% 48%, #000 0%, transparent 78%);
  mask-image: radial-gradient(ellipse 65% 55% at 50% 48%, #000 0%, transparent 78%);
  z-index: 0;
}

.field-bloom {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle 520px at 50% 48%,
    rgba(var(--accent-rgb), 0.10) 0%,
    rgba(var(--accent-rgb), 0.035) 35%,
    transparent 68%);
  z-index: 0;
  animation: field-breathe 7s ease-in-out infinite;
}

@keyframes field-breathe {
  0%, 100% { opacity: 0.75; }
  50%      { opacity: 1; }
}

.field-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0,0,0,0) 0px,
      rgba(0,0,0,0) 2px,
      rgba(0,0,0,0.14) 3px,
      rgba(0,0,0,0) 4px
    ),
    radial-gradient(ellipse 80% 70% at 50% 48%, transparent 40%, rgba(0,0,0,0.85) 100%);
  z-index: 1;
}

.hud-corner {
  position: fixed;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(var(--accent-rgb), 0.32);
  pointer-events: none;
  z-index: 3;
}
.hud-corner.tl { top: 18px; left: 18px;  border-right: none; border-bottom: none; }
.hud-corner.tr { top: 18px; right: 18px; border-left: none;  border-bottom: none; }
.hud-corner.bl { bottom: 18px; left: 18px;  border-right: none; border-top: none; }
.hud-corner.br { bottom: 18px; right: 18px; border-left: none;  border-top: none; }

/* ══ HEADER ══ */

.masthead {
  position: relative;
  z-index: 4;
  padding: 46px 32px 0;
  text-align: center;
  user-select: none;
}

.wordmark {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 5px;
  color: var(--text-primary);
  text-transform: uppercase;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}

.wordmark .bracket {
  color: var(--accent);
  font-weight: 400;
  text-shadow: 0 0 12px rgba(var(--accent-rgb), 0.7);
}

.wordmark .tld {
  color: var(--text-tertiary);
  font-weight: 400;
  letter-spacing: 3px;
}

.masthead-rule {
  width: 172px;
  height: 1px;
  margin: 14px auto 12px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.5), transparent);
}

/* ══ REACTOR STAGE ══ */

.stage {
  flex: 1;
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 34px 20px 60px;
}

/* Grid geometry is load-bearing: 148px cells + 22px gutters = 488px.
   The SVG trace layer uses a matching 0 0 488 488 viewBox so routes
   land on real pixel coordinates. Change one, change both. */
.reactor {
  position: relative;
  width: 488px;
  height: 488px;
  display: grid;
  grid-template-columns: repeat(3, 148px);
  grid-template-rows: repeat(3, 148px);
  gap: 22px;
}

/* ══ PCB TRACE LAYER ══ */

.trace-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.trace-etch {
  fill: none;
  stroke: var(--cy-substrate);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trace-live {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 0.28s ease-out;
}

.trace-live.on {
  opacity: 1;
  filter: drop-shadow(0 0 5px rgba(var(--accent-rgb), 0.95));
}

.trace-flow {
  fill: none;
  stroke: var(--cy-hot);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 16 400;
  opacity: 0;
}

.trace-flow.on {
  opacity: 1;
  filter: drop-shadow(0 0 7px var(--cy-hot));
  animation: charge 1.1s linear infinite;
}

@keyframes charge {
  from { stroke-dashoffset: 416; }
  to   { stroke-dashoffset: 0; }
}

.trace-via {
  fill: var(--field);
  stroke: var(--cy-deep);
  stroke-width: 1.5;
  transition: stroke 0.28s ease-out, fill 0.28s ease-out;
}

.trace-via.on {
  stroke: var(--cy-hot);
  fill: rgba(var(--accent-rgb), 0.35);
  filter: drop-shadow(0 0 5px var(--cy-hot));
}

/* ══ TOOL SLOTS ══ */

.slot {
  position: relative;
  z-index: 2;
  display: block;
  text-decoration: none;
  color: inherit;
}

/* Corner brackets live OUTSIDE the clipped surface so they can push
   outward on hover without being cut off. */
.slot-bracket {
  position: absolute;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--cy-deep);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 3;
}
.slot-bracket.tl { top: -1px; left: -1px;  border-right: none; border-bottom: none; }
.slot-bracket.tr { top: -1px; right: -1px; border-left: none;  border-bottom: none; }
.slot-bracket.bl { bottom: -1px; left: -1px;  border-right: none; border-top: none; }
.slot-bracket.br { bottom: -1px; right: -1px; border-left: none;  border-top: none; }

.slot.live:hover .slot-bracket,
.slot.live:focus-visible .slot-bracket {
  border-color: var(--cy-hot);
  width: 19px;
  height: 19px;
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.55);
}
.slot.live:hover .slot-bracket.tl,
.slot.live:focus-visible .slot-bracket.tl { top: -6px; left: -6px; }
.slot.live:hover .slot-bracket.tr,
.slot.live:focus-visible .slot-bracket.tr { top: -6px; right: -6px; }
.slot.live:hover .slot-bracket.bl,
.slot.live:focus-visible .slot-bracket.bl { bottom: -6px; left: -6px; }
.slot.live:hover .slot-bracket.br,
.slot.live:focus-visible .slot-bracket.br { bottom: -6px; right: -6px; }

.slot-surface {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 3px;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.035) 0%, transparent 42%),
    linear-gradient(180deg, #10171c 0%, #080d11 100%);
  border: 1px solid rgba(var(--accent-rgb), 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.28s ease-out, box-shadow 0.28s ease-out,
              background 0.28s ease-out, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slot.live { cursor: pointer; }

.slot.live:hover .slot-surface,
.slot.live:focus-visible .slot-surface {
  border-color: rgba(var(--accent-rgb), 0.75);
  background:
    linear-gradient(160deg, rgba(var(--accent-rgb), 0.10) 0%, transparent 46%),
    linear-gradient(180deg, #142228 0%, #0a1216 100%);
  box-shadow:
    inset 0 0 26px rgba(var(--accent-rgb), 0.14),
    0 0 0 1px rgba(var(--accent-rgb), 0.22),
    0 0 34px rgba(var(--accent-rgb), 0.28);
  transform: translateY(-3px);
}

.slot-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 40%;
  top: -40%;
  background: linear-gradient(180deg,
    transparent,
    rgba(var(--accent-rgb), 0.16) 55%,
    rgba(127, 243, 255, 0.22) 82%,
    transparent);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}

.slot.live:hover .slot-scan,
.slot.live:focus-visible .slot-scan {
  opacity: 1;
  animation: scan-sweep 1.6s ease-in-out infinite;
}

@keyframes scan-sweep {
  0%   { top: -40%; opacity: 0; }
  18%  { opacity: 1; }
  82%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* Inline SVG fallback glyph — used when a slot has no uploaded icon. */
.slot-icon {
  width: 40px;
  height: 40px;
  color: #4d757f;
  transition: color 0.28s ease-out, filter 0.28s ease-out, transform 0.28s ease-out;
}

.slot.live:hover .slot-icon,
.slot.live:focus-visible .slot-icon {
  color: var(--cy-hot);
  filter: drop-shadow(0 0 9px rgba(var(--accent-rgb), 0.95));
  transform: scale(1.06);
}

/* R2-hosted raster/SVG icon. Raster can't inherit currentColor, so the
   hover response is carried by opacity, saturation, and bloom instead
   of a color shift. Upload icons pre-tinted; nothing needs re-coloring. */
.slot-icon-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  opacity: 0.55;
  filter: grayscale(0.4);
  transition: opacity 0.28s ease-out, filter 0.28s ease-out, transform 0.28s ease-out;
  user-select: none;
  -webkit-user-drag: none;
}

.slot.live:hover .slot-icon-img,
.slot.live:focus-visible .slot-icon-img {
  opacity: 1;
  filter: grayscale(0) brightness(1.12) drop-shadow(0 0 9px rgba(var(--accent-rgb), 0.9));
  transform: scale(1.06);
}

.slot-name {
  position: absolute;
  left: 50%;
  bottom: -25px;
  transform: translateX(-50%) translateY(-5px);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: var(--cy-hot);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.28s ease-out, transform 0.28s ease-out;
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.6);
  z-index: 4;
}

.slot.live:hover .slot-name,
.slot.live:focus-visible .slot-name {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ══ EMPTY SLOT — inert by construction ══ */

.slot.empty { cursor: default; }

.slot.empty .slot-bracket {
  border-color: rgba(var(--accent-rgb), 0.13);
  border-style: dashed;
}

.slot.empty .slot-surface {
  background:
    repeating-linear-gradient(45deg,
      rgba(var(--accent-rgb), 0.035) 0px,
      rgba(var(--accent-rgb), 0.035) 1px,
      transparent 1px,
      transparent 9px);
  border: 1px dashed rgba(var(--accent-rgb), 0.10);
  box-shadow: none;
  transform: none;
}

.slot-index {
  position: absolute;
  top: 8px;
  left: 10px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 1.2px;
  color: rgba(var(--accent-rgb), 0.18);
  user-select: none;
}

.slot-empty-label {
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 2.4px;
  color: rgba(var(--accent-rgb), 0.26);
  user-select: none;
}

/* ══ THE CORE — signature element ══
   Layer order back to front: halo, chrome rings, art, singularity.
   Rendered entirely in SVG + CSS. No image asset, nothing fetched. */

.core {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.core-stack {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease-out, filter 0.4s ease-out;
}

/* core yields power when a subsystem draws on it */
.reactor.drawing .core-stack {
  opacity: 0.5;
  filter: saturate(0.55) brightness(0.8);
}

.core-halo {
  position: absolute;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(232, 254, 255, 0.30) 0%,
    rgba(var(--accent-rgb), 0.30) 22%,
    rgba(var(--accent-rgb), 0.10) 48%,
    transparent 70%);
  animation: halo-pulse 4.2s ease-in-out infinite;
}

@keyframes halo-pulse {
  0%, 100% { transform: scale(1);    opacity: 0.82; }
  50%      { transform: scale(1.13); opacity: 1; }
}

.core-rings {
  position: absolute;
  width: 158px;
  height: 158px;
  overflow: visible;
}

.ring-outer {
  fill: none;
  stroke: rgba(var(--accent-rgb), 0.55);
  stroke-width: 1;
  stroke-dasharray: 2 7;
  transform-origin: 80px 80px;
  animation: spin-cw 44s linear infinite;
}

.ring-mid {
  fill: none;
  stroke: rgba(127, 243, 255, 0.5);
  stroke-width: 1.5;
  stroke-dasharray: 34 26;
  stroke-linecap: round;
  transform-origin: 80px 80px;
  animation: spin-ccw 27s linear infinite;
}

.ring-tick {
  stroke: rgba(var(--accent-rgb), 0.7);
  stroke-width: 1.25;
  stroke-linecap: round;
  transform-origin: 80px 80px;
  animation: spin-cw 44s linear infinite;
}

@keyframes spin-cw  { to { transform: rotate(360deg); } }
@keyframes spin-ccw { to { transform: rotate(-360deg); } }

.core-art {
  position: relative;
  width: 92px;
  height: 92px;
  color: var(--cy-hot);
  filter: drop-shadow(0 0 14px rgba(var(--accent-rgb), 0.9));
  animation: art-breathe 4.2s ease-in-out infinite;
}

@keyframes art-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

.core-singularity {
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--cy-white);
  box-shadow:
    0 0 12px 3px var(--cy-hot),
    0 0 30px 8px rgba(var(--accent-rgb), 0.75);
  animation: singularity 4.2s ease-in-out infinite;
}

@keyframes singularity {
  0%, 100% { transform: scale(1);    opacity: 0.9; }
  50%      { transform: scale(1.22); opacity: 1; }
}

/* ══ RESPONSIVE ══ */

@media (max-width: 560px) {
  .reactor {
    width: 92vw;
    height: 92vw;
    grid-template-columns: repeat(3, calc((92vw - 28px) / 3));
    grid-template-rows: repeat(3, calc((92vw - 28px) / 3));
    gap: 14px;
  }
  .core-halo  { width: 130px; height: 130px; }
  .core-rings { width: 108px; height: 108px; }
  .core-art   { width: 62px;  height: 62px; }
  .core-singularity { width: 9px; height: 9px; }
  .slot-icon     { width: 30px; height: 30px; }
  .slot-icon-img { width: 34px; height: 34px; }
  .slot-name  { bottom: -20px; font-size: 8.5px; letter-spacing: 1.6px; }
  .masthead   { padding-top: 34px; }
  .wordmark   { font-size: 13px; letter-spacing: 3.5px; }
  .hud-corner { width: 18px; height: 18px; }
}

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

.slot:focus-visible { outline: none; }
