/* Page shell, header, viewport, wrapper */

body.page-text-mode {
  background:
    radial-gradient(circle at top, rgba(114, 98, 63, 0.08), transparent 34%),
    linear-gradient(180deg, #0d1419 0%, var(--bg) 44%, #090e12 100%);
}

body.page-text-mode::before {
  display: none;
}

body.page-text-mode .text-mode-main {
  padding: 26px 28px 38px;
}

.enigma-tab {
  color: #ffffff;
  font-family: "Courier New", monospace;
  font-size: 12pt;
  line-height: 1.45;
  text-align: left;
}

.machine-header {
  width: min(1180px, 100%);
  margin: 0 auto 22px;
}

.machine-header h1 {
  margin: 0 0 22px;
  color: #ffffff;
  font-family: "Allerta Stencil", sans-serif;
  font-size: 20pt;
  font-weight: 400;
}

.machine-header .reference-kicker {
  margin: 0 0 12px;
  color: #ffffff;
  font-family: "Allerta Stencil", sans-serif;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.machine-header > p:not(.reference-kicker) {
  max-width: calc(100% - 30px);
  margin: 0 0 16px 30px;
  color: #ffffff;
  font-size: 1rem;
  line-height: 1.75;
  text-align: justify;
  text-indent: 2.2em;
}

.machine-zoom-controls {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.2vw, 12px);
  width: min(1120px, 100%);
  margin: 8px auto -18px;
  vertical-align: middle;
}

.zoom-button {
  min-width: clamp(38px, 4.2vw, 46px);
  min-height: clamp(38px, 4.2vw, 46px);
  padding: 0 clamp(0px, 0vw, 0px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.34);
  color: #ffffff;
  font-family: "Courier New", monospace;
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.08),
    0 6px 14px rgba(0, 0, 0, 0.24);
}

.zoom-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.zoom-button--window {
  min-width: clamp(38px, 4vw, 44px);
  text-transform: uppercase;
}

.machine-form {
  text-align: center;
}

.enigma-viewport {
  width: min(896px, 100%);
  margin: -6px auto 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.enigma-zoom {
  --enigma-scale: 1;
  width: 896px;
  margin: 0 auto;
  transform: none;
  transform-origin: initial;
  will-change: width;
}

.enigma-zoom-inner {
  width: 896px;
  transform: scale(var(--enigma-scale));
  transform-origin: top left;
  will-change: transform;
}

.enigma-wrapper {
  position: relative;
  width: 896px;
  height: 1354px;
  margin: 0 auto 24px;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  text-align: center;
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
}

.enigma-wrapper--reference-template {
  isolation: isolate;
  background: url("/assets/text-mode/media/jashik.png") center top / 1040px 1354px no-repeat;
}

.enigma-wrapper--reference-template::before {
  display: none;
}

.enigma-machine {
  position: relative;
  z-index: 1;
  isolation: isolate;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(20, 12, 7, 0.22), rgba(8, 5, 3, 0.16)),
    url("/assets/text-mode/media/wood-board-h.jpg") center / cover no-repeat;
  box-shadow:
    inset 0 0 0 2px rgba(78, 47, 23, 0.55),
    inset 0 0 0 4px rgba(20, 12, 7, 0.42),
    inset 0 24px 40px rgba(255, 255, 255, 0.05),
    inset 0 -38px 64px rgba(0, 0, 0, 0.34),
    0 14px 26px rgba(0, 0, 0, 0.4);
}

.enigma-machine--reference-template {
  background: transparent;
  box-shadow: none;
}

.enigma-machine::before,
.enigma-machine::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.enigma-machine::before {
  opacity: 0.1;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 26%, transparent 78%, rgba(0, 0, 0, 0.16)),
    repeating-linear-gradient(90deg, transparent 0 84px, rgba(255, 255, 255, 0.025) 85px, transparent 87px);
}

.enigma-machine--reference-template::before,
.enigma-machine--reference-template::after {
  display: none;
}

.machine-inset {
  position: absolute;
  left: 72px;
  top: 70px;
  width: 752px;
  height: 966px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  pointer-events: none;
}

.machine-inset > * {
  pointer-events: auto;
}

.case-frame-hardware,
.machine-hardware {
  position: absolute;
  pointer-events: none;
}

.case-frame-hardware {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
}

.case-corner,
.case-front-plate,
.case-front-lock {
  position: absolute;
  display: block;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.case-corner {
  opacity: 0;
  pointer-events: none;
}

.case-corner::before,
.case-corner::after,
.case-front-plate::before,
.case-front-plate::after {
  display: none;
}

.case-corner::before,
.case-front-plate::before {
  left: 5px;
}

.case-corner::after,
.case-front-plate::after {
  right: 5px;
}

.case-corner--top-left {
  top: 4px;
  left: 34px;
}

.case-corner--top-right {
  top: 4px;
  right: 34px;
}

.case-corner--bottom-left {
  bottom: 4px;
  left: 34px;
}

.case-corner--bottom-right {
  right: 34px;
  bottom: 4px;
}

.case-front-plate {
  bottom: 8px;
  width: 80px;
  height: 22px;
  border-radius: 8px;
  display: none;
}

.case-front-plate--left {
  left: 112px;
}

.case-front-plate--right {
  right: 108px;
}

.case-front-lock {
  left: 50%;
  bottom: 3px;
  width: 52px;
  height: 28px;
  transform:
    translateX(-50%)
    translate(var(--hardware-drag-x, 0), var(--hardware-drag-y, 0))
    rotate(var(--lock-angle, 0deg));
  transform-origin: 50% 50%;
  border-radius: 10px;
  display: none;
}

.case-front-lock::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(233, 209, 149, 0.08);
}
