/* Kuala Lumpur 3D Digital Twin — Axiom Core Jalur Gemilang Dark Editorial
   House laws:
   - ZERO border-radius, ZERO box-shadow, ZERO gradients
   - Hairline borders, signal palette
   - Sharp corners, Newsreader serif + IBM Plex Mono tabular nums
*/

:root {
  --bg-3d: #080b11;
  --panel-3d: #0f141d;
  --panel-border: rgba(255, 255, 255, 0.12);
  --panel-border-bright: rgba(255, 255, 255, 0.28);
  --ink-3d: #f3f4f6;
  --ink-dim: #94a3b8;
  --accent-3d: #ffcc00;
  --cyan-3d: #38bdf8;
  --green-3d: #34d399;
  --warn-3d: #f87171;
}

body.kl3d-body {
  margin: 0;
  padding: 0;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-3d);
  color: var(--ink-3d);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}

/* Force zero radius & no shadows across all 3D surface widgets */
.kl3d-body *,
.kl3d-body *::before,
.kl3d-body *::after {
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* Top Header */
.kl3d-top {
  height: 56px;
  background: var(--panel-3d);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  z-index: 1000;
  flex-shrink: 0;
}

.kl3d-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.kl3d-back {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--cyan-3d);
  text-decoration: none;
  border: 1px solid var(--panel-border);
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.03);
}
.kl3d-back:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--cyan-3d);
}

.kl3d-titles {
  display: flex;
  flex-direction: column;
}

.kl3d-eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent-3d);
}

.kl3d-h1 {
  font-family: "Newsreader", serif;
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  line-height: 1.1;
  color: #fff;
}

.kl3d-sub {
  font-size: 11px;
  color: var(--ink-dim);
  margin: 0;
  display: none;
}
@media (min-width: 900px) {
  .kl3d-sub { display: block; }
}

.kl3d-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-3d) !important;
  color: #000 !important;
  font-weight: 700 !important;
  border: 1px solid var(--accent-3d) !important;
}
.btn-primary:hover {
  background: #ffe066 !important;
}

.fly-icon {
  margin-right: 4px;
}

.basemap-group {
  display: flex;
  border: 1px solid var(--panel-border);
}
.basemap-group .btn {
  border: none;
  padding: 4px 10px;
  font-size: 11px;
  font-family: "IBM Plex Mono", monospace;
  background: transparent;
  color: var(--ink-dim);
}
.basemap-group .btn.active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-weight: 600;
}

/* Stage & Map Viewport */
.kl3d-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.kl3d-viewport {
  width: 100%;
  height: 100%;
  background: #000;
}

/* Loading Overlay */
.kl3d-loading {
  position: absolute;
  inset: 0;
  background: rgba(8, 11, 17, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.4s ease;
}
.kl3d-loading-box {
  border: 1px solid var(--panel-border-bright);
  background: var(--panel-3d);
  padding: 24px 32px;
  text-align: center;
  max-width: 380px;
}
.kl3d-loading-glyph {
  font-family: "Newsreader", serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-3d);
  letter-spacing: 0.1em;
}
.kl3d-loading-txt {
  font-size: 14px;
  font-weight: 600;
  margin: 12px 0 4px;
  color: #fff;
}
.kl3d-loading-sub {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  color: var(--ink-dim);
  margin: 0;
}

/* Arnis 1:1 HUD */
.kl3d-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(15, 20, 29, 0.92);
  border: 1px solid var(--panel-border);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 500;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.hud-item {
  display: flex;
  flex-direction: column;
}
.hud-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
}
.hud-val {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: #fff;
}
.hud-sep {
  color: var(--panel-border-bright);
  font-size: 12px;
}
.hud-tp-btn {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: var(--cyan-3d);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.hud-tp-btn:hover {
  background: var(--cyan-3d);
  color: #000;
}
.hud-tp-cmd {
  font-size: 11px;
  font-weight: 600;
}
.hud-tp-copy {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: 6px;
}

/* Flyover Chapter Ribbon */
.kl3d-chapter-ribbon {
  position: absolute;
  top: 70px;
  left: 14px;
  background: rgba(15, 20, 29, 0.95);
  border: 1px solid var(--accent-3d);
  padding: 12px 16px;
  max-width: 440px;
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.chapter-tag {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  color: var(--accent-3d);
  letter-spacing: 0.12em;
}
.chapter-title {
  font-family: "Newsreader", serif;
  font-size: 16px;
  font-weight: 700;
  margin: 2px 0 4px;
  color: #fff;
}
.chapter-desc {
  font-size: 11.5px;
  color: var(--ink-dim);
  margin: 0;
  line-height: 1.4;
}
.chapter-ctrls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.chapter-idx {
  font-size: 10px;
  color: var(--ink-dim);
  padding: 0 4px;
}

/* Layers Panel */
.kl3d-layers-panel {
  position: absolute;
  bottom: 24px;
  left: 14px;
  background: rgba(15, 20, 29, 0.92);
  border: 1px solid var(--panel-border);
  padding: 10px 14px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lp-head {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.lp-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  cursor: pointer;
  color: var(--ink-3d);
}
.lp-toggle input {
  margin: 0;
  cursor: pointer;
}
.swatch {
  width: 10px;
  height: 10px;
  display: inline-block;
  flex-shrink: 0;
}
.swatch-bld { background: #f59e0b; }
.swatch-hero { background: var(--accent-3d); }
.swatch-water { background: var(--cyan-3d); }
.swatch-transit { background: #ef4444; }

/* Quick Jump Rail */
.kl3d-quick-rail {
  position: absolute;
  bottom: 24px;
  left: 230px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 20, 29, 0.92);
  border: 1px solid var(--panel-border);
  padding: 6px 10px;
  z-index: 500;
  overflow-x: auto;
  max-width: calc(100vw - 250px);
}
.quick-title {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  color: var(--ink-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-right: 4px;
}
.quick-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--ink-3d);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.quick-btn:hover {
  background: rgba(255, 204, 0, 0.2);
  border-color: var(--accent-3d);
  color: #fff;
}

/* Building Inspect Card */
.kl3d-inspect {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 320px;
  max-height: calc(100vh - 100px);
  background: rgba(15, 20, 29, 0.96);
  border: 1px solid var(--panel-border-bright);
  padding: 16px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.inspect-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-size: 14px;
  cursor: pointer;
}
.inspect-close:hover { color: #fff; }
.inspect-eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-3d);
}
.inspect-title {
  font-family: "Newsreader", serif;
  font-size: 20px;
  font-weight: 700;
  margin: 4px 0 2px;
  color: #fff;
}
.inspect-style {
  font-size: 11px;
  color: var(--ink-dim);
  margin: 0 0 12px;
}
.inspect-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.metric-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
}
.metric-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  color: var(--ink-dim);
}
.metric-val {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
.inspect-desc {
  font-size: 12px;
  line-height: 1.45;
  color: #cbd5e1;
  margin: 0 0 14px;
}
.inspect-arnis {
  border-top: 1px solid var(--panel-border);
  padding-top: 10px;
}
.arnis-section-title {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  color: var(--green-3d);
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.arnis-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}
.arnis-badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: #6ee7b7;
  padding: 2px 6px;
}
.arnis-tp-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  padding: 8px;
}
.arnis-tp-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  color: var(--ink-dim);
  display: block;
  margin-bottom: 4px;
}
.arnis-tp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.arnis-tp-row code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  color: var(--accent-3d);
}

/* Modal Dialog */
.arnis-dialog {
  background: var(--panel-3d);
  color: var(--ink-3d);
  border: 1px solid var(--panel-border-bright);
  padding: 24px;
  max-width: 640px;
  width: 90vw;
  z-index: 3000;
}
.arnis-dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
}
.arnis-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 10px;
}
.arnis-modal-header h2 {
  font-family: "Newsreader", serif;
  font-size: 20px;
  margin: 0;
  color: #fff;
}
.modal-lead {
  font-size: 13px;
  line-height: 1.5;
  color: #cbd5e1;
}
.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}
.spec-item {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}
.spec-lbl {
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  color: var(--ink-dim);
}
.spec-val {
  font-size: 11px;
  color: #fff;
  margin-top: 2px;
}
.code-block {
  background: #000;
  border: 1px solid var(--panel-border);
  padding: 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--cyan-3d);
  overflow-x: auto;
  line-height: 1.45;
}
.cli-box {
  background: #000;
  border: 1px solid var(--accent-3d);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 16px;
}
.cli-box code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: #fff;
  word-break: break-all;
}
.arnis-palette-list {
  padding-left: 20px;
  font-size: 12px;
  line-height: 1.6;
}
.arnis-modal-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  border-top: 1px solid var(--panel-border);
  padding-top: 14px;
  flex-wrap: wrap;
}

/* Toast */
.kl3d-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--accent-3d);
  color: #000;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  font-weight: 700;
  padding: 8px 16px;
  border: 1px solid #000;
  z-index: 4000;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .kl3d-hud {
    font-size: 9px;
    padding: 4px 8px;
    gap: 6px;
  }
  .hud-gps { display: none; }
  .kl3d-quick-rail {
    left: 14px;
    bottom: 120px;
    max-width: calc(100vw - 28px);
  }
  .kl3d-inspect {
    width: calc(100vw - 28px);
    right: 14px;
    left: 14px;
    top: auto;
    bottom: 14px;
    max-height: 50vh;
  }
}
