/* =====================================================
   DW STUDIO · REALITY CAPTURE VIEWER
   Design-Tokens und Shell.
   Farbwelt, Glas-Optik und Typo-Rhythmus sind aus der
   urspruenglichen index.html uebernommen (index.legacy.html).
   ===================================================== */

:root {
  /* Flaechen */
  --bg:            #080808;
  --stage:         radial-gradient(circle at 50% 35%, #242424 0%, #111 45%, #070707 100%);
  --glass:         rgba(10, 10, 10, .55);
  --glass-strong:  rgba(10, 10, 10, .62);
  --glass-hover:   rgba(255, 255, 255, .12);
  --glass-active:  rgba(255, 255, 255, .14);

  /* Linien */
  --line:          rgba(255, 255, 255, .12);
  --line-soft:     rgba(255, 255, 255, .10);

  /* Schrift */
  --text:          #ffffff;
  --text-2:        rgba(255, 255, 255, .82);
  --text-3:        rgba(255, 255, 255, .58);
  --text-4:        rgba(255, 255, 255, .45);

  /* Akzent */
  --accent:        #55d88a;
  --accent-glow:   rgba(85, 216, 138, .7);

  /* Form */
  --r-pill:        999px;
  --r-panel:       16px;
  --blur:          18px;
  --blur-sm:       14px;

  --shadow-panel:  0 20px 60px rgba(0, 0, 0, .25);
  --shadow-dock:   0 15px 50px rgba(0, 0, 0, .35);

  --ease:          .2s ease;

  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: var(--font);
}

/* Bei Browsern mit dynamischer Adressleiste (iOS) */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

/* -----------------------------------------------------
   BUEHNE — Container aller Ansichten
   ----------------------------------------------------- */

.stage {
  position: absolute;
  inset: 0;
  background: var(--stage);
}

.view {
  position: absolute;
  inset: 0;
}

/* display:none statt opacity — inaktive Canvas kosten so keine GPU-Zeit.
   Fuer den weichen Wechsel wird zusaetzlich die Deckkraft animiert:
   erst display freigeben, dann im naechsten Frame einblenden. */
.view[hidden] { display: none; }

.view {
  opacity: 0;
  transition: opacity .26s ease;
}

.view.visible { opacity: 1; }

/* Nutzer, die reduzierte Bewegung bevorzugen, bekommen harte Schnitte. */
@media (prefers-reduced-motion: reduce) {
  .view { transition: none; }
  .info, .dock { animation: none !important; }
}

.view model-viewer {
  width: 100%;
  height: 100%;
  background: transparent;
  --progress-bar-color: transparent;
}

/* -----------------------------------------------------
   TOPBAR — Marke links, Ansichts-Tabs rechts
   ----------------------------------------------------- */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  padding: 24px 28px;

  pointer-events: none;
}

.brand {
  color: var(--text);
  pointer-events: auto;
  flex: none;
}

.brand-small {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  opacity: .55;
  margin-bottom: 7px;
}

.brand-title {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -.4px;
}

/* -----------------------------------------------------
   PROJEKTWAEHLER  (STEP 3b·6)

   Er steht an der Stelle der Titelzeile und traegt deren
   Typografie — es soll aussehen wie der Projektname, der
   sich anfassen laesst, nicht wie ein Formularfeld. Die
   Bausteine sind die des Docks: dieselbe Glasflaeche,
   dieselbe Linie, derselbe Winkel als Aufklapp-Andeutung.
   ----------------------------------------------------- */

/* Der Deckel sitzt am <select>, nicht an dieser Huelle: die Huelle ist
   schrumpfend, ihre Breite waere die Bezugsgroesse fuer ein max-width:100%
   am Feld — und damit ein Kreis, der das Feld genau um die negativen
   Raender zu schmal macht. Der Name bekaeme drei Punkte, obwohl Platz ist. */
.projects {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.project-select {
  appearance: none;
  -webkit-appearance: none;

  max-width: min(46vw, 340px);

  /* Der negative Rand hebt die Flaeche auf: der NAME steht damit exakt
     unter „DW STUDIO“, und erst beim Zeigen wird die Schaltflaeche
     sichtbar. */
  margin: -5px -10px;
  padding: 5px 30px 5px 10px;

  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;

  color: var(--text);
  font-family: inherit;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -.4px;

  /* Ein langer Projektname darf die Tabs nicht aus der Topbar druecken. */
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;

  cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
}

.project-select:hover {
  background: var(--glass-hover);
  border-color: var(--line-soft);
}

.project-select:focus-visible {
  outline: none;
  background: var(--glass-active);
  border-color: var(--line);
}

/* Das Aufklappmenue ist ein Fenster des Systems, keine Glasflaeche:
   halbtransparente Tokens haetten dort keine Wirkung.

   Bewusst OHNE eigene Schriftgroesse: die Eigenbreite eines <select>
   rechnet der Browser aus den OPTIONEN. Eine kleinere Schrift dort macht
   das geschlossene Feld zu schmal, und der Projektname bekaeme drei Punkte,
   obwohl in der Topbar Platz waere. */
.project-select option {
  background: #141414;
  color: var(--text);
}

/* Derselbe Winkel wie am Dock-Aufklapper — kein neues Muster. */
.projects::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 50%;

  width: 4px;
  height: 4px;

  border-right: 1.2px solid var(--text);
  border-bottom: 1.2px solid var(--text);

  opacity: .45;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* Projektangaben — bewusst sehr zurueckhaltend, damit die Marke
   die Topbar traegt und nicht die Kennzahlen. */
.brand-meta {
  margin-top: 6px;

  font-size: 10px;
  letter-spacing: 1.2px;
  color: var(--text-4);
}

/* Tabs */

.tabs {
  display: flex;
  gap: 4px;

  padding: 5px;

  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);

  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));

  box-shadow: var(--shadow-dock);

  pointer-events: auto;
}

.tab {
  display: flex;
  align-items: center;
  gap: 7px;

  border: 0;
  background: transparent;
  color: var(--text-3);

  padding: 9px 16px;
  border-radius: var(--r-pill);

  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  white-space: nowrap;

  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.tab:hover:not(:disabled)  { color: var(--text); background: var(--glass-hover); }
.tab[aria-selected="true"] { color: var(--text); background: var(--glass-active); }

.tab:disabled {
  opacity: .3;
  cursor: not-allowed;
}

.tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .5;
  transition: opacity var(--ease), box-shadow var(--ease);
}

.tab[aria-selected="true"] .tab-dot {
  background: var(--accent);
  opacity: 1;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* -----------------------------------------------------
   INFO-PANEL
   ----------------------------------------------------- */

.info {
  position: fixed;
  left: 28px;
  bottom: 105px;
  z-index: 20;

  max-width: 330px;

  padding: 18px 20px;

  color: var(--text);

  background: var(--glass);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-panel);

  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));

  box-shadow: var(--shadow-panel);

  pointer-events: none;
  transition: opacity var(--ease);
}

.info.enter, .dock.enter {
  animation: chrome-enter .32s ease both;
}

@keyframes chrome-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Das Dock ist horizontal zentriert — die Verschiebung darf
   die Zentrierung nicht aufheben. */
.dock.enter {
  animation-name: dock-enter;
}

@keyframes dock-enter {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%); }
}

.info-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: .45;
  margin-bottom: 7px;
}

.info-title  { font-size: 18px; margin-bottom: 6px; }
.info-text   { font-size: 12px; line-height: 1.55; color: var(--text-3); }

.info-meta {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);

  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;

  font-size: 10px;
  letter-spacing: .6px;
  color: var(--text-4);
}

/* -----------------------------------------------------
   CONTROL-DOCK
   ----------------------------------------------------- */

.dock {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);

  z-index: 25;

  display: flex;
  align-items: center;
  gap: 7px;

  padding: 7px;

  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);

  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));

  box-shadow: var(--shadow-dock);

  max-width: calc(100vw - 56px);
}

.dock button {
  border: 0;
  background: transparent;
  color: var(--text-2);

  padding: 11px 16px;
  border-radius: var(--r-pill);

  font-family: inherit;
  font-size: 12px;
  white-space: nowrap;

  cursor: pointer;
  transition: background var(--ease), color var(--ease), transform var(--ease);
}

.dock button:hover  { color: var(--text); background: var(--glass-hover); }
.dock button:active { transform: scale(.96); }

.dock button.active {
  background: var(--glass-active);
  color: var(--text);
}

.dock-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex: none;
}

/* Segmentierte Gruppe im Dock — z. B. Blickwinkel ISO / FRONT / TOP.
   Bewusst zurueckhaltend: nur eine leicht abgesetzte Flaeche, keine
   Rahmen und keine zusaetzlichen Trennlinien. */

.dock-segment {
  display: flex;
  gap: 2px;

  padding: 2px;

  background: rgba(255, 255, 255, .045);
  border-radius: var(--r-pill);
}

.dock-segment button {
  padding: 9px 13px;

  font-size: 10px;
  letter-spacing: 1.3px;
  text-transform: uppercase;

  color: var(--text-3);
}

/* Reine Symbolschaltflaechen (z. B. Zoom) brauchen mehr Zeichengroesse
   als die Kurzwoerter, sonst wirken sie im Segment zu zart. */
.dock-segment button.glyph {
  font-size: 15px;
  letter-spacing: 0;
  padding: 6px 15px;
  line-height: 1;
}

.dock-segment button:hover  { color: var(--text); background: var(--glass-hover); }
.dock-segment button.active { color: var(--text); background: rgba(255, 255, 255, .16); }

/* Ausklappbare Auswahl im Dock (z. B. Faerbung) */

.dock-group { position: relative; }

/* Ein zurueckhaltender Winkel zeigt, dass sich die Schaltflaeche
   oeffnet — ohne den ruhigen Gesamteindruck zu stoeren. */
.dock-group > button:first-child::after {
  content: "";
  display: inline-block;

  width: 4px;
  height: 4px;
  margin-left: 7px;
  margin-bottom: 2px;

  border-right: 1.2px solid currentColor;
  border-bottom: 1.2px solid currentColor;

  opacity: .45;
  transform: rotate(45deg);
  transition: transform var(--ease), opacity var(--ease);
}

.dock-group.open > button:first-child::after {
  transform: rotate(-135deg);
  margin-bottom: -2px;
  opacity: .8;
}

.dock-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);

  display: none;
  flex-direction: column;
  gap: 2px;

  padding: 6px;
  min-width: 170px;

  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: 12px;

  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));

  box-shadow: var(--shadow-dock);
}

.dock-group.open .dock-menu { display: flex; }

.dock-menu button {
  width: 100%;
  text-align: left;
  border-radius: 8px;
  padding: 9px 12px;
}

/* -----------------------------------------------------
   LADEZUSTAND
   ----------------------------------------------------- */

.loading {
  position: fixed;
  inset: 0;
  z-index: 100;

  display: flex;
  align-items: center;
  justify-content: center;

  background: var(--bg);
  color: var(--text);

  transition: opacity .5s ease, visibility .5s ease;
}

.loading.hidden {
  opacity: 0;
  visibility: hidden;
}

.loader-content { text-align: center; }

.loader-brand {
  font-size: 11px;
  letter-spacing: 4px;
  text-transform: uppercase;
  opacity: .5;
  margin-bottom: 20px;
}

.loader-bar {
  width: 180px;
  height: 2px;
  margin: 0 auto;

  background: rgba(255, 255, 255, .1);
  border-radius: 2px;
  overflow: hidden;
}

.loader-progress {
  width: 35%;
  height: 100%;
  background: var(--text);
  animation: loading 1.4s infinite ease-in-out;
}

.loader-note {
  margin-top: 18px;
  font-size: 11px;
  letter-spacing: .5px;
  color: var(--text-4);
  min-height: 14px;
}

@keyframes loading {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(500%); }
}

/* Leichteres Overlay beim Ansichtswechsel — die Buehne bleibt sichtbar */
.loading.overlay {
  background: rgba(8, 8, 8, .72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 90;
}

/* -----------------------------------------------------
   FEHLERZUSTAND
   ----------------------------------------------------- */

.view-error {
  position: absolute;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 32px;
  text-align: center;
}

.view-error-box {
  max-width: 420px;

  padding: 24px 26px;

  background: var(--glass);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-panel);

  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));

  color: var(--text-3);
  font-size: 12px;
  line-height: 1.6;
}

.view-error-box strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

/* -----------------------------------------------------
   PROJEKTZUSTAENDE  (STEP 3b·4)

   Dieselben Bausteine wie .view-error, nur ganzseitig statt im Pane:
   Registry oder Manifest unbrauchbar (Faelle 5/6) und "keine Ansicht
   vorhanden" (Fall 14). Der Streifen .project-note traegt die stille
   Korrektur aus Fall 3.
   ----------------------------------------------------- */

.project-error {
  position: fixed;
  inset: 0;
  z-index: 60;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 32px;
  text-align: center;

  background: var(--stage);
}

.project-error-box {
  max-width: 460px;

  padding: 24px 26px;

  background: var(--glass);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-panel);

  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));

  color: var(--text-3);
  font-size: 12px;
  line-height: 1.6;

  /* Der Fehlertext ist eine Meldung, kein Fliesstext: Umbrueche und
     fuehrende Leerzeichen aus dem Validator bleiben lesbar. */
  white-space: pre-wrap;
}

.project-error-box strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

/* Im Stil der Dock-Knoepfe — kein neues Muster. */
.project-retry {
  display: inline-block;
  margin-top: 18px;
  padding: 8px 16px;

  background: var(--glass-hover);
  border: 1px solid var(--line-soft);
  border-radius: 10px;

  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.project-retry:hover { background: var(--glass-active); }

/* Fall 3 — schmal, nicht blockierend, unter der Topbar. */
.project-note {
  position: fixed;
  top: 76px;
  left: 0; right: 0;
  z-index: 25;

  margin: 0 auto;
  width: max-content;
  max-width: calc(100% - 56px);

  padding: 8px 14px;

  background: var(--glass-strong);
  border: 1px solid var(--line-soft);
  border-radius: 10px;

  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));

  color: var(--text-3);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;

  pointer-events: none;

  opacity: 1;
  transition: opacity .5s ease;
}

.project-note.weg { opacity: 0; }

/* -----------------------------------------------------
   MOBILE
   ----------------------------------------------------- */

@media (max-width: 860px) {
  .tab span { display: none; }
  .tab      { padding: 9px 12px; }
  .tab-dot  { width: 7px; height: 7px; }
  .tab::after {
    content: attr(data-short);
    font-size: 10px;
    letter-spacing: 1px;
  }
}

/* Auf kleinen Displays wird das Info-Panel antippbar und laesst sich
   einklappen, damit die Viewerflaeche moeglichst gross bleibt. */
@media (max-width: 700px) {
  .info {
    pointer-events: auto;
    cursor: pointer;
  }

  .info::after {
    content: "";
    position: absolute;
    right: 14px;
    top: 16px;

    width: 7px;
    height: 7px;

    border-right: 1.5px solid rgba(255, 255, 255, .4);
    border-bottom: 1.5px solid rgba(255, 255, 255, .4);

    transform: rotate(45deg);
    transition: transform var(--ease);
  }

  .info.collapsed::after { transform: rotate(-135deg); }

  .info.collapsed .info-text,
  .info.collapsed .info-meta { display: none; }

  .info.collapsed .info-title { margin-bottom: 0; }
}

@media (max-width: 700px) {
  .topbar     { padding: 16px 18px; align-items: flex-start; }
  .brand-title{ font-size: 16px; }
  .brand-small{ margin-bottom: 5px; }

  .info {
    left: 18px; right: 18px;
    bottom: 88px;
    max-width: none;
    padding: 14px 16px;
  }
  .info-title { font-size: 16px; }
  .info-meta  { gap: 4px 12px; }

  .dock {
    bottom: 16px;
    max-width: calc(100vw - 24px);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .dock::-webkit-scrollbar { display: none; }
  .dock button { padding: 10px 13px; }
  .dock-segment button { padding: 9px 10px; letter-spacing: 1px; }

  .dock-menu { min-width: 150px; }
}

@media (max-width: 700px) {
  .brand-meta { display: none; }

  /* Schmal bekommt der Waehler genau den Platz, den die Tabs uebriglassen.
     Die Rechnung ist gemessen, nicht geraten: Topbar-Innenrand 2 x 18 px,
     Abstand 16 px, und die Tabs sind ab 860 px auf ihre Kuerzel geschrumpft
     und dann 164 px breit — zusammen 216 px. Das Feld traegt davon 20 px
     negativen Rand, also 196, aufgerundet auf 200. Ohne diesen Deckel
     schiebt ein langer Projektname die Tabs aus der Topbar. */
  .project-select { max-width: min(calc(100vw - 200px), 260px); font-size: 16px; }
}

@media (max-width: 420px) {
  .brand-small { display: none; }
}

/* -----------------------------------------------------
   RASTER-ANSICHT (Orthophoto / DSM / DTM)
   ----------------------------------------------------- */

.raster-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

.raster-canvas.dragging { cursor: grabbing; }

.raster-readout {
  position: absolute;
  right: 20px;
  bottom: 20px;
  z-index: 15;

  padding: 10px 13px;

  background: var(--glass);
  border: 1px solid var(--line-soft);
  border-radius: 12px;

  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));

  font-size: 10.5px;
  line-height: 1.7;
  letter-spacing: .3px;
  color: var(--text-3);

  pointer-events: none;
  white-space: pre;

  opacity: 0;
  transition: opacity var(--ease);
}

.raster-readout.visible { opacity: 1; }
.raster-readout b { color: var(--text-2); font-weight: 500; }

.raster-scale {
  position: absolute;
  left: 20px;
  bottom: 20px;
  z-index: 15;

  display: flex;
  flex-direction: column;
  gap: 4px;

  font-size: 10px;
  letter-spacing: .8px;
  color: var(--text-4);

  pointer-events: none;
}

.raster-scale-bar {
  height: 3px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-top: 0;
  background: linear-gradient(90deg,
    rgba(255,255,255,.55) 0 50%, transparent 50% 100%);
}

@media (max-width: 700px) {
  .raster-readout { right: 12px; bottom: 84px; font-size: 10px; padding: 8px 10px; }
  .raster-scale   { left: 12px;  bottom: 84px; }
}
