.portrait-frame {
  position: relative;
  z-index: 3;
  width: min(100%, 586px);
  height: min(100%, 820px);
  aspect-ratio: 700 / 909;
}

.portrait-media {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  filter: contrast(0.98) saturate(0.84) sepia(0.08);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.portrait-base {
  position: relative;
  z-index: 1;
  transform: scale(1);
  transform-origin: center top;
}

.portrait-video-source {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.portrait-canvas {
  background: transparent;
}

.portrait-frame.is-raw-video .portrait-video-source {
  opacity: 1;
}

.portrait-frame.is-raw-video .portrait-canvas {
  opacity: 0;
}

.portrait-scene {
  position: relative;
  width: min(100%, 1100px);
  height: min(100%, 824px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.scene-backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.scene-backdrop::before {
  content: "";
  position: absolute;
  inset: 3% 2% 10%;
  background:
    linear-gradient(180deg, transparent, rgba(10, 15, 18, 0.12)),
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent 86px,
      var(--grid-line) 86px,
      var(--grid-line) 87px
    ),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 86px,
      var(--grid-line) 86px,
      var(--grid-line) 87px
    );
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 1) 38%, transparent 82%);
}

.scene-backdrop::after {
  content: "";
  position: absolute;
  inset: 10% 18% 12%;
  background:
    radial-gradient(circle at 48% 34%, rgba(184, 155, 98, 0.12), transparent 33%),
    radial-gradient(circle at 58% 60%, rgba(125, 138, 115, 0.08), transparent 26%),
    radial-gradient(circle at 62% 42%, rgba(255, 241, 218, 0.05), transparent 18%);
  filter: blur(16px);
}

.scene-formula {
  position: absolute;
  color: rgba(230, 214, 184, 0.16);
  font-family: "PT Mono", monospace;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.formula-alpha {
  top: 12%;
  left: 9%;
  font-size: clamp(0.82rem, 0.32vw + 0.74rem, 1.08rem);
}

.formula-beta {
  top: 28%;
  right: 8%;
  font-size: clamp(0.96rem, 0.4vw + 0.84rem, 1.24rem);
}

.formula-gamma {
  bottom: 16%;
  left: 11%;
  color: rgba(125, 138, 115, 0.2);
  font-size: clamp(0.72rem, 0.22vw + 0.68rem, 0.94rem);
}

.formula-delta {
  top: 62%;
  right: 2%;
  color: rgba(234, 223, 199, 0.12);
  font-size: clamp(0.68rem, 0.2vw + 0.64rem, 0.84rem);
}

.scene-watermark {
  position: absolute;
  top: 36%;
  left: 50%;
  z-index: 1;
  color: var(--stamp);
  font-family: "PT Mono", monospace;
  font-size: clamp(3.2rem, 5.4vw + 0.8rem, 6.2rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%) rotate(-10deg);
}

.cipher-ribbon {
  position: absolute;
  left: 8%;
  right: 8%;
  overflow: hidden;
  color: rgba(234, 223, 199, 0.12);
  font-family: "PT Mono", monospace;
  font-size: clamp(0.64rem, 0.18vw + 0.6rem, 0.78rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: clip;
}

.ribbon-top {
  top: 18%;
  animation: ribbon-drift 18s linear infinite;
}

.ribbon-bottom {
  bottom: 8%;
  animation: ribbon-drift-reverse 22s linear infinite;
  color: rgba(125, 138, 115, 0.16);
}

.signal-lane {
  position: absolute;
  z-index: 1;
  height: 1px;
  background: linear-gradient(
    90deg,
    rgba(184, 155, 98, 0),
    rgba(184, 155, 98, 0.34) 24%,
    rgba(125, 138, 115, 0.28) 72%,
    rgba(184, 155, 98, 0)
  );
}

.lane-main {
  top: 48%;
  left: 3%;
  width: 58%;
}

.lane-secondary {
  top: 72%;
  left: 54%;
  width: 42%;
}

.signal-label {
  position: absolute;
  z-index: 2;
  color: rgba(234, 223, 199, 0.22);
  font-family: "PT Mono", monospace;
  font-size: clamp(0.58rem, 0.14vw + 0.56rem, 0.72rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.label-rotors {
  top: 45%;
  left: 7%;
}

.label-reflector {
  bottom: 26%;
  right: 10%;
  color: rgba(125, 138, 115, 0.24);
}

.label-left-edge {
  top: 18%;
  left: 4%;
}

.label-right-edge {
  top: 54%;
  right: 0;
}

.scene-rotor,
.scene-arc {
  position: absolute;
  border: 1px solid rgba(196, 179, 141, 0.13);
  border-radius: 50%;
}

.scene-rotor::before,
.scene-rotor::after {
  content: "";
  position: absolute;
  inset: 14%;
  border: 1px solid rgba(196, 179, 141, 0.08);
  border-radius: 50%;
}

.scene-rotor::after {
  inset: 34%;
  border-color: rgba(125, 138, 115, 0.18);
}

.rotor-left {
  top: 18%;
  left: 3%;
  width: 240px;
  height: 240px;
  box-shadow:
    inset 0 0 0 1px rgba(196, 179, 141, 0.05),
    0 0 28px rgba(176, 149, 92, 0.04);
}

.rotor-right {
  right: 0;
  bottom: 14%;
  width: 188px;
  height: 188px;
}

.rotor-edge-left {
  top: 56%;
  left: 1%;
  width: 172px;
  height: 172px;
  opacity: 0.64;
}

.rotor-edge-right {
  top: 6%;
  right: -3%;
  width: 164px;
  height: 164px;
  opacity: 0.54;
}

.scene-arc {
  border-color: rgba(184, 155, 98, 0.18);
  border-top-color: transparent;
  border-left-color: transparent;
}

.arc-upper {
  top: 17%;
  left: 18%;
  width: 440px;
  height: 440px;
  transform: rotate(16deg);
}

.arc-lower {
  right: 6%;
  bottom: 8%;
  width: 340px;
  height: 340px;
  transform: rotate(112deg);
}

.arc-edge-left {
  left: -1%;
  bottom: 2%;
  width: 280px;
  height: 280px;
  transform: rotate(188deg);
}

.arc-edge-right {
  top: -2%;
  right: -8%;
  width: 300px;
  height: 300px;
  transform: rotate(34deg);
}

.scene-node {
  position: absolute;
  z-index: 2;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(184, 155, 98, 0.86);
  box-shadow:
    0 0 0 6px rgba(184, 155, 98, 0.08),
    0 0 18px rgba(184, 155, 98, 0.22);
  animation: node-pulse 3.6s ease-in-out infinite;
}

.node-alpha {
  top: 21%;
  left: 35%;
}

.node-beta {
  top: 43%;
  right: 22%;
  animation-delay: 1s;
}

.node-gamma {
  bottom: 21%;
  right: 17%;
  background: rgba(125, 138, 115, 0.82);
  box-shadow:
    0 0 0 6px rgba(125, 138, 115, 0.08),
    0 0 18px rgba(125, 138, 115, 0.2);
  animation-delay: 2s;
}

.scene-card {
  position: absolute;
  z-index: 2;
  padding: 10px 14px;
  border: 1px solid rgba(196, 179, 141, 0.15);
  border-radius: 8px;
  background: rgba(25, 29, 27, 0.68);
  color: rgba(234, 223, 199, 0.56);
  font-family: "PT Mono", monospace;
  font-size: clamp(0.58rem, 0.15vw + 0.56rem, 0.72rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  max-width: 260px;
}

.card-upper {
  top: 18%;
  right: 4%;
}

.card-lower {
  bottom: 14%;
  left: 4%;
}

.card-edge-left {
  top: 24%;
  left: 3%;
}

.card-edge-right {
  bottom: 8%;
  right: -2%;
}

.scene-bracket {
  position: absolute;
  z-index: 2;
  width: 88px;
  height: 88px;
  opacity: 0.42;
}

.scene-bracket::before,
.scene-bracket::after {
  content: "";
  position: absolute;
  background: rgba(196, 179, 141, 0.18);
}

.bracket-top-left {
  top: 6%;
  left: 4%;
}

.bracket-top-left::before {
  top: 0;
  left: 0;
  width: 88px;
  height: 1px;
}

.bracket-top-left::after {
  top: 0;
  left: 0;
  width: 1px;
  height: 88px;
}

.bracket-bottom-right {
  right: 3%;
  bottom: 10%;
}

.bracket-bottom-right::before {
  right: 0;
  bottom: 0;
  width: 88px;
  height: 1px;
}

.bracket-bottom-right::after {
  right: 0;
  bottom: 0;
  width: 1px;
  height: 88px;
}

.bracket-edge-left {
  left: 2%;
  top: 36%;
}

.bracket-edge-left::before {
  top: 0;
  left: 0;
  width: 88px;
  height: 1px;
}

.bracket-edge-left::after {
  top: 0;
  left: 0;
  width: 1px;
  height: 88px;
}

.bracket-edge-right {
  right: -2%;
  top: 24%;
}

.bracket-edge-right::before {
  right: 0;
  top: 0;
  width: 88px;
  height: 1px;
}

.bracket-edge-right::after {
  right: 0;
  top: 0;
  width: 1px;
  height: 88px;
}

.scene-docket {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid rgba(196, 179, 141, 0.14);
  border-radius: 6px;
  background: rgba(29, 31, 26, 0.8);
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.16);
  color: rgba(234, 223, 199, 0.7);
}

.scene-docket strong {
  font-family: "PT Serif", Georgia, serif;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scene-docket small {
  font-family: "PT Mono", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(234, 223, 199, 0.48);
}

.docket-right {
  right: 4%;
  bottom: 18%;
  width: 228px;
  transform: rotate(-3deg);
}

@keyframes ribbon-drift {
  0% {
    transform: translateX(-2%);
    opacity: 0.02;
  }

  25%,
  75% {
    opacity: 0.18;
  }

  100% {
    transform: translateX(2%);
    opacity: 0.02;
  }
}

@keyframes ribbon-drift-reverse {
  0% {
    transform: translateX(2%);
    opacity: 0.02;
  }

  25%,
  75% {
    opacity: 0.16;
  }

  100% {
    transform: translateX(-2%);
    opacity: 0.02;
  }
}

@keyframes node-pulse {
  0%,
  100% {
    transform: scale(0.88);
    opacity: 0.45;
  }

  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

.portrait-fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 28px;
  text-align: center;
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.6;
}

.portrait-frame.is-missing .portrait-fallback {
  display: grid;
}

.portrait-frame.is-missing .portrait-canvas,
.portrait-frame.is-missing .portrait-video-source {
  display: none;
}

@media (max-width: 900px) {
  .portrait-frame {
    height: min(54svh, 470px);
  }

  .portrait-scene {
    width: min(100%, 760px);
    height: min(100%, 520px);
  }

  .scene-formula,
  .scene-watermark,
  .rotor-right,
  .rotor-edge-left,
  .rotor-edge-right,
  .arc-lower,
  .arc-edge-left,
  .arc-edge-right,
  .cipher-ribbon,
  .scene-node,
  .scene-card,
  .scene-bracket,
  .signal-lane,
  .signal-label,
  .scene-docket {
    display: none;
  }

  .rotor-left {
    top: 12%;
    left: 6%;
    width: 180px;
    height: 180px;
  }

  .arc-upper {
    top: 16%;
    left: 14%;
    width: 260px;
    height: 260px;
  }
}
