/* ============================================================
   CSS 3D model — Hikvision DS-K1T344MBWX-QRE1 face terminal
   Modeled after real reference photos.
   Markup injected by js/terminal-markup.js into [data-terminal]
   ============================================================ */

.t3d-anchor { perspective: 1700px; }

.t3d {
  --tw: 236px;
  --th: 514px;
  --td: 76px;
  position: relative;
  width: var(--tw);
  height: var(--th);
  transform-style: preserve-3d;
  will-change: transform;
}

/* WebGL mount for the hero device */
.t3d-webgl {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.t3d-webgl canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* JS-driven face culling (robust across renderers) */
.t3d[data-side="back"] .t3d-front { visibility: hidden; }
.t3d[data-side="front"] .t3d-back { visibility: hidden; }

.t3d-core {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.t3d-face {
  position: absolute;
  top: 50%;
  left: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.t3d-front,
.t3d-back {
  width: var(--tw);
  height: var(--th);
  margin: calc(var(--th) / -2) 0 0 calc(var(--tw) / -2);
  border-radius: 10px;
}

.t3d-front { transform: translateZ(calc(var(--td) / 2)); }
.t3d-back { transform: rotateY(180deg) translateZ(calc(var(--td) / 2)); }

.t3d-left,
.t3d-right {
  width: var(--td);
  height: calc(var(--th) - 6px);
  margin: calc((var(--th) - 6px) / -2) 0 0 calc(var(--td) / -2);
  border-radius: 3px;
}

.t3d-right { transform: rotateY(90deg) translateZ(calc(var(--tw) / 2 - 1px)); }
.t3d-left { transform: rotateY(-90deg) translateZ(calc(var(--tw) / 2 - 1px)); }

.t3d-top,
.t3d-bottom {
  width: calc(var(--tw) - 6px);
  height: var(--td);
  margin: calc(var(--td) / -2) 0 0 calc((var(--tw) - 6px) / -2);
  border-radius: 3px;
}

.t3d-top { transform: rotateX(90deg) translateZ(calc(var(--th) / 2 - 1px)); }
.t3d-bottom { transform: rotateX(-90deg) translateZ(calc(var(--th) / 2 - 1px)); }

/* ---- Sides: silver front rim + ribbed black cooling fins ---- */
/* right face: front edge = left side of face */
.t3d-right {
  background:
    linear-gradient(90deg, #b3b8be 0, #8e949b 11%, #6f757c 13%, transparent 13%),
    repeating-linear-gradient(90deg, #23272d 0 4px, #0a0d10 4px 9px);
  background-color: #101317;
}

/* left face: front edge = right side of face */
.t3d-left {
  background:
    linear-gradient(270deg, #b3b8be 0, #8e949b 11%, #6f757c 13%, transparent 13%),
    repeating-linear-gradient(90deg, #0a0d10 0 5px, #23272d 5px 9px);
  background-color: #101317;
}

/* top face: front edge = bottom of face */
.t3d-top {
  background:
    linear-gradient(180deg, transparent 87%, #6f757c 87%, #9aa0a7 91%, #c0c5ca 100%),
    repeating-linear-gradient(180deg, #23272d 0 4px, #0a0d10 4px 9px);
  background-color: #101317;
}

/* bottom face: front edge = top of face */
.t3d-bottom {
  background:
    linear-gradient(0deg, transparent 87%, #6f757c 87%, #9aa0a7 91%, #c0c5ca 100%),
    repeating-linear-gradient(180deg, #0a0d10 0 5px, #23272d 5px 9px);
  background-color: #101317;
}

/* ---- Front: edge-to-edge glossy black glass ---- */
.t3d-front {
  background: linear-gradient(165deg, #15181d 0%, #0a0c0f 35%, #050608 70%, #0b0d11 100%);
  box-shadow:
    inset 0 0 0 2px rgba(180, 186, 192, 0.5),
    inset 0 0 0 3.5px rgba(20, 24, 28, 0.9),
    inset 0 0 30px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

.t3d-sheen {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, transparent 26%, rgba(255, 255, 255, 0.045) 40%, rgba(255, 255, 255, 0.11) 47%, rgba(255, 255, 255, 0.04) 54%, transparent 68%),
    linear-gradient(295deg, transparent 70%, rgba(255, 255, 255, 0.03) 82%, transparent 94%);
  pointer-events: none;
  z-index: 6;
}

/* Camera cluster — top strip, like the real glass */
.t3d-camzone {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 11.5%;
}

.t3d-lens {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #3c4750 0%, #16202a 36%, #04070a 70%);
  box-shadow: 0 0 0 2px #050708, 0 0 0 3px #1c2126, inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

.t3d-lens i {
  position: absolute;
  width: 28%;
  height: 28%;
  left: 24%;
  top: 18%;
  border-radius: 50%;
  background: rgba(150, 190, 215, 0.38);
  filter: blur(1px);
}

/* main lens with metallic ring, left-center */
.lens-a {
  width: 30px; height: 30px; left: 25%; top: 17px;
  box-shadow: 0 0 0 2px #06080a, 0 0 0 3.5px #454d55, 0 0 0 5px #14181c, inset 0 2px 4px rgba(255, 255, 255, 0.1);
}
/* IR lens, right of center */
.lens-b { width: 22px; height: 22px; left: 56%; top: 21px; }

/* small dark porthole, far left */
.t3d-port {
  position: absolute;
  left: 9%;
  top: 22px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, #1a2129 0%, #0a0e13 55%, #04060a 80%);
  box-shadow: 0 0 0 1.5px #050708, inset 0 1px 2px rgba(255, 255, 255, 0.05);
}

/* dual pinholes (mic / sensor) between lenses */
.t3d-pinholes {
  position: absolute;
  left: 48.5%;
  top: 21px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.t3d-pinholes i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #1a2026;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.9);
}

/* IR illuminator disc, right side */
.t3d-ir {
  position: absolute;
  right: 12%;
  top: 17px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 32%, #1f1a24 0%, #100d15 50%, #050309 80%);
  box-shadow: 0 0 0 2px #050708, inset 0 1px 3px rgba(255, 255, 255, 0.05);
}

/* ambient light sensor, top-right corner */
.t3d-alsensor {
  position: absolute;
  right: 6%;
  top: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #141a20;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* ---- Screen: 4.5" portrait, upper-middle of the glass ---- */
.t3d-screen {
  position: absolute;
  left: 14%;
  right: 14%;
  top: 11.5%;
  height: 50.5%;
  border-radius: 3px;
  background:
    radial-gradient(120% 70% at 50% -10%, oklch(0.45 0.09 200 / 0.4), transparent 60%),
    linear-gradient(196deg, #0d2331 0%, #091420 48%, #070d16 100%);
  box-shadow: inset 0 0 0 1px rgba(120, 200, 230, 0.12), 0 0 26px oklch(0.6 0.1 200 / 0.14);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 14px 10px;
  transition: background 0.4s ease;
}

.scr-status {
  display: flex;
  gap: 5px;
  align-self: flex-end;
}

.scr-status i {
  width: 9px;
  height: 5px;
  border-radius: 1.5px;
  background: rgba(180, 220, 235, 0.5);
}

.scr-status i:first-child { width: 5px; }

.scr-time {
  margin-top: 10px;
  font-family: var(--font-display, sans-serif);
  font-size: 31px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #e8f4f8;
  line-height: 1;
}

.scr-date {
  margin-top: 5px;
  font-size: 10.5px;
  font-weight: 500;
  color: rgba(190, 220, 232, 0.65);
}

.scr-faceframe {
  position: relative;
  margin-top: 13px;
  width: 92px;
  height: 112px;
  flex: 0 0 auto;
}

/* corner brackets */
.scr-faceframe::before,
.scr-faceframe::after,
.scr-faceframe .fr-b::before,
.scr-faceframe .fr-b::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid oklch(0.72 0.13 165 / 0.85);
}

.scr-faceframe::before { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 5px 0 0 0; }
.scr-faceframe::after { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 5px 0 0; }
.scr-faceframe .fr-b::before { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 5px; }
.scr-faceframe .fr-b::after { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 5px 0; }

.scr-face-svg {
  position: absolute;
  inset: 12px 19px;
  opacity: 0.75;
}

.scr-face-svg path {
  fill: none;
  stroke: rgba(170, 215, 230, 0.55);
  stroke-width: 2;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
}

.scr-scanline {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 10px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, oklch(0.78 0.14 165), transparent);
  box-shadow: 0 0 12px oklch(0.78 0.14 165 / 0.8);
  opacity: 0;
}

.scr-check {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.scr-check svg {
  width: 58px;
  height: 58px;
}

.scr-check circle {
  fill: oklch(0.72 0.135 165 / 0.16);
  stroke: oklch(0.74 0.14 165);
  stroke-width: 2;
}

.scr-check path {
  fill: none;
  stroke: oklch(0.78 0.15 165);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scr-hint {
  margin-top: auto;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(190, 220, 232, 0.6);
  text-transform: uppercase;
}

/* Screen states */
.t3d[data-scr="scan"] .scr-scanline {
  opacity: 1;
  animation: t3dScan 1.5s ease-in-out infinite;
}

@keyframes t3dScan {
  0% { transform: translateY(0); }
  50% { transform: translateY(90px); }
  100% { transform: translateY(0); }
}

.t3d[data-scr="ok"] .scr-check { opacity: 1; transform: scale(1); }
.t3d[data-scr="ok"] .scr-face-svg,
.t3d[data-scr="ok"] .scr-scanline { opacity: 0; }

.t3d[data-scr="ok"] .t3d-screen {
  background:
    radial-gradient(120% 80% at 50% 0%, oklch(0.55 0.12 165 / 0.32), transparent 62%),
    linear-gradient(196deg, #0a2a20 0%, #081a14 50%, #060d16 100%);
  box-shadow: inset 0 0 0 1px oklch(0.7 0.13 165 / 0.3), 0 0 30px oklch(0.7 0.13 165 / 0.25);
}

/* ---- HIKVISION wordmark + QR-scanner module (bottom glass) ---- */
.t3d-brandmark {
  position: absolute;
  top: 67.5%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-body, sans-serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.26em;
  color: #6a747d;
  z-index: 4;
}

.t3d-qr {
  position: absolute;
  top: 73.5%;
  left: 50%;
  width: 76px;
  height: 76px;
  margin-left: -38px;
  border-radius: 10px;
  background: linear-gradient(160deg, #1b2026 0%, #0e1216 55%, #14181d 100%);
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.1),
    inset 0 -3px 8px rgba(0, 0, 0, 0.6),
    0 3px 10px rgba(0, 0, 0, 0.55);
  z-index: 4;
}

.t3d-qr-lens {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #36424c 0%, #131c24 40%, #04070a 72%);
  box-shadow: 0 0 0 2.5px #060809, 0 0 0 4px #20262c;
}

.t3d-qr-lens::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  left: 7px;
  top: 5px;
  border-radius: 50%;
  background: rgba(150, 190, 215, 0.35);
  filter: blur(1px);
}

/* the little signal-arcs next to the module (as on the real glass) */
.t3d-qr-arcs {
  position: absolute;
  left: -14px;
  top: -4px;
  width: 16px;
  height: 16px;
  border: 2px solid #4a545d;
  border-right: 0;
  border-bottom: 0;
  border-radius: 16px 0 0 0;
  opacity: 0.7;
}

.t3d-qr-arcs::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 5px;
  width: 7px;
  height: 7px;
  border: 2px solid #4a545d;
  border-right: 0;
  border-bottom: 0;
  border-radius: 8px 0 0 0;
}

/* ---- Back: matte housing, labels, recessed wiring bay ---- */
.t3d-back {
  background: linear-gradient(175deg, #1b1f25 0%, #14171c 35%, #101317 100%);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.06);
}

.bk-screw {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2c333a, #0c0f12 75%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
}

.bk-screw.s1 { top: 14px; left: 16px; }
.bk-screw.s2 { top: 14px; right: 16px; }
.bk-screw.s3 { top: 47%; left: 16px; }
.bk-screw.s4 { top: 47%; right: 16px; }
.bk-screw.s5 { bottom: 14px; left: 16px; }
.bk-screw.s6 { bottom: 14px; right: 16px; }

/* main white label */
.bk-label-main {
  position: absolute;
  top: 5.5%;
  left: 16%;
  right: 16%;
  height: 21%;
  border-radius: 4px;
  background: #e9eaea;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  padding: 9px 10px;
  overflow: hidden;
}

.bk-label-main .lbl-brand {
  font-family: var(--font-body, sans-serif);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #1c2126;
  line-height: 1;
}

.bk-label-main .lbl-line {
  font-family: var(--font-mono, monospace);
  font-size: 6.8px;
  letter-spacing: 0.02em;
  color: #3a4148;
  line-height: 1.7;
}

.bk-label-main .lbl-line.is-model { font-weight: 700; color: #23282e; }

.bk-label-main .lbl-qr {
  position: absolute;
  right: 9px;
  bottom: 9px;
  width: 26px;
  height: 26px;
  background:
    conic-gradient(from 90deg at 4px 4px, #1c2126 90deg, transparent 0) 0 0 / 9px 9px,
    repeating-linear-gradient(0deg, #1c2126 0 2px, #e9eaea 2px 4px);
  opacity: 0.85;
}

.bk-label-main .lbl-ce {
  position: absolute;
  right: 10px;
  top: 8px;
  font-family: var(--font-body, sans-serif);
  font-size: 12px;
  font-weight: 700;
  color: #2a3036;
  letter-spacing: 0.08em;
}

.bk-label-main .lbl-barcode {
  position: absolute;
  left: 10px;
  bottom: 9px;
  width: 64px;
  height: 14px;
  background: repeating-linear-gradient(90deg, #23282e 0 1.5px, transparent 1.5px 3px, #23282e 3px 5.5px, transparent 5.5px 7px);
  opacity: 0.8;
}

/* small cutout below main label */
.bk-cut {
  position: absolute;
  top: 29%;
  left: 50%;
  width: 38px;
  height: 24px;
  margin-left: -19px;
  border-radius: 3px;
  background: #07090b;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.9), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* secondary label */
.bk-label-sub {
  position: absolute;
  top: 36%;
  left: 13%;
  right: 13%;
  height: 10.5%;
  border-radius: 3px;
  background: #e9eaea;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  padding: 6px 8px;
  overflow: hidden;
}

.bk-label-sub i {
  display: block;
  height: 2.5px;
  margin-bottom: 3.5px;
  background: #9aa1a8;
  border-radius: 1px;
}

.bk-label-sub i:nth-child(2) { width: 88%; }
.bk-label-sub i:nth-child(3) { width: 94%; }
.bk-label-sub i:nth-child(4) { width: 72%; }
.bk-label-sub i:nth-child(5) { width: 83%; }

/* recessed wiring bay — deep inset with beveled lip */
.bk-recess {
  position: absolute;
  left: 13%;
  right: 13%;
  top: 52%;
  bottom: 5%;
  border-radius: 8px;
  background: linear-gradient(180deg, #04060a 0%, #060809 40%, #05070a 100%);
  border-top: 2px solid #020304;
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    inset 0 12px 22px rgba(0, 0, 0, 0.95),
    inset 0 -5px 12px rgba(0, 0, 0, 0.8),
    inset 4px 0 10px rgba(0, 0, 0, 0.7),
    inset -4px 0 10px rgba(0, 0, 0, 0.7),
    0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 10px;
}

/* ambient-occlusion vignette over the bay contents */
.bk-recess::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 26%),
    radial-gradient(140% 120% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.5) 100%);
  pointer-events: none;
}

/* brass mounting inserts */
.bk-brass {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c9a24f, #6e5420 70%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

.bk-brass.b1 { top: 38%; left: 8px; }
.bk-brass.b2 { top: 38%; right: 8px; }

/* white wiring connector (left) */
.bk-conn-white {
  position: absolute;
  left: 12px;
  top: 14px;
  width: 30px;
  height: 52px;
  border-radius: 3px;
  background: linear-gradient(180deg, #c6c1b4, #9d988c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3), 0 3px 7px rgba(0, 0, 0, 0.8);
}

.bk-conn-white::after {
  content: "";
  position: absolute;
  inset: 5px 6px;
  background: repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.22) 0 3px, transparent 3px 8px);
  border-radius: 2px;
}

/* terminal block with pin-table label (right) */
.bk-term {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 64px;
  height: 56px;
  border-radius: 3px;
  background-color: #c2bdb0;
  background-image:
    repeating-linear-gradient(180deg, transparent 0 6px, rgba(40, 46, 52, 0.45) 6px 7px),
    repeating-linear-gradient(90deg, transparent 0 15px, rgba(40, 46, 52, 0.35) 15px 16px);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3), 0 3px 7px rgba(0, 0, 0, 0.8);
}

/* RJ45 LAN port — the PoE story */
.bk-rj45 {
  position: absolute;
  left: 50%;
  bottom: 30px;
  width: 58px;
  height: 46px;
  margin-left: -29px;
  border-radius: 4px;
  background: linear-gradient(180deg, #2e353d, #1a1f24);
  box-shadow: inset 0 0 0 1.5px #424b54, 0 4px 9px rgba(0, 0, 0, 0.85);
}

/* port opening */
.bk-rj45::before {
  content: "";
  position: absolute;
  inset: 7px 9px 12px;
  border-radius: 2px;
  background: #0a0d10;
  box-shadow: inset 0 0 0 1px #39424b;
}

/* gold pins */
.bk-rj45 .rj-pins {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 9px;
  height: 5px;
  background-image: linear-gradient(90deg, #c9a24f 0 2px, transparent 2px);
  background-size: 4px 100%;
}

/* clip notch at bottom of the port */
.bk-rj45 .rj-clip {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 18px;
  height: 7px;
  margin-left: -9px;
  background: #0a0d10;
  box-shadow: inset 0 0 0 1px #39424b;
}

.bk-rj45-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  text-align: center;
  font-family: var(--font-mono, monospace);
  font-size: 8.5px;
  letter-spacing: 0.16em;
  color: oklch(0.72 0.135 165);
  text-transform: uppercase;
  text-shadow: 0 0 10px oklch(0.72 0.135 165 / 0.5);
}

.bk-bay-label {
  position: absolute;
  left: 0;
  right: 0;
  top: 49%;
  text-align: center;
  font-family: var(--font-mono, monospace);
  font-size: 7.5px;
  letter-spacing: 0.14em;
  color: #5b656e;
  text-transform: uppercase;
}

/* ---- Stage ground shadow (sibling, 2D) ---- */
.stage-shadow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 300px;
  height: 56px;
  margin: -28px 0 0 -150px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.55), transparent 70%);
  will-change: transform, opacity;
  pointer-events: none;
}

html[data-theme="light"] .stage-shadow {
  background: radial-gradient(ellipse, rgba(25, 40, 38, 0.3), transparent 70%);
}

/* ---- Mini variant (finale) ---- */
.t3d-mini {
  position: relative;
  width: calc(236px * 0.34);
  height: calc(514px * 0.34);
}

.t3d-mini .t3d {
  transform: scale(0.34);
  transform-origin: top left;
}
