/* Enigma Machine — museum-style simulator */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0c10;
  --surface: #141820;
  --metal: #1c222e;
  --metal-light: #2a3344;
  --border: #3d4a5f;
  --brass: #c9a227;
  --brass-dim: #8a7020;
  --accent: #4f8ef7;
  --cyan: #5eead4;
  --green: #3ecf8e;
  --amber: #f7b84f;
  --text: #e8edf5;
  --text-dim: #8b97ab;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

body.enigma-page {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

/* Atmospheric layers (static; canvas adds motion) */
body.enigma-page::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 55% at 50% 8%, rgba(201, 162, 39, 0.22) 0%, transparent 58%),
    radial-gradient(ellipse 70% 45% at 12% 55%, rgba(79, 142, 247, 0.12) 0%, transparent 52%),
    radial-gradient(ellipse 65% 50% at 88% 48%, rgba(94, 234, 212, 0.1) 0%, transparent 50%),
    linear-gradient(180deg, rgba(10, 12, 16, 0.35) 0%, rgba(10, 12, 16, 0.75) 100%);
}

body.enigma-page::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 47px,
      rgba(94, 234, 212, 0.045) 47px,
      rgba(94, 234, 212, 0.045) 48px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 47px,
      rgba(201, 162, 39, 0.035) 47px,
      rgba(201, 162, 39, 0.035) 48px
    ),
    radial-gradient(ellipse 100% 100% at 50% 50%, transparent 42%, rgba(0, 0, 0, 0.55) 100%);
  opacity: 0.85;
}

.enigma-atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

#enigma-bg-canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0.72;
}

.enigma-page a:not(.site-footer-nav a) { color: var(--accent); }

.enigma-hero,
.enigma-wrap {
  position: relative;
  z-index: 1;
}

/* Hero */
.enigma-hero {
  position: relative;
  min-height: 42vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3.5rem 1.25rem 2.5rem;
  overflow: hidden;
  isolation: isolate;
}

.enigma-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 75% 65% at 50% 42%, rgba(201, 162, 39, 0.28) 0%, transparent 62%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(94, 234, 212, 0.12) 0%, transparent 70%);
}

.enigma-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cpath d='M0 60h40M80 60h40M60 0v40M60 80v40' stroke='%23c9a227' stroke-width='0.35' opacity='0.35'/%3E%3Ccircle cx='60' cy='60' r='22' fill='none' stroke='%235eead4' stroke-width='0.3' opacity='0.25'/%3E%3Ccircle cx='60' cy='60' r='14' fill='none' stroke='%23c9a227' stroke-width='0.25' opacity='0.2'/%3E%3C/svg%3E");
  background-size: 140px 140px;
  mask-image: radial-gradient(ellipse 85% 75% at 50% 45%, #000 20%, transparent 72%);
}

#enigma-hero-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.78;
}

.enigma-hero-content {
  position: relative;
  z-index: 2;
  max-width: 640px;
  padding: 1.25rem 1.5rem;
  border-radius: 16px;
  background: rgba(10, 12, 16, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.45);
}

.enigma-hero h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 800;
  margin-bottom: 0.65rem;
  background: linear-gradient(135deg, var(--brass) 0%, #e8d48b 50%, var(--cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.65)) drop-shadow(0 0 28px rgba(201, 162, 39, 0.35));
}

.hero-sub {
  color: #b4c0d4;
  font-size: 1rem;
  margin-bottom: 1.25rem;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.85);
}

.btn-hero {
  padding: 0.8rem 1.5rem;
  background: linear-gradient(180deg, var(--brass) 0%, var(--brass-dim) 100%);
  color: #1a1408;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(201, 162, 39, 0.35);
}

/* Layout */
.enigma-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem 4rem;
  width: 100%;
}

.enigma-section {
  position: relative;
  margin-bottom: 2.5rem;
}

.enigma-section > h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--brass);
}

.machine-instruction {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
  max-width: 720px;
}

.enigma-lab-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(400px, 1fr) minmax(240px, 300px);
  gap: 20px;
  align-items: stretch;
}

.enigma-lab-grid > * { min-width: 0; }

@media (max-width: 1100px) {
  .enigma-lab-grid {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

.enigma-card,
.enigma-settings,
.enigma-machine-column,
.enigma-trace {
  min-width: 0;
  overflow: hidden;
}

.enigma-card {
  background: rgba(20, 24, 32, 0.78);
  border: 1px solid rgba(61, 74, 95, 0.85);
  border-radius: 12px;
  padding: 1.15rem 1.2rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.enigma-settings.enigma-card {
  padding: 0.65rem 0.75rem 0.75rem;
}

@media (min-width: 1101px) {
  .enigma-lab-grid {
    grid-template-columns: minmax(280px, 320px) minmax(400px, 1fr) minmax(260px, 300px);
  }

  .enigma-lab-grid > .machine-console,
  .enigma-lab-grid > .signal-trace,
  .enigma-lab-grid > .enigma-machine-column {
    align-self: stretch;
    height: 100%;
    min-height: 0;
  }

  .machine-console.enigma-card,
  .signal-trace.enigma-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 1.15rem 1.2rem;
    border-radius: 12px;
  }

  .machine-console .panel-title,
  .signal-trace .panel-title {
    flex-shrink: 0;
    margin-bottom: 0.65rem;
  }

  .machine-console-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .machine-console .settings-actions-grid {
    flex-shrink: 0;
    margin-top: auto;
  }

  .signal-trace-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .signal-trace .trace-intro {
    flex-shrink: 0;
  }

  .enigma-machine-column {
    display: flex;
    flex-direction: column;
    min-height: 100%;
  }

  .machine-housing {
    flex: 1 1 auto;
    border-radius: 12px;
  }
}

.panel-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brass);
  margin-bottom: 0.55rem;
  line-height: 1.2;
}

/* Settings panel — compact console */
.enigma-settings { overflow-wrap: anywhere; }
.enigma-settings select { overflow-wrap: normal; word-break: normal; }

.settings-group {
  margin-bottom: 0.55rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid rgba(61, 74, 95, 0.45);
}

.settings-group--machine {
  padding-bottom: 0.45rem;
  margin-bottom: 0.45rem;
}

.settings-group-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.settings-io {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 520px) {
  .settings-io { grid-template-columns: 1fr; }
}

.settings-block { margin-bottom: 0; }
.settings-block--compact { min-width: 0; }

.settings-block label {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
  line-height: 1.2;
}

.settings-block textarea,
.settings-block input,
.settings-block select,
.machine-grid input,
.machine-grid select,
.enigma-settings input,
.enigma-settings select,
.enigma-settings button {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.settings-block textarea,
.settings-block input,
.settings-block select,
.machine-grid input,
.machine-grid select {
  padding: 0.35rem 0.45rem;
  background: var(--metal);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.25;
}

.settings-block textarea {
  resize: vertical;
  min-height: 2.6rem;
}

.ciphertext-display {
  min-height: 2.6rem;
  padding: 0.4rem 0.5rem;
  background: var(--metal);
  border: 1px solid var(--green);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--green);
  word-break: break-all;
  letter-spacing: 0.1em;
  line-height: 1.35;
}

.ciphertext-display--compact { min-height: 2.6rem; }

.ciphertext-display:empty::before {
  content: '—';
  color: var(--text-dim);
}

.field-hint {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
  line-height: 1.35;
}

.field-hint--tight {
  margin-top: 0.35rem;
  margin-bottom: 0;
}

/* 3-column machine configuration grid */
.machine-grid {
  display: grid;
  gap: 4px;
}

.machine-grid-head,
.machine-grid-row {
  display: grid;
  grid-template-columns: 2.75rem repeat(3, minmax(0, 1fr));
  gap: 4px;
  align-items: center;
}

.machine-grid-head span {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brass);
  text-align: center;
}

.machine-grid-corner { visibility: hidden; }

.machine-grid-row-label {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}

.machine-grid--dense { margin-bottom: 0.35rem; }

.machine-grid input {
  text-align: center;
  padding: 0.3rem 0.2rem;
  font-size: 0.76rem;
}

/* Accordions */
.settings-accordion {
  margin-bottom: 0.35rem;
  border: 1px solid rgba(61, 74, 95, 0.55);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.settings-accordion-summary {
  padding: 0.4rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.settings-accordion-summary::-webkit-details-marker { display: none; }

.settings-accordion-summary::before {
  content: '▸ ';
  color: var(--brass);
  display: inline-block;
  transition: transform 0.2s ease;
}

.settings-accordion[open] .settings-accordion-summary::before {
  transform: rotate(90deg);
}

.settings-accordion-body {
  padding: 0 0.55rem 0.5rem;
  border-top: 1px solid rgba(61, 74, 95, 0.35);
}

.plug-pair-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cyan);
}

.plug-pair-list li {
  padding: 0.15rem 0;
  border-bottom: 1px solid rgba(61, 74, 95, 0.3);
}

.plug-pair-list:empty::after {
  content: 'No pairs configured';
  color: var(--text-dim);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.65rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: none;
  font-weight: 400;
  line-height: 1.3;
}

.checkbox-row--compact { margin-top: 0.25rem; margin-bottom: 0; }

.checkbox-row input { width: auto; flex-shrink: 0; }

.settings-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(61, 74, 95, 0.45);
}

.settings-actions-grid .btn {
  flex: none;
  width: 100%;
  padding: 0.38rem 0.5rem;
  font-size: 0.72rem;
  border-radius: 6px;
}

.settings-actions-grid .btn-sm {
  grid-column: span 1;
  padding: 0.32rem 0.45rem;
  font-size: 0.68rem;
}

.btn {
  padding: 0.38rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--metal);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 0;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--brass) 0%, var(--brass-dim) 100%);
  border-color: var(--brass);
  color: #1a1408;
}

.btn-sm { flex: 0 1 auto; padding: 0.4rem 0.65rem; font-size: 0.75rem; }

/* Machine housing */
.enigma-machine-column { display: flex; flex-direction: column; gap: 0.75rem; }

.machine-housing {
  background: linear-gradient(165deg, rgba(37, 45, 58, 0.92) 0%, rgba(21, 26, 34, 0.94) 45%, rgba(15, 18, 24, 0.96) 100%);
  border: 2px solid var(--metal-light);
  border-radius: 16px;
  padding: 1.25rem 1rem 1.5rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(201, 162, 39, 0.08);
  transition: border-color 0.35s, box-shadow 0.35s;
}

.machine-housing.machine-active {
  border-color: rgba(201, 162, 39, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 0 32px rgba(201, 162, 39, 0.18),
    0 0 48px rgba(94, 234, 212, 0.08);
}

.machine-plate {
  text-align: center;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--brass-dim);
}

/* Rotor windows */
.rotor-row {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.rotor-unit { text-align: center; min-width: 0; }

.rotor-unit-label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.rotor-window-frame {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3a4558, #1a2030);
  border: 3px solid var(--brass);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.4s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.rotor-unit.stepped .rotor-window-frame {
  transform: rotate(14deg);
}

.rotor-window-letter {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brass);
  text-shadow: 0 0 12px rgba(201, 162, 39, 0.5);
}

/* Signal rail */
.signal-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
}

.signal-step {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.58rem;
  color: var(--text-dim);
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.signal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.signal-step.active-fwd {
  background: rgba(79, 142, 247, 0.2);
  color: var(--cyan);
}
.signal-step.active-fwd .signal-dot {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.signal-step.active-bwd {
  background: rgba(62, 207, 142, 0.15);
  color: var(--green);
}
.signal-step.active-bwd .signal-dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.signal-step.active-reflect {
  background: rgba(247, 184, 79, 0.2);
  color: var(--amber);
}
.signal-step.active-reflect .signal-dot {
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
  animation: reflect-pulse 0.5s ease;
}

@keyframes reflect-pulse {
  50% { transform: scale(1.4); }
}

/* Lampboard & keyboard rows */
.board-section { margin-bottom: 1rem; }

.board-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 0.5rem;
}

.lampboard,
.keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.key-row {
  display: flex;
  gap: 5px;
  justify-content: center;
}

/* Lamps */
.lamp {
  width: clamp(26px, 4.5vw, 36px);
  height: clamp(26px, 4.5vw, 36px);
  border-radius: 50%;
  border: 2px solid var(--metal-light);
  background: radial-gradient(circle at 40% 35%, #2a3344, #12161e);
  font-family: var(--font-mono);
  font-size: clamp(0.55rem, 2vw, 0.72rem);
  font-weight: 700;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.lamp.on {
  background: radial-gradient(circle at 40% 35%, #6effc8, #1a8a5c);
  border-color: var(--green);
  color: #0a1a12;
  box-shadow: 0 0 16px rgba(62, 207, 142, 0.85), 0 0 32px rgba(62, 207, 142, 0.4);
}

/* Keyboard keys */
.key {
  width: clamp(28px, 4.8vw, 38px);
  height: clamp(28px, 4.8vw, 38px);
  border-radius: 6px;
  border: 1px solid #1a1f28;
  border-bottom-width: 3px;
  background: linear-gradient(180deg, #4a5568 0%, #2d3544 100%);
  font-family: var(--font-mono);
  font-size: clamp(0.6rem, 2vw, 0.75rem);
  font-weight: 700;
  color: #e2e8f0;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s;
}

.key:hover:not(:disabled) {
  background: linear-gradient(180deg, #5a6578 0%, #3d4554 100%);
}

.key:active:not(:disabled),
.key.pressed {
  transform: translateY(2px);
  border-bottom-width: 1px;
  background: linear-gradient(180deg, var(--brass-dim) 0%, #5a4a18 100%);
  box-shadow: 0 0 12px rgba(201, 162, 39, 0.4);
}

.key:disabled { opacity: 0.5; cursor: not-allowed; }

/* Plugboard on machine */
.plugboard-section { margin-bottom: 0; }

.plugboard-sockets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(32px, 1fr));
  gap: 5px;
  max-width: 420px;
  margin: 0 auto;
}

.plug-socket {
  aspect-ratio: 1;
  min-width: 0;
  width: 100%;
  border-radius: 50%;
  border: 2px solid var(--metal-light);
  background: radial-gradient(circle at 40% 30%, #3a4558, #1e2535);
  font-family: var(--font-mono);
  font-size: clamp(0.55rem, 2vw, 0.7rem);
  font-weight: 700;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, color 0.2s;
}

.plug-socket.selected {
  border-color: var(--amber);
  color: var(--amber);
  box-shadow: 0 0 10px rgba(247, 184, 79, 0.4);
}

.plug-socket.paired {
  border-color: var(--cyan);
  color: var(--cyan);
  background: radial-gradient(circle at 40% 30%, #1e3a4a, #152535);
}

.plug-socket.signal-active {
  box-shadow: 0 0 14px var(--cyan);
}

.now-encoding {
  text-align: center;
  font-size: 0.88rem;
  color: var(--cyan);
  padding: 0.5rem;
  background: rgba(94, 234, 212, 0.08);
  border-radius: 8px;
  border: 1px solid rgba(94, 234, 212, 0.25);
}

.now-encoding-meta { color: var(--text-dim); font-size: 0.8rem; }

/* Trace */
.enigma-trace {
  display: flex;
  flex-direction: column;
}

.trace-intro {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.65rem;
}

.trace-panel,
.signal-trace-log {
  flex: 1;
  min-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

@media (min-width: 1101px) {
  .enigma-trace { max-height: none; }

  .trace-panel,
  .signal-trace-log {
    flex: 1;
    min-height: 0;
    max-height: none;
  }
}

.trace-letter-header {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--amber);
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.trace-step {
  padding: 0.4rem 0.5rem;
  border-left: 3px solid transparent;
  margin-bottom: 0.2rem;
  border-radius: 0 6px 6px 0;
  color: var(--text-dim);
}

.trace-step.active {
  background: rgba(79, 142, 247, 0.12);
  border-left-color: var(--cyan);
  color: var(--text);
}

.trace-step.done { border-left-color: rgba(62, 207, 142, 0.45); }

.trace-arrow { color: var(--cyan); margin: 0.1rem 0; }

/* Advanced / edu */
.advanced-block {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  background: var(--metal);
}

.advanced-block summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brass);
}

.wiring-tables {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

@media (min-width: 700px) {
  .wiring-tables { grid-template-columns: repeat(3, 1fr); }
}

.wiring-mini {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  max-height: 180px;
  overflow-y: auto;
}

.wiring-mini div {
  display: flex;
  justify-content: space-between;
  padding: 0.12rem 0;
  border-bottom: 1px solid rgba(61, 74, 95, 0.4);
}

.card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
}

.edu-article { max-width: 800px; margin: 0 auto; }
.edu-article h2 { font-size: 1.25rem; margin: 2rem 0 0.75rem; color: var(--text); }
.edu-article p { color: var(--text-dim); font-size: 0.93rem; margin-bottom: 0.85rem; }
.edu-article ul { margin: 0 0 0.85rem 1.25rem; color: var(--text-dim); font-size: 0.93rem; }

.formula {
  font-family: var(--font-mono);
  background: var(--metal);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.88rem;
  color: var(--cyan);
  overflow-x: auto;
}

.keyspace-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.keyspace-stat {
  background: var(--metal);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  text-align: center;
}

.keyspace-stat strong { display: block; font-size: 1.05rem; color: var(--amber); }
.keyspace-stat span { font-size: 0.72rem; color: var(--text-dim); }

.back-link {
  display: inline-block;
  color: #9aa4b2;
  text-decoration: none;
  font-size: 0.9rem;
  margin: 1rem 0;
}

.back-link:hover { color: #fff; }

.site-footer-nav {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: center;
}

.site-footer-nav a { color: #9aa4b2; text-decoration: none; font-size: 13px; }
.site-footer-nav a:hover { color: #fff; }

.footer-contact { margin-top: 14px; text-align: center; font-size: 13px; color: var(--text-dim); }
.footer-contact a { color: var(--accent); text-decoration: none; }

.enigma-section::before {
  content: '';
  position: absolute;
  inset: -1rem -0.5rem;
  z-index: -1;
  pointer-events: none;
  border-radius: 20px;
  background: radial-gradient(ellipse 80% 60% at 50% 30%, rgba(79, 142, 247, 0.06) 0%, transparent 70%);
}

.edu-article.card-panel {
  background: rgba(20, 24, 32, 0.82) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(61, 74, 95, 0.6);
}

@media (prefers-reduced-motion: reduce) {
  .rotor-window-frame,
  .key,
  .lamp,
  .signal-step.active-reflect .signal-dot { transition: none; animation: none; }

  #enigma-bg-canvas,
  #enigma-hero-canvas {
    opacity: 0.65;
  }
}
