/* Sprechende Bilder – Editor CSS */
/* Design: Monospace, schwarz/weiß, kein border-radius, keine Schatten */

:root {
  --accent: #ff3b00;
  --bg: #ffffff;
  --fg: #000000;
  --muted: #666666;
  --border: #000000;
  --border-light: #cccccc;
  --panel-bg: #f5f5f5;
  --hover-bg: #000000;
  --hover-fg: #ffffff;
  --font: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
  --sidebar-width: 200px;
  --props-width: 280px;
  --header-height: 48px;
  --footer-height: 32px;
  --hotspot-pulse-color: rgba(255, 59, 0, 0.5);
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 13px;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
}

/* ── Layout ─────────────────────────────────────────── */

#app {
  display: grid;
  grid-template-rows: var(--header-height) 1fr var(--footer-height);
  grid-template-columns: var(--sidebar-width) 1fr var(--props-width);
  grid-template-areas:
    "header  header  header"
    "scenes  canvas  props"
    "footer  footer  footer";
  height: 100vh;
}

/* ── Header ──────────────────────────────────────────── */

#header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

#header h1 {
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

#header h1 span {
  color: var(--accent);
}

.header-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ── Buttons ─────────────────────────────────────────── */

button, .btn {
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 10px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
}

button:hover, .btn:hover {
  background: var(--hover-bg);
  color: var(--hover-fg);
}

button:active {
  opacity: 0.7;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary {
  background: var(--fg);
  color: var(--bg);
}

button.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

button.danger {
  border-color: var(--accent);
  color: var(--accent);
}

button.danger:hover {
  background: var(--accent);
  color: var(--bg);
}

button.active {
  background: var(--fg);
  color: var(--bg);
}

/* ── Szenen-Sidebar ──────────────────────────────────── */

#scenes-panel {
  grid-area: scenes;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  overflow: hidden;
}

#scenes-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#scenes-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.scene-item {
  padding: 6px 8px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 2px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scene-item:hover {
  border-color: var(--border-light);
  background: var(--bg);
}

.scene-item.active {
  border-color: var(--border);
  background: var(--bg);
}

.scene-item.is-start::before {
  content: "▶ START";
  font-size: 9px;
  color: var(--accent);
  font-weight: bold;
  letter-spacing: 0.05em;
}

.scene-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  object-fit: cover;
  display: block;
}

.scene-thumb.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--border-light);
}

.scene-title {
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Hauptbereich / Canvas ───────────────────────────── */

#canvas-area {
  grid-area: canvas;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-light);
  background: var(--panel-bg);
  flex-shrink: 0;
}

#canvas-toolbar .toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border-light);
  margin: 0 4px;
}

#canvas-toolbar label {
  font-size: 11px;
  color: var(--muted);
}

#image-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, #e8e8e8 25%, transparent 25%) -8px 0,
    linear-gradient(-45deg, #e8e8e8 25%, transparent 25%) -8px 0,
    linear-gradient(45deg, transparent 75%, #e8e8e8 75%),
    linear-gradient(-45deg, transparent 75%, #e8e8e8 75%);
  background-size: 16px 16px;
  background-color: #f0f0f0;
}

#drop-zone {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  pointer-events: none;
}

#drop-zone.hidden {
  display: none;
}

#drop-zone .drop-icon {
  font-size: 48px;
  line-height: 1;
}

#drop-zone p {
  font-size: 13px;
  text-align: center;
}

#drop-zone p strong {
  display: block;
  font-size: 15px;
  color: var(--fg);
  margin-bottom: 4px;
}

#image-container.drag-over {
  outline: 3px dashed var(--accent);
  outline-offset: -3px;
}

#scene-image-wrapper {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#scene-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

#hotspots-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#hotspots-layer.mode-place {
  pointer-events: all;
  cursor: crosshair;
}

/* ── Hotspots ────────────────────────────────────────── */

.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: all;
  cursor: pointer;
  z-index: 10;
}

.hotspot-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--fg);
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6em;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.hotspot-circle::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0% { opacity: 0.8; transform: scale(0.85); }
  70% { opacity: 0; transform: scale(1.4); }
  100% { opacity: 0; transform: scale(1.4); }
}

.hotspot:hover .hotspot-circle {
  background: rgba(255, 59, 0, 0.15);
  border-color: var(--accent);
}

.hotspot.selected .hotspot-circle {
  border-color: var(--accent);
  background: rgba(255, 59, 0, 0.2);
  border-width: 2px;
}

.hotspot.selected .hotspot-circle::after {
  display: none;
}

.hotspot.mode-move {
  cursor: move;
}

.hotspot-label-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  font-size: 11px;
  padding: 2px 6px;
  white-space: nowrap;
  pointer-events: none;
  display: none;
  z-index: 20;
}

.hotspot:hover .hotspot-label-tooltip {
  display: block;
}

.hotspot-icon {
  font-size: 0.8em;
  line-height: 1;
}

/* ── Eigenschaften-Panel ─────────────────────────────── */

#props-panel {
  grid-area: props;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  overflow: hidden;
}

#props-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

#props-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

#props-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

/* Image optimizer panel */
#image-optimizer-panel {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

/* Hotspot properties */
#hotspot-props {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.prop-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prop-group label {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.prop-group input[type="text"],
.prop-group textarea,
.prop-group select {
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 7px;
  border: 1px solid var(--border-light);
  background: var(--bg);
  color: var(--fg);
  width: 100%;
  outline: none;
}

.prop-group input[type="text"]:focus,
.prop-group textarea:focus,
.prop-group select:focus {
  border-color: var(--border);
}

.prop-group textarea {
  resize: vertical;
  min-height: 60px;
}

.prop-group input[type="range"] {
  width: 100%;
  accent-color: var(--fg);
}

.prop-group .range-with-value {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prop-group .range-with-value input[type="range"] {
  flex: 1;
}

.prop-group .range-value {
  font-size: 12px;
  min-width: 30px;
  text-align: right;
  color: var(--muted);
}

.prop-group .coord-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.coord-row .coord-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.coord-row .coord-field label {
  font-size: 10px;
}

.coord-row .coord-field input {
  font-family: var(--font);
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border-light);
  background: var(--bg);
  color: var(--fg);
  width: 100%;
  outline: none;
}

.coord-row .coord-field input:focus {
  border-color: var(--border);
}

.prop-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.prop-divider {
  height: 1px;
  background: var(--border-light);
}

/* Size preview in optimizer */
.size-indicator {
  font-size: 11px;
  color: var(--muted);
}

.size-indicator.warn {
  color: var(--accent);
  font-weight: bold;
}

/* ── Footer ──────────────────────────────────────────── */

#footer {
  grid-area: footer;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  gap: 16px;
}

#footer .footer-right {
  margin-left: auto;
}

/* ── Scrollbars ──────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Utilities ───────────────────────────────────────── */

.hidden { display: none !important; }

.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-small { font-size: 11px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 2px; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }

/* ── Nutzungsbedingungen-Modal ───────────────────────── */

.terms-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.terms-overlay.hidden {
  display: none !important;
}

.terms-box {
  background: var(--bg);
  border: 2px solid var(--border);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.terms-box h2 {
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 0;
}

.terms-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: -10px;
}

.terms-box section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.terms-box h3 {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
}

.terms-box p {
  font-size: 12px;
  line-height: 1.65;
  color: var(--fg);
}

.terms-box strong {
  font-weight: bold;
}

.terms-actions {
  display: flex;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}

/* Kleiner Link im Footer */
.footer-terms-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font);
  font-size: 11px;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-terms-btn:hover {
  color: var(--fg);
  background: none;
}

/* ── Autosave-Indikator im Footer ────────────────────── */

.footer-autosave {
  font-size: 10px;
  color: #aaa;
  transition: opacity 1.5s ease;
  white-space: nowrap;
}

/* ── Autosave-Wiederherstellungs-Banner ──────────────── */

#restore-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: #fffbeb;
  border-bottom: 1px solid #e8d060;
  font-size: 12px;
  color: #5a4800;
  flex-shrink: 0;
}

#restore-banner span { flex: 1; }

#restore-banner button {
  background: transparent;
  color: #5a4800;
  border-color: #c8a800;
  font-size: 11px;
  padding: 3px 8px;
  flex-shrink: 0;
}

#restore-banner button:hover {
  background: #5a4800;
  color: #fff;
  border-color: #5a4800;
}

#restore-banner #restore-btn {
  background: #5a4800;
  color: #fff;
  border-color: #5a4800;
}

#restore-banner #restore-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Szenen-Eigenschaften ────────────────────────────── */

#scene-props {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.scene-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border-light);
  background: var(--bg);
}

.scene-link-line {
  font-size: 11px;
  color: var(--muted);
  display: block;
}

/* ── Footer Export-Größe ─────────────────────────────── */

.footer-size {
  font-size: 11px;
  color: var(--muted);
  padding: 0 8px;
  border-left: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
}

.footer-size--info { color: #c07000; }
.footer-size--warn { color: var(--accent); font-weight: bold; }

/* ── Audio-Recorder ──────────────────────────────────── */

.prop-audio-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rec-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: bold;
  padding: 6px 0;
}

.rec-dot {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  animation: rec-blink 1s ease-in-out infinite;
}

@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}

#rec-timer {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  min-width: 36px;
}

.audio-meta {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  word-break: break-all;
}

/* Native audio-Player – passt sich dem Design an */
audio {
  width: 100%;
  height: 34px;
  display: block;
  accent-color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border-light);
}

/* ── Vorschau-Modus ──────────────────────────────────── */

#preview-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: #111;
  color: #fff;
  flex-shrink: 0;
}

#preview-toolbar button {
  background: transparent;
  color: #fff;
  border-color: #444;
  font-size: 12px;
}

#preview-toolbar button:hover {
  background: #fff;
  color: #000;
}

#preview-toolbar button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#preview-toolbar button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pv-title {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: #aaa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#preview-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
}

/* Blätter-Pfeile (nur bei mehreren Szenen sichtbar) */
.pv-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  width: 44px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  padding: 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: 1px solid #444;
  cursor: pointer;
}
.pv-nav-prev { left: 8px; }
.pv-nav-next { right: 8px; }
.pv-nav:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.pv-nav:disabled { opacity: 0.25; cursor: not-allowed; }

/* Bild und Hotspot-Ebene liegen in DERSELBEN Grid-Zelle (1/1) und sind
   dadurch garantiert deckungsgleich – kein Höhen-Versatz durch inline-block. */
.pv-stage {
  position: relative;
  display: grid;
  max-width: 100%;
  max-height: 100%;
  line-height: 0;
}

.pv-image {
  grid-area: 1 / 1;
  place-self: center;
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.pv-hotspots {
  grid-area: 1 / 1;
  align-self: stretch;
  justify-self: stretch;
  position: relative;
  pointer-events: none;
}

.pv-hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: all;
  cursor: pointer;
  z-index: 10;
}

.pv-hotspot-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  /* Standardmäßig unsichtbar, kurzer Hint alle 5 s */
  opacity: 0;
  animation: hotspot-hint 5s ease-in-out infinite;
}

@keyframes hotspot-hint {
  0%, 72%   { opacity: 0; }
  78%, 88%  { opacity: 0.72; }
  96%, 100% { opacity: 0; }
}

.pv-hotspot-circle::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  /* Ring im Hint-Moment mitwachsen, sonst unsichtbar */
  opacity: 0;
  animation: pulse 4s ease-out infinite;
}

/* Hover / Fokus: voll sichtbar, Animation pausieren */
.pv-hotspot:hover .pv-hotspot-circle,
.pv-hotspot:focus .pv-hotspot-circle {
  opacity: 1;
  animation: none;
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.95);
  outline: none;
}

.pv-hotspot:hover .pv-hotspot-circle::after,
.pv-hotspot:focus .pv-hotspot-circle::after {
  animation: pulse 2s ease-out infinite;
}

.pv-hotspot--playing .pv-hotspot-circle {
  opacity: 1;
  background: rgba(255, 59, 0, 0.4);
  border-color: var(--accent);
  animation: playing-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes playing-pulse {
  from { transform: scale(0.95); }
  to   { transform: scale(1.05); }
}

.pv-hotspot-icon {
  font-size: 0.65em;
  color: #fff;
  line-height: 1;
}

/* Text-Overlay-Modal */
.pv-text-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.pv-text-box {
  background: #fff;
  color: #000;
  padding: 24px;
  max-width: 80%;
  max-height: 80%;
  overflow-y: auto;
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pv-text-body {
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 0;
}

.pv-text-close {
  align-self: flex-end;
  font-family: var(--font);
  font-size: 12px;
  padding: 6px 14px;
  background: #000;
  color: #fff;
  border: none;
  cursor: pointer;
}

.pv-text-close:hover {
  background: var(--accent);
}

/* ── Sound-Library-Browser ────────────────────────────── */

#hp-lib-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lib-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lib-search {
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border-light);
  background: var(--bg-light);
  color: var(--fg);
}

.lib-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.lib-item {
  padding: 6px 8px;
  background: var(--bg-light);
  border: 1px solid var(--border-light);
  border-radius: 0;
  cursor: pointer;
  transition: background 80ms;
  font-size: 11px;
  line-height: 1.4;
}

.lib-item:hover {
  background: var(--border);
}

.lib-item-name { font-weight: bold; }
.lib-item-cat { color: var(--muted); font-size: 10px; }

.lib-actions {
  display: flex;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--border-light);
}

.lib-actions button {
  flex: 1;
  font-size: 11px;
  padding: 4px 8px;
}
