/* ============================================================
   ssptools.dev — reactor console
   Botanical / clinical theme. Light default, dark toggle,
   background line drift toggle. Sterling Specialty Pharmacy.
   ============================================================ */

html {
  /* ── LIGHT THEME (default) ── */
  --paper:        #FAFAF6;
  --paper-raised: #FFFFFF;
  --ink:          #1C2418;
  --ink-soft:     rgba(28, 36, 24, 0.52);
  --ink-faint:    rgba(28, 36, 24, 0.30);
  --sage:         #4F8330;
  --sage-rgb:     79, 131, 48;
  --sage-deep:    #2F5A1B;
  --sage-pale:    #E4EEDB;
  --line:         rgba(79, 131, 48, 0.18);
  --line-soft:    rgba(79, 131, 48, 0.09);
  --card-bg:      linear-gradient(180deg, #FFFFFF 0%, #F6F9F1 100%);
  --card-border:  rgba(79, 131, 48, 0.16);
  --card-hover-border: rgba(79, 131, 48, 0.55);
  --shadow-ambient: rgba(47, 90, 27, 0.10);

  --tile-empty-border: rgba(79, 131, 48, 0.42);
  --tile-empty-text: rgba(28, 36, 24, 0.55);

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

  font-family: var(--sf);
  color: var(--ink);
  background-color: var(--paper);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.35s ease, color 0.35s ease;
}

html.dark {
  /* ── DARK THEME ── */
  --paper:        #0E1510;
  --paper-raised: #16211A;
  --ink:          #EDF3E7;
  --ink-soft:     rgba(237, 243, 231, 0.60);
  --ink-faint:    rgba(237, 243, 231, 0.34);
  --sage:         #7FC950;
  --sage-rgb:     127, 201, 80;
  --sage-deep:    #A9E080;
  --sage-pale:    #1B2A16;
  --line:         rgba(127, 201, 80, 0.22);
  --line-soft:    rgba(127, 201, 80, 0.10);
  --card-bg:      linear-gradient(180deg, #182319 0%, #101A12 100%);
  --card-border:  rgba(127, 201, 80, 0.20);
  --card-hover-border: rgba(127, 201, 80, 0.65);
  --shadow-ambient: rgba(0, 0, 0, 0.4);

  --tile-empty-border: rgba(127, 201, 80, 0.4);
  --tile-empty-text: rgba(237, 243, 231, 0.5);

  --shimmer-1: #1B4D0F;
  --shimmer-2: #4F8330;
  --shimmer-3: #7FC950;
  --shimmer-4: #C3EFA8;
  --shimmer-5: #F2FBEA;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* ══ BACKGROUND WATERMARK — three flowing lines derived from the
   logo's own strand skeleton, traced from source geometry, not
   redrawn freehand. Static by default; "drift" toggle animates
   a slow dash-offset crawl along the paths. ══ */

/* Canvas-rendered 3-strand helix braid. Opacity is CSS-driven same as
   before (0 at rest, 0.55 when body.drifting is active) but the actual
   render loop is gated separately in JS — canvas has a real per-frame
   cost that a paused CSS animation didn't, so app.js/admin.js stop
   requestAnimationFrame entirely when not drifting, not just fade it. */
/* .field-lines / body.drifting removed — braid canvas animation
   dropped entirely per v2 rework. Background is now just the
   vignette below. */

.field-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse 85% 70% at 50% 45%, transparent 45%, var(--paper) 100%);
  transition: background 0.35s ease;
}

/* ══ HEADER — full width bar, split around a center emblem. This
   replaces the old .masthead entirely. ══ */

.core-header {
  position: relative;
  width: 100%;
  max-width: 720px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  margin: 20px auto 0;
}

.header-shell {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  z-index: 1;
}

.header-wing {
  flex: 1;
  height: 56px;
  background: var(--paper-raised);
  border: 1px solid var(--card-border);
  box-shadow: 0 1px 2px var(--shadow-ambient);
  display: flex;
  align-items: center;
  position: relative;
  z-index: 2;
}
.header-wing.left {
  justify-content: flex-start;
  padding-left: 22px;
}
.header-wing.right {
  justify-content: flex-end;
  padding-right: 18px;
}

.wordmark {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 3px;
  color: var(--ink-faint);
  text-transform: uppercase;
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  opacity: 0.75;
}
.wordmark .tld { font-weight: 400; letter-spacing: 2px; opacity: 0.85; }

.header-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: color 0.2s ease-out, border-color 0.2s ease-out, background 0.2s ease-out;
  padding: 0;
}
.icon-btn:hover {
  color: var(--sage);
  border-color: var(--line);
  background: var(--line-soft);
}
.icon-btn svg { width: 16px; height: 16px; }

/* sun/moon crossfade */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute;
  transition: opacity 0.25s ease, transform 0.35s ease;
}
.theme-toggle { position: relative; }
.theme-toggle .icon-moon { opacity: 0; transform: rotate(-40deg) scale(0.6); }
.theme-toggle .icon-sun  { opacity: 1; transform: rotate(0) scale(1); }
html.dark .theme-toggle .icon-sun  { opacity: 0; transform: rotate(40deg) scale(0.6); }
html.dark .theme-toggle .icon-moon { opacity: 1; transform: rotate(0) scale(1); }

/* Header trace sweep — ONE continuous beam traveling the full header
   width (both wings + the emblem seam), not two independent
   per-wing sweeps. Dark mode only. */
.header-sweep-track {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
  border-radius: 10px;
  opacity: 0;
}
html.dark .header-sweep-track {
  opacity: 1;
}
.header-sweep-beam {
  position: absolute;
  top: 0;
  left: -35%;
  width: 35%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(127, 201, 80, 0.0) 15%,
    rgba(127, 201, 80, 0.4) 45%,
    rgba(201, 240, 168, 0.65) 50%,
    rgba(127, 201, 80, 0.4) 55%,
    rgba(127, 201, 80, 0.0) 85%,
    transparent 100%
  );
}
html.dark .header-sweep-beam {
  animation: header-sweep 5.5s linear infinite;
}
@keyframes header-sweep {
  0%   { left: -35%; }
  100% { left: 100%; }
}

/* ══ CENTER EMBLEM — smaller S-curve mark in a glow ring, sits on
   top of the header seam. Click target for the mini-tile drawer.
   Purely a trigger; the main .core logo elsewhere stays decorative
   only and is never wired to anything. ══ */

.emblem-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 12;
}

.emblem-btn {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  background: var(--paper-raised);
  box-shadow:
    0 4px 16px var(--shadow-ambient),
    0 0 0 1px var(--card-border),
    0 0 0 6px var(--paper);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: box-shadow 0.3s ease-out, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.emblem-btn svg { width: 34px; height: 34px; }
.emblem-btn path { fill: var(--sage); transition: fill 0.25s ease-out; }

/* Static glow ring — always present, subtle, communicates
   "clickable" even before hover/interaction. */
.emblem-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  opacity: 0.55;
  transition: border-color 0.25s ease-out, opacity 0.25s ease-out, box-shadow 0.25s ease-out;
  pointer-events: none;
}

.emblem-btn:hover,
.emblem-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow:
    0 6px 22px var(--shadow-ambient),
    0 0 0 1px var(--card-hover-border),
    0 0 0 6px var(--paper);
}
.emblem-btn:hover ~ .emblem-ring,
.emblem-btn:focus-visible ~ .emblem-ring {
  border-color: var(--sage);
  opacity: 1;
  box-shadow: 0 0 14px rgba(var(--sage-rgb), 0.4);
}

.emblem-btn.drawer-open {
  box-shadow:
    0 6px 22px var(--shadow-ambient),
    0 0 0 1px var(--sage),
    0 0 0 6px var(--paper);
}
.emblem-btn.drawer-open ~ .emblem-ring {
  border-color: var(--sage);
  opacity: 1;
  box-shadow: 0 0 16px rgba(var(--sage-rgb), 0.5);
}

/* Header emblem glow — SAME layered-shimmer technique as the main
   core mark below. Three scaled-down layers behind the emblem
   button, same shade progression (deep green -> mint -> near-white),
   same "no lockstep" staggered timing. Runs whenever dark mode is
   active — no separate animation toggle. */
.emblem-glow-layer {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  filter: blur(9px);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}
html.dark .emblem-glow-layer { display: block; }
html:not(.dark) .emblem-glow-layer { display: none; }

.emblem-glow-1 {
  width: 92px; height: 92px;
  margin: -46px 0 0 -46px;
  background: radial-gradient(circle, var(--shimmer-2) 0%, transparent 68%);
  animation: shimmer-a 7.5s ease-in-out infinite;
}
.emblem-glow-2 {
  width: 68px; height: 68px;
  margin: -34px 0 0 -34px;
  background: radial-gradient(circle, var(--shimmer-3) 0%, transparent 62%);
  transform: translate(5px, -4px);
  animation: shimmer-c 6.2s ease-in-out infinite;
}
.emblem-glow-3 {
  width: 42px; height: 42px;
  margin: -21px 0 0 -21px;
  background: radial-gradient(circle, var(--shimmer-5) 0%, transparent 55%);
  transform: translate(-3px, 3px);
  animation: shimmer-d 4.8s ease-in-out infinite;
}

/* ══ STAGE / REACTOR GRID ══ */

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

/* Row gap is wider than column gap on purpose — the slot name label
   sits below each tile and needs clearance from the row underneath,
   whereas columns don't carry a label between them so they can stay
   tighter. Trace-layer SVG coordinates below are computed to match
   this exact geometry (488 x 536, col gap 22 / row gap 46). */
.reactor {
  position: relative;
  width: 488px;
  height: 536px;
  display: grid;
  grid-template-columns: repeat(3, 148px);
  grid-template-rows: repeat(3, 148px);
  column-gap: 22px;
  row-gap: 46px;
}

/* ══ CONNECTIVE LINES — restyled from PCB traces into glowing
   sage-green root/vein lines. Same mechanic: hover reveals the
   route from core to that slot; all others dim. ══ */

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

.trace-etch {
  fill: none;
  stroke: var(--line);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 1;
  transition: opacity 0.28s ease-out, stroke 0.35s ease;
}

.reactor.drawing .trace-etch { opacity: 0.22; }
.trace-etch.on { opacity: 1; }

.trace-live {
  fill: none;
  stroke: var(--sage);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 0.28s ease-out, stroke 0.35s ease;
}
.trace-live.on {
  opacity: 1;
  filter: drop-shadow(0 0 5px rgba(var(--sage-rgb), 0.85));
}

.trace-flow {
  fill: none;
  stroke: var(--sage-deep);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 14 400;
  opacity: 0;
}
.trace-flow.on {
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(var(--sage-rgb), 0.9));
  animation: charge 1.1s linear infinite;
}
@keyframes charge {
  from { stroke-dashoffset: 414; }
  to   { stroke-dashoffset: 0; }
}

.trace-via {
  fill: var(--paper);
  stroke: var(--line);
  stroke-width: 1.5;
  transition: stroke 0.28s ease-out, fill 0.28s ease-out;
}
.trace-via.on {
  stroke: var(--sage);
  fill: rgba(var(--sage-rgb), 0.35);
  filter: drop-shadow(0 0 5px rgba(var(--sage-rgb), 0.8));
}

/* ══ TOOL SLOTS ══ */

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

.slot-bracket {
  position: absolute;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--line);
  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.armed .slot-bracket,
.slot.live:hover .slot-bracket,
.slot.live:focus-visible .slot-bracket {
  border-color: var(--sage);
  width: 19px;
  height: 19px;
  box-shadow: 0 0 8px rgba(var(--sage-rgb), 0.35);
}
.slot.live.armed .slot-bracket.tl, .slot.live:hover .slot-bracket.tl, .slot.live:focus-visible .slot-bracket.tl { top: -6px; left: -6px; }
.slot.live.armed .slot-bracket.tr, .slot.live:hover .slot-bracket.tr, .slot.live:focus-visible .slot-bracket.tr { top: -6px; right: -6px; }
.slot.live.armed .slot-bracket.bl, .slot.live:hover .slot-bracket.bl, .slot.live:focus-visible .slot-bracket.bl { bottom: -6px; left: -6px; }
.slot.live.armed .slot-bracket.br, .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: 10px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 1px 2px var(--shadow-ambient);
  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.armed .slot-surface,
.slot.live:hover .slot-surface,
.slot.live:focus-visible .slot-surface {
  border-color: var(--card-hover-border);
  box-shadow:
    0 8px 24px var(--shadow-ambient),
    0 0 0 1px rgba(var(--sage-rgb), 0.12);
  transform: translateY(-3px);
}

.slot-icon {
  width: 42%;
  height: 42%;
  color: var(--ink-faint);
  transition: color 0.28s ease-out, filter 0.28s ease-out, transform 0.28s ease-out;
}
.slot.live.armed .slot-icon, .slot.live:hover .slot-icon, .slot.live:focus-visible .slot-icon {
  color: var(--sage);
  transform: scale(1.06);
}

.slot-icon-img {
  width: 58%;
  height: 58%;
  object-fit: contain;
  opacity: 0.88;
  transition: opacity 0.28s ease-out, filter 0.28s ease-out, transform 0.28s ease-out;
}
.slot.live.armed .slot-icon-img, .slot.live:hover .slot-icon-img, .slot.live:focus-visible .slot-icon-img {
  opacity: 1;
  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: 2px;
  text-transform: uppercase;
  color: var(--sage-deep);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.28s ease-out, transform 0.28s ease-out;
  z-index: 4;
}
.slot.live.armed .slot-name, .slot.live:hover .slot-name, .slot.live:focus-visible .slot-name {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Row 1 only: label sits above the tile so it doesn't intersect the
   downward-drawing connecting line on hover. Same crossfade mechanic,
   opposite side and opposite translate direction. */
.slot[data-slot="1"] .slot-name,
.slot[data-slot="2"] .slot-name,
.slot[data-slot="3"] .slot-name {
  bottom: auto;
  top: -25px;
  transform: translateX(-50%) translateY(5px);
}
.slot[data-slot="1"].live.armed .slot-name, .slot[data-slot="1"].live:hover .slot-name, .slot[data-slot="1"].live:focus-visible .slot-name,
.slot[data-slot="2"].live.armed .slot-name, .slot[data-slot="2"].live:hover .slot-name, .slot[data-slot="2"].live:focus-visible .slot-name,
.slot[data-slot="3"].live.armed .slot-name, .slot[data-slot="3"].live:hover .slot-name, .slot[data-slot="3"].live:focus-visible .slot-name {
  transform: translateX(-50%) translateY(0);
}

/* ══ EMPTY SLOT ══ */

.slot.empty { cursor: default; }
.slot.empty .slot-bracket {
  border-color: var(--tile-empty-border);
  border-style: dashed;
}
.slot.empty .slot-surface {
  background: transparent;
  border: 1.5px dashed var(--tile-empty-border);
  box-shadow: none;
  transform: none;
}
.slot-index {
  position: absolute;
  top: 9px;
  left: 11px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 1.2px;
  color: var(--tile-empty-text);
  user-select: none;
}
.slot-empty-label {
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 2.4px;
  color: var(--tile-empty-text);
  user-select: none;
}

/* ══ MINI-TILE DRAWER — opens down and outward from the emblem
   simultaneously. Never renders through or below the main center
   logo elsewhere on the page; this drawer belongs entirely to the
   header and sits in front of everything beneath it. ══ */

.drawer-zone {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
}

.mini-drawer {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px) scaleX(0.3);
  transform-origin: top center;
  width: min(92%, 640px);
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 16px 14px 14px;
  background: var(--paper-raised);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 10px 28px var(--shadow-ambient);
  opacity: 0;
  pointer-events: none;
  z-index: 8;
  transition:
    opacity 0.32s cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 0.42s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.mini-drawer.open {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scaleX(1);
  pointer-events: auto;
}

.mini-tile {
  flex: 1;
  max-width: 76px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 1px 2px var(--shadow-ambient);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.22s ease-out, box-shadow 0.22s ease-out, transform 0.22s ease-out;
}
.mini-tile:hover {
  border-color: var(--card-hover-border);
  box-shadow: 0 6px 14px var(--shadow-ambient), 0 0 0 1px rgba(var(--sage-rgb), 0.12);
  transform: translateY(-2px);
}
.mini-tile svg {
  width: 40%;
  height: 40%;
  color: var(--ink-faint);
  transition: color 0.22s ease-out;
}
.mini-tile:hover svg { color: var(--sage); }
.mini-tile .mini-label {
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.mini-tile.empty {
  background: transparent;
  border-width: 1.5px;
  border-style: dashed;
  border-color: var(--tile-empty-border);
}
.mini-tile.empty .mini-label { color: var(--tile-empty-text); }

/* ══ THE CORE — redrawn SVG logo, layered shimmer glow ══ */

.core {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  z-index: 4;
  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 stays fully bright when a route is drawing — dimming it made
   the trace line look like it was showing through a faded logo.
   Only the glow eases back slightly so the active tile still reads
   as the thing drawing power. */
.reactor.drawing .core-glow {
  opacity: 0.85;
}

/* Layer 3 of the core stack (rendered first / furthest back) — a
   scaled duplicate of the mark itself, blurred, sage-colored, sitting
   behind the backing disc. Only the portion extending past the disc's
   edge is visible: a soft glowing echo of the S shape, not a generic
   circular halo. Values locked after mockup review
   (ssp-core-glow-mockup.html): scale 2.7x, blur 4px, breathe 0.11 to
   0.54 opacity over 8s. Opacity-primary pulse — scaling a blurred
   shape reads as resizing rather than glowing, since blur radius is a
   fixed pixel value and doesn't track transform scale. */
.core-glow {
  position: absolute;
  width: 118px;
  height: 118px;
  transform: scale(2.7);
  filter: blur(4px);
  color: var(--sage);
  mix-blend-mode: screen;
  opacity: 0.11;
  pointer-events: none;
  animation: core-glow-breathe 8s ease-in-out infinite;
}
html:not(.dark) .core-glow { display: none; }

@keyframes core-glow-breathe {
  0%, 100% { opacity: 0.11; }
  50% { opacity: 0.54; }
}

/* Shared with the header emblem glow (.emblem-glow-1/2/3 below) —
   do not remove even though the core no longer uses shimmer-b/e. */
@keyframes shimmer-a { 0%,100% { opacity: 0.30; } 45% { opacity: 0.82; } 70% { opacity: 0.46; } }
@keyframes shimmer-c { 0%,100% { opacity: 0.40; } 50% { opacity: 0.95; } 80% { opacity: 0.52; } }
@keyframes shimmer-d { 0%,100% { opacity: 0.28; } 40% { opacity: 0.80; } 75% { opacity: 0.36; } }

.core-plate {
  position: absolute;
  width: 138px;
  height: 138px;
  border-radius: 50%;
  background: var(--paper-raised);
  box-shadow:
    0 4px 28px var(--shadow-ambient),
    0 0 0 1px var(--card-border);
}

.core-art {
  position: relative;
  width: 118px;
  height: 118px;
  filter: drop-shadow(0 2px 6px rgba(var(--sage-rgb), 0.25));
}

/* ══ RESPONSIVE ══ */

/* Width drives tile size; height is derived so the row gap (which
   carries the slot-name label) stays roughly double the column gap
   at every size, matching the base 488x536 / 22px / 46px geometry. */
@media (min-width: 561px) {
  .reactor {
    --rs: clamp(420px, 42vmin, 620px);
    --col-gap: calc(var(--rs) * 0.045);
    --row-gap: calc(var(--rs) * 0.094);
    width: var(--rs);
    height: calc(var(--rs) + var(--row-gap) - var(--col-gap));
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    column-gap: var(--col-gap);
    row-gap: var(--row-gap);
  }
  .core-plate { width: calc(var(--rs) * 0.283); height: calc(var(--rs) * 0.283); }
  .core-art   { width: calc(var(--rs) * 0.242); height: calc(var(--rs) * 0.242); }
}

@media (max-width: 560px) {
  .reactor {
    --rs: min(92vw, 58dvh);
    --col-gap: 14px;
    --row-gap: 30px;
    width: var(--rs);
    height: calc(var(--rs) + var(--row-gap) - var(--col-gap));
    grid-template-columns: repeat(3, calc((var(--rs) - 2 * var(--col-gap)) / 3));
    grid-template-rows: repeat(3, calc((var(--rs) - 2 * var(--col-gap)) / 3));
    column-gap: var(--col-gap);
    row-gap: var(--row-gap);
  }
  .core-plate { width: 100px; height: 100px; }
  .core-art   { width: 84px;  height: 84px; }
  .slot-name  { bottom: -20px; font-size: 8.5px; letter-spacing: 1.6px; }
  .slot[data-slot="1"] .slot-name,
  .slot[data-slot="2"] .slot-name,
  .slot[data-slot="3"] .slot-name { bottom: auto; top: -20px; }
  .core-header { height: 72px; }
  .header-wing { height: 48px; }
  .emblem-btn { width: 56px; height: 56px; }
  .emblem-btn svg { width: 28px; height: 28px; }
  .mini-tile { max-width: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .core-glow, .header-sweep-beam, .emblem-glow-layer {
    display: none;
  }
}

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