/* Mithandes UI Styles — shared base: fonts, reset, 3D cabinet, style switcher */

@font-face { font-family: "Alexandria"; src: url("../fonts/Alexandria-VariableFont_wght.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("../fonts/Tajawal-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("../fonts/Tajawal-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("../fonts/Tajawal-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Tajawal", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.display { font-family: "Alexandria", "Tajawal", sans-serif; }
.num { font-family: "Alexandria", sans-serif; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--focus, #0f7d87); outline-offset: 3px; }

/* ---------- 3D cabinet (built by configurator.js) ---------- */
.cab-stage {
  position: relative;
  perspective: 1400px;
  perspective-origin: 50% 40%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.cab-stage:active { cursor: grabbing; }
.cab-shadow {
  position: absolute; left: 50%; bottom: 6%;
  width: 62%; height: 9%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(20, 30, 35, .32), rgba(20, 30, 35, 0));
  filter: blur(4px);
  pointer-events: none;
}
.cab {
  position: absolute; left: 50%; top: 46%;
  width: 0; height: 0;
  direction: ltr;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.2, .7, .2, 1);
}
.cab.dragging { transition: none; }
/* every plane shows one side only, so outer and inner skins never fight */
.cab-p, .cab-door .dp {
  position: absolute; left: 0; top: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: width .45s ease, height .45s ease, margin .45s ease, transform .45s ease, background-color .3s, border-width .45s ease;
}
.cab-p::after, .cab-door .dp::after { content: ""; position: absolute; inset: 0; pointer-events: none; }

/* outer skins */
.p-out { background-color: var(--metal, #b9c0c4); box-shadow: inset 0 0 0 1px rgba(0,0,0,.14); }
.p-side::after { background: linear-gradient(180deg, rgba(0,0,0,.06), rgba(0,0,0,.22)); }
.p-top::after { background: linear-gradient(0deg, rgba(255,255,255,.38), rgba(255,255,255,.14)); }
.p-back::after, .p-bottom::after { background: rgba(0,0,0,.32); }

/* inner skins: darker, with ambient occlusion in the corners */
.p-in { background-color: var(--metal-inner, #8e979c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12), inset 0 0 42px rgba(0,0,0,.34); }
.p-in-back::after { background: linear-gradient(180deg, rgba(0,0,0,.22), rgba(0,0,0,.08) 60%, rgba(0,0,0,.18)); }
.p-in-side::after { background: linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,.06) 45%, rgba(0,0,0,.2)); }
.p-in-top::after { background: rgba(0,0,0,.34); }
.p-in-bottom::after { background: linear-gradient(0deg, rgba(255,255,255,.14), rgba(0,0,0,.16)); }

/* folded front flange around the opening */
.p-flange {
  border: 12px solid var(--metal, #b9c0c4); background: transparent;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.22), 0 0 0 1px rgba(0,0,0,.14);
}
.p-flange::after { display: none; }
.p-flange-in { border: 10px solid var(--metal-inner, #8e979c); background: transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }

/* galvanised mounting plate: punched holes, two DIN rails, a slotted cable duct */
.p-plate {
  background-color: #d2d8db;
  background-image: radial-gradient(circle, rgba(0,0,0,.28) 1.2px, transparent 1.6px);
  background-size: 14px 14px;
  background-position: 7px 7px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
}
.p-plate::after { background: linear-gradient(180deg, rgba(0,0,0,.14), rgba(255,255,255,.08) 50%, rgba(0,0,0,.12)); }
.p-plate .rail {
  position: absolute; left: 8%; right: 30%; height: 7%; min-height: 6px; max-height: 14px;
  background: linear-gradient(180deg, #e6eaec 0 18%, #a3acb1 18% 30%, #c4cbcf 30% 70%, #a3acb1 70% 82%, #e6eaec 82%);
  box-shadow: 0 2px 3px rgba(0,0,0,.25);
}
.p-plate .duct {
  position: absolute; right: 8%; top: 10%; bottom: 10%; width: 14%; min-width: 10px;
  background: repeating-linear-gradient(180deg, #8f989d 0 3px, #b6bec2 3px 9px);
  box-shadow: 0 2px 4px rgba(0,0,0,.25);
}

/* perforated louvres on the side walls */
.cab-vents {
  position: absolute; left: 22%; right: 22%; top: 12%;
  height: 16%;
  background-image: radial-gradient(circle, rgba(0,0,0,.45) 1.3px, transparent 1.7px);
  background-size: 8px 8px;
  opacity: .8;
}
.cab-vents.in { background-image: radial-gradient(circle, rgba(255,255,255,.5) 1.2px, transparent 1.6px); opacity: .6; }
.cab-vents.low { top: auto; bottom: 12%; }
.cab.no-vents .cab-vents { display: none; }

/* doors: a thin box (outer skin, inner skin, four folded edges) hinged on its outer edge */
.cab-door {
  position: absolute; left: 0; top: 0;
  transform-style: preserve-3d;
  transform-origin: right center;
  transition: transform .8s cubic-bezier(.3, .7, .2, 1), width .45s ease, height .45s ease, margin .45s ease;
}
.cab-door.d-left { transform-origin: left center; }
.cab-door .dp { background-color: var(--metal, #b9c0c4); }
.cab-door .d-out { box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.cab-door .d-out::after { background: linear-gradient(160deg, rgba(255,255,255,.34), rgba(255,255,255,0) 60%); }
.cab-door .d-in { transform: rotateY(180deg); background-color: var(--metal-inner, #8e979c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.cab-door .d-in .stiffener { position: absolute; left: 18%; right: 18%; top: 8%; bottom: 8%; border: 2px solid rgba(0,0,0,.14); border-radius: 2px; }
.cab-door .d-edge::after { background: rgba(0,0,0,.18); }
.cab-door .d-edge-l { transform-origin: left center; transform: rotateY(-90deg); }
.cab-door .d-edge-r { transform-origin: right center; transform: rotateY(90deg); }
.cab-door .d-edge-t { transform-origin: center top; transform: rotateX(90deg); }
.cab-door .d-edge-b { transform-origin: center bottom; transform: rotateX(-90deg); }
.cab-door .d-edge-t::after { background: rgba(255,255,255,.2); }
.cab-door .handle {
  position: absolute; top: 44%; width: 6px; height: 12%; min-height: 18px; border-radius: 3px;
  background: var(--handle, #2b3136);
  box-shadow: 1px 2px 3px rgba(0,0,0,.3);
  z-index: 1;
}
.cab-door.d-right .handle { left: 10px; }
.cab-door.d-left .handle { right: 10px; }
.cab-door .hinge { position: absolute; width: 5px; height: 7%; min-height: 10px; background: #3a4146; border-radius: 1px; }
.cab-door .hinge.h1 { top: 12%; }
.cab-door .hinge.h2 { bottom: 12%; }
.cab-door.d-right .hinge { right: 2px; }
.cab-door.d-left .hinge { left: 2px; }

/* ---------- style switcher (injected by switcher.js) ---------- */
.mh-switch {
  position: fixed; z-index: 100;
  left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(28, 31, 35, .92);
  color: #fff;
  font: 500 13px/1 "Tajawal", sans-serif;
  box-shadow: 0 12px 32px rgba(0,0,0,.25);
  backdrop-filter: blur(10px);
}
.mh-switch span { padding: 0 12px 0 8px; color: #b8c2c8; }
.mh-switch a { padding: 9px 14px; border-radius: 999px; color: #e7ecee; white-space: nowrap; }
.mh-switch a:hover { background: rgba(255,255,255,.1); }
.mh-switch a[aria-current="page"] { background: #0f7d87; color: #fff; }
@media (max-width: 520px) { .mh-switch span { display: none; } .mh-switch a { padding: 9px 10px; } }

.cab.booting, .cab.booting * { transition: none !important; }
