/* ============================================================
   museum.css — Digital Museum exhibition public pages
   Inherits global.css variables from ave-team-landing
   ============================================================ */

/* ── Page shell ─────────────────────────────────────────────── */
.museum-page {
  min-height: calc(100vh - var(--nav-height));
  background: var(--footer-light, #f7f7f7);
  padding-bottom: 80px;
}

.museum-container {
    max-width: 1140px;
    margin: 0 auto;       /* ВИПРАВЛЕНО: автоматичне центрування по центру екрана */
    padding: 40px 50px 0;
}

/* ── Breadcrumb ──────────────────────────────────────────────── */
.museum-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--color-grey);
  margin-bottom: 28px;
}
.museum-breadcrumb a {
  color: var(--color-grey);
  text-decoration: none;
  transition: color 0.2s;
}
.museum-breadcrumb a:hover { color: var(--color-black); }
.museum-breadcrumb span[aria-hidden] {
  color: var(--color-grey);
  user-select: none;
}

/* ── Museum home header ─────────────────────────────────────── */
.museum-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 36px; /* Трохи збільшено відступ під заголовком */
}

.museum-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.museum-icon svg {
  width: 100%;
  height: 100%;
}

.museum-title {
  font-size: 1.85rem; /* Злегка збільшено розмір головного заголовка */
  font-weight: 700;
  color: var(--color-black);
  margin: 0;
  line-height: 1.25;
}

/* ── District list (docs-listing style) ─────────────────────── */
.museum-section {
  margin-bottom: 24px;
}

.museum-section-label {
  font-size: 0.75rem; /* Оновлено розмір підзаголовка */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-grey);
  margin-bottom: 16px; /* Збільшено відступ до початку списку */
}

.museum-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  background: #f4f7fb; /* Дуже бліде сіре тло з приємним синім відтінком */
  overflow: hidden;
  border: 1px solid #e1e8f0; /* Легка рамка в тон нового тла */
  border-radius: 16px;
}

.museum-list-item {
  border-bottom: 1px solid #e1e8f0; /* Колір розділювача адаптовано під тло */
}
.museum-list-item:last-child {
  border-bottom: none;
}

.museum-list-link {
  display: flex;
  align-items: center;
  gap: 18px; /* Оптимізовано простір між іконкою та текстом */
  padding: 22px 26px; /* Збільшено внутрішні відступи для більшого об'єму рядків */
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
.museum-list-link:hover {
  background: #edf3f9; /* М'який сіро-синій ховер-ефект */
}
.museum-list-link:hover .museum-list-arrow {
  transform: translateX(4px);
  color: var(--color-accent); /* Стрілочка підсвічується брендовим кольором при наведенні */
}

.museum-list-icon {
  flex-shrink: 0;
  width: 38px; /* Злегка скориговано розміри плашки під іконку */
  height: 38px;
  background: var(--color-accent-tag);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.museum-list-body {
  flex: 1;
  min-width: 0;
}

.museum-list-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-black);
  display: block;
  line-height: 1.4;
}

.museum-list-meta {
  display: block;       /* Щоб працювали відступи та вирівнювання */
  font-size: 0.75rem;
  color: var(--color-grey);
  margin-top: 2px;
  margin-bottom: 20px;  /* Відступ до блоків районів */
  line-height: 1.5;
  text-align: justify;  /* Вирівнювання тексту по ширині (двобічне вирівнювання) */
}

.museum-list-arrow {
  flex-shrink: 0;
  color: var(--color-grey);
  transition: transform 0.2s ease, color 0.2s;
}

/* ══════════════════════════════════════════════════════════════
   STELA PAGE
   ══════════════════════════════════════════════════════════════ */

/* ── Page header ─────────────────────────────────────────────── */
.stela-header {
  margin-bottom: 28px;
}
.stela-district-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--color-black);
  margin: 0 0 4px;
}
.stela-subtitle {
  font-size: 0.82rem;
  color: var(--color-grey);
}

/* ── Card shell (shared) ─────────────────────────────────────── */
.stela-card {
  background: var(--color-white);
  margin-bottom: 60px;
}
.stela-card-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-grey);
  margin: 0 0 16px;
}

/* ── Sector selector ─────────────────────────────────────────── */
.sector-selector-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: start;
}

/* Image + overlay wrapper — 1/3 of the original size */
.stela-viewer {
    position: relative;
    line-height: 0;
    overflow: hidden;
    max-width: 450px;
    flex-shrink: 0;
}

.stela-schema-img {
  width: 100%;
  height: auto;
  display: block;
  opacity: 0.88;
}

/* Grid overlay — 93.9% of image width, anchored to bottom-right.
   Stable for both districts, no per-district overrides needed. */
.stela-grid-overlay {
  position: absolute;
  right:  0;
  bottom: 0;
  width:  93.9%;
  height: 93.9%;

  display: grid;
  /* 7 sector columns, no row-label column */
  grid-template-columns: repeat(7, 1fr);
  /* 7 sector rows, no col-header row */
  grid-template-rows: repeat(7, 1fr);
}

.grid-corner { /* top-left empty cell */ }

.grid-col-header {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

.grid-row-header {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

.grid-cell {
  border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer;
  background: rgba(0,0,0,0);
  transition: background 0.12s ease;
  position: relative;
  /* prevent text selection on click */
  user-select: none;
}

.grid-cell:hover {
  background: rgba(255, 210, 0, 0.32);
  border-color: rgba(218, 165, 0, 0.6);
  z-index: 1;
}

.grid-cell.selected {
  background: rgba(255, 210, 0, 0.52);
  border-color: rgba(218, 165, 0, 0.9);
  z-index: 2;
}

.grid-cell-label {
  display: none;
}

/* ── SVG Scheme Overlays (letters + герб) ────────────────────── */

/* Container sits above grid, passes through mouse events by default */
.stela-scheme-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 3; /* above .stela-grid-overlay */
}

/* Each per-sector SVG wrapper covers the full viewer */
.scheme-svg-wrapper {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; /* wrapper itself is transparent to events */
}

/* The inline SVG stretches to fill exactly */
.scheme-svg-wrapper > svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* All paths are invisible by default */
.scheme-svg-wrapper > svg path {
  opacity: 0;
  transition: opacity 0.14s ease;
}

/* Fill-coloured paths capture pointer events (override parent none) */
.scheme-svg-wrapper > svg path.scheme-fill-path {
  pointer-events: fill;
  cursor: pointer;
}

/* Hovering a fill path: show all paths in this wrapper */
.scheme-svg-wrapper.hovered > svg path {
  opacity: 1;
}

/* Active (selected) state: keep visible, slightly more opaque fill */
.scheme-svg-wrapper.active > svg path {
  opacity: 1;
}
.scheme-svg-wrapper.active > svg path.scheme-fill-path {
  fill-opacity: 0.72; /* stronger than the SVG's default 0.52 */
}

/* ── Side panel ──────────────────────────────────────────────── */
.sector-side-panel {
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sector-panel-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-grey);
  margin-bottom: 4px;
}

.button-section {
    display: flex;      /* Вишиковує елементи в один рядок */
    gap: 20px;          /* Задає відступ 20px між кнопками */
    flex-wrap: wrap;    /* Дозволить кнопкам красиво перенестися, якщо екран буде замалим (наприклад, на мобільних) */
}

.sector-special-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-white);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-black);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    font-family: var(--font-main);
    flex: 1;
}
.sector-special-btn:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-tag);
}
.sector-special-btn.active {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-white);
}

.sector-divider {
  height: 1px;
  background: var(--color-border);
  margin: 4px 0;
}

.sector-reset-btn {
  padding: 9px 14px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: transparent;
  font-size: 0.8rem;
  color: var(--color-grey);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-main);
  width: 100%;
}
.sector-reset-btn:hover {
  border-color: var(--color-grey);
  color: var(--color-black);
}

.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  min-height: 24px;
}
.selected-chip {
  background: var(--color-accent-tag);
  color: var(--color-accent);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 0.7rem;
  font-weight: 600;
}
.sector-status-hint {
  font-size: 0.73rem;
  color: var(--color-grey);
  font-style: italic;
}

/* ── Timeline ────────────────────────────────────────────────── */
.timeline-wrap {
  padding: 8px 0 4px;
  width: 100%;
}

.timeline-wrap .sector-panel-label {
    padding: 12px 0;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.timeline-label-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.timeline-label-year {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-black);
}
.timeline-label-hint {
  font-size: 0.66rem;
  color: var(--color-grey);
}

/* Double range slider */
.timeline-slider-wrap {
  position: relative;
  height: 32px;
  display: flex;
  align-items: center;
}

.timeline-track-bg {
  position: absolute;
  left: 0; right: 0;
  height: 4px;
  background: var(--color-border);
  border-radius: 4px;
}
.timeline-track-range {
  position: absolute;
  height: 4px;
  background: var(--color-accent);
  border-radius: 4px;
}

.timeline-range-input {
  position: absolute;
  width: 100%;
  height: 4px;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  pointer-events: none;
}
.timeline-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-white);
  border: 2px solid var(--color-accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  cursor: grab;
  pointer-events: all;
  transition: transform 0.1s;
}
.timeline-range-input::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}
.timeline-range-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-white);
  border: 2px solid var(--color-accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  cursor: grab;
  pointer-events: all;
}

.timeline-track-bg, .timeline-track-range {
  border-radius: 4px;
}

/* Текстовий режим (<=20 дат на широких екранах) */
.timeline-year-ticks-text {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}
.timeline-tick {
  font-size: 0.68rem;
  color: var(--color-grey);
}
.timeline-tick.active {
  color: var(--color-accent);
  font-weight: 600;
}

/* Режим крапок (>20 дат, або будь-яка кількість на вузьких екранах) */
.timeline-year-ticks-dots {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 8px;
  margin-top: 10px;
}
.timeline-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-border);
  transition: background 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}
.timeline-dot.active {
  background: var(--color-accent);
  transform: scale(1.6);
}

.timeline-no-dates-note {
  font-size: 0.75rem;
  color: var(--color-grey);
  font-style: italic;
  text-align: center;
  padding: 8px 0;
}

/* ── Gallery ─────────────────────────────────────────────────── */
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.gallery-count {
  font-size: 0.78rem;
  color: var(--color-grey);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.gallery-item {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--color-accent-border); /* Тонкий контур замість тіні */
  border-radius: 4px; /* Значно зменшено заокруглення */
  overflow: hidden;
  aspect-ratio: 4/3;
  cursor: pointer;
}

.gallery-item img,
.gallery-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease, opacity 0.3s;
  opacity: 0;
}
.gallery-item img.loaded,
.gallery-item video.loaded {
  opacity: 1;
}
.gallery-item:hover img,
.gallery-item:hover video {
  transform: scale(1.04);
}

.gallery-item-overlay {
  position: absolute;
  inset: 0;
  /* М'який градієнт із синім акцентом від темно-синього до напівпрозорого акцентного */
  background: linear-gradient(to top, rgba(17, 55, 91, 0.85) 0%, rgba(40, 100, 153, 0.2) 70%, transparent 100%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: flex-end;
  padding: 10px;
}
.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.gallery-item-date {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.95);
  font-weight: 600;
}

.gallery-item-video-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(17, 55, 91, 0.75);
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.9);
  font-weight: 600;
  backdrop-filter: blur(4px);
}

/* Gallery placeholder skeleton */
.gallery-skeleton {
  aspect-ratio: 4/3;
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: 4px; /* Синхронізовано зі зменшеним заокругленням */
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Gallery empty state */
.gallery-empty {
  grid-column: 1/-1;
  text-align: center;
  padding: 56px 24px;
  color: var(--color-grey);
}
.gallery-empty-icon {
  font-size: 2.4rem;
  margin-bottom: 12px;
}
.gallery-empty-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-black);
  margin-bottom: 4px;
}
.gallery-empty-sub {
  font-size: 0.8rem;
}

/* Sentinel / load more */
.gallery-sentinel {
  grid-column: 1/-1;
  padding-top: 32px; /* Додано відчутний відступ, щоб відштовхнути нотатку від фото */
  padding-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.gallery-end-note {
  font-size: 0.75rem;
  color: var(--color-grey);
}

/* ── Lightbox ────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.lightbox.open {
  opacity: 1;
  pointer-events: all;
}
.lightbox-inner {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 70px;
}
.lightbox-inner img,
.lightbox-inner video {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
}
.lightbox-meta {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
  text-align: center;
}
.lightbox-close {
  position: fixed;
  top: 90px;
  right: 24px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }

/* ── Thumb tooltip (підказка над повзунком під час перетягування) ── */
.timeline-thumb-tooltip {
  position: absolute;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--color-black);
  color: var(--color-white);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 5;
}
.timeline-thumb-tooltip.visible {
  opacity: 1;
}
.timeline-thumb-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--color-black);
}

/* ── Date filter control (поряд з таймлайном) ──────────────────── */
.date-filter-control {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.date-filter-btn {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-white);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-grey);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-main);
  text-align: center;
}
.date-filter-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-black);
}
.date-filter-btn.active {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-white);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  /* Паддінги головного контейнера зменшуємо, щоб звільнити простір */
  .museum-container {
    padding: 24px 20px 0;
    margin: 0 auto;
  }

  /* Розвертаємо сітку в один стовпчик: Схема зверху, панель знизу */
  .sector-selector-layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  /* Центруємо схему стели, щоб вона не липла до лівого краю */
  .stela-viewer {
    margin: 0 auto;
    max-width: 100%;
  }

  /* Повертаємо колонку! Кожен блок (кнопки, таймлайн) тепер має свій рядок */
  .sector-side-panel {
    flex-direction: column;
    min-width: unset;
    width: 100%;
    gap: 16px;
  }

  /* Кнопки вишикуємо акуратно по дві в ряд або адаптивно */
  .button-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    width: 100%;
  }

  .sector-special-btn {
    width: 100%;
    justify-content: center; /* Центруємо текст на мобільних */
    padding: 12px;
  }

  .date-filter-control {
    display: grid;
    gap: 10px;
    width: 100%;
  }

  .date-filter-btn {
    width: 100%;
    justify-content: center; /* Центруємо текст на мобільних */
    padding: 12px;
  }

  /* Кнопка скидання на всю ширину для зручного тапу пальцем */
  .sector-reset-btn {
    width: 100%;
    padding: 12px;
  }

  /* Стрічка таймлайну розтягується на повну ширину під своїм інпутом */
  .timeline-wrap {
    width: 100%;
  }
  
  .timeline-wrap .sector-panel-label {
    padding: 20px 0;
  }

  /* На вузьких екранах — завжди крапки, незалежно від кількості дат.
     !important потрібен, бо PHP виставляє display через inline style. */
  .timeline-year-ticks-text {
    display: none !important;
  }
  .timeline-year-ticks-dots {
    display: flex !important;
  }

  /* Галерея: 3 колонки на планшетах */
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
}

@media (max-width: 640px) {
  .museum-title {
    font-size: 1rem;
  }
  
  .museum-header {
    gap: 14px;
    margin-bottom: 24px;
  }
  
  .museum-icon {
    width: 44px;
    height: 44px;
  }
  
  .museum-list-link {
    padding: 14px 16px;
    gap: 12px;
  }

  .stela-district-title {
    font-size: 1.3rem;
  }

  /* Кнопки вибору частин стели стають одна під одною на дрібних екранах */
  .button-section {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* Галерея: строго 2 колонки на мобільних */
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Адаптуємо підписи років під таймлайном, щоб не накладалися */
  .timeline-tick {
    font-size: 0.62rem;
  }
  .timeline-label-year {
    font-size: 0.72rem;
  }
}

@media (max-width: 991px) {
    .museum-container {
        padding: 40px 40px 0;
    }
}