/* =========================================================
   ENIGMA M3 · 拟物化 (Skeuomorphic) UI
   设计灵感: 真实的二战德军 Enigma 木质箱体 + 黄铜 + 胶木键帽
   ========================================================= */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  min-height: 100vh;
  font-family: "Georgia", "Times New Roman", serif;
  color: #2b1d12;
  -webkit-font-smoothing: antialiased;
}

body {
  /* 桌面: 深色橡木纹理 + vignette */
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0) 40%, rgba(0,0,0,0.75) 100%),
    repeating-linear-gradient(
      90deg,
      #3a2614 0px, #4a3018 3px, #3a2614 6px, #2f1d0e 9px, #3a2614 12px
    ),
    linear-gradient(180deg, #2a1a0c 0%, #1a0f06 100%);
  background-blend-mode: multiply, normal, normal;
  min-height: 100vh;
  padding: 30px 20px 60px;
  overflow-x: hidden;
}

.workbench {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
}

/* ============================================================
   主机身 — 黑色胶木 + 黄铜外框
   ============================================================ */
.enigma-machine {
  position: relative;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255,255,255,0.04), transparent 50%),
    linear-gradient(180deg, #1c1410 0%, #0e0907 100%);
  border: 8px solid;
  border-image: linear-gradient(180deg, #6b4a1d, #3a260f) 1;
  border-radius: 14px;
  padding: 24px 30px 30px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.06),
    inset 0 -6px 20px rgba(0,0,0,0.7),
    0 30px 60px rgba(0,0,0,0.7),
    0 10px 25px rgba(0,0,0,0.5);
}

.wood-trim {
  position: absolute;
  inset: -8px;
  border-radius: 16px;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 20px,
      rgba(0,0,0,0.15) 20px 21px
    );
  mix-blend-mode: overlay;
}

/* ============================================================
   铭牌 — 黄铜质感 + 螺丝
   ============================================================ */
.nameplate {
  position: relative;
  margin-bottom: 22px;
  padding: 14px 50px;
}

.brass-plate {
  background:
    linear-gradient(180deg, #d9b066 0%, #a87e35 50%, #8a6224 100%);
  border: 2px solid #5a3f15;
  border-radius: 6px;
  padding: 12px 20px;
  text-align: center;
  color: #2a1b06;
  font-family: "Georgia", serif;
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.45),
    inset 0 -2px 4px rgba(0,0,0,0.4),
    0 2px 6px rgba(0,0,0,0.6);
  position: relative;
}

.brass-plate::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(90,63,21,0.5);
  border-radius: 4px;
  pointer-events: none;
}

.plate-line {
  font-size: 11px;
  letter-spacing: 4px;
  font-weight: bold;
}
.plate-model {
  font-size: 28px;
  letter-spacing: 12px;
  font-weight: 900;
  margin: 4px 0;
  font-family: "Georgia", serif;
}
.plate-serial {
  font-size: 10px;
  letter-spacing: 2px;
  margin-top: 4px;
  font-style: italic;
}

.screw {
  position: absolute;
  width: 18px; height: 18px;
  background: radial-gradient(circle at 35% 30%, #e8c98a, #7a5418 70%, #3a2608);
  border-radius: 50%;
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.4),
    inset 0 -2px 3px rgba(0,0,0,0.5),
    0 1px 2px rgba(0,0,0,0.5);
}
.screw::after {
  content: "";
  position: absolute;
  top: 50%; left: 15%; right: 15%;
  height: 2px;
  background: #1a1208;
  transform: translateY(-50%) rotate(35deg);
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.15);
}
.screw.tl { top: 12px; left: 14px; }
.screw.tr { top: 12px; right: 14px; }
.screw.bl { bottom: 12px; left: 14px; }
.screw.br { bottom: 12px; right: 14px; }

/* ============================================================
   转子窗口
   ============================================================ */
.rotor-bay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 34px;
  padding: 18px;
  background:
    linear-gradient(180deg, #6a4a1c 0%, #4a320f 100%);
  border-radius: 8px;
  border: 2px solid #2a1a08;
  box-shadow:
    inset 0 3px 6px rgba(0,0,0,0.6),
    inset 0 -1px 0 rgba(255,255,255,0.1);
}

.rotor-housing {
  display: flex;
  gap: 14px;
  padding: 10px 16px;
  background:
    linear-gradient(180deg, #1a120a, #050302);
  border-radius: 6px;
  border: 2px solid #000;
  box-shadow:
    inset 0 4px 10px rgba(0,0,0,0.9),
    0 1px 0 rgba(255,255,255,0.1);
}

.rotor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.rotor-window {
  width: 52px;
  height: 64px;
  background:
    linear-gradient(180deg, #e8d8b4 0%, #c8b48a 40%, #a8946a 60%, #e8d8b4 100%);
  border: 3px solid #2a1a08;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 6px 10px rgba(0,0,0,0.4),
    inset 0 -4px 8px rgba(0,0,0,0.3),
    0 1px 2px rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}

.rotor-window::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.4), transparent);
  pointer-events: none;
}

.rotor-letter {
  font-family: "Courier New", monospace;
  font-size: 34px;
  font-weight: bold;
  color: #1a0f06;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
  transition: transform 0.18s ease;
}

.rotor-btn {
  width: 38px;
  height: 18px;
  background: linear-gradient(180deg, #c9a558, #6a4716);
  border: 1px solid #2a1a08;
  color: #1a0f06;
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.4),
    0 1px 2px rgba(0,0,0,0.5);
  transition: all 0.08s;
}
.rotor-btn:hover { filter: brightness(1.1); }
.rotor-btn:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

.rotor-label {
  color: #f5d98a;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 2px;
  margin-top: 2px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.7);
}

.reflector-badge {
  color: #f5d98a;
  font-family: "Courier New", monospace;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 2px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(245,217,138,0.4);
  border-radius: 4px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.8);
}

/* ============================================================
   灯板 (Lampboard) — 26 个磨砂玻璃灯泡
   ============================================================ */
.lampboard {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  row-gap: 16px;
  column-gap: 0;
  max-width: 720px;
  margin: 0 auto 34px;
  padding: 28px 30px 30px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.05), transparent 60%),
    linear-gradient(180deg, #1a1410 0%, #0a0604 100%);
  border-radius: 10px;
  border: 2px solid #000;
  box-shadow:
    inset 0 4px 12px rgba(0,0,0,0.9),
    inset 0 -1px 0 rgba(255,255,255,0.08);
}

/* 三排键盘的德文 Enigma 排列: QWERTZ */
.lamp {
  width: min(50px, 82%);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #4a3a28 0%, #1a120a 70%, #050302 100%);
  border: 2px solid #2a1a08;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.8),
    inset 0 -1px 2px rgba(255,255,255,0.05),
    0 1px 2px rgba(0,0,0,0.5);
  transition: all 0.15s ease;
  justify-self: center;
  align-self: center;
}

.lamp-letter {
  font-family: "Courier New", monospace;
  font-size: 18px;
  font-weight: bold;
  color: #4a3a28;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6);
  transition: all 0.15s ease;
  user-select: none;
}

.lamp.on {
  background:
    radial-gradient(circle at 35% 30%, #fff6c8 0%, #ffd54a 40%, #b8852a 90%);
  box-shadow:
    inset 0 2px 4px rgba(255,255,255,0.5),
    0 0 18px 4px rgba(255,200,60,0.85),
    0 0 36px 10px rgba(255,170,40,0.5);
  border-color: #6a4a18;
}
.lamp.on .lamp-letter {
  color: #3a2408;
  text-shadow: 0 0 4px rgba(255,255,200,0.9);
}

/* ============================================================
   键盘 — 圆形胶木键帽 + 金属环
   ============================================================ */
.keyboard {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  row-gap: 18px;
  column-gap: 0;
  max-width: 760px;
  margin: 0 auto 38px;
  padding: 28px 30px 32px;
  background:
    linear-gradient(180deg, #2a1d10, #1a1208);
  border-radius: 10px;
  border: 2px solid #050302;
  box-shadow:
    inset 0 3px 8px rgba(0,0,0,0.7),
    inset 0 -1px 0 rgba(255,255,255,0.08);
}

.key {
  width: min(56px, 84%);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 30%, #5a3a18 0%, #2a1a08 60%, #1a0e04 100%);
  border: 3px solid #6a4a18;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  justify-self: center;
  align-self: center;
  font-family: "Georgia", serif;
  font-size: 22px;
  font-weight: bold;
  color: #f5d98a;
  text-shadow:
    0 -1px 0 rgba(0,0,0,0.8),
    0 1px 1px rgba(255,255,255,0.15);
  box-shadow:
    inset 0 2px 0 rgba(255,200,120,0.3),
    inset 0 -3px 6px rgba(0,0,0,0.7),
    0 4px 0 #1a0e04,
    0 6px 8px rgba(0,0,0,0.6);
  transition: all 0.07s ease;
  user-select: none;
}

.key::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 25%, rgba(255,255,255,0.18), transparent 60%);
  pointer-events: none;
}

.key:hover { filter: brightness(1.1); }
.key.pressed, .key:active {
  transform: translateY(4px);
  box-shadow:
    inset 0 3px 8px rgba(0,0,0,0.9),
    0 0 0 #1a0e04,
    0 1px 2px rgba(0,0,0,0.4);
}

/* ============================================================
   插线板 (Steckerbrett)
   ============================================================ */
.plugboard-wrap {
  position: relative;
  padding: 24px 20px 30px;
  background:
    linear-gradient(180deg, #6a4a1c, #3a260f);
  border-radius: 10px;
  border: 2px solid #2a1a08;
  box-shadow:
    inset 0 3px 6px rgba(0,0,0,0.5),
    inset 0 -1px 0 rgba(255,255,255,0.1);
}

.plugboard-title {
  color: #f5d98a;
  font-size: 12px;
  letter-spacing: 4px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 16px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.7);
}

.plugboard {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 6px 8px;
  position: relative;
  z-index: 2;
}

.plug-socket {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.socket-label {
  font-size: 10px;
  color: #f5d98a;
  font-weight: bold;
  text-shadow: 0 1px 1px rgba(0,0,0,0.7);
  font-family: "Courier New", monospace;
}

.socket-hole {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #050302 0%, #1a120a 60%, #2a1a08 100%);
  border: 2px solid #1a0e04;
  cursor: pointer;
  position: relative;
  box-shadow:
    inset 0 2px 3px rgba(0,0,0,0.9),
    inset 0 -1px 1px rgba(255,255,255,0.08),
    0 1px 1px rgba(255,255,255,0.1);
  transition: all 0.1s;
}

.socket-hole::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #000 0%, #0a0604 100%);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.9);
}

.socket-hole.connected {
  background: radial-gradient(circle at 50% 30%, #d4a04a 0%, #8a5a18 70%, #4a2e08 100%);
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,0.4),
    inset 0 -2px 3px rgba(0,0,0,0.6),
    0 0 6px rgba(255,180,60,0.5);
}
.socket-hole.connected::after {
  background: radial-gradient(circle at 50% 30%, #f5d08a, #8a5a18);
}
.socket-hole.selecting {
  box-shadow:
    0 0 0 2px #ffcc44,
    inset 0 2px 3px rgba(0,0,0,0.9);
}

.cable-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

/* ============================================================
   浮动日志窗口
   ============================================================ */
.log-window {
  position: fixed;
  top: 30px;
  right: 30px;
  width: 320px;
  background:
    linear-gradient(180deg, #ebe1c8 0%, #d9cca8 100%);
  border: 1px solid #6a4a1c;
  border-radius: 8px;
  box-shadow:
    0 12px 30px rgba(0,0,0,0.6),
    0 4px 10px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.5);
  z-index: 100;
  font-family: "Courier New", monospace;
  color: #2a1d0e;
  user-select: none;
}

.log-header {
  background: linear-gradient(180deg, #6a4a1c, #3a260f);
  color: #f5d98a;
  padding: 8px 12px;
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: move;
  font-weight: bold;
  font-size: 12px;
  letter-spacing: 2px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.8);
  border-bottom: 1px solid #1a0e04;
}

.log-btn {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(245,217,138,0.4);
  color: #f5d98a;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
}
.log-btn:hover { background: rgba(255,80,40,0.6); }

.log-body { padding: 12px; }

.log-section { margin-bottom: 12px; }

.log-label {
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: bold;
  color: #5a3f1a;
  margin-bottom: 4px;
  padding-bottom: 2px;
  border-bottom: 1px dashed #a87e35;
}

.log-content {
  min-height: 50px;
  max-height: 100px;
  overflow-y: auto;
  font-size: 14px;
  letter-spacing: 1px;
  line-height: 1.4;
  word-break: break-all;
  padding: 4px;
  background: rgba(255,255,255,0.3);
  border: 1px inset rgba(90,63,26,0.3);
  border-radius: 3px;
  user-select: text;
}
.log-content.cipher {
  color: #6a1818;
  font-weight: bold;
  letter-spacing: 2px;
}

.log-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.export-btn, .reset-btn {
  flex: 1;
  background: linear-gradient(180deg, #c9a558, #6a4716);
  border: 1px solid #2a1a08;
  color: #1a0f06;
  font-family: "Georgia", serif;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1px;
  padding: 6px 8px;
  border-radius: 3px;
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.4),
    0 1px 2px rgba(0,0,0,0.5);
  transition: all 0.08s;
}
.export-btn:hover, .reset-btn:hover { filter: brightness(1.1); }
.export-btn:active, .reset-btn:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

.reset-btn { flex: 0.5; }

/* ============================================================
   文档导出模态框 — 拟物化德军电报纸
   ============================================================ */
.doc-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.doc-modal.show { display: flex; }

.doc-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(3px);
}

.doc-paper {
  position: relative;
  max-width: 600px;
  width: 100%;
  background:
    /* 纸张污渍 */
    radial-gradient(ellipse 80px 30px at 15% 20%, rgba(140,90,40,0.18), transparent 70%),
    radial-gradient(ellipse 60px 40px at 85% 75%, rgba(140,90,40,0.15), transparent 70%),
    radial-gradient(ellipse 100px 50px at 50% 50%, rgba(110,70,30,0.08), transparent 70%),
    /* 纸张纤维纹理 */
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(120,80,30,0.03) 2px 3px),
    linear-gradient(180deg, #f0e3c0 0%, #d9c89a 100%);
  border: 1px solid #8a6a30;
  padding: 30px 40px 24px;
  border-radius: 2px;
  font-family: "Courier New", "Georgia", monospace;
  color: #2a1d0e;
  box-shadow:
    0 30px 60px rgba(0,0,0,0.7),
    inset 0 0 0 4px rgba(140,100,50,0.15),
    inset 0 0 30px rgba(140,90,40,0.2);
  max-height: 88vh;
  overflow-y: auto;
}

.doc-paper::before {
  /* 撕边效果 */
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background:
    linear-gradient(90deg,
      transparent 0%, rgba(0,0,0,0.1) 25%, transparent 50%,
      rgba(0,0,0,0.1) 75%, transparent 100%);
  clip-path: polygon(0 0, 2% 100%, 5% 0, 8% 100%, 12% 0, 16% 100%, 20% 0, 24% 100%, 28% 0, 32% 100%, 36% 0, 40% 100%, 44% 0, 48% 100%, 52% 0, 56% 100%, 60% 0, 64% 100%, 68% 0, 72% 100%, 76% 0, 80% 100%, 84% 0, 88% 100%, 92% 0, 96% 100%, 100% 0);
}

.doc-stamp {
  position: absolute;
  top: 30px;
  right: 30px;
  color: #8a1818;
  border: 4px double #8a1818;
  padding: 6px 18px;
  font-family: "Georgia", serif;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 6px;
  transform: rotate(-12deg);
  opacity: 0.78;
  text-shadow: 0 0 1px #8a1818;
  background: rgba(255,255,255,0.05);
}

.doc-stamp-bottom {
  position: absolute;
  bottom: 50px;
  left: 30px;
  color: #6a1818;
  border: 2px solid #6a1818;
  padding: 4px 12px;
  font-family: "Georgia", serif;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 3px;
  transform: rotate(8deg);
  opacity: 0.7;
}

.doc-header {
  text-align: center;
  border-bottom: 2px solid #5a3f1a;
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.eagle {
  font-size: 32px;
  color: #2a1d0e;
  margin-bottom: 4px;
}
.doc-title {
  font-family: "Georgia", serif;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 8px;
}
.doc-sub {
  font-size: 11px;
  letter-spacing: 3px;
  margin-top: 4px;
  font-style: italic;
}

.doc-meta {
  font-size: 11px;
  margin-bottom: 16px;
  padding: 8px 10px;
  background: rgba(140,100,50,0.1);
  border-left: 3px solid #5a3f1a;
  line-height: 1.7;
  letter-spacing: 1px;
}

.doc-field {
  margin-bottom: 14px;
}
.doc-field-label {
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: bold;
  margin-bottom: 4px;
  color: #5a3f1a;
}
.doc-field-content {
  padding: 8px 10px;
  background: rgba(255,255,255,0.25);
  border: 1px dashed #8a6a30;
  font-size: 14px;
  letter-spacing: 2px;
  word-break: break-all;
  line-height: 1.5;
  min-height: 28px;
}
.doc-field-content.cipher {
  font-weight: bold;
  color: #6a1818;
  letter-spacing: 3px;
  /* 4字母一组 */
}

.doc-sig {
  margin-top: 22px;
  text-align: right;
  font-size: 11px;
  font-style: italic;
}
.sig-line {
  margin-top: 24px;
  font-family: "Brush Script MT", cursive;
  font-size: 14px;
  color: #4a2818;
}

.doc-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.doc-actions button {
  background: linear-gradient(180deg, #c9a558, #6a4716);
  border: 1px solid #2a1a08;
  color: #1a0f06;
  font-family: "Georgia", serif;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 8px 14px;
  border-radius: 3px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 2px 4px rgba(0,0,0,0.4);
}
.doc-actions button:hover { filter: brightness(1.1); }
.doc-actions button:active { transform: translateY(1px); }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 4px;}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #c9a558, #6a4716);
  border-radius: 4px;
}

/* 响应式 */
@media (max-width: 900px) {
  .rotor-bay { margin-bottom: 28px; }
  .lampboard {
    row-gap: 12px;
    margin-bottom: 28px;
    padding: 22px 18px 24px;
  }
  .lamp { width: min(38px, 82%); }
  .lamp-letter { font-size: 14px; }
  .keyboard {
    row-gap: 14px;
    margin-bottom: 30px;
    padding: 22px 18px 26px;
  }
  .key { width: min(42px, 84%); font-size: 16px; }
  .log-window { width: 280px; right: 10px; top: 10px; }
}
