.page-kosmologie {
  width: min(100% - 32px, 1100px);
}

.kosmologie-page {
  overflow: hidden;
}

.cosmo-wrap {
  position: relative;
  width: 100%;
  margin-top: 24px;
}

/*
 * Základní SVG i všechny barevné vrstvy mají stejný viewBox 4961 × 3508.
 * Proto se vrství přesně na sebe bez ručních posunů a zvětšování.
 */
.cosmo-idol-area {
  position: relative;
  width: 100%;
  aspect-ratio: 4961 / 3508;
}

.cosmo-idol-base {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  color: transparent;
  font-size: 0;
  opacity: 0;
  transition: opacity 0.18s ease;
}

/*
 * Obrázek se ukáže až po skutečném načtení SVG. Tím se při prvním
 * vykreslení nezobrazí náhradní ALT text „Kresba idolu ze Zbruče“.
 */
.cosmo-idol-base.is-loaded {
  opacity: 1;
}

.cosmo-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}

.cosmo-layer.active {
  opacity: 1;
}

/* Klikací oblasti leží jen nad jednotlivými částmi idolu. */
.cosmo-hotspot {
  position: absolute;
  left: 28.2%;
  z-index: 5;
  width: 12.5%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  appearance: none;
  cursor: pointer;
}

.cosmo-hotspot:hover,
.cosmo-hotspot:active,
.cosmo-hotspot[aria-expanded="true"] {
  background: transparent !important;
  box-shadow: none !important;
}

.cosmo-hotspot:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.hotspot-rod {
  top: 13.8%;
  height: 9.5%;
}

.hotspot-prav {
  top: 22.5%;
  height: 34.5%;
}

.hotspot-jav {
  top: 56.7%;
  height: 11.5%;
}

.hotspot-nav {
  top: 67.5%;
  height: 19.5%;
}

/* Texty jsou umístěné přímo do čtyř polí vymezených čarami v základním SVG. */
.cosmo-info {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.cosmo-text {
  position: absolute;
  left: 48.5%;
  width: 44%;
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.cosmo-text.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* Staré CSS čáry se už nezobrazují – jsou součástí idol-ze-zbruce-cary.svg. */
.cosmo-line {
  display: none !important;
}

.cosmo-text[data-text="rod"] {
  top: 5.5%;
}

.cosmo-text[data-text="prav"] {
  top: 24.5%;
}

.cosmo-text[data-text="jav"] {
  top: 52.8%;
}

.cosmo-text[data-text="nav"] {
  top: 70.5%;
}

.cosmo-text h2 {
  margin: 0 0 9px;
  padding: 0;
  color: var(--red);
  font-size: clamp(1.25rem, 2.1vw, 1.65rem);
  line-height: 1.15;
  text-align: left;
}

.cosmo-text p {
  margin: 0;
  padding: 0;
  color: var(--red);
  font-size: clamp(0.88rem, 1.35vw, 1rem);
  line-height: 1.42;
  text-align: left;
}

.idol-description {
  max-width: 700px;
  margin: 70px auto 0;
}

.idol-description .blue-text {
  text-align: left;
}


/* Ovládací názvy jsou určené pouze pro mobilní rozložení. */
.cosmo-mobile-labels {
  display: none;
}

@media (max-width: 768px) {
  .page-kosmologie {
    width: min(100% - 20px, 680px);
  }

  .kosmologie-page {
    overflow-x: hidden;
  }

  .cosmo-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    margin-top: 10px;
    overflow: visible;
  }

  /* Mobil používá samostatně připravené SVG s kratším rozložením čar. */
  .cosmo-idol-area {
    position: relative;
    width: min(100%, 760px);
    max-width: none;
    margin: 0 auto;
    aspect-ratio: 4961 / 3508;
  }

  .cosmo-idol-base,
  .cosmo-idol-base.nc-cosmo-mobile-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .cosmo-mobile-labels {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: block;
    pointer-events: none;
  }

  .cosmo-mobile-label {
    position: absolute;
    right: 1.5%;
    z-index: 51;
    min-width: 66px;
    padding: 6px 10px;
    transform: translateY(-50%);
    border: 1px solid rgba(156, 31, 31, 0.45);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 3px 12px rgba(70, 20, 20, 0.12);
    color: var(--red);
    font: inherit;
    font-size: clamp(0.88rem, 3.8vw, 1.05rem);
    font-weight: 400;
    line-height: 1.1;
    text-align: center;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    transition:
      background-color 180ms ease,
      border-color 180ms ease,
      color 180ms ease,
      transform 180ms ease;
  }

  .cosmo-mobile-label:hover,
  .cosmo-mobile-label:focus-visible {
    border-color: var(--red);
    outline: 2px solid rgba(156, 31, 31, 0.2);
    outline-offset: 2px;
  }

  .cosmo-mobile-label:active {
    transform: translateY(-50%) scale(0.96);
  }

  .cosmo-mobile-label.active {
    border-color: var(--red);
    background: var(--red);
    color: var(--white);
  }

  /* Pozice odpovídají čtyřem liniím v mobilním SVG. */
  .cosmo-mobile-label.label-rod {
    top: 18.5%;
  }

  .cosmo-mobile-label.label-prav {
    top: 38.2%;
  }

  .cosmo-mobile-label.label-jav {
    top: 61.8%;
  }

  .cosmo-mobile-label.label-nav {
    top: 76.2%;
  }

  /* Textová část se na mobilu zobrazí pod grafikou. */
  .cosmo-info {
    position: relative;
    inset: auto;
    z-index: 4;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    height: auto;
    margin: 12px auto 0;
    padding: 0 8px 34px;
    pointer-events: auto;
  }

  .cosmo-text,
  .cosmo-text[data-text] {
    display: none;
    position: static;
    inset: auto;
    width: min(100%, 560px);
    max-width: 560px;
    min-height: 0;
    height: auto;
    margin: 0 auto;
    padding: 19px 17px 21px;
    transform: none;
    visibility: visible;
    border: 1px solid rgba(156, 31, 31, 0.18);
    border-radius: 14px;
    background: rgba(156, 31, 31, 0.035);
    box-shadow: 0 6px 22px rgba(60, 20, 20, 0.06);
    opacity: 1;
    pointer-events: auto;
    text-align: left;
  }

  .cosmo-text.active,
  .cosmo-text[data-text].active {
    display: block;
    animation: cosmo-mobile-text-in 260ms ease both;
  }

  .cosmo-text h1,
  .cosmo-text h2,
  .cosmo-text h3 {
    margin: 0 0 11px;
    line-height: 1.2;
    text-align: center;
  }

  .cosmo-text p {
    margin: 0;
    font-size: clamp(1rem, 4.2vw, 1.08rem);
    line-height: 1.58;
    text-align: left;
  }

  .idol-description {
    margin-top: 42px;
  }
}

@media (max-width: 430px) {
  .cosmo-mobile-label {
    right: 0.8%;
    min-width: 60px;
    padding: 5px 8px;
  }

  .cosmo-info {
    padding-right: 5px;
    padding-left: 5px;
  }

  .cosmo-text,
  .cosmo-text[data-text] {
    padding: 17px 15px 19px;
  }
}

@keyframes cosmo-mobile-text-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cosmo-layer,
  .cosmo-text,
  .cosmo-mobile-label {
    transition: none;
  }

  .cosmo-text.active,
  .cosmo-text[data-text].active {
    animation: none;
  }
}
