/*
 * DEHB temalı küçük dokunuşlar: dağınık noktaların toparlanması, başlıkta fosforlu kalem,
 * nefes molası ve odak modu. Girişler tek seferliktir; nefes ve odak modu yalnızca kullanıcı
 * başlatınca çalışır. "Hareketi azalt" tercihinde base.css'teki genel kural hepsini kapatır.
 */

/* ---------- Fosforlu kalem ---------- */
.marker {
  background: linear-gradient(
      transparent 60%,
      color-mix(in srgb, var(--color-highlight) 50%, transparent) 60%
    )
    no-repeat left / 100% 100%;
}

/* ---------- Dağınık başlayıp sıraya giren noktalar ---------- */
.focus-dots {
  position: absolute;
  top: calc(-1 * var(--space-3));
  right: calc(-1 * var(--space-4));
  z-index: 1;
  display: flex;
  gap: 0.375rem;
}
.focus-dots span {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--color-accent);
}
.focus-dots span:nth-child(3n + 2) {
  background: var(--color-highlight);
}
.focus-dots span:nth-child(3n) {
  background: var(--color-text-muted);
}

/* ---------- Nefes molası ---------- */
.breath {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  text-align: center;
}
.breath__stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 12rem;
  height: 12rem;
}
.breath--compact .breath__stage {
  width: 10.5rem;
  height: 10.5rem;
}
.breath--compact .breath__label {
  max-width: 6rem;
}
.breath__circle {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--color-shape), var(--color-surface-muted));
  border: 2px solid var(--color-highlight);
  transform: scale(0.72);
}
.breath[data-phase='in'] .breath__circle,
.breath[data-phase='hold'] .breath__circle {
  transform: scale(1);
}
.breath__label {
  position: relative;
  max-width: 7rem;
  margin: 0;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1.3;
}
.breath__controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-target);
}
/* Widget: kendiliğinden açılmaz; yalnızca düğmeye basınca görünür. */
.breath-widget {
  position: fixed;
  left: var(--space-4);
  bottom: var(--space-4);
  z-index: 20;
  display: grid;
  justify-items: start;
  gap: var(--space-3);
}
.breath-widget[hidden],
.breath-widget__panel[hidden],
.focus-mode .breath-widget__fab:not(.is-running, .is-done) {
  display: none;
}
.breath-widget__fabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.breath-widget__fab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-target);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--border-width) solid var(--color-highlight);
  border-radius: 999px;
  box-shadow: 0 8px 24px -12px rgb(29 27 38 / 0.45);
  font: inherit;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
}
.breath-widget__dot {
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  background: var(--color-highlight);
}
.breath-widget__panel {
  display: grid;
  gap: var(--space-3);
  width: min(19rem, calc(100vw - 2 * var(--space-4)));
  padding: var(--space-4) var(--space-5) var(--space-5);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px -16px rgb(29 27 38 / 0.5);
  transform-origin: bottom left;
}
.breath-widget__panel p {
  margin: 0;
}
.breath-widget__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.breath-widget__title {
  font-weight: var(--font-weight-bold);
}
.breath-widget__close {
  display: grid;
  place-items: center;
  width: var(--tap-target);
  height: var(--tap-target);
  margin-right: calc(-1 * var(--space-3));
  background: none;
  color: var(--color-text-muted);
  border: 0;
  border-radius: 50%;
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
@media print {
  .breath-widget {
    display: none;
  }
}

/* ---------- Odak modu ---------- */
.focus-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}
.focus-row[hidden],
.focus-exit[hidden] {
  display: none;
}
.focus-exit {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 20;
  min-height: var(--tap-target);
  padding: var(--space-2) var(--space-4);
  background: var(--color-text);
  color: var(--color-bg);
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: var(--font-size-sm);
  cursor: pointer;
}
.focus-mode .site-header {
  transform: translateY(-100%);
}
.focus-mode .site-header:focus-within {
  transform: none;
}
.focus-mode .notify,
.focus-mode .site-footer,
.focus-mode .article ~ section {
  opacity: 0.15;
}
.focus-mode .notify:hover,
.focus-mode .notify:focus-within,
.focus-mode .site-footer:hover,
.focus-mode .site-footer:focus-within,
.focus-mode .article ~ section:hover,
.focus-mode .article ~ section:focus-within {
  opacity: 1;
}
.focus-mode .prose > * {
  opacity: 0.3;
}
.focus-mode .prose > .is-focus,
.focus-mode .prose > .is-reading,
.focus-mode .prose > :focus-within {
  opacity: 1;
}

/* ---------- Okuma: kalan süre, kaldığın yerden devam, bitiş ---------- */
.read-pill {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 19;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-2);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: 999px;
  box-shadow: 0 8px 24px -12px rgb(29 27 38 / 0.45);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}
.read-pill[hidden],
.resume[hidden] {
  display: none;
}
.focus-mode .read-pill {
  bottom: calc(var(--space-4) + var(--tap-target) + var(--space-2));
}
.read-pill__ring {
  transform: rotate(-90deg);
}
.read-pill__track,
.read-pill__bar {
  fill: none;
  stroke-width: 3;
}
.read-pill__track {
  stroke: var(--color-border);
}
.read-pill__bar {
  stroke: var(--color-accent);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}
.resume {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--color-shape);
  border-radius: var(--radius-md);
}
.resume p {
  flex: 1 1 14rem;
  margin: 0;
}
.resume__dismiss {
  min-height: var(--tap-target);
  padding: 0;
  background: none;
  border: 0;
  color: var(--color-text);
  font: inherit;
  font-size: var(--font-size-sm);
  text-decoration: underline;
  cursor: pointer;
}
.read-done {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
}
.read-done > .stack-sm {
  flex: 1 1 14rem;
}
.read-done p {
  margin: 0;
}
.read-done__title {
  font-weight: var(--font-weight-bold);
}
.read-done__mark {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--color-surface-muted);
  color: var(--color-accent);
}
.read-done__confetti i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.5rem;
  height: 0.5rem;
  margin: -0.25rem;
  border-radius: 50%;
  background: var(--color-highlight);
  opacity: 0;
}
.read-done__confetti i:nth-child(even) {
  background: var(--color-accent);
  border-radius: 2px;
}

/* ---------- Yazı boyutu ---------- */
.read-size {
  display: inline-flex;
  gap: var(--space-2);
}
.focus-row__hint {
  flex: 1 1 100%;
}
[data-read-size='1'] .prose {
  font-size: 1.25rem;
}
[data-read-size='2'] .prose {
  font-size: 1.4rem;
  line-height: 1.8;
}
.prose h2 {
  scroll-margin-top: 6rem;
}

/* ---------- Ara başlık haritası: yalnızca geniş ekranda, yazının solunda ---------- */
.toc {
  display: none;
}
@media (min-width: 80rem) {
  .toc:not([hidden]) {
    position: fixed;
    top: 8rem;
    right: calc(50% + 25.5rem);
    display: block;
    width: 13rem;
    max-height: calc(100vh - 14rem);
    overflow-y: auto;
    font-size: 0.875rem;
    line-height: 1.4;
  }
  .focus-mode .toc:not([hidden]) {
    display: none;
  }
}
.toc__title {
  margin: 0 0 var(--space-2);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
}
.toc ol {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 2px solid var(--color-border);
}
.toc a {
  display: block;
  margin-left: -2px;
  padding: var(--space-1) var(--space-3);
  border-left: 2px solid transparent;
  color: var(--color-text-muted);
  text-decoration: none;
}
.toc a:hover {
  color: var(--color-text);
}
.toc a[aria-current='location'] {
  border-left-color: var(--color-accent);
  color: var(--color-accent);
  font-weight: var(--font-weight-medium);
}

/* ---------- Podcast: ses dalgası ---------- */
.wave {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 0.875rem;
  margin-right: var(--space-1);
  vertical-align: -1px;
}
.wave i {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--color-accent);
  transform: scaleY(0.4);
}
.wave i:nth-child(2) { transform: scaleY(0.8); }
.wave i:nth-child(3) { transform: scaleY(1); }
.wave i:nth-child(4) { transform: scaleY(0.6); }

@media (prefers-reduced-motion: no-preference) {
  .marker {
    animation: marker-draw 700ms var(--motion-ease) 900ms backwards;
  }
  .focus-dots span {
    animation: dots-gather 1400ms var(--motion-ease) 500ms backwards;
  }
  .focus-dots span:nth-child(1) { --dx: -3.5rem; --dy: 2.5rem; }
  .focus-dots span:nth-child(2) { --dx: 1.5rem; --dy: -2.25rem; }
  .focus-dots span:nth-child(3) { --dx: -1.25rem; --dy: 4rem; }
  .focus-dots span:nth-child(4) { --dx: 2.25rem; --dy: 3rem; }
  .focus-dots span:nth-child(5) { --dx: -2.5rem; --dy: -1.5rem; }
  .focus-dots span:nth-child(6) { --dx: 1rem; --dy: 5rem; }
  .focus-dots span:nth-child(7) { --dx: -4.5rem; --dy: 1rem; }

  .read-pill,
  .resume {
    animation: widget-in var(--motion-base) var(--motion-ease);
  }
  .read-pill__bar {
    transition: stroke-dashoffset var(--motion-base) linear;
  }
  .is-done .read-done__mark {
    animation: pop 500ms var(--motion-ease);
  }
  .is-done .read-done__tick {
    stroke-dasharray: 1;
    animation: tick-draw 500ms var(--motion-ease) 150ms backwards;
  }
  .is-done .read-done__confetti i {
    animation: confetti 900ms var(--motion-ease) 250ms;
  }
  .read-done__confetti i:nth-child(1) { --cx: 0rem; --cy: -2.75rem; }
  .read-done__confetti i:nth-child(2) { --cx: 2rem; --cy: -2rem; }
  .read-done__confetti i:nth-child(3) { --cx: 2.75rem; --cy: 0rem; }
  .read-done__confetti i:nth-child(4) { --cx: 2rem; --cy: 2rem; }
  .read-done__confetti i:nth-child(5) { --cx: 0rem; --cy: 2.75rem; }
  .read-done__confetti i:nth-child(6) { --cx: -2rem; --cy: 2rem; }
  .read-done__confetti i:nth-child(7) { --cx: -2.75rem; --cy: 0rem; }
  .read-done__confetti i:nth-child(8) { --cx: -2rem; --cy: -2rem; }

  .toc a {
    transition:
      color var(--motion-fast) var(--motion-ease),
      border-color var(--motion-fast) var(--motion-ease);
  }
  .prose {
    transition: font-size var(--motion-base) var(--motion-ease);
  }
  /* Kitap kapağı: üstüne gelince kapak aralanır, arkasından sayfalar görünür. */
  .book-hero .book-cover--large {
    transform-origin: left center;
    transition:
      transform var(--motion-slow) var(--motion-ease),
      box-shadow var(--motion-slow) var(--motion-ease);
  }
  .book-hero:hover .book-cover--large {
    transform: perspective(700px) rotateY(-24deg);
    box-shadow:
      5px 0 0 -1px var(--color-surface),
      6px 0 0 -1px var(--color-border),
      11px 0 0 -2px var(--color-surface),
      12px 0 0 -2px var(--color-border),
      17px 0 0 -3px var(--color-surface),
      18px 0 0 -3px var(--color-border),
      30px 14px 30px -18px rgb(29 27 38 / 0.5);
  }
  /* Yazı kartı: üstüne gelince saat bir tur döner. */
  .card:hover .icon--clock,
  .card:focus-within .icon--clock {
    animation: clock-turn 800ms var(--motion-ease);
  }

  /* Dalga yalnızca kartın üstündeyken (ya da klavyeyle içindeyken) kıpırdar. */
  .episode-list__item:hover .wave i,
  .episode-list__item:focus-within .wave i {
    animation: wave 900ms ease-in-out var(--wave-delay, 0ms) infinite alternate;
  }
  .wave i:nth-child(2) { --wave-delay: -300ms; }
  .wave i:nth-child(3) { --wave-delay: -600ms; }
  .wave i:nth-child(4) { --wave-delay: -150ms; }
  .wave i:nth-child(5) { --wave-delay: -450ms; }

  .breath-widget__panel {
    animation: widget-in var(--motion-base) var(--motion-ease);
  }
  .breath-widget__fab {
    transition:
      transform var(--motion-fast) var(--motion-ease),
      box-shadow var(--motion-fast) var(--motion-ease);
  }
  .breath-widget__fab:hover {
    transform: translateY(-2px);
  }
  .breath[data-phase='in'] .breath__circle {
    transition: transform 4s ease-in-out;
  }
  .breath[data-phase='out'] .breath__circle {
    transition: transform 6s ease-in-out;
  }
  .focus-mode .site-header {
    transition: transform var(--motion-slow) var(--motion-ease);
  }
  .notify,
  .site-footer,
  .article ~ section,
  .prose > * {
    transition: opacity var(--motion-slow) var(--motion-ease);
  }
}

@keyframes marker-draw {
  from {
    background-size: 0% 100%;
  }
}
@keyframes dots-gather {
  from {
    opacity: 0;
    transform: translate(var(--dx, 0), var(--dy, 0)) scale(1.6);
  }
  35% {
    opacity: 1;
  }
}
@keyframes widget-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
}
@keyframes tick-draw {
  from {
    stroke-dashoffset: 1;
  }
}
@keyframes confetti {
  from {
    opacity: 1;
    transform: translate(0, 0) scale(0.4);
  }
  to {
    opacity: 0;
    transform: translate(var(--cx, 0), var(--cy, 0)) scale(1);
  }
}
@keyframes wave {
  from {
    transform: scaleY(0.3);
  }
  to {
    transform: scaleY(1);
  }
}
@keyframes clock-turn {
  to {
    transform: rotate(360deg);
  }
}
