/* Zemin renkleri dergiye göre değişir; @property ile renkler yumuşak geçer */
@property --zemin-1 { syntax: "<color>"; inherits: true; initial-value: #8f877e; }
@property --zemin-2 { syntax: "<color>"; inherits: true; initial-value: #5e5750; }
@property --zemin-3 { syntax: "<color>"; inherits: true; initial-value: #34302c; }
@property --isik-renk { syntax: "<color>"; inherits: true; initial-value: #d6cdc2; }
:root {
  --zemin-1: #8f877e;
  --zemin-2: #5e5750;
  --zemin-3: #34302c;
  --isik-renk: #d6cdc2;
  --yazi: #f3efe9;
  --yazi-soluk: rgba(243, 239, 233, .58);
  --cizgi: rgba(243, 239, 233, .18);
  --gutter: clamp(16px, 3vw, 40px);
  --ust-h: 72px;
  --alt-h: 96px;
  --kayma: 0px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Host Grotesk", system-ui, sans-serif;
  color: var(--yazi);
  background: var(--zemin-3);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: --zemin-1 1.2s ease, --zemin-2 1.2s ease, --zemin-3 1.2s ease, --isik-renk 1.2s ease;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
button:focus:not(:focus-visible) { outline: none; }
button:focus-visible { outline: 1px solid var(--yazi); outline-offset: 2px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.4; }

/* Stüdyo ışığı: sol alttan yumuşak ışık, sıcak gri duvar */
.isik {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(90% 70% at 12% 92%, color-mix(in srgb, var(--isik-renk) 75%, transparent), transparent 60%),
    radial-gradient(70% 60% at 30% 40%, rgba(160, 150, 139, .55), transparent 70%),
    linear-gradient(115deg, var(--zemin-1) 0%, var(--zemin-2) 45%, var(--zemin-3) 100%);
}
.isik::after {
  content: ""; position: absolute; inset: 0; opacity: .09; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Üst */
.ust {
  height: var(--ust-h); flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 var(--gutter);
}
.marka { display: flex; flex-direction: column; gap: 2px; }
.marka__ad { font-size: 14px; font-weight: 500; letter-spacing: .01em; }
.marka__alt, .baslik__no { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--yazi-soluk); }
.baslik { display: flex; align-items: baseline; gap: 12px; text-align: right; }
.baslik__ad { font-size: 14px; font-weight: 400; }
.baslik.degisiyor .baslik__ad, .baslik.degisiyor .baslik__no { opacity: 0; transform: translateY(6px); }
.baslik__ad, .baslik__no { transition: opacity .35s, transform .35s; }

/* Sahne */
.sahne {
  position: relative; flex: 1; min-height: 0;
  overflow: clip; /* kapakta/arka kapakta kayan boş yarı sayfayı dışarı taşırmasın */
}
.suzul, .egim, .kaydir, .kitap-yeri { position: absolute; inset: 0; }
.suzul { inset: 4% calc(var(--gutter) + max(72px, 6vw)) 6%; animation: suzul 7s ease-in-out infinite; }
.egim {
  transform: none;
  transition: transform .9s cubic-bezier(.22, .8, .2, 1), opacity .7s;
}
.kaydir { transform: translateX(var(--kayma)) scale(var(--olcek, 1)); transition: transform .8s cubic-bezier(.22, .8, .2, 1); }
/* büyütülmüş kapakta dokunmayı app.js karşılar */
body.kapak-buyuk .kitap-yeri { pointer-events: none; }

/* Okurken süzülme durur (sayfa çevirme rahat olsun) */
body.okuma .suzul { animation-play-state: paused; }

@keyframes suzul {
  0%, 100% { transform: translate3d(0, -6px, 0); }
  50% { transform: translate3d(0, 8px, 0); }
}

/* Yerdeki yumuşak gölge */
.golge {
  position: absolute; left: 50%; bottom: 1%;
  width: 46%; height: 7%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(20, 16, 12, .42), transparent);
  filter: blur(14px);
  animation: golge 7s ease-in-out infinite;
  transition: opacity .6s;
}
@keyframes golge {
  0%, 100% { transform: translateX(-50%) scale(.92); opacity: .75; }
  50% { transform: translateX(-50%) scale(1.04); opacity: 1; }
}

/* Dergi geçişi: eskisi yukarı süzülüp gider, yenisi aşağıdan gelir (eğilmeden) */
.egim.cikis { transition: transform .5s cubic-bezier(.6, 0, .8, .4), opacity .4s; opacity: 0;
  transform: translateY(-8%) scale(.96); }
.egim.giris { transition: none; opacity: 0;
  transform: translateY(10%) scale(.96); }
.egim { opacity: 1; }

/* Kitap */
.kitap-yeri > .kitap { position: absolute; inset: 0; }
.kitap-yeri .stf__parent { margin: 0 auto; }
.sayfa { background: #f4f2ed; overflow: hidden; user-select: none; }
.sayfa img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
.sayfa__renk { position: absolute; inset: 0; }
/* Cilt yeri gölgesi */
/* Kağıt hissi: tek katmanda gren + ışık düşüşü + cilt yeri gölgesi (sabit, çevirmede ek yük yok) */
.sayfa::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: url("kagit.png"), var(--isik), var(--cilt);
  /* doku görseli kendi boyutunda (128 px) tekrar eder, geçişler sayfayı kaplar */
}
.sayfa.--left {
  /* cilde doğru kağıt içeri kıvrılır: derin gölge → yumuşak geçiş → kıvrımın tepesinde ince parlama */
  --cilt: linear-gradient(to left,
    rgba(0,0,0,.34) 0%, rgba(0,0,0,.16) 1.2%, rgba(0,0,0,.06) 3%,
    rgba(255,255,255,.10) 5.5%, rgba(255,255,255,.04) 8%, rgba(0,0,0,.025) 12%, transparent 20%);
  /* ışık sol üstten: üst kenar biraz parlak, alt dış köşe hafif koyu */
  --isik: radial-gradient(130% 100% at 15% 0%, rgba(255,255,255,.09), transparent 55%),
          linear-gradient(to bottom, transparent 75%, rgba(0,0,0,.035));
}
.sayfa.--right {
  --cilt: linear-gradient(to right,
    rgba(0,0,0,.28) 0%, rgba(0,0,0,.12) 1.2%, rgba(0,0,0,.04) 3%,
    rgba(255,255,255,.12) 5%, rgba(255,255,255,.05) 7.5%, rgba(0,0,0,.02) 11%, transparent 18%);
  --isik: radial-gradient(130% 100% at 40% 0%, rgba(255,255,255,.07), transparent 55%),
          linear-gradient(to bottom, transparent 70%, rgba(0,0,0,.045)),
          linear-gradient(to left, rgba(0,0,0,.03), transparent 12%);
}
/* Sayfa kalınlığı: dış kenarda ince sayfa katmanları */
.sayfa::before { content: ""; position: absolute; top: 0; bottom: 0; width: 5px; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(to right, rgba(0,0,0,.10) 0 1px, rgba(255,255,255,.0) 1px 2px); opacity: .7; }
.sayfa.--left::before { left: 0; }
.sayfa.--right::before { right: 0; }

/* Derginin gölgesi her sayfanın kendisinde: sayfa nerede ise gölge orada (filtre yok, hafif) */
.stf__item { box-shadow: 0 30px 50px -16px rgba(20, 16, 12, .5), 0 6px 12px -4px rgba(20, 16, 12, .25); }
/* Kapak dönerken (kütüphane satır içi rotateY yazar) gölge gri bir kutu gibi kalmasın */
.stf__item[style*="rotateY"] { box-shadow: none; }
/* Sert kapağın karşı tarafa düşen gölgesi: kapak çevrilirken altında sayfa yok, zeminde kutu gibi kalıyor */
.stf__hardShadow { visibility: hidden; }
/* Kapağın yanındaki görünmez boş sayfa */
.sayfa.sayfa--bos { background: none; box-shadow: none; }
.sayfa.sayfa--bos::before, .sayfa.sayfa--bos::after { content: none; }
.kitap.bos-acik .stf__outerShadow { visibility: hidden; }
.stf__item[data-kirp] { box-shadow: none; }

/* Oklar */
.ok {
  position: absolute; top: 50%; z-index: 5;
  width: 48px; height: 48px; margin-top: -24px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--yazi); border: 1px solid var(--cizgi);
  background: rgba(40, 35, 31, .18); backdrop-filter: blur(6px);
  transition: background .25s, opacity .25s;
}
.ok:hover { background: rgba(40, 35, 31, .4); }
.ok:disabled { opacity: .25; cursor: default; }
.ok--geri { left: var(--gutter); }
.ok--ileri { right: var(--gutter); }

/* Alt */
.alt {
  height: var(--alt-h); flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 0 var(--gutter) env(safe-area-inset-bottom);
}
.secici { display: flex; gap: 8px; }
.secim {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 16px 6px 6px; border-radius: 6px;
  border: 1px solid transparent; text-align: left;
  transition: background .25s, border-color .25s;
}
.secim:hover { background: rgba(255, 255, 255, .06); }
.secim[aria-current="true"] { border-color: var(--cizgi); background: rgba(255, 255, 255, .08); }
.secim img { width: 44px; height: 44px; object-fit: cover; border-radius: 2px; box-shadow: 0 4px 10px rgba(0,0,0,.3); }
.secim__yazi { display: flex; flex-direction: column; gap: 3px; }
.secim__no { font-size: 11px; letter-spacing: .14em; color: var(--yazi-soluk); }
.secim__ad { font-size: 13px; white-space: nowrap; }

.kontrol { display: flex; align-items: center; gap: 8px; }
.sayac { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--yazi-soluk); min-width: 96px; text-align: right; margin-right: 8px; }
.ikon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--cizgi); transition: background .25s; }
.ikon:hover { background: rgba(255, 255, 255, .08); }

/* Tüm sayfalar */
.izgara {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(30, 27, 24, .86); backdrop-filter: blur(14px);
  display: flex; flex-direction: column;
  animation: belir .3s ease;
}
.izgara[hidden] { display: none; }
@keyframes belir { from { opacity: 0; } }
.izgara__ust { display: flex; justify-content: space-between; align-items: center; padding: 16px var(--gutter); font-size: 14px; }
.izgara__liste {
  flex: 1; overflow-y: auto; padding: 8px var(--gutter) 40px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 28px 20px; align-content: start;
}
.kucuk { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.kucuk__resim { display: flex; justify-content: center; width: 100%; }
.kucuk__resim img, .kucuk__resim span { display: block; width: 50%; height: auto; aspect-ratio: 1; object-fit: cover; box-shadow: 0 6px 16px rgba(0,0,0,.35); }
.kucuk__resim span { display: block; background: var(--arka); }
.kucuk__no { font-size: 12px; color: var(--yazi-soluk); font-variant-numeric: tabular-nums; }
.kucuk:hover .kucuk__resim img { outline: 1px solid var(--yazi); }
.kucuk.aktif .kucuk__no { color: var(--yazi); }

/* Büyük ekran (iMac): arayüz yazıları büyüsün */
@media (min-width: 1800px) {
  .ust, .alt, .ok { zoom: 1.5; }
}
/* Tablet */
@media (max-width: 1100px) {
  .suzul { inset: 4% calc(var(--gutter) + 56px) 6%; }
  .secim { padding-right: 10px; }
  .secim__ad { display: none; }
}
/* Telefon */
@media (max-width: 640px) {
  :root { --ust-h: 64px; --alt-h: 128px; }
  .baslik__no { display: none; }
  .marka__ad { font-size: 13px; }
  .baslik__ad { font-size: 13px; }
  .suzul { inset: 2% var(--gutter); }
  .ok { display: none; }
  .alt { flex-direction: column; justify-content: center; gap: 12px; }
  .secici { width: 100%; justify-content: space-between; }
  .secim { flex: 1; justify-content: center; padding: 6px; }
  .secim__yazi { display: none; }
  .kontrol { width: 100%; }
  .sayac { text-align: left; margin-right: auto; }
  .izgara__liste { grid-template-columns: repeat(2, 1fr); gap: 20px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .suzul, .golge { animation: none; }
}
