/* Fabric viewer. Hextronics brand theme (dark default).
   Palette, typography, and component rules follow fabrick-brand/BRAND.md.
   Fonts are served locally from ./fonts so the viewer is self contained. */

@font-face {
  font-family: "Exo 2";
  src: url("./fonts/Exo2-VariableFont_wght.ttf") format("truetype");
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Syncopate";
  src: url("./fonts/Syncopate-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/IBMPlexMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/IBMPlexMono-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Backgrounds */
  --hex-black: #121212;
  --hex-white: #fffefa;

  /* Primary: yellow */
  --hex-yellow-light: #ffe585;
  --hex-yellow: #fed141;
  --hex-yellow-mid: #d6a736;
  --hex-yellow-dark: #b98b2d;

  /* Secondary: blue */
  --hex-blue-light: #77b6fd;
  --hex-blue: #3176d1;
  --hex-blue-dark: #244f93;

  /* Neutrals */
  --hex-dark: #30302e;
  --hex-mid: #5a6069;
  --hex-light: #acb9cc;

  /* Failure only */
  --hex-sunset: #ff5959;

  /* Surfaces derived from the brand neutrals */
  --surface: #1a1a19;
  --surface-2: #232321;
  --border: #30302e;

  --font-hero: "Syncopate", sans-serif;
  --font-body: "Exo 2", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --sidebar-w: 340px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--hex-white);
  background-color: var(--hex-black);
  overflow: hidden;
}

#app { display: flex; height: 100vh; width: 100vw; }

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 18px;
  gap: 14px;
}

.brand { display: flex; align-items: center; }
.brand-logo { height: 30px; width: auto; }

.hero-heading {
  font-family: var(--font-hero);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 2.1rem;
  line-height: 1.06;
  letter-spacing: -0.01em;
  color: var(--hex-white);
}
.hero-heading .dot { color: var(--hex-yellow); }

.tagline {
  font-size: 0.8rem;
  color: var(--hex-light);
  line-height: 1.4;
  max-width: 30ch;
}

.base-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.76rem;
  color: var(--hex-light);
  cursor: pointer;
  user-select: none;
}
.base-toggle input { accent-color: var(--hex-yellow); cursor: pointer; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hex-light);
}

.ghost-btn {
  font-family: var(--font-body);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--hex-light);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.ghost-btn:hover { color: var(--hex-yellow); border-color: var(--hex-yellow); }

/* New job form */
.new-job {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px;
}
.new-job.hidden { display: none; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hex-light);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }

.new-job input[type="text"],
.new-job select {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--hex-white);
  background: var(--hex-black);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 9px;
  width: 100%;
}
.new-job input[type="text"]::placeholder { color: var(--hex-mid); }
.new-job input[type="text"]:focus,
.new-job select:focus { outline: none; border-color: var(--hex-yellow); }

.new-job input[type="file"] {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--hex-light);
}
.new-job input[type="file"]::file-selector-button {
  font-family: var(--font-body);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--hex-light);
  border-radius: 8px;
  padding: 5px 10px;
  margin-right: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.new-job input[type="file"]::file-selector-button:hover {
  color: var(--hex-yellow); border-color: var(--hex-yellow);
}

.primary-btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--hex-yellow);
  color: var(--hex-black);
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.primary-btn:hover { background: var(--hex-yellow-light); }
.primary-btn:disabled { background: var(--hex-mid); color: var(--hex-light); cursor: default; }

.nj-progress {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--hex-light);
  min-height: 14px;
  word-break: break-word;
}
.nj-progress.error { color: var(--hex-sunset); }

#job-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.job {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  transition: border-color 0.15s ease;
}
.job.loadable { cursor: pointer; }
.job.loadable:hover { border-color: var(--hex-yellow); }
.job.selected { border-color: var(--hex-blue-light); }
.job.active-load { border-color: var(--hex-yellow); box-shadow: inset 0 0 0 1px var(--hex-yellow-dark); }

.job-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.job-name { font-size: 0.92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-id { font-family: var(--font-mono); font-size: 0.72rem; color: var(--hex-mid); margin-top: 2px; }

.badge {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
/* Complete is the primary, loadable state: solid yellow CTA. */
.badge.complete { background: var(--hex-yellow); color: var(--hex-black); }
/* Active / in progress: yellow accent. */
.badge.processing, .badge.post_processing, .badge.queued, .badge.uploading, .badge.created {
  background: rgba(254, 209, 65, 0.16); color: var(--hex-yellow);
}
/* Failure only: sunset. */
.badge.failed { background: rgba(255, 89, 89, 0.16); color: var(--hex-sunset); }
/* Idle / canceled: neutral. */
.badge.canceled { background: rgba(90, 96, 105, 0.22); color: var(--hex-light); }
/* Paused: neutral blue, distinct from the yellow active states. */
.badge.paused { background: rgba(119, 182, 253, 0.16); color: var(--hex-blue-light); }

/* Per-job control row (pause / resume / cancel / delete). */
.job-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.job-btn {
  font-family: var(--font-body);
  font-size: 0.7rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--hex-light);
  border-radius: 7px;
  padding: 3px 9px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.job-btn:hover { color: var(--hex-yellow); border-color: var(--hex-yellow); }
.job-btn.danger:hover { color: var(--hex-sunset); border-color: var(--hex-sunset); }

.job-stage { margin-top: 7px; font-size: 0.74rem; color: var(--hex-light); }

.progress {
  margin-top: 9px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress > span { display: block; height: 100%; background: var(--hex-yellow); transition: width 0.4s ease; }

/* Selected job detail: stage plus the mono log tail. */
.job-detail {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.job-detail.hidden { display: none; }
.detail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.detail-title { font-size: 0.8rem; font-weight: 600; }
.detail-meta { font-family: var(--font-mono); font-size: 0.72rem; color: var(--hex-mid); }
.logs {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.45;
  color: var(--hex-light);
  background: var(--hex-black);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  max-height: 168px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.status-line { font-family: var(--font-mono); font-size: 0.72rem; color: var(--hex-mid); min-height: 15px; }

#viewer-wrap { position: relative; flex: 1; height: 100%; }
#cesiumContainer { width: 100%; height: 100%; }

.overlay {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 18, 18, 0.88);
  border: 1px solid var(--border);
  color: var(--hex-light);
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 0.8rem;
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}
.overlay.hidden { display: none; }
.overlay { display: flex; flex-direction: column; align-items: center; gap: 8px; }

/* Globe-being-built loader, shown in the overlay while a job reconstructs or a
   tileset loads: a little planet with a sweeping build scan and an orbiting
   brick, in the brand yellow. Pure CSS. */
.globe-loader {
  display: none;
  position: relative;
  width: 72px;
  height: 72px;
  margin: 2px auto 0;
}
.overlay.loading .globe-loader { display: block; }

.globe-loader .planet {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 229, 133, 0.6), rgba(254, 209, 65, 0.12) 46%, rgba(18, 18, 18, 0) 70%),
    radial-gradient(circle at 50% 50%, #20201d, #121212);
  box-shadow: inset 0 0 16px rgba(254, 209, 65, 0.22), 0 0 16px rgba(254, 209, 65, 0.16);
  overflow: hidden;
  animation: globe-bob 3s ease-in-out infinite;
}
/* Lat/long grid masked to the sphere so it reads as a globe. */
.globe-loader .planet::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent 0 11px, rgba(255, 254, 250, 0.08) 11px 12px),
    repeating-linear-gradient(90deg, transparent 0 11px, rgba(255, 254, 250, 0.08) 11px 12px);
  -webkit-mask: radial-gradient(circle at 50% 50%, #000 58%, transparent 72%);
          mask: radial-gradient(circle at 50% 50%, #000 58%, transparent 72%);
}
/* Sweeping build/scan beam rotating over the planet. */
.globe-loader .planet::before {
  content: "";
  position: absolute;
  inset: -30%;
  background: conic-gradient(from 0deg, transparent 0 68%, rgba(254, 209, 65, 0.5) 84%, transparent 100%);
  animation: globe-scan 1.6s linear infinite;
}
/* A tilted orbit with a brick riding it, like a piece being added. */
.globe-loader .orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 78px;
  height: 26px;
  margin: -13px 0 0 -39px;
  border: 1px solid rgba(119, 182, 253, 0.45);
  border-radius: 50%;
  animation: globe-orbit 2.2s linear infinite;
}
.globe-loader .orbit::after {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  border-radius: 2px;
  background: var(--hex-yellow);
  box-shadow: 0 0 8px var(--hex-yellow);
}

@keyframes globe-scan { to { transform: rotate(360deg); } }
@keyframes globe-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes globe-orbit { from { transform: rotate(-20deg); } to { transform: rotate(340deg); } }

@media (prefers-reduced-motion: reduce) {
  .globe-loader .planet,
  .globe-loader .planet::before,
  .globe-loader .orbit { animation: none; }
}

/* Let the Hextronics theme dominate over Cesium chrome. */
.cesium-widget-credits { display: none !important; }
