/*
 * Ziselin Render Shell
 * --------------------
 * Gemeinsame Vorlage für die Hauptansicht einer App: Kopfzeile, gerenderter
 * Inhaltsbereich und Fußzeile. Die Shell enthält bewusst keine fachliche
 * Renderlogik. App-spezifische Flächen wie Globus, Textsatz oder Timelines
 * liegen als Inhalt im Renderbereich und erben nur Position, Höhen und
 * Bedienlogik der äußeren Bühne.
 *
 * Neue Apps sollen bevorzugt die generischen Klassen verwenden:
 * .app-frame > .preview-view > .topbar + .app-render-stage + .workspace-strip
 * Bestehende Apps können die historischen Alias-Klassen weiter nutzen.
 */

:root {
  --z-render-shell-topbar-height: 82px;
  --z-render-shell-footer-height: 48px;
  --z-render-shell-header-padding: 18px 18px 10px 20px;
  --z-render-shell-brand-gap: 14px;
  --z-render-shell-brand-height: 54px;
  --z-render-shell-icon-color: var(--ink, var(--text, #213633));
  --z-render-shell-icon-accent: var(--amber, var(--accent, #ffb347));
  --z-render-shell-line: var(--line, rgba(33, 54, 51, 0.14));
  --z-render-shell-line-strong: var(--line-strong, rgba(255, 179, 71, 0.34));
  --z-render-shell-footer-bg: rgba(45, 53, 59, 0.96);
  --z-render-shell-footer-bg-hover: rgba(50, 59, 66, 0.98);
  --z-render-shell-footer-text: #a8b2ba;
  --z-render-shell-footer-text-hover: #d9dee2;
  --z-render-shell-drawer-bg: var(--z-render-shell-footer-bg);
  --z-render-shell-drawer-bg-hover: var(--z-render-shell-footer-bg-hover);
  --z-render-shell-drawer-panel-bg: var(--z-render-shell-footer-bg);
  --z-render-shell-drawer-text: #d9dee2;
  --z-render-shell-drawer-muted: #a8b2ba;
  --z-render-shell-drawer-top-highlight: rgba(255, 179, 71, 0.28);
}

.app-frame {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.preview-view,
.details-view {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  transition: transform 220ms ease, opacity 180ms ease;
}

.preview-view {
  z-index: 2;
  opacity: 1;
  transform: translateY(0);
}

.details-view {
  z-index: 1;
  opacity: 0;
  transform: translateY(7%);
  pointer-events: none;
}

.workspace-mode-details .preview-view {
  z-index: 1;
  opacity: 0;
  transform: translateY(-7%);
  pointer-events: none;
}

.workspace-mode-details .details-view {
  z-index: 3;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--z-render-shell-topbar-height);
  min-height: var(--z-render-shell-topbar-height);
  padding: var(--z-render-shell-header-padding);
  overflow: visible;
}

.brand-plate,
.brand-mark,
.topbar-actions,
.control-grid {
  display: flex;
  align-items: center;
}

.brand-plate {
  position: relative;
  gap: var(--z-render-shell-brand-gap);
  height: var(--z-render-shell-brand-height);
  min-height: var(--z-render-shell-brand-height);
  min-width: 0;
  padding: 0 12px;
  z-index: 1;
}

.brand-mark {
  position: relative;
  gap: 12px;
  min-width: 0;
  z-index: 2;
}

.brand-home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  border-radius: 6px;
}

.brand-bird {
  display: block;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-name,
.brand-wordmark-text {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: var(--z-render-shell-icon-color);
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(1.32rem, 2.05vw, 1.82rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-transform: lowercase;
  white-space: nowrap;
}

.topbar-actions,
.topbar-search {
  justify-content: flex-end;
  gap: 3px;
  padding-right: 8px;
}

.topbar-icon-button,
.header-icon-button.topbar-icon-button,
.theme-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--z-render-shell-icon-color);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.app-menu-button,
.type-menu-button,
.header-icon-button.menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--z-render-shell-icon-accent);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.app-menu-button img,
.type-menu-button img,
.header-icon-button.menu-button img {
  display: block;
  width: 28px;
  height: 28px;
  opacity: 0.94;
}

.app-menu-button:hover,
.app-menu-button[aria-expanded="true"],
.type-menu-button:hover,
.type-menu-button[aria-expanded="true"],
.header-icon-button.menu-button:hover,
.header-icon-button.menu-button[aria-expanded="true"],
.topbar-icon-button:hover,
.topbar-icon-button:focus-visible,
.topbar-icon-button[aria-expanded="true"],
.header-icon-button.topbar-icon-button:hover,
.header-icon-button.topbar-icon-button:focus-visible,
.header-icon-button.topbar-icon-button[aria-expanded="true"] {
  border-color: var(--z-render-shell-line-strong);
  background: rgba(255, 179, 71, 0.08);
}

.topbar-action-icon {
  display: block;
  width: 20px;
  height: 20px;
  background: currentColor;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

.topbar-export-icon {
  mask-image: url("https://api.iconify.design/uil/export.svg");
  -webkit-mask-image: url("https://api.iconify.design/uil/export.svg");
}

.topbar-print-icon {
  mask-image: url("https://api.iconify.design/material-symbols/print-outline-rounded.svg");
  -webkit-mask-image: url("https://api.iconify.design/material-symbols/print-outline-rounded.svg");
}

.app-render-stage,
.globe-stage {
  height: calc(100dvh - var(--z-render-shell-topbar-height) - var(--z-render-shell-footer-height));
  min-height: 0;
  overflow: hidden;
}

.workspace-strip {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--z-render-shell-footer-height);
  min-height: var(--z-render-shell-footer-height);
  padding: 0 16px;
  border: 0;
  border-top: 1px solid var(--z-render-shell-line);
  background: var(--z-render-shell-footer-bg);
  color: rgba(217, 222, 226, 0.45);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  backdrop-filter: blur(16px);
}

.workspace-strip-top {
  top: 0;
  bottom: auto;
  border-top: 0;
  border-bottom: 1px solid var(--z-render-shell-line);
}

.workspace-strip-label,
.workspace-strip span {
  color: var(--z-render-shell-footer-text);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.workspace-strip:hover {
  background: var(--z-render-shell-footer-bg-hover);
  color: rgba(217, 222, 226, 0.68);
}

.workspace-strip:hover .workspace-strip-label,
.workspace-strip:hover span {
  color: var(--z-render-shell-footer-text-hover);
}

.workspace-fullscreen-button {
  position: absolute;
  top: 50%;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: rgba(238, 243, 246, 0.78);
  font: inherit;
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
  z-index: 2;
}

.workspace-fullscreen-button:hover,
.workspace-fullscreen-button:focus-visible {
  border-color: rgba(255, 179, 71, 0.58);
  background: rgba(255, 179, 71, 0.12);
  outline: 0;
}

.workspace-fullscreen-button.is-active {
  border-color: rgba(255, 179, 71, 0.45);
  background: rgba(255, 179, 71, 0.12);
  color: var(--z-render-shell-icon-accent);
}

.workspace-fullscreen-button.is-muted {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #8b949b;
}

.app-view-drawer {
  position: absolute;
  left: clamp(14px, 2.4vw, 28px);
  bottom: calc(var(--z-render-shell-footer-height) - 3px);
  z-index: 14;
  width: min(360px, calc(100vw - 28px));
  pointer-events: none;
}

.app-view-drawer-tab {
  position: relative;
  left: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 22px;
  margin-bottom: -1px;
  padding: 5px 18px 4px;
  border: 1px solid var(--z-render-shell-line);
  border-bottom: 0;
  border-radius: 15px 15px 0 0;
  background: var(--z-render-shell-drawer-panel-bg);
  color: var(--z-render-shell-drawer-muted);
  font: inherit;
  cursor: grab;
  user-select: none;
  touch-action: none;
  pointer-events: auto;
  backdrop-filter: blur(16px);
  box-shadow:
    0 -8px 24px rgba(0, 0, 0, 0.09),
    inset 0 1px 0 rgba(255,255,255,.055);
  transition: box-shadow 140ms ease, color 140ms ease;
  z-index: 2;
}

.app-view-drawer-tab::before,
.app-view-drawer-tab::after {
  content: "";
  position: absolute;
  bottom: -1px;
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.app-view-drawer-tab::before {
  left: -14px;
  border-bottom-right-radius: 14px;
  box-shadow: 7px 7px 0 6px var(--z-render-shell-drawer-panel-bg);
}

.app-view-drawer-tab::after {
  right: -14px;
  border-bottom-left-radius: 14px;
  box-shadow: -7px 7px 0 6px var(--z-render-shell-drawer-panel-bg);
}

.app-view-drawer-tab:active {
  cursor: grabbing;
}

.app-view-drawer-tab:hover,
.app-view-drawer.is-open .app-view-drawer-tab,
.preview-view:has(> .workspace-strip:hover) .app-view-drawer-tab,
.timeline-view:has(> .workspace-strip:hover) .app-view-drawer-tab {
  background: var(--z-render-shell-drawer-panel-bg);
  color: var(--z-render-shell-drawer-text);
  box-shadow:
    0 -8px 24px rgba(0, 0, 0, 0.09),
    inset 0 1px 0 var(--z-render-shell-drawer-top-highlight);
}

.app-view-drawer-tab:hover::before,
.app-view-drawer.is-open .app-view-drawer-tab::before,
.preview-view:has(> .workspace-strip:hover) .app-view-drawer-tab::before,
.timeline-view:has(> .workspace-strip:hover) .app-view-drawer-tab::before {
  box-shadow: 7px 7px 0 6px var(--z-render-shell-drawer-panel-bg);
}

.app-view-drawer-tab:hover::after,
.app-view-drawer.is-open .app-view-drawer-tab::after,
.preview-view:has(> .workspace-strip:hover) .app-view-drawer-tab::after,
.timeline-view:has(> .workspace-strip:hover) .app-view-drawer-tab::after {
  box-shadow: -7px 7px 0 6px var(--z-render-shell-drawer-panel-bg);
}

.app-view-drawer-tab-grip {
  display: block;
  width: 16px;
  height: 16px;
  color: var(--z-render-shell-drawer-muted);
  background: currentColor;
  opacity: 0.7;
  mask-image: url("https://api.iconify.design/dashicons/arrow-up.svg");
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-image: url("https://api.iconify.design/dashicons/arrow-up.svg");
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  transition: color 140ms ease, opacity 140ms ease, transform 140ms ease;
}

.app-view-drawer-tab:hover .app-view-drawer-tab-grip,
.app-view-drawer.is-open .app-view-drawer-tab-grip,
.preview-view:has(> .workspace-strip:hover) .app-view-drawer-tab-grip,
.timeline-view:has(> .workspace-strip:hover) .app-view-drawer-tab-grip {
  color: var(--z-render-shell-drawer-text);
  opacity: 0.92;
}

.app-view-drawer.is-open .app-view-drawer-tab-grip {
  transform: rotate(180deg);
}

.app-view-drawer-panel {
  display: grid;
  gap: 10px;
  width: 100%;
  --z-render-shell-drawer-panel-max-height: min(42dvh, 320px);
  max-height: min(42dvh, 320px);
  overflow: auto;
  scrollbar-width: none;
  padding: 15px;
  border: 1px solid var(--z-render-shell-line);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: var(--z-render-shell-drawer-panel-bg);
  color: var(--z-render-shell-drawer-text);
  box-shadow: 0 -18px 52px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(18px);
  pointer-events: auto;
  animation: z-render-shell-drawer-open 180ms cubic-bezier(.2, .78, .26, 1) both;
  will-change: max-height, opacity, padding-top, padding-bottom;
}

.app-view-drawer-panel.is-closing {
  animation: z-render-shell-drawer-close 180ms ease both;
}

.app-view-drawer-panel[hidden] {
  display: none !important;
}

.app-view-drawer-panel::-webkit-scrollbar {
  display: none;
}

.app-view-drawer-option {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 11px;
  min-height: 38px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--z-render-shell-drawer-text);
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.app-view-drawer-option:hover,
.app-view-drawer-option:focus-visible {
  background: rgba(255,255,255,.055);
  outline: 0;
}

.app-view-drawer-option-icon,
.app-view-drawer-option-check {
  display: block;
  width: 18px;
  height: 18px;
  background: currentColor;
  opacity: .76;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

.app-view-drawer-option-icon-grid {
  mask-image: url("https://api.iconify.design/mdi/grid.svg");
  -webkit-mask-image: url("https://api.iconify.design/mdi/grid.svg");
}

.app-view-drawer-option-icon-boundary {
  mask-image: url("https://api.iconify.design/ri/treasure-map-line.svg");
  -webkit-mask-image: url("https://api.iconify.design/ri/treasure-map-line.svg");
}

.app-view-drawer-option-icon-projection {
  mask-image: url("https://api.iconify.design/mdi/earth.svg");
  -webkit-mask-image: url("https://api.iconify.design/mdi/earth.svg");
}

.app-view-drawer-option-label {
  min-width: 0;
}

.app-view-drawer-option-check {
  justify-self: end;
  opacity: 0;
  transform: scale(.86);
  color: var(--z-render-shell-icon-accent);
  mask-image: url("https://api.iconify.design/material-symbols/check-rounded.svg");
  -webkit-mask-image: url("https://api.iconify.design/material-symbols/check-rounded.svg");
  transition: opacity 140ms ease, transform 140ms ease;
}

.app-view-drawer-option.is-active .app-view-drawer-option-check,
.app-view-drawer-option[aria-pressed="true"] .app-view-drawer-option-check {
  opacity: 1;
  transform: scale(1);
}

.app-view-drawer-note {
  color: var(--z-render-shell-drawer-muted);
  font-size: 0.82rem;
  line-height: 1.35;
  padding: 5px 2px;
}

@keyframes z-render-shell-drawer-open {
  from {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
  to {
    max-height: var(--z-render-shell-drawer-panel-max-height);
    opacity: 1;
    padding-top: 15px;
    padding-bottom: 15px;
  }
}

@keyframes z-render-shell-drawer-close {
  from {
    max-height: var(--z-render-shell-drawer-panel-max-height);
    opacity: 1;
    padding-top: 15px;
    padding-bottom: 15px;
  }
  to {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
}

@media (max-width: 620px) {
  :root {
    --z-render-shell-footer-height: calc(52px + env(safe-area-inset-bottom, 0px));
    --z-render-shell-header-padding: 18px 10px 10px 12px;
  }

  .brand-name,
  .brand-wordmark-text {
    font-size: 1.4rem;
  }

  .brand-home-link,
  .brand-bird {
    width: 44px;
    height: 44px;
  }

  .preview-view > .workspace-strip:not(.workspace-strip-top) {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 28;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .app-view-drawer {
    position: fixed;
    left: 10px;
    bottom: calc(var(--z-render-shell-footer-height) - 3px);
    z-index: 29;
    width: min(340px, calc(100vw - 20px));
  }
}
