/* Hilfe-Sprechblase im Stil der anderen Sprechblasen */

/* Hilfe- & Pausen-Button */
#help-icon {
  position: relative;
  height: 4vw;
  padding: 0 0.9vw 0 0.45vw;
  background: var(--alert);
  border: solid 2px #ffffff;
  border-radius: 1.1vw;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 0.55vw;
  font-family: "Wilson ExtraBold", Arial, sans-serif;
  font-size: 2vw;
  color: #ffffff;
  margin-top: 0;
  margin-left: 15px;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.3);
  transition:
    width 0.35s ease,
    height 0.35s ease,
    border-radius 0.35s ease,
    transform 0.2s,
    box-shadow 0.2s,
    opacity 0.5s ease;
  z-index: 101;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

#help-icon.visible {
  opacity: 1;
  pointer-events: auto;
}

#help-icon:hover {
  transform: scale(1.1);
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.4);
}

/* Pause-Symbol im Hilfe-Button */
.help-icon-pause-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4vw;
  width: 2.9vw;
  height: 2.9vw;
  border-radius: 0.6vw;
  flex-shrink: 0;
  box-sizing: border-box;
}

.help-icon-pause-indicator .bar {
  width: 0.5vw;
  height: 1.5vw;
  background: #ffffff;
  border-radius: 2px;
}

/* Hilfe-Label */
#help-icon .help-icon-mark {
  display: block;
  transition: opacity 0.2s;
  white-space: nowrap;
}

/* Panel (versteckt, wenn nicht expanded) */
#help-icon .help-icon-panel {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.6vw;
  padding: 1vw;
  white-space: nowrap;
}

#help-icon .help-icon-panel-title {
  font-family: "Wilson ExtraBold", Arial, sans-serif;
  font-size: 1.5vw;
  margin-bottom: 0.3vw;
}

#help-icon .help-icon-panel button {
  font-family: "Wilson ExtraBold", Arial, sans-serif;
  font-size: 1.4vw;
  padding: 0.4vw 1.2vw;
  border: 3px solid #ffffff;
  color: #fff;
  border-radius: 8px;
  background: transparent;
  transition:
    background 0.2s,
    transform 0.2s;
  width: 100%;
  margin-top: 0;
}

#help-icon .help-icon-panel button:hover {
  background: #da6440;
}

#help-icon .help-icon-language-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5vw;
  margin-top: 0.35vw;
}

#help-icon .help-lang-btn {
  margin-top: 0;
  padding: 0.2vw 0.6vw;
  font-size: 0.85vw;
  border-width: 2px;
  min-width: 2.6vw;
  color: #ffffff;
  background: #587947;
}

#help-icon .help-lang-btn.active {
  background: var(--base-color);
}

/* Expanded state */
#help-icon.expanded {
  width: 14vw;
  height: auto;
  border-radius: 14px;
  flex-direction: column;
  padding: 0.8vw;
  transform: none;
}

#help-icon.expanded:hover {
  transform: none;
}

#help-icon.expanded .help-icon-pause-indicator {
  display: none;
}

@keyframes help-icon-pulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

#help-icon.pulse {
  animation: help-icon-pulse 0.5s ease-out;
}

#help-icon.expanded .help-icon-mark {
  display: none;
}

#help-icon.expanded .help-icon-panel {
  display: flex;
}

/* Panorama-Hilfe-Panels */
.help-panel-center-right,
.help-panel-top-right {
  position: fixed;
  background: #fffbe6;
  border: 3px solid #000;
  border-radius: 12px;
  padding: 18px 22px;
  font-family: "Wilson", Arial, sans-serif;
  font-size: 1.2em;
  line-height: 1.4;
  width: 22vw;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  text-align: center;
}

.help-panel-center-right {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 30vw !important;
}

.help-panel-top-right {
  right: calc(4% + 6vw + 2vw);
  top: 4%;
  width: 22vw;
}

.help-bubble {
  position: fixed;
  top: 15vw;
  left: 1vw;
  padding: 38px 44px 26px 44px;
  background: #fffbe6;
  border: solid 3px #000;
  border-radius: 100%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  font-size: 1.35em;
  font-family: "Promisupria", Arial, sans-serif;
  width: 380px;
  text-align: center;
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.4s ease-out;
  z-index: 1000;
  line-height: 1.3;
}

/* Tail/Schwanz für alle Hilfsbubbles (immer tail-side.png) */
.help-bubble::after,
.help-bubble.contextual::after {
  content: "";
  position: absolute;
  width: 50px;
  height: 60px;
  left: 41px;
  top: -40px;
  transform: translateX(-50%) rotate(153deg);
  background-image: url(../img/tail-side.png);
  background-size: contain;
  background-position: top;
  background-repeat: no-repeat;
  pointer-events: none;
}

.help-bubble.visible {
  opacity: 1;
  transform: scale(1);
}

/* Dezente Aufmerksamkeits-Animation */
.help-bubble.visible {
  animation: help-attention 3s ease-in-out infinite;
}

@keyframes help-attention {
  0%,
  90%,
  100% {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  }
  5%,
  10% {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}

/* Pausenanzeige für die Uhr */
#timer.paused {
  animation: timer-pause-pulse 1.5s ease-in-out infinite;
}

@keyframes timer-pause-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Deaktivierte Spielelemente während der Pause */
.place.disabled {
  opacity: 0.5;
  pointer-events: auto; /* Erlaubt Klicks für Hilfeanzeige */
}

.place.disabled::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.1);
  border-radius: inherit;
  pointer-events: none;
}

/* Sicherstellen, dass Placemarks nicht verschoben werden */
.paused .place {
  transition: all 0.2s ease;
  position: absolute !important; /* Placemarks sind absolute positioniert */
  opacity: 1 !important; /* Überschreibt die .disabled opacity */
}

.paused .place:hover {
  transform: none;
}

.paused .place::after,
.paused .place::before {
  display: none !important;
}

#carousel.disabled,
.panorama-container.disabled,
#panorama.disabled,
#pano.disabled {
  pointer-events: auto; /* Erlaubt Klicks für Hilfeanzeige */
}

#carousel.disabled .character {
  pointer-events: none;
  opacity: 0.7;
}

/* Panorama-Elemente bleiben vollständig sichtbar */
.panorama-container.disabled .tile,
.panorama-container.disabled .check,
#panorama.disabled .tile,
#panorama.disabled .check,
#pano.disabled .tile {
  pointer-events: auto !important; /* Erlaubt Klicks für Hilfeanzeige */
}

/* Kontextuelle Hilfsbubble */
.help-bubble.contextual {
  background: #fffbe6;
  border-color: #000;
  animation: none;
}

/* Kontextuelle Help-Labels bei den jeweiligen Elementen */
.help-context-label {
  position: absolute;
  background: #d0dcca;
  border: solid 5px #ffffff;
  border-radius: 14px;
  padding: 15px 14px;
  font-size: 1.2em;
  font-weight: bold;
  font-family: "Wilson", Arial, sans-serif;
  line-height: 1.3;
  width: 250px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-out;
}

#co2-scale .help-context-label {
  margin-right: -5vw;
}

.help-context-label.visible {
  opacity: 1;
}

/* Positionierungsvarianten */
.help-context-label.help-context-left {
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
}

.help-context-label.help-context-right {
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
}

.help-context-label.help-context-bottom {
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
}

.help-context-label.help-context-top {
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
}

/* Hilfe-Bubble im Pausenmodus – kein spezielles Übergrösserung mehr nötig */
.help-bubble[data-message-type="pause"] {
  width: 380px;
}

/* Interaktive Elemente während der Pause hervorheben */
.paused #co2-display,
.paused #food-display,
.paused #player,
.paused #score,
.paused #score-value,
.paused #co2-scale,
.paused #food,
.paused #circle,
.paused #inner-circle,
.paused #pano .tile,
.paused #carousel .character,
.paused .tile-info,
.paused .values,
.paused .tile .values,
.paused .co2,
.paused .food,
.paused .co2-value,
.paused .food-value {
  position: relative;
  transition: all 0.2s ease;
}

/* Panorama Check-Button muss absolut positioniert bleiben */
.paused #panorama .navicon.check {
  position: absolute !important;
  transition: all 0.2s ease;
}

/* Placemarks separat behandeln - siehe oben */

/* Intro-Popup nach Charakterauswahl */
.game-intro-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: var(--app-height, 100dvh);
  padding:
    max(12px, env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.4s ease-out;
}

.game-intro-overlay.visible {
  opacity: 1;
}

.game-intro-popup {
  background: #d0dcca;
  border: solid 5px #ffffff;
  border-radius: 30px;
  padding: 2vw 2.5vw;
  width: min(920px, 100%);
  max-width: 920px;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  text-align: center;
  font-weight: bold;
  font-family: "Wilson", Arial, sans-serif;
  font-size: 1.5em;
  line-height: 1.4;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  transform: scale(0.9);
  transition: transform 0.4s ease-out;
}

.game-intro-overlay.visible .game-intro-popup {
  transform: scale(1);
}

.game-intro-popup button {
  margin-top: 25px;
  font-family: "Wilson", Arial, sans-serif;
  font-weight: bold;
  background: var(--base-color);
  border: solid 5px #fff;
  color: #fff;
}

.game-intro-text {
  margin-bottom: 20px;
}

.difficulty-title {
  font-size: 1.05em;
  margin-bottom: 14px;
  color: #2f4e1f;
}

.difficulty-selector {
  --difficulty-divider-gap: 44px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: flex-start;
  column-gap: var(--difficulty-divider-gap);
  width: min(100%, 760px);
  margin: 10px auto 0;
  position: relative;
}

.difficulty-selector::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 6px;
  bottom: 6px;
  width: 4px;
  transform: translateX(-50%);
  background: rgba(47, 78, 31, 0.45);
}

.difficulty-selector button {
  background: transparent;
  border: none;
}

.difficulty-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: auto;
  padding: 0;
}

.difficulty-characters {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 110px;
}

.difficulty-character {
  width: 84px;
  height: 104px;
  border: 4px solid transparent;
  border-radius: 22px;
  margin-top: 0;
  padding: 6px;
  background: transparent;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background-color 0.2s ease;
}

.difficulty-character img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.difficulty-character.active {
  background: var(--base-color);
}

.difficulty-label {
  margin-top: 6px;
  font-size: 1.15em;
  color: #1f3417;
}

.difficulty-hint {
  min-height: 1.2em;
  margin-top: 2px;
  font-size: 0.85em;
  color: #1f3417;
}

#controls.panorama-overlay-controls {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1400;
  width: 15vw;
  height: 100vh;
  height: var(--app-height, 100dvh);
  padding-left: 2vw;
  background: var(--base-color-dark);
}

body.difficulty-hard #panorama .tile .values {
  display: none;
}

/* Im Easy-Modus: Navicon über den Controls-Overlay schieben */
body.difficulty-easy #panorama .navicon {
  z-index: 1500;
  right: calc(var(--panorama-controls-width, 15vw) + 2%);
}

/* Im Easy-Modus steht das Navicon weiter links (wegen Controls-Overlay).
   Das zugehoerige Hilfe-Panel entsprechend mitverschieben. */
body.difficulty-easy.panorama-visible .help-panel-top-right {
  right: calc(var(--panorama-controls-width, 15vw) + 2% + 6vw + 2vw);
}

@media (max-width: 1100px) {
  .game-intro-popup {
    padding: 18px;
    font-size: 1.2em;
  }

  .difficulty-selector {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
  }

  .difficulty-selector::before {
    display: none;
  }

  .difficulty-group {
    width: 100%;
    padding: 0;
  }

  .difficulty-group + .difficulty-group {
    border-left: none;
    border-top: 3px solid rgba(47, 78, 31, 0.35);
    padding-top: 12px;
  }
}

@media (max-height: 700px) {
  .game-intro-popup {
    padding: 12px 18px;
    border-radius: 22px;
    font-size: 1.05em;
  }

  .game-intro-text {
    margin-bottom: 10px;
  }

  .difficulty-title {
    margin-bottom: 8px;
  }

  .difficulty-selector {
    margin-top: 4px;
  }

  .difficulty-characters {
    min-height: 86px;
  }

  .difficulty-character {
    width: 68px;
    height: 84px;
  }

  .game-intro-popup button {
    margin-top: 12px;
  }
}

.paused #player img {
  pointer-events: none;
  transform-origin: center;
  transition: transform 0.2s ease;
}

/* Pausierte Timer-Anzeige */
.pause-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -37%);
  width: 38%;
  height: 35%;
  border-radius: 6px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes pause-pulse {
  0%,
  100% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* Fix: Player im Pausenmodus klickbar machen */
.paused #player,
.paused .player-img-container,
.paused .player-img {
  pointer-events: auto !important;
  z-index: 10;
}

/* Fix: Placemarks im Pausenmodus immer klickbar */
.paused .place.disabled {
  pointer-events: auto !important;
}

/* Fix: Sicherstellen, dass alle Elternelemente von Placemarks klickbar sind */
.paused .map-container,
.paused #map {
  pointer-events: auto !important;
}

.paused .place,
.paused .place img {
  pointer-events: auto !important;
}
