/* =========================================================================
   KAMPEN — Procedural API drill-pipe connection configurator.
   Dark technical / terminal aesthetic, monospace, orange accent.
   Reproduces the client's proof-of-concept look & feel.
   ========================================================================= */

:root{
  --bg:      #0d1117;
  --panel:   #11161f;
  --panel2:  #161d29;
  --line:    #222c3a;
  --ink:     #e6edf3;
  --muted:   #7d8da3;
  --accent:  #ff8c42;
  --accent2: #3fb6ff;
  --grid:    #1a2230;
  --ok:      #7ee787;
}

/* NOTE: this stylesheet is now scoped to the configurator that lives inside the
   #configurator landing section. The page-level html/body resets live in
   landing.css. The configurator UI inherits the JetBrains Mono technical look. */

/* ----------------------------------------------- configurator section shell */
/* Wider than the rest of the landing: the 3D stage benefits from the extra
   width, so the configurator section breaks out of the 1200px container. */
.configurator-section .container{ max-width:1600px; }

/* The configurator is now an in-page section (NOT 100vh fixed). #app is a
   section-scoped 2-col grid: 360px control panel + 1fr stage, stacked on
   mobile. The whole block uses the configurator's monospace technical font. */
#app{
  display:grid;
  grid-template-columns:360px 1fr;
  gap:1px;
  background:var(--line);          /* shows as the divider line between cols */
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
  font-family:'JetBrains Mono', ui-monospace, monospace;
  min-height:640px;
}

/* ----------------------------------------------------------------- sidebar */
.sidebar{
  background:linear-gradient(180deg, var(--panel2), var(--panel));
  padding:22px 20px;
  display:flex;
  flex-direction:column;
  gap:22px;
}

.brand{ line-height:1.1; }
.brand-name{
  font-family:'Chakra Petch', sans-serif;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.08em;
  font-size:24px;
  color:var(--accent);
}
.brand-sub{
  font-size:11px;
  color:var(--muted);
  margin-top:4px;
  letter-spacing:0.02em;
}

/* groups */
.group{ display:flex; flex-direction:column; gap:9px; }
.group-label{
  font-size:10px;
  text-transform:uppercase;
  letter-spacing:0.18em;
  color:var(--muted);
}
.group-brand{ letter-spacing:0; color:var(--accent2); }

/* segmented buttons ------------------------------------------------------- */
.seg{ display:flex; flex-direction:column; gap:7px; }

.seg button{
  all:unset;
  box-sizing:border-box;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  cursor:pointer;
  padding:11px;
  border:1px solid var(--line);
  border-radius:7px;
  background:#0f141d;
  color:var(--ink);
  font-family:inherit;
  font-size:12px;
  transition:border-color .15s ease, background .15s ease, color .15s ease;
}
.seg button:hover{ border-color:#33425a; }
.seg button.on{
  border-color:var(--accent);
  background:rgba(255,140,66,.10);
  color:#ffd9b8;
}
.seg button:focus-visible{ outline:1px solid var(--accent2); outline-offset:1px; }

.seg .seg-main{ white-space:nowrap; }
.seg .tag{
  font-size:10px;
  color:var(--muted);
  letter-spacing:0.04em;
  transition:color .15s ease;
}
.seg button.on .tag{ color:var(--accent); }

/* disabled / unavailable size */
.seg button.disabled{
  cursor:not-allowed;
  opacity:.45;
}
.seg button.disabled .seg-main{ text-decoration:line-through; }
.seg button.disabled:hover{ border-color:var(--line); }

/* 3-way gender row (— / BOX / PIN): 3 equal columns side by side */
.seg-row{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:7px;
}
.seg-row button{
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  padding:9px 6px;
  text-align:center;
}
.seg-row .seg-main{ font-weight:600; }
.seg-row .tag{ font-size:9px; }

/* an end whose gender is "none" dims its size selector to signal it's inactive */
.end-size.muted{ opacity:.4; pointer-events:none; }

/* size buttons: 2-col grid, centered content */
.seg-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:7px;
}
.seg-grid button{
  justify-content:center;
  text-align:center;
  padding:10px 8px;
  font-size:11px;
}
.loading-note{
  grid-column:1 / -1;
  color:var(--muted);
  font-size:11px;
  padding:6px 0;
}

/* tool length (spec-only field) ------------------------------------------- */
.length-row{
  display:flex;
  align-items:center;
  gap:9px;
}
.length-row input[type="range"]{
  flex:1;
  -webkit-appearance:none;
  appearance:none;
  height:4px;
  border-radius:999px;
  background:var(--line);
  cursor:pointer;
}
.length-row input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none;
  appearance:none;
  width:14px; height:14px;
  border-radius:50%;
  background:var(--accent);
  cursor:pointer;
  border:2px solid #0f141d;
}
.length-row input[type="range"]::-moz-range-thumb{
  width:14px; height:14px;
  border-radius:50%;
  background:var(--accent);
  cursor:pointer;
  border:2px solid #0f141d;
}
.length-row input[type="number"]{
  width:64px;
  box-sizing:border-box;
  padding:7px 8px;
  border:1px solid var(--line);
  border-radius:6px;
  background:#0f141d;
  color:var(--ink);
  font-family:inherit;
  font-size:12px;
  text-align:right;
}
.length-row input[type="number"]:focus-visible{
  outline:1px solid var(--accent2);
  outline-offset:1px;
  border-color:var(--accent2);
}
.length-unit{ font-size:11px; color:var(--muted); }
.length-note{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:10px;
  font-size:10px;
  color:var(--muted);
}
.length-note #lengthMin{ color:var(--accent2); }
.length-note .spec-note{ font-style:italic; opacity:.8; text-align:right; }

/* stat panel -------------------------------------------------------------- */
.stats{ margin-top:auto; gap:0; }
.stats .group-label{ margin-bottom:9px; }

/* configuration summary + KIND badge */
.summary-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}
.summary-text{
  font-size:12px;
  color:var(--ink);
  line-height:1.35;
}
.kind-badge{
  flex:none;
  font-size:9px;
  font-weight:600;
  letter-spacing:0.12em;
  text-transform:uppercase;
  padding:4px 9px;
  border-radius:999px;
  border:1px solid var(--line);
  color:var(--muted);
  white-space:nowrap;
}
.kind-badge.single{ color:var(--accent2); border-color:#1f4a66; background:rgba(63,182,255,.08); }
.kind-badge.joint{ color:var(--ok); border-color:#23472b; background:rgba(126,231,135,.08); }
.kind-badge.crossover{ color:var(--accent); border-color:var(--accent); background:rgba(255,140,66,.10); }
.stat{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:10px;
  padding:4px 0;
  font-size:11px;
  border-bottom:1px solid rgba(34,44,58,.5);
}
.stat .k{ color:var(--muted); }
.stat .v{ color:var(--ink); text-align:right; }
.stat.gen .v{ color:var(--accent); }
/* real-CAD source highlighted in green to match the cache HIT styling */
.stat .v.accent-v{ color:var(--ok); }
/* procedural source highlighted in orange */
.stat .v.warn-v{ color:var(--accent); }

/* ------------------------------------------------------------------ stage */
.stage{
  position:relative;
  overflow:hidden;
  background:var(--bg);
  min-height:640px;
}
.stage canvas{ display:block; width:100%; height:100%; }

/* top-left info badge */
.badge{
  position:absolute;
  top:16px; left:16px;
  z-index:4;
  font-family:'Chakra Petch', sans-serif;
  font-weight:600;
  font-size:13px;
  letter-spacing:0.04em;
  padding:8px 13px;
  border-radius:8px;
  border:1px solid var(--line);
  background:rgba(13,17,23,.62);
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
  color:var(--ink);
}
.badge .accent{ color:var(--accent); }

/* top-right cache pill */
.cache{
  position:absolute;
  top:16px; right:16px;
  z-index:4;
  font-size:11px;
  letter-spacing:0.02em;
  padding:7px 12px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(13,17,23,.62);
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
  color:var(--muted);
}
.cache.hit{ color:var(--ok); border-color:#23472b; }
.cache.miss{ color:var(--accent); border-color:var(--accent); }

/* bottom control hints */
.controls{
  position:absolute;
  bottom:16px; left:50%;
  transform:translateX(-50%);
  z-index:4;
  display:flex;
  gap:18px;
  font-size:11px;
  color:var(--muted);
  padding:8px 16px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(13,17,23,.62);
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
  white-space:nowrap;
}
.controls b{ color:var(--accent2); font-weight:500; }

/* loading overlay */
.loader{
  position:absolute;
  inset:0;
  z-index:5;
  display:grid;
  place-items:center;
  gap:16px;
  background:rgba(13,17,23,.35);
  backdrop-filter:blur(1px);
  transition:opacity .25s ease;
}
.loader.hidden{ opacity:0; pointer-events:none; }
.loader .spin{
  width:40px; height:40px;
  border-radius:50%;
  border:3px solid rgba(255,255,255,.10);
  border-top-color:var(--accent);
  animation:spin .8s linear infinite;
}
.loader .ltext{
  position:absolute;
  bottom:30%;
  font-size:11px;
  letter-spacing:0.2em;
  text-transform:uppercase;
  color:var(--muted);
}
@keyframes spin{ to{ transform:rotate(360deg); } }

/* friendly error message inside stage */
.stage-error{
  position:absolute;
  top:50%; left:50%;
  transform:translate(-50%,-50%);
  z-index:6;
  max-width:440px;
  width:calc(100% - 48px);
  background:rgba(28,18,10,.94);
  border:1px solid var(--accent);
  border-radius:10px;
  padding:18px 20px;
  color:#ffe2bd;
  font-size:12px;
  line-height:1.6;
  display:none;
}
.stage-error.show{ display:block; }
.stage-error .err-title{
  font-family:'Chakra Petch', sans-serif;
  font-weight:600;
  color:var(--accent);
  font-size:13px;
  letter-spacing:0.04em;
  margin-bottom:8px;
}
.stage-error .chips{ margin-top:10px; display:flex; flex-wrap:wrap; gap:6px; }
.stage-error .chip{
  font-size:11px;
  padding:3px 9px;
  border-radius:999px;
  border:1px solid rgba(255,140,66,.4);
  background:rgba(255,140,66,.10);
  color:var(--accent);
}

/* ------------------------------------------------------------- responsive */
/* On mobile the configurator panel stacks ABOVE the canvas (panel then stage). */
@media (max-width:860px){
  #app{
    grid-template-columns:1fr;
    grid-template-rows:auto 1fr;
    min-height:0;
  }
  .stats{ margin-top:18px; }
  .stage{ min-height:480px; }
  .controls{ gap:12px; font-size:10px; padding:7px 12px; }
}
