/*
 * Kumsel — 3D anlatım bölümü (yalnızca ana sayfa, inc/partials/story.php)
 * Canlı mod: html.story-live (head betiği ekler; WebGL/yükleme hatasında JS kaldırır)
 * Statik mod: html:not(.story-live) — adım kartları + fotoğraflar
 * Kural: .story ve atalarında overflow:hidden YOK (position: sticky bozulur).
 * Tempo: adım yükseklikleri aşağıda; JS adım aralıklarını bu yüksekliklerden ölçer.
 * Geniş yerleşim koşulu JS ile aynı: (min-width: 900px) and (min-aspect-ratio: 6/5)
 */

.story {
  position: relative;
  background: #000;
  color: var(--c-text);
}
.story__canvas { display: block; width: 100%; height: 100%; }
.story__media { display: none; }
.story-after { display: block; height: 0; outline: none; }

/* ── Canlı mod: sticky sahne ─────────────────────────────── */
html.story-live .story__stage {
  position: sticky;
  top: 0;
  z-index: 0;
  height: 100vh;
  height: 100svh;
}
html.story-live .story__canvas {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .9s var(--ease-out);
}
html.story-live .story.is-ready .story__canvas { opacity: 1; }

/* Dikeyde alt perde (metin okunurluğu) */
html.story-live .story__stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 52%;
  background: linear-gradient(to top, rgba(0, 0, 0, .92) 0%, rgba(0, 0, 0, .74) 38%, rgba(0, 0, 0, 0) 100%);
  pointer-events: none;
}

/* Yükleniyor */
.story__loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s var(--ease-out);
}
html.story-live .story:not(.is-ready) .story__loading { opacity: 1; }
.story__spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .16);
  border-top-color: rgba(255, 255, 255, .78);
  animation: story-spin .9s linear infinite;
}
.story.is-ready .story__spinner { animation: none; }
@keyframes story-spin { to { transform: rotate(1turn); } }

/* Metin katmanı sahnenin üzerinden kayar */
html.story-live .story__beats {
  position: relative;
  z-index: 1;
  margin-top: -100vh;
  margin-top: -100svh;
  pointer-events: none;
}
html.story-live .story__beat {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
html.story-live .story__copy {
  position: sticky;
  bottom: 20px;
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
  max-width: 560px;
  padding-block: 8px;
  pointer-events: auto;
}
html.story-live .story__copy:focus-within { opacity: 1 !important; }

/* Adım yükseklikleri — dikey/mobil (toplam ≈ 430svh). Giriş 70svh: alta yapışan ilk adım
   metninin bölüm sabitlendiğinde yerinde kalabilmesi için (40svh'de hemen kayıp gidiyordu). */
html.story-live .story__beat--intro { height: 70vh; height: 70svh; }
html.story-live .story__beat[data-step="1"] { height: 60vh; height: 60svh; }
html.story-live .story__beat[data-step="2"] { height: 90vh; height: 90svh; }
html.story-live .story__beat[data-step="3"] { height: 50vh; height: 50svh; }
html.story-live .story__beat[data-step="4"] { height: 45vh; height: 45svh; }
html.story-live .story__beat[data-step="5"] { height: 45vh; height: 45svh; }
html.story-live .story__beat[data-step="6"] { height: 70vh; height: 70svh; }

/* ── Tipografi ───────────────────────────────────────────── */
.story__eyebrow,
.story__num {
  display: block;
  margin: 0 0 var(--s-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--c-text-2);
}
.story__title {
  font-size: clamp(2rem, 1.25rem + 3vw, 3.5rem);
  line-height: 1.04;
  letter-spacing: -.032em;
  font-weight: 700;
}
.story__heading {
  font-size: clamp(1.625rem, 1.15rem + 1.9vw, 2.625rem);
  line-height: 1.08;
  letter-spacing: -.026em;
  font-weight: 700;
}
.story__lead,
.story__text {
  margin-top: var(--s-4);
  font-size: clamp(1.0625rem, 1rem + .3vw, 1.1875rem);
  line-height: 1.5;
  color: var(--c-text-2);
  text-wrap: pretty;
}
.story__title--finale { font-size: clamp(1.875rem, 1.3rem + 2.2vw, 3rem); }
.story__skip {
  margin-top: var(--s-5);
  font-size: var(--fs-small);
}
.story__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-4) var(--s-6);
  margin-top: var(--s-6);
}

/* ── Adım göstergesi (dikey: nav altında 6 parçalı çubuk) ─── */
.story__steps { display: none; }
html.story-live .story__steps {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.story__steps-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: calc(var(--nav-h) + 8px) var(--gutter) 0;
}
.story__steps-list {
  display: flex;
  gap: 4px;
  width: min(100%, 360px);
  pointer-events: auto;
}
.story__steps-list li { flex: 1; }
.story__dot {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  cursor: pointer;
}
.story__dot::before {
  content: "";
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .24);
  transition: background-color .35s var(--ease-out), height .35s var(--ease-out), width .35s var(--ease-out);
}
.story__dot.is-done::before { background: rgba(255, 255, 255, .56); }
.story__dot[aria-current="step"]::before { background: #fff; }
.story__dot:hover::before { background: rgba(255, 255, 255, .8); }
.story__dot:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.story__dot-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Geniş yerleşim: metin solda, pano sağda, noktalar sağ kenarda ── */
@media (min-width: 900px) and (min-aspect-ratio: 6/5) {
  html.story-live .story__stage::after {
    top: 0;
    right: auto;
    width: 46%;
    height: auto;
    background: linear-gradient(to right, rgba(0, 0, 0, .7) 0%, rgba(0, 0, 0, .35) 55%, rgba(0, 0, 0, 0) 100%);
  }
  html.story-live .story__copy {
    max-width: 440px;
    /* Dikey ortalama: --copy-h JS tarafından ölçülür (CSSOM) */
    bottom: calc(50vh - var(--nav-h) / 2 - var(--copy-h, 16rem) / 2);
    bottom: calc(50svh - var(--nav-h) / 2 - var(--copy-h, 16rem) / 2);
  }
  html.story-live .story__beat--intro { height: 60vh; height: 60svh; }
  html.story-live .story__beat[data-step="1"] { height: 80vh; height: 80svh; }
  html.story-live .story__beat[data-step="2"] { height: 120vh; height: 120svh; }
  html.story-live .story__beat[data-step="3"] { height: 70vh; height: 70svh; }
  html.story-live .story__beat[data-step="4"] { height: 60vh; height: 60svh; }
  html.story-live .story__beat[data-step="5"] { height: 60vh; height: 60svh; }
  html.story-live .story__beat[data-step="6"] { height: 100vh; height: 100svh; }

  .story__steps-rail {
    justify-content: flex-end;
    align-items: center;
    padding: 0 max(8px, calc(var(--gutter) - 16px)) 0 0;
  }
  .story__steps-list {
    flex-direction: column;
    gap: 2px;
    width: auto;
  }
  .story__dot {
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 14px;
  }
  .story__dot::before {
    width: 6px;
    height: 6px;
    border-radius: 3px;
  }
  .story__dot[aria-current="step"]::before { height: 22px; }
  .story__dot-label {
    right: 100%;
    top: 50%;
    width: auto;
    height: auto;
    clip: auto;
    overflow: visible;
    margin-right: 6px;
    padding: 4px 10px;
    border-radius: var(--r-pill);
    background: rgba(44, 44, 46, .9);
    color: #f5f5f7;
    font-size: .75rem;
    font-weight: 500;
    line-height: 1.3;
    opacity: 0;
    transform: translate(4px, -50%);
    transition: opacity .2s var(--ease-out), transform .2s var(--ease-out);
    pointer-events: none;
  }
  .story__dot:hover .story__dot-label,
  .story__dot:focus-visible .story__dot-label {
    opacity: 1;
    transform: translate(0, -50%);
  }
}

/* ── Statik mod: kartlar + görseller ─────────────────────── */
html:not(.story-live) .story { padding-block: var(--section-y); }
html:not(.story-live) .story__stage { display: none; }
html:not(.story-live) .story__skip { display: none; }
html:not(.story-live) .story__copy { opacity: 1 !important; }
html:not(.story-live) .story__beats {
  display: grid;
  gap: var(--s-5);
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
html:not(.story-live) .story__beat {
  display: grid;
  gap: var(--s-5);
  align-items: center;
  padding: clamp(20px, 4vw, 48px);
  border-radius: var(--r-4);
  background: var(--c-surface);
}
html:not(.story-live) .story__beat--intro {
  justify-items: center;
  padding: 0 0 var(--s-6);
  background: none;
  text-align: center;
}
html:not(.story-live) .story__beat--intro .story__copy { max-width: 680px; }
html:not(.story-live) .story__media {
  display: block;
  border-radius: var(--r-3);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: #f5f5f7;
}
html:not(.story-live) .story__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
html:not(.story-live) .story__media--render img {
  object-fit: contain;
  mix-blend-mode: multiply;
}
html:not(.story-live) .story__media--detail img {
  object-position: 100% 40%;
  transform: scale(1.6);
  transform-origin: 96% 42%;
}
@media (min-width: 900px) {
  html:not(.story-live) .story__beat:not(.story__beat--intro) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--s-7);
  }
  html:not(.story-live) .story__beat[data-step="2"] .story__copy,
  html:not(.story-live) .story__beat[data-step="4"] .story__copy,
  html:not(.story-live) .story__beat[data-step="6"] .story__copy { order: 2; }
}

/* ── Hareket azaltma ve baskı ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .story__spinner { animation-duration: 2.4s; }
  .story__canvas, .story__dot::before, .story__dot-label { transition: none !important; }
}
@media print {
  html.story-live .story__beats { margin-top: 0; }
  .story__steps, .story__loading { display: none !important; }
  .story__copy { opacity: 1 !important; }
  html.story-live .story__beat { height: auto !important; }
}
