/* ==========================================================
   Nörondan Dil Modeline — görsel sistem
   "Karanlık alan mikroskobu": çivit zemin, floresan boyalar
   ========================================================== */

:root {
  --bg: #0a0f2c;          /* karanlık alan */
  --bg-2: #10173d;        /* sahne zemini */
  --panel: #161f4f;       /* kontrol yüzeyi */
  --line: #2a3570;        /* ince çizgiler */
  --ink: #ece8f7;         /* metin */
  --ink-2: #b5b6d8;       /* ikincil metin */
  --muted: #7d80ad;       /* soluk */
  --pos: #4be3a0;         /* GFP yeşili  — pozitif ağırlık, doğru */
  --neg: #ff5fa8;         /* rodamin pembesi — negatif ağırlık, hata */
  --gold: #f4b740;        /* Golgi boyası — vurgu, aktivasyon */
  --blue: #74a9ff;        /* DAPI mavisi — nötr bilgi */

  --f-display: "Bricolage Grotesque", system-ui, sans-serif;
  --f-body: "Source Serif 4", Georgia, serif;
  --f-num: "IBM Plex Mono", ui-monospace, monospace;

  --r-sm: 6px;
  --r-md: 12px;
  --gutter: clamp(16px, 3.2vw, 48px);
  --bar-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: clamp(15px, 0.75vw + 6.5px, 18px);
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* mikroskop alanının hafif vinyeti */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 60% 45%, transparent 55%, rgba(3, 5, 20, 0.55) 100%);
  z-index: 0;
}

button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }

/* ---------- Slayt kabı ---------- */
#deck {
  position: fixed; inset: 0 0 var(--bar-h) 0;
  z-index: 1;
}
.slide {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: minmax(300px, 0.78fr) 1.22fr;
  gap: clamp(20px, 3vw, 56px);
  padding: clamp(24px, 4.5vh, 56px) var(--gutter) clamp(16px, 3vh, 32px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, transform 0.55s cubic-bezier(.2,.7,.2,1), visibility 0s linear 0.55s;
  transform: translateX(28px);
}
.slide.before { transform: translateX(-28px); }
.slide.active {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity 0.45s ease, transform 0.55s cubic-bezier(.2,.7,.2,1), visibility 0s;
}
.slide.wide { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
.slide.center { grid-template-columns: 1fr; place-items: center; text-align: center; }

body.text-hidden .slide:not(.center) { grid-template-columns: 0 1fr; gap: 0; }
body.text-hidden .slide:not(.center) .text { display: none; }

/* ---------- Metin sütunu ---------- */
.text {
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  max-width: 62ch;
  align-self: start;
  max-height: 100%;
}
.chapter-tag {
  font-family: var(--f-display);
  font-size: 0.82rem;
  color: var(--gold);
  letter-spacing: 0.01em;
  margin: 0 0 0.6rem;
  display: flex; align-items: center; gap: 0.6em;
}
.chapter-tag b {
  display: inline-grid; place-items: center;
  width: 1.7em; height: 1.7em; border-radius: 50%;
  border: 1px solid currentColor; font-weight: 600; font-size: 0.85em;
}
h1, h2, h3 {
  font-family: var(--f-display);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.025em;
  margin: 0 0 0.9rem;
  font-variation-settings: "opsz" 96;
}
h1 { font-size: clamp(2.8rem, 6.4vw, 6.4rem); letter-spacing: -0.04em; }
h2 { font-size: clamp(2rem, 3.3vw, 3.4rem); }
h3 { font-size: 1.15rem; letter-spacing: -0.01em; margin: 1.4rem 0 0.4rem; }
.text p { margin: 0 0 0.95em; color: var(--ink-2); }
.text p.lead { color: var(--ink); font-size: 1.12em; line-height: 1.5; }
.text strong { color: var(--ink); font-weight: 600; }
.text em { color: var(--ink); }
.text ul { padding-left: 1.1em; margin: 0 0 1em; color: var(--ink-2); }
.text li { margin-bottom: 0.35em; }
.text li::marker { color: var(--gold); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.gold { color: var(--gold); }
.blue { color: var(--blue); }
.num { font-family: var(--f-num); font-size: 0.92em; }

details.more {
  margin: 1.2rem 0 0.6rem;
  border-left: 2px solid var(--line);
  padding: 0.2rem 0 0.2rem 1rem;
}
details.more summary {
  cursor: pointer;
  font-family: var(--f-display);
  font-weight: 600;
  color: var(--blue);
  list-style: none;
}
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+ "; }
details.more[open] summary::before { content: "− "; }
details.more p { margin-top: 0.6rem; font-size: 0.95em; }

.try {
  margin-top: 1.2rem;
  padding: 0.75rem 1rem;
  border-radius: var(--r-md);
  background: rgba(244, 183, 64, 0.08);
  border: 1px solid rgba(244, 183, 64, 0.25);
  color: var(--ink);
  font-size: 0.95em;
}
.try::before { content: "Dene: "; font-family: var(--f-display); font-weight: 700; color: var(--gold); }

/* sunucu notları — ekranda gizli, N ile açılır */
aside.notes { display: none; }

/* ---------- Sahne (etkileşim alanı) ---------- */
.stage {
  position: relative;
  min-height: 0;
  min-width: 0;
  border-radius: 18px;
  background:
    radial-gradient(80% 70% at 50% 40%, rgba(116, 169, 255, 0.06), transparent 70%),
    var(--bg-2);
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.stage.bare { background: transparent; border: 0; }
.stage canvas { display: block; }
.stage .fill { flex: 1; min-height: 0; position: relative; }
.stage .fill > canvas, .stage .fill > svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.controls {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 10px 14px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: rgba(10, 15, 44, 0.55);
  font-family: var(--f-display);
  font-size: 0.9rem;
}
.controls.top { border-top: 0; border-bottom: 1px solid var(--line); }
.controls .spacer { flex: 1; }
.controls label { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }

.btn {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5em 1em;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--gold); color: #1d1300; border-color: var(--gold); }
.btn.primary:hover { background: #ffc85c; }
.btn.on { border-color: var(--gold); color: var(--gold); }
.btn:disabled { opacity: 0.4; cursor: default; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--panel); }
.seg button {
  border: 0; background: transparent; padding: 0.35em 0.9em; border-radius: 999px; cursor: pointer;
  font-family: var(--f-display); font-weight: 600; font-size: 0.86rem; color: var(--ink-2);
}
.seg button.on { background: var(--ink); color: var(--bg); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 140px; height: 22px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--gold); margin-top: -6px; border: 0; box-shadow: 0 0 0 4px rgba(244,183,64,.18);
}
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--gold); border: 0; }
.val { font-family: var(--f-num); font-size: 0.85rem; color: var(--ink); min-width: 3.4em; display: inline-block; }

/* ---------- Alt çubuk ---------- */
#bar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--bar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 var(--gutter);
  z-index: 5;
  font-family: var(--f-display);
  font-size: 0.86rem;
  color: var(--ink-2);
}
#bar .chapter-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 260px; }
#bar .chapter-name b { color: var(--ink); font-weight: 600; }
#progress { flex: 1; display: flex; gap: 6px; align-items: center; min-width: 0; }
#progress .ch { display: flex; gap: 3px; flex: var(--n) 1 0; min-width: 0; }
#progress .dot {
  flex: 1; height: 4px; border-radius: 2px; background: var(--line); cursor: pointer; border: 0; padding: 0;
  transition: background 0.3s;
}
#progress .dot.seen { background: #4a558f; }
#progress .dot.cur { background: var(--gold); }
#bar .counter { font-family: var(--f-num); font-size: 0.8rem; min-width: 4.5em; text-align: right; }
.iconbtn {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--ink);
}
.iconbtn:hover { border-color: var(--muted); }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn.on { border-color: var(--gold); color: var(--gold); }

/* ---------- Notlar paneli ---------- */
#notes {
  position: fixed; right: var(--gutter); bottom: calc(var(--bar-h) + 10px);
  width: min(460px, calc(100vw - 32px)); max-height: 45vh; overflow: auto;
  background: #fff8e6; color: #241a05;
  border-radius: var(--r-md);
  padding: 16px 20px;
  font-size: 1rem; line-height: 1.5;
  z-index: 6;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  display: none;
}
#notes.open { display: block; }
#notes h4 { margin: 0 0 6px; font-family: var(--f-display); font-size: 0.8rem; color: #8a6200; }
#notes ul { margin: 0; padding-left: 1.1em; }

/* ---------- Genel bakış ---------- */
#overview {
  position: fixed; inset: 0; z-index: 8;
  background: rgba(8, 11, 34, 0.96);
  overflow: auto;
  padding: 40px var(--gutter) 60px;
  display: none;
}
#overview.open { display: block; }
#overview h2 { font-size: 1.6rem; margin-bottom: 1.4rem; }
#overview .ov-ch { margin-bottom: 28px; }
#overview .ov-ch h3 { margin: 0 0 10px; color: var(--gold); font-size: 1rem; }
#overview .ov-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
#overview .ov-item {
  text-align: left; padding: 10px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--bg-2); cursor: pointer;
  font-family: var(--f-display); font-size: 0.92rem; color: var(--ink);
  display: flex; gap: 10px;
}
#overview .ov-item span { color: var(--muted); font-family: var(--f-num); font-size: 0.8rem; padding-top: 2px; }
#overview .ov-item.cur { border-color: var(--gold); }
#overview .keys { color: var(--ink-2); font-size: 0.92rem; margin-top: 24px; }
#overview kbd {
  font-family: var(--f-num); font-size: 0.8rem; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; background: var(--panel);
}

/* ---------- Ortak demo bileşenleri ---------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--f-display); font-size: 0.82rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

.overlay-label {
  position: absolute; font-family: var(--f-display); font-size: 0.85rem; color: var(--ink-2); pointer-events: none;
}

table.truth {
  border-collapse: collapse; font-family: var(--f-num); font-size: 0.88rem;
}
table.truth th { font-family: var(--f-display); font-weight: 600; color: var(--muted); font-size: 0.8rem; padding: 4px 10px; text-align: center; }
table.truth td { padding: 5px 10px; text-align: center; border-top: 1px solid var(--line); }
table.truth td.ok { color: var(--pos); }
table.truth td.bad { color: var(--neg); }

.bars { display: grid; gap: 4px; }
.bars .row { display: grid; grid-template-columns: 1.6em 1fr 3.4em; align-items: center; gap: 8px; font-family: var(--f-num); font-size: 0.82rem; }
.bars .track { height: 12px; background: rgba(255,255,255,0.05); border-radius: 3px; overflow: hidden; }
.bars .fillbar { height: 100%; background: var(--blue); border-radius: 3px; transition: width 0.25s; }
.bars .row.top .fillbar { background: var(--gold); }
.bars .row.top { color: var(--gold); }

.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-family: var(--f-display); font-size: 0.8rem;
  border: 1px solid var(--line); color: var(--ink-2);
}

/* ---------- Kapak ---------- */
.cover { padding: 0; }
.cover canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cover .cover-text {
  position: relative; z-index: 2; pointer-events: none;
  text-align: left; align-self: end; justify-self: start;
  padding: 0 var(--gutter) 7vh;
  max-width: 1100px;
}
.cover h1 { margin-bottom: 1.2rem; text-shadow: 0 4px 40px rgba(10, 15, 44, 0.9); }
.cover p { font-size: 1.2rem; color: var(--ink-2); max-width: 46ch; margin: 0 0 1.6rem; }
.cover .hint { font-family: var(--f-display); font-size: 0.9rem; color: var(--muted); }
.cover .hint kbd { font-family: var(--f-num); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; color: var(--ink-2); }

/* ---------- Duyarlı ---------- */
@media (max-width: 860px) {
  body { overflow: auto; }
  #deck { position: relative; inset: auto; }
  .slide {
    position: relative; inset: auto; display: none;
    grid-template-columns: 1fr !important; grid-auto-rows: auto;
    padding: 24px 16px 96px; transform: none !important;
  }
  .slide.active { display: grid; }
  .text { max-height: none; overflow: visible; }
  .stage { min-height: 70vh; }
  .cover { min-height: calc(100vh - var(--bar-h)); }
  #bar { gap: 10px; background: var(--bg); border-top: 1px solid var(--line); }
  #bar .chapter-name { display: none; }
  body.text-hidden .slide .text { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .slide, .slide.active { transition: opacity 0.2s; transform: none; }
}

/* ---------- Sözlük balonları ---------- */
.term {
  color: inherit;
  text-decoration: underline dotted rgba(116, 169, 255, 0.75);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  cursor: help;
  border-radius: 3px;
}
.term:hover, .term:focus-visible { background: rgba(116, 169, 255, 0.12); text-decoration-color: var(--blue); outline: none; }
#gloss {
  position: fixed; z-index: 20;
  width: min(320px, calc(100vw - 24px));
  padding: 12px 14px 12px;
  background: #18215a;
  border: 1px solid rgba(116, 169, 255, 0.45);
  border-radius: var(--r-md);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  font-family: var(--f-body); font-size: 0.9rem; line-height: 1.45; color: var(--ink-2);
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity .15s, transform .15s;
}
#gloss.open { opacity: 1; transform: none; pointer-events: auto; }
#gloss h4 { margin: 0 0 4px; font-family: var(--f-display); font-size: 0.98rem; color: var(--ink); }
#gloss p { margin: 0 0 8px; }
#gloss a { font-family: var(--f-display); font-size: 0.82rem; font-weight: 600; color: var(--blue); text-decoration: none; }
#gloss a:hover { text-decoration: underline; }

/* ---------- Sesli anlatım çubuğu ---------- */
#narrator {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 8px); z-index: 7;
  transform: translate(-50%, 12px);
  width: min(620px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px 8px 8px;
  background: rgba(22, 31, 79, 0.94);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  font-family: var(--f-display); font-size: 0.82rem; color: var(--ink-2);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#narrator.open { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.np-play {
  width: 36px; height: 36px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--gold); color: #1d1300; display: grid; place-items: center;
}
.np-play svg { width: 18px; height: 18px; }
.np-track { flex: 1; min-width: 60px; height: 6px; border-radius: 3px; background: var(--line); cursor: pointer; position: relative; }
.np-track i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 3px; background: var(--gold); }
.np-time { font-family: var(--f-num); font-size: 0.78rem; color: var(--ink); white-space: nowrap; }
.np-auto { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer; }
.np-auto input { accent-color: var(--gold); }
.np-status:empty { display: none; }
.np-status { color: var(--gold); white-space: nowrap; }
.np-close { border: 0; background: transparent; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 6px; }
.np-close:hover { color: var(--ink); }
@media (max-width: 860px) {
  #narrator { border-radius: var(--r-md); flex-wrap: wrap; }
  .np-auto { order: 5; }
}
/* anlatım açıkken slaytlar oynatıcıya yer açar */
body.narrating #deck { bottom: calc(var(--bar-h) + 58px); transition: bottom .2s; }
@media (max-width: 860px) { body.narrating #deck { bottom: auto; padding-bottom: 90px; } }

/* ---------- Deney rehberi ---------- */
#ghost-hand {
  position: fixed; left: 0; top: 0; z-index: 30; width: 34px; height: 34px;
  pointer-events: none; opacity: 0; transition: opacity .25s;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.5));
}
#ghost-hand svg { width: 100%; height: 100%; transition: transform .12s; transform-origin: 34% 12%; }
#ghost-hand.on { opacity: .95; }
#ghost-hand.down svg { transform: scale(.86); }
.ghost-ripple {
  position: fixed; z-index: 29; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  border: 2px solid var(--gold); pointer-events: none; animation: ghostRipple .6s ease-out forwards;
}
@keyframes ghostRipple { to { transform: scale(3.6); opacity: 0; } }
#guide-ring {
  position: fixed; z-index: 6; pointer-events: none; border: 2px solid var(--gold); opacity: 0;
}
#guide-ring.on { animation: guidePulse 1.3s ease-out 3; }
#guide-ring.on.still { animation: none; opacity: 1; box-shadow: 0 0 0 4px rgba(244,183,64,.18), 0 0 22px rgba(244,183,64,.35); }
@keyframes guidePulse {
  0% { opacity: 1; box-shadow: 0 0 0 0 rgba(244,183,64,.55); }
  70% { opacity: .9; box-shadow: 0 0 0 14px rgba(244,183,64,0); }
  100% { opacity: 0; box-shadow: 0 0 0 14px rgba(244,183,64,0); }
}
.try.try-live { cursor: pointer; position: relative; padding-right: 92px; transition: background .2s, border-color .2s; }
.try.try-live:hover, .try.try-live:focus-visible { background: rgba(244,183,64,.14); border-color: rgba(244,183,64,.6); outline: none; }
.try-cta {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--f-display); font-weight: 700; font-size: 0.8rem; color: #1d1300;
  background: var(--gold); border-radius: 999px; padding: 4px 11px 4px 9px;
}
.try-cta::before { content: ""; width: 0; height: 0; border-left: 7px solid #1d1300; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
#guide-toast {
  position: fixed; left: 50%; top: 22px; transform: translate(-50%, -10px); z-index: 40;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px;
  font-family: var(--f-display); font-size: .88rem; color: var(--ink);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#guide-toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { #guide-ring.on { animation: none; opacity: 1; } }
