/* Orakel v3 — ruhige Befragung in der Szene (Design-Handoff)
   Ersetzt orakel-v2.css. Benötigt styles.css (Basis) + Cormorant Garamond.
   app.js bleibt unverändert: nutzt #question-form, #question-input, #chat-list,
   #status[data-state], body.is-oracle-speaking, .chat-message.user/.oracle */

.v3-body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: #050d13;
  color: #f2ead9;
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}

/* ---------- Hintergrund: 4 Himmelsrichtungen, 72s-Zyklus ---------- */
.v3-sky { position: fixed; inset: 0; z-index: 0; }

.v3-himmel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  animation: v3-himmel 72s ease-in-out infinite, v3-drift 46s ease-in-out infinite alternate;
}
.v3-h1 { animation-delay: -3s, 0s; }
.v3-h2 { animation-delay: -57s, -12s; }
.v3-h3 { animation-delay: -39s, -24s; }
.v3-h4 { animation-delay: -21s, -36s; }

@keyframes v3-himmel {
  0% { opacity: 0; }
  11% { opacity: 1; }
  25% { opacity: 1; }
  36% { opacity: 0; }
  100% { opacity: 0; }
}
@keyframes v3-drift {
  from { transform: scale(1.03); }
  to { transform: scale(1.1); }
}

.v3-dim { position: absolute; inset: 0; background: rgba(4, 10, 15, 0.38); }
.v3-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(120vmin 100vmin at 58% 42%, rgba(4,10,15,0) 30%, rgba(4,10,15,0.5) 62%, rgba(3,8,12,0.88) 100%);
}
.v3-scrim-left {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(4,10,15,0.86) 0%, rgba(4,10,15,0.62) 34%, rgba(4,10,15,0) 62%),
    linear-gradient(180deg, rgba(4,10,15,0) 30%, rgba(4,10,15,0.42) 62%, rgba(4,10,15,0.6) 100%);
}
.v3-scrim-bottom {
  position: absolute;
  inset: auto 0 0 0;
  height: 22vh;
  background: linear-gradient(180deg, rgba(4,10,15,0), rgba(4,10,15,0.7));
}

/* Leuchten hinter der Eule — verstärkt sich, wenn das Orakel spricht/denkt */
.v3-glow {
  position: absolute;
  left: max(58%, calc(min(680px, 46vw) + 20vmin));
  top: 48%;
  width: 52vmin;
  height: 68vmin;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(150,225,210,0.72), rgba(120,200,200,0.28) 46%, rgba(150,225,210,0) 74%);
  mix-blend-mode: screen;
  opacity: 0.62;
  animation: v3-glow-pulse 6.5s ease-in-out infinite alternate;
  transition: opacity 1.8s ease;
}
.is-oracle-speaking .v3-glow { opacity: 1; }
@keyframes v3-glow-pulse {
  from { transform: translate(-50%, -50%) scale(0.94); }
  to { transform: translate(-50%, -50%) scale(1.06); }
}

.v3-owl {
  position: absolute;
  left: max(58%, calc(min(680px, 46vw) + 20vmin));
  bottom: -12vh;
  height: 96vh;
  transform: translateX(-50%);
  opacity: 0.94;
  filter: brightness(0.68) saturate(0.86) contrast(1.04) drop-shadow(0 0 50px rgba(150,225,210,0.26));
  transition: filter 1.4s ease, opacity 1.4s ease;
  pointer-events: none;
}
.is-oracle-speaking .v3-owl {
  opacity: 1;
  filter: brightness(0.84) saturate(0.96) contrast(1.02) drop-shadow(0 0 64px rgba(170,235,220,0.48));
}
/* Aktuelle Himmelsrichtung, unten rechts, blendet mit den Bildern */
.v3-richtung { position: absolute; right: clamp(24px, 5vw, 64px); bottom: 34px; height: 20px; }
.v3-richtung span {
  position: absolute;
  right: 0;
  bottom: 0;
  font-size: 12px;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: rgba(200, 168, 106, 0.85);
  opacity: 0;
  white-space: nowrap;
  animation: v3-himmel 72s ease-in-out infinite;
}
/* Muss .v3-richtung span an Spezifitaet erreichen, sonst setzt die
   Kurzform dort die Verzoegerung wieder auf 0 und alle vier blenden
   gleichzeitig. */
.v3-richtung span.v3-r1 { animation-delay: -3s; }
.v3-richtung span.v3-r2 { animation-delay: -57s; }
.v3-richtung span.v3-r3 { animation-delay: -39s; }
.v3-richtung span.v3-r4 { animation-delay: -21s; }

/* ---------- Layout ---------- */
.v3-shell { position: relative; z-index: 2; height: 100vh; height: 100dvh; }

.v3-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px clamp(24px, 5vw, 64px);
}
.v3-kicker {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #c8a86a;
  font-weight: 500;
}

.v3-oracle {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-sizing: border-box;
  padding: 96px clamp(24px, 5vw, 110px) clamp(32px, 5vh, 56px);
  width: min(620px, 44vw);
  min-width: 320px;
}

.v3-eyebrow {
  margin: 0 0 18px;
  font-size: 12px;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: #c8a86a;
}
.v3-brand h1 {
  margin: 0 0 20px;
  font-size: clamp(64px, 9vw, 124px);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: 0.01em;
  color: #f2ead9;
}
.v3-intro {
  margin: 0 0 4vh;
  font-size: 21px;
  line-height: 1.55;
  color: rgba(242, 234, 217, 0.75);
  max-width: 42ch;
  text-wrap: pretty;
}
/* Sobald ein Gespräch läuft, tritt der Titel zurück und die Antwort
   bekommt den freiwerdenden Raum. */
body.has-conversation .v3-brand h1 { display: none; }
body.has-conversation .v3-brand .v3-kicker { display: none; }
body.has-conversation .v3-brand p { font-size: 0.95rem; opacity: 0.62; }

/* ---------- Gespräch: keine Bubbles, eine ruhige Litanei ---------- */
.v3-chat {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 24px;
  min-height: 0;
}
.v2-chat-tools { display: none; }

.v3-chat .chat-list {
  overflow-y: auto;
  max-height: min(58vh, calc(100vh - 230px));
  display: flex;
  flex-direction: column;
  gap: 44px;
  padding: 24px 2px 8px;
}
/* Laeuft der Text ueber, wird die Leiste dezent sichtbar. Kein weicher
   Auslauf mehr: der liess die letzte Zeile verblassen, auch wenn sie
   vollstaendig da war. */
.v3-chat .chat-list.is-overflowing {
  scrollbar-width: thin;
  scrollbar-color: rgba(200, 168, 106, 0.42) transparent;
}
.v3-chat .chat-list.is-overflowing::-webkit-scrollbar { width: 3px; }
.v3-chat .chat-list.is-overflowing::-webkit-scrollbar-thumb {
  background: rgba(200, 168, 106, 0.42);
  border-radius: 3px;
}
.v3-chat .chat-list::-webkit-scrollbar { width: 0; }

.v3-chat .chat-message { width: 100%; align-self: auto; animation: v3-rise 0.9s ease both; }
.v3-chat .chat-message p {
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: none;
  overflow-wrap: anywhere;
}

/* Frage der Besucherin */
.v3-chat .chat-message.user p {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 22px;
  font-style: italic;
  line-height: 1.4;
  color: rgba(242, 234, 217, 0.78);
}
.v3-chat .chat-message.user p::before {
  content: "Du fragst";
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #c8a86a;
}

/* Antwort des Orakels */
.v3-chat .chat-message.oracle p {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(17px, 1.35vw, 20px);
  font-weight: 500;
  line-height: 1.5;
  color: #f2ead9;
  text-wrap: pretty;
}
.v3-chat .chat-message.oracle p::before {
  content: "";
  display: block;
  width: 44px;
  height: 1px;
  margin-bottom: 20px;
  background: rgba(200, 168, 106, 0.55);
}

@keyframes v3-rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Eingabe ---------- */
.v3-question-form {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  max-width: 680px;
}
.v3-question-form textarea,
.v3-question-form .question-editor {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(200, 168, 106, 0.45);
  border-radius: 0;
  padding: 10px 2px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 22px;
  color: #f2ead9;
  transition: border-color 0.4s;
  box-shadow: none;
}
.v3-question-form textarea::placeholder { color: rgba(242, 234, 217, 0.38); font-style: italic; }
.v3-question-form .question-editor { overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.v3-question-form .question-editor:empty::before { content: attr(data-placeholder); color: rgba(242, 234, 217, 0.38); font-style: italic; pointer-events: none; }
.v3-question-form textarea:focus,
.v3-question-form .question-editor:focus { outline: none; border-bottom-color: rgba(200, 168, 106, 0.9); }

.v3-question-form .control-row { display: flex; }
.v3-question-form .primary-button {
  flex-shrink: 0;
  background: rgba(6, 14, 20, 0.72);
  border: 1px solid rgba(200, 168, 106, 0.6);
  color: #c8a86a;
  border-radius: 999px;
  padding: 11px 26px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 15px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.3s, color 0.3s;
}
.v3-question-form .primary-button:hover,
.v3-question-form .primary-button:focus-visible {
  background: rgba(200, 168, 106, 0.25);
  color: #e6cf9a;
}

/* ---------- Status als stilles Licht ---------- */
.v3-oracle .status {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 20px 0 0 2px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 250, 240, 0.32);
  border-radius: 50%;
  background: #77818a;
  color: transparent;
  font-size: 0;
}
/* Im Ruhezustand unsichtbar. Der Punkt meldet sich nur, wenn die Eule
   zuhoert, denkt oder spricht. */
.v3-oracle .status,
.v3-oracle .status[data-state="ready"] { opacity: 0; background: #8fae9e; box-shadow: none; }
.v3-oracle .status[data-state="recording"],
.v3-oracle .status[data-state="thinking"],
.v3-oracle .status[data-state="speaking"],
.v3-oracle .status[data-state="error"] { opacity: 1; }
.v3-oracle .status[data-state="recording"] { background: #c96a5a; box-shadow: 0 0 22px rgba(255, 110, 90, 0.5); }
.v3-oracle .status[data-state="thinking"],
.v3-oracle .status[data-state="speaking"] { background: #c8a86a; box-shadow: 0 0 22px rgba(200, 168, 106, 0.6); }
.v3-oracle .status[data-state="error"] { background: #c96a5a; }

.v2-hidden-settings { display: none; }

@media (prefers-reduced-motion: reduce) {
  .v3-himmel, .v3-glow, .v3-owl, .v3-richtung span { animation: none; }
  .v3-h1, .v3-r1 { opacity: 1; }
}

/* ---------- Schmale Fenster / Hochformat ---------- */
@media (max-width: 900px) {
  /* Scrollen erlauben: bei kleinen Schirmen und offener Tastatur passt
     nicht alles gleichzeitig auf die Seite. */
  .v3-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .v3-shell { height: auto; min-height: 100dvh; }
  .v3-chat .chat-list { overflow: visible; }

  /* Im Hochformat oben beginnen statt unten ausrichten: sonst bleibt die
     halbe Seite leer und das Gespraech bekommt kaum Platz. */
  .v3-oracle {
    width: auto;
    min-width: 0;
    padding: 64px 22px 20px;
    justify-content: flex-start;
    gap: 18px;
  }
  .v3-chat { flex: 1; min-height: 0; }
  /* Eule mittig hinter dem Text, dezent. bottom und height muessen hier
     gesetzt werden, sonst wirken die Desktop-Werte weiter. */
  /* Eule ueber den Verlauf heben: im Hochformat wirkt er ueber die ganze
     Breite und legte sich sonst direkt auf sie. */
  .v3-owl {
    left: 50%;
    bottom: 9vh;
    height: 60vh;
    opacity: 1;
    z-index: 1;
    filter: brightness(0.74) saturate(0.9) contrast(1.02);
  }
  .v3-glow { left: 50%; top: 58%; width: 70vmin; height: 70vmin; opacity: 0.55; }
  /* Abdunklung von oben nach unten, damit der Text auf jedem der vier
     Himmelsbilder lesbar bleibt. */
  .v3-scrim-left {
    background: linear-gradient(180deg, rgba(4,10,15,0.46) 0%, rgba(4,10,15,0.3) 38%, rgba(4,10,15,0.52) 78%, rgba(4,10,15,0.72) 100%);
  }
  .v3-brand h1 { font-size: clamp(52px, 15vw, 80px); }
  .v3-eyebrow { font-size: 11px; letter-spacing: 0.24em; }
  .v3-intro { font-size: 17px; max-width: none; }
  /* Platz fuer die angeheftete Eingabe, damit kein Text dahinter durchlaeuft. */
  .v3-chat .chat-list { max-height: none; padding-bottom: 26px; }
  .v3-chat .chat-message.oracle p { font-size: 18px; line-height: 1.5; }
  .v3-chat .chat-message { width: 100%; }
  .v3-question-form textarea,
.v3-question-form .question-editor { font-size: 16px; }
  /* Eingabe am unteren Bildschirmrand, nicht an der Containerkante:
     sonst schwebt sie mitten im Bild, solange das Gespraech kurz ist. */
  .v3-question-form {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    padding: 14px 22px calc(24px + env(safe-area-inset-bottom));
    margin: 0;
    background: linear-gradient(180deg, rgba(5,11,16,0) 0%, rgba(5,11,16,0.92) 26%, rgb(5,11,16) 58%);
  }
  /* Platz, damit das Gespraech nicht unter der Eingabe endet. */
  .v3-oracle { padding-bottom: 128px; }
  .v3-richtung { bottom: 26px; }
}

/* Sehr schmale Geraete */
@media (max-width: 430px) {
  .v3-brand h1 { font-size: clamp(44px, 13vw, 58px); }
  .v3-owl { height: 54vh; opacity: 1; }
  .v3-intro { font-size: 16px; }
}
