/* =========================================================
   stories.css — нүүр хуудасны "Travel stories": босоо видео карт,
   томруулж харах цонх, Join our community (stories.js)
   ========================================================= */
.stories {
  background:
    radial-gradient(900px 420px at 12% 0%, rgba(217, 169, 108, 0.22), transparent 70%),
    radial-gradient(800px 420px at 95% 100%, rgba(140, 191, 122, 0.18), transparent 70%),
    linear-gradient(180deg, #FCF7F0 0%, #F7F7F2 100%);
  overflow: hidden;
}
.stories[hidden], .community[hidden], .stories-head[hidden] { display: none; }

.stories-head { max-width: 860px; margin-bottom: 36px; }
.stories-title { color: var(--charcoal); font-size: clamp(1.8rem, 3.6vw, 2.5rem); margin-bottom: 12px; }
.stories-text { color: #4a5050; font-size: 1.1rem; }
.stories mark, .st-stories mark {
  background: linear-gradient(transparent 8%, rgba(217, 169, 108, 0.45) 8%, rgba(217, 169, 108, 0.45) 92%, transparent 92%);
  color: inherit; padding: 0 0.2em; border-radius: 4px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* Видео картууд: 4 багана, олон бол хажуу тийш гүйлгэнэ */
.stories-track {
  --gap: 24px;
  display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 3 * var(--gap)) / 4);
  gap: var(--gap); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  padding-bottom: 4px;
}
.stories-track::-webkit-scrollbar { display: none; }
.stories-track[data-count="1"], .stories-track[data-count="2"], .stories-track[data-count="3"] { justify-content: start; }
.story { scroll-snap-align: start; min-width: 0; }

.story-media {
  position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; padding: 0; border: 0;
  border-radius: 14px; overflow: hidden; background: #1F2323; cursor: pointer;
  box-shadow: 0 10px 30px -14px rgba(31, 35, 35, 0.45);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.story-media img, .story-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.story-media img { transition: transform 0.6s ease; }
.story-media::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, rgba(31, 35, 35, 0.35));
}
.story-preview { opacity: 0; transition: opacity 0.3s ease; }
.story-preview.is-playing { opacity: 1; }
.story-play {
  position: absolute; z-index: 1; top: 50%; left: 50%; translate: -50% -50%;
  display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%;
  background: rgba(31, 35, 35, 0.35); border: 2px solid rgba(255, 255, 255, 0.9); color: #fff;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform 0.3s ease, background 0.3s ease, opacity 0.3s ease;
}
.story-play svg { width: 24px; height: 24px; margin-left: 3px; }
.story-media:hover, .story-media:focus-visible { transform: translateY(-4px); box-shadow: 0 18px 40px -16px rgba(31, 35, 35, 0.55); }
.story-media:hover img { transform: scale(1.04); }
.story-media:hover .story-play { transform: scale(1.08); background: var(--altai-forest); border-color: var(--altai-forest); }
.story-media:has(.is-playing) .story-play { opacity: 0; }
.story-media:focus-visible { outline: 3px solid var(--sand-gold); outline-offset: 3px; }

.story-blank {
  position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 14px; color: rgba(255, 255, 255, 0.75);
  font-weight: 700; font-size: 0.85rem; letter-spacing: 0.04em; text-transform: uppercase;
  background: radial-gradient(120% 80% at 20% 10%, rgba(217, 169, 108, 0.55), transparent 60%), linear-gradient(160deg, #1B5E3B, #1F2323);
}
.story-badge {
  position: absolute; z-index: 1; top: 10px; left: 10px; padding: 3px 9px; border-radius: 999px;
  background: rgba(31, 35, 35, 0.55); color: #fff; font-size: 0.72rem; font-weight: 700;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.story-link {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; color: var(--altai-forest);
  font-weight: 700; font-size: 0.88rem; text-decoration: underline; text-underline-offset: 3px;
}
.story-link svg { width: 14px; height: 14px; }
.story-link:hover { color: var(--charcoal); }
.story-title { margin-top: 16px; font-size: 1rem; letter-spacing: 0; color: var(--charcoal); }
.story-text { margin-top: 6px; font-size: 0.95rem; line-height: 1.55; color: #4a5050; }

/* ---------- Join our community ---------- */
.community { margin-top: 72px; text-align: center; }
.community-photos { display: flex; justify-content: center; align-items: center; margin-bottom: 24px; }
.community-photos:empty { display: none; }
.community-photos img {
  width: 104px; height: 104px; border-radius: 50%; object-fit: cover;
  border: 4px solid #FCF7F0; box-shadow: 0 8px 22px -10px rgba(31, 35, 35, 0.5);
}
.community-photos img + img { margin-left: -22px; }
.community-photos[data-count="3"] img:nth-child(2) { width: 140px; height: 140px; position: relative; z-index: 1; }
.community-title { font-size: clamp(1.5rem, 2.6vw, 1.9rem); color: var(--charcoal); margin-bottom: 10px; }
.community-text { max-width: 620px; margin: 0 auto; color: #4a5050; }
.community-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.community-link {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 22px; border-radius: 999px;
  background: #fff; color: var(--charcoal); font-weight: 700; font-size: 0.95rem; text-decoration: none;
  border: 1px solid rgba(31, 35, 35, 0.1); box-shadow: 0 6px 18px -12px rgba(31, 35, 35, 0.5);
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.community-link svg { width: 22px; height: 22px; flex: none; }
.community-link.is-facebook svg { color: #1877F2; }
.community-link.is-instagram svg { color: #D62976; }
.community-link.is-whatsapp svg { color: var(--whatsapp); }
.community-link:hover, .community-link:focus-visible { transform: translateY(-2px); color: #fff; box-shadow: 0 12px 24px -12px rgba(31, 35, 35, 0.6); }
.community-link:hover svg, .community-link:focus-visible svg { color: #fff; }
.community-link.is-facebook:hover, .community-link.is-facebook:focus-visible { background: #1877F2; }
.community-link.is-instagram:hover, .community-link.is-instagram:focus-visible { background: linear-gradient(45deg, #F58529, #DD2A7B 50%, #8134AF); }
.community-link.is-whatsapp:hover, .community-link.is-whatsapp:focus-visible { background: var(--whatsapp); }

/* ---------- Томруулж харах цонх ---------- */
html.story-open { overflow: hidden; }
.story-box {
  position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; margin: 0;
  padding: 0; border: 0; background: transparent; color: #fff;
  display: none; place-items: center;
}
.story-box[open] { display: grid; animation: sb-in 0.25s ease; }
.story-box::backdrop { background: rgba(20, 24, 24, 0.82); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
@keyframes sb-in { from { opacity: 0; transform: scale(0.97); } }

.sb-stage {
  position: relative; height: min(86vh, 860px); aspect-ratio: 9 / 16; max-width: calc(100vw - 32px);
  border-radius: 16px; overflow: hidden; background: #000; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
}
.sb-media, .sb-media video, .sb-media iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.sb-media video { object-fit: cover; cursor: pointer; }
.sb-media.is-embed { background: #fff; }
/* Платформын тоглуулагч өөрийн товчтой: тайлбарыг доод талд тусад нь харуулна */
.sb-stage:has(.is-embed) { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.sb-stage:has(.is-embed) .sb-media { position: relative; inset: auto; }
.sb-stage:has(.is-embed) .sb-info { position: static; background: #1F2323; padding: 14px 18px 18px; }
.sb-info {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 60px 18px 18px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.75)); pointer-events: none;
}
.sb-info[hidden] { display: none; }
.sb-title { display: block; font-size: 1rem; }
.sb-text { font-size: 0.9rem; line-height: 1.45; margin-top: 4px; opacity: 0.92; }
.sb-text:empty { display: none; }
.sb-link {
  pointer-events: auto; display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 14px; padding: 11px 16px; border-radius: 10px; background: #fff; color: var(--charcoal);
  font-weight: 700; font-size: 0.92rem; text-decoration: none; transition: background 0.2s ease, color 0.2s ease;
}
.sb-link svg { width: 16px; height: 16px; }
.sb-link:hover { background: var(--altai-forest); color: #fff; }
.sb-link[hidden] { display: none; }

.sb-top {
  position: absolute; top: 20px; left: 50%; translate: -50% 0; width: min(1000px, 100% - 32px);
  display: flex; justify-content: space-between; align-items: center; z-index: 2;
}
.sb-count { padding: 7px 12px; border-radius: 8px; background: rgba(255, 255, 255, 0.14); font-weight: 700; font-size: 0.85rem; }
.sb-actions { display: flex; gap: 8px; }
.sb-btn, .sb-nav {
  display: grid; place-items: center; border: 0; cursor: pointer; color: var(--charcoal); background: #fff;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.sb-btn { width: 42px; height: 42px; border-radius: 10px; }
.sb-btn svg { width: 22px; height: 22px; }
.sb-btn[hidden], .sb-nav[hidden] { display: none; }
.sb-nav {
  position: absolute; top: 50%; translate: 0 -50%; z-index: 2; width: 46px; height: 46px; border-radius: 50%;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.sb-nav svg { width: 22px; height: 22px; }
.sb-prev { left: calc(50% - min(43vh, 430px) - 72px); }
.sb-next { right: calc(50% - min(43vh, 430px) - 72px); }
.sb-btn:hover, .sb-nav:hover { background: var(--altai-forest); color: #fff; }

@media (max-width: 1000px) {
  .stories-track { grid-auto-columns: calc((100% - 2 * var(--gap)) / 2.6); }
}
@media (max-width: 760px) {
  .stories-head { margin-bottom: 24px; }
  .stories-track { --gap: 14px; grid-auto-columns: 68%; margin-right: -16px; padding-right: 16px; }
  .story-play { width: 52px; height: 52px; }
  .community { margin-top: 52px; }
  .community-photos img { width: 84px; height: 84px; }
  .community-photos[data-count="3"] img:nth-child(2) { width: 112px; height: 112px; }
  .community-link { flex: 1 1 100%; justify-content: center; }
  .sb-stage { height: 100%; max-height: none; max-width: none; width: 100%; aspect-ratio: auto; border-radius: 0; }
  .sb-top { top: 14px; }
  .sb-count, .sb-btn { background: rgba(0, 0, 0, 0.45); color: #fff; }
  .sb-nav { display: none; }
  .sb-info { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .story-media, .story-media img, .story-play, .community-link { transition: none; }
  .story-box[open] { animation: none; }
}

/* Аяллын хуудас: нарийн баганад 3 карт */
.st-stories .stories-track { grid-auto-columns: calc((100% - 2 * var(--gap)) / 3); --gap: 18px; }
.st-stories .stories-text { font-size: 1rem; margin-bottom: 20px; }
@media (max-width: 760px) {
  .st-stories .stories-track { grid-auto-columns: 68%; }
}
