/* Hikâye katmanı: 3B sahne + başlık + şablon şeridi. Ortak tokenlar core/style.css'te. */
.story {
  position: fixed;
  inset: 54px 0 0 0;
  z-index: 20;
  overflow: hidden;
  background: #e9ece9;
}
.story-canvas { position: absolute; inset: 0; }
.story-canvas canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }

/* Başlık bloğu: sahnenin boş duvar alanına oturur. Okunurluk için arkasında yumuşak bir kâğıt tonu. */
.story-copy {
  position: absolute;
  left: clamp(20px, 6vw, 96px);
  top: clamp(28px, 8vh, 96px);
  width: min(560px, calc(100% - 40px));
  pointer-events: none;
}
.story-copy::before {
  content: '';
  position: absolute;
  inset: -60px -90px -50px -80px;
  background: radial-gradient(closest-side, rgba(233, 236, 233, 0.82), rgba(233, 236, 233, 0));
  z-index: -1;
}
.story-title {
  margin: 0 0 18px;
  font-size: clamp(40px, 5.4vw, 80px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 650;
  color: var(--ink);
  text-wrap: balance;
}
.story-title .sw { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.story-title .swi { display: inline-block; will-change: transform; }
.story-lede { margin: 0 0 22px; font-size: 18px; line-height: 1.5; color: var(--ink-2); max-width: 42ch; text-wrap: pretty; }
.story-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; pointer-events: auto; }
.story-cta {
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(120, 50, 10, 0.25), 0 8px 20px rgba(190, 85, 25, 0.22);
  transition: background-color 0.15s ease-out, transform 0.15s ease-out;
}
.story-cta:hover { background: var(--accent-ink); transform: translateY(-1px); }
.story-hint { font-size: 14px; color: var(--ink-2); }

/* Sahne üzerindeki işaretçiler: her tıklanabilir şablonun yanında kısa bir not.
   Konum JS ile her karede güncellenir; üst üste binen notlarda arkadaki yalnız nokta kalır (.mini). */
.story-pins { position: absolute; inset: 0; pointer-events: none; }
.pin {
  position: absolute;
  left: 0; top: 0;
  border: 0; background: none; padding: 0;
  pointer-events: auto;
  transition: opacity 0.2s ease-out;
}
.pin::before { /* dokunmatik için 44 px vuruş alanı */
  content: '';
  position: absolute;
  left: -22px; top: -22px;
  width: 44px; height: 44px;
}
.pin.off, .pin.is-cur { opacity: 0; pointer-events: none; }
.pin-dot {
  position: absolute;
  left: -6px; top: -6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent), 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s cubic-bezier(0, 0, 0.2, 1);
}
/* Sahne açılınca her nokta iki kez nabız atar: "buraya tıklanabilir". */
.pin-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--accent);
  opacity: 0;
}
.story.pins-ready .pin-dot::after { animation: pin-pulse 1.5s cubic-bezier(0, 0, 0.2, 1) 2 both; animation-delay: calc(var(--i, 0) * 110ms); }
@keyframes pin-pulse {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(2.8); opacity: 0; }
}
.pin-label {
  position: absolute;
  left: 13px; top: -13px;
  display: flex; flex-direction: column;
  white-space: nowrap;
  padding: 4px 9px 5px;
  border-radius: 8px;
  background: rgba(43, 48, 54, 0.88);
  color: var(--panel);
  font-size: 12.5px; line-height: 1.25;
  text-align: left;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  transition: opacity 0.18s ease-out, transform 0.18s cubic-bezier(0, 0, 0.2, 1), background-color 0.15s ease-out;
}
.pin-label b { font-weight: 600; }
.pin-label i { display: none; font-style: normal; font-size: 12px; color: #f2b48a; }
.pin.left .pin-label { left: auto; right: 13px; align-items: flex-end; text-align: right; }
.pin.on .pin-dot { transform: scale(1.3); }
.pin.on .pin-label { background: var(--ink); }
.pin.on .pin-label i { display: block; }
.pin.mini:not(.on) .pin-label { opacity: 0; transform: translateX(-4px); pointer-events: none; }
.pin.left.mini:not(.on) .pin-label { transform: translateX(4px); }

/* Yakın planda notlar susar (yalnız noktalar kalır); üzerine gelinen not görünür. */
.story.is-focused .pin:not(.on) .pin-label { opacity: 0; transform: translateX(-4px); pointer-events: none; }
.story.is-focused .story-canvas canvas { touch-action: none; }

/* Yakın plan kartı: şablonun adı, tek cümle, "Bu şablonla tasarla" ve "Geri". */
.story-card {
  position: absolute;
  left: clamp(20px, 6vw, 96px);
  bottom: 96px;
  z-index: 2;
  width: min(380px, calc(100% - 40px));
  padding: 18px 20px 16px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 14px 40px rgba(30, 35, 40, 0.16);
}
.sc-title { margin: 0 0 6px; font-size: 20px; line-height: 1.2; letter-spacing: -0.01em; font-weight: 650; color: var(--ink); }
.sc-desc { margin: 0 0 14px; font-size: 15px; line-height: 1.5; color: var(--ink-2); text-wrap: pretty; }
.sc-desc:empty { display: none; }
.sc-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sc-go {
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600; font-size: 15px;
  padding: 11px 18px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(120, 50, 10, 0.25), 0 6px 16px rgba(190, 85, 25, 0.2);
  transition: background-color 0.15s ease-out;
}
.sc-go:hover { background: var(--accent-ink); }
.sc-back {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font-weight: 600; font-size: 15px;
  padding: 10px 16px;
  border-radius: 10px;
  transition: background-color 0.15s ease-out;
}
.sc-back:hover { background: var(--sunk); }
.sc-soon { flex: 1 1 100%; font-size: 14px; color: var(--ink-2); }
.sc-hint { margin: 12px 0 0; font-size: 13px; color: var(--ink-3); }
@media (prefers-reduced-motion: reduce) {
  .story.pins-ready .pin-dot::after { animation: none; }
}

/* Şablon şeridi: klavye, ekran okuyucu ve dokunmatik için ana yol. */
.story-strip {
  position: absolute;
  left: 50%; bottom: 22px;
  transform: translateX(-50%);
  display: flex; gap: 6px;
  max-width: calc(100% - 32px);
  padding: 6px;
  border-radius: 14px;
  background: rgba(248, 249, 248, 0.9);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 10px 30px rgba(30, 35, 40, 0.12);
  overflow-x: auto;
  scrollbar-width: none;
}
.story-strip::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: flex; flex-direction: column; align-items: flex-start;
  min-height: 44px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 6px 12px;
  text-align: left;
  transition: background-color 0.15s ease-out, border-color 0.15s ease-out;
}
.chip-name { font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.chip-act { font-size: 12px; color: var(--accent-ink); }
.chip.soon .chip-act { color: var(--ink-2); }
.chip:hover, .chip.on { background: var(--panel); border-color: var(--line); }
.chip.focused { background: var(--ink); }
.chip.focused .chip-name { color: var(--panel); }
.chip.focused .chip-act { color: #f2b48a; }

/* Seçimde ve girişte kullanılan perde (sayfa rengine kararma). */
.story-veil { position: absolute; inset: 0; background: #e9ece9; pointer-events: none; z-index: 3; }

.story-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.story.no-webgl .story-canvas { display: none; }
.story.no-webgl .story-veil { display: none; }
.story.no-webgl .story-pins { display: none; } /* 3B yoksa notların konumu da yok; şerit yeterli */

@media (max-width: 860px) {
  .story-copy { top: 18px; left: 18px; width: calc(100% - 36px); }
  .story-title { font-size: clamp(32px, 9vw, 44px); margin-bottom: 10px; }
  .story-lede { font-size: 15px; margin-bottom: 14px; }
  .story-cta { padding: 11px 16px; }
  .pin-label { font-size: 12px; padding: 3px 8px 4px; }
  .story-strip { left: 12px; right: 12px; transform: none; max-width: none; bottom: 12px; }
  .story-card { left: 12px; right: 12px; width: auto; bottom: 80px; padding: 14px 16px 14px; }
  .sc-title { font-size: 18px; }
  .sc-desc { font-size: 14px; margin-bottom: 12px; }
}
@media (pointer: coarse) { .sc-go, .sc-back { min-height: 44px; } }

/* ---------- Sayfa düzeni: sahne açıkken atölye gizli (yer kaplar, boyutlanır) ---------- */
.story { display: none; }
html.story-on .story { display: block; }
html.story-on main.tool { visibility: hidden; }
.story[hidden] { display: none !important; }

/* Sahne hazırlanırken perdenin ortasında kısa bir yazı */
.story[aria-busy="true"] .story-veil::after {
  content: attr(data-loading);
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px; color: var(--ink-2);
}

/* Atölyesi olmayan araçta "Tüm araçlar" */
.story-alt {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  font-weight: 600; font-size: 15px;
  padding: 11px 18px; border-radius: 10px;
  text-decoration: none;
  transition: background-color 0.15s ease-out;
}
.story-alt:hover { background: var(--sunk); }

/* Üst çubuk: sahneye dönüş ve tüm araçlar */
.scene-back {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-strong); background: var(--panel);
  border-radius: 999px; padding: 5px 12px 5px 9px;
  font-size: 13px; font-weight: 600; color: var(--ink);
  transition: background-color 0.15s ease-out;
}
.scene-back:hover { background: var(--sunk); }
.scene-back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.toplink { font-size: 13.5px; font-weight: 600; color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.toplink:hover { background: var(--sunk); color: var(--ink); }
.story-title:focus { outline: none; }
.tool-title:focus { outline: none; }

@media (pointer: coarse) {
  .scene-back, .toplink { min-height: 44px; }
}
@media (max-width: 520px) {
  .scene-back span { display: none; }
  .scene-back { padding: 6px 9px; }
}
