/* ========== Voice picker modal ========== */
.voice-modal {
  position: fixed;
  inset: 0;
  z-index: 10300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 13, 35, 0.55);
}
.voice-modal.active { display: flex; }

.voice-modal-card {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 22px;
  padding: 28px 28px 24px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  text-align: center;
  font-family: 'Quicksand', sans-serif;
}

.voice-modal-title {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 700;
  color: #1f1d2b;
}

.voice-picker-row {
  display: flex;
  gap: 16px;
}

.voice-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: transform 120ms ease;
  font-family: 'Quicksand', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #1f1d2b;
  text-align: center;
}
.voice-card:active { transform: translateY(1px); }

.voice-avatar {
  width: 128px;
  height: 128px;
  border-radius: 16px;
  border: 1px solid #E6EBF1;
  background: #fafafe;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  transition: border-color 160ms ease;
}
.voice-card:hover .voice-avatar { border-color: #5750f1; }

@media (max-width: 420px) {
  .voice-modal-card { padding: 22px 20px 20px; }
  .voice-picker-row { flex-direction: column; }
}

/* ========== Replay mode ========== */
body.storify-active #btnFinish { display: none !important; }
body.storify-active .stage-arrow { display: none !important; }

/* ---- Autoplay toggle (footer, far left): iOS-style switch + label ---- */
.autoplay-toggle {
  position: absolute;
  left: var(--footer-pad-x, 20px);
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 30;
}
body.storify-active .autoplay-toggle { display: inline-flex; }

.autoplay-toggle-label {
  font-family: 'Quicksand', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: rgba(31, 42, 68, 0.85);
  letter-spacing: 0.2px;
  user-select: none;
}

.autoplay-switch {
  position: relative;
  width: 41px;
  height: 25px;
  border-radius: 999px;
  border: 0;
  padding: 0;
  background: #34C759; /* iOS green = ON */
  cursor: pointer;
  transition: background-color 220ms ease;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
          appearance: none;
  box-shadow: none;
}

/* iOS Safari draws a focus/tap halo (box-shadow ring) on buttons even with
   outline:none. Suppress every state aggressively so the halo never shows up
   when focus drifts onto the switch after recControls rebuilds on page turn. */
.autoplay-switch:focus,
.autoplay-switch:focus-visible,
.autoplay-switch:focus-within,
.autoplay-switch:active,
.autoplay-switch:hover {
  outline: none !important;
  box-shadow: none !important;
  -webkit-box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}

.autoplay-switch-thumb {
  position: absolute;
  top: 2px;
  left: 18px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.22), 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: left 220ms cubic-bezier(0.2, 0.8, 0.3, 1);
  pointer-events: none;
}

.autoplay-switch[aria-checked="false"] {
  background: #E5E5EA;
}
.autoplay-switch[aria-checked="false"] .autoplay-switch-thumb {
  left: 2px;
}

.autoplay-switch:active .autoplay-switch-thumb { width: 24px; }
.autoplay-switch[aria-checked="false"]:active .autoplay-switch-thumb { left: 2px; width: 24px; }
.autoplay-switch[aria-checked="true"]:active .autoplay-switch-thumb { left: 15px; width: 24px; }

/* Portrait: shrink so the label + switch don't collide with the centered
   84px play button. Turkish "Otomatik geçiş" is wider than English
   "Autoplay" and pushes into the play button on narrow viewports. */
@media (orientation: portrait) {
  .autoplay-toggle { gap: 6px; }
  .autoplay-toggle-label { font-size: 11px; letter-spacing: 0; }
  .autoplay-switch { width: 32px; height: 19px; }
  .autoplay-switch-thumb { width: 15px; height: 15px; top: 2px; left: 15px; }
  .autoplay-switch[aria-checked="false"] .autoplay-switch-thumb { left: 2px; }
  .autoplay-switch:active .autoplay-switch-thumb { width: 18px; }
  .autoplay-switch[aria-checked="false"]:active .autoplay-switch-thumb { left: 2px; width: 18px; }
  .autoplay-switch[aria-checked="true"]:active .autoplay-switch-thumb { left: 12px; width: 18px; }
}

/* 250ms page-turn during storify replay. */
body.storify-active .page-turn-left,
body.storify-active .page-turn-right { animation-duration: 250ms; }

/* Row layout: [back arrow] [center play/pause 90px] [invisible spacer]. The
   spacer mirrors the back arrow so the play button stays at the center. */
.storify-row {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.storify-row-spacer {
  display: inline-block;
  width: 54px;
  height: 54px;
  visibility: hidden;
  pointer-events: none;
}

/* Make the small autoplay-OFF center button anchor an inner ring (it is the
   pause button while audio is playing). */
.storify-arrow { position: relative; }

/* Audio playing: thin white progress INSIDE the button, around the pause icon.
   The SVG fills the button (inset: 0), audio.currentTime/duration drives the
   stroke-dashoffset via JS rAF. */
.storify-inner-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: rotate(-90deg);
}
.storify-inner-ring .storify-inner-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 3;
}
.storify-inner-ring .storify-inner-fill {
  fill: none;
  stroke: #ffffff;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 80ms linear;
}

/* Inline flanking arrows (only rendered when paused). Icon-only; the 54×54
   footprint stays as a tap target but no visible background/shadow so it
   doesn't read as a "big white circle" beside the autoplay toggle. */
.storify-arrow {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: transparent;
  color: #4B5563;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms ease;
}
.storify-arrow:active { transform: scale(0.94); }
.storify-arrow svg { display: block; pointer-events: none; }
/* Disabled (first page → left, last page → right): no slide-in animation,
   stays dim and unclickable. */
.storify-arrow--disabled {
  animation: none !important;
  opacity: 0.35 !important;
  pointer-events: none !important;
  cursor: not-allowed;
}

/* Back arrow stays visible without slide-in animation regardless of mode. */
.storify-arrow--left {
  animation: none !important;
  opacity: 1;
  transform: none;
}

/* Play button passive state: when the current page has no audio (red dot). */
.storify-play-disabled {
  opacity: 0.35 !important;
  pointer-events: none !important;
  cursor: not-allowed;
  animation: none !important;
  box-shadow: none !important;
  filter: saturate(0.2);
}

/* Coral star (book-end). */
.rec-circle--star {
  background: #D85A30;
  box-shadow: 0 8px 22px rgba(216, 90, 48, 0.4);
  animation: rec-breath 1.6s ease-in-out infinite;
}

/* Done-state actions: [Baştan dinle] [Kitabı kapat] side-by-side pills. */
body.storify-done .autoplay-toggle { display: none !important; }

.storify-done-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.storify-done-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font-family: 'Quicksand', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms ease, box-shadow 160ms ease, background-color 160ms ease;
  white-space: nowrap;
}
.storify-done-btn:active { transform: scale(0.96); }
.storify-done-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.storify-done-ico svg { display: block; pointer-events: none; }

/* Primary: replay (coral, like the star). */
.storify-done-btn--replay {
  background: #D85A30;
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(216, 90, 48, 0.32);
}
.storify-done-btn--replay:hover { background: #c2511f; }

/* Secondary: close (neutral gray). */
.storify-done-btn--close {
  background: #F1EFE8;
  color: #4B5563;
}
.storify-done-btn--close:hover { background: #e6e2d4; }

@media (max-width: 480px) {
  .storify-done-row { gap: 8px; }
  .storify-done-btn { height: 44px; padding: 0 14px; font-size: 13px; }
}

/* Confetti overlay. */
.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10500;
}

/* ========== Storify generation overlay ========== */
.storify-overlay {
  position: fixed;
  inset: 0;
  z-index: 10400;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
  background: rgba(20, 16, 50, 0.78);
  color: #ffffff;
  font-family: 'Quicksand', sans-serif;
}
.storify-overlay.active { display: flex; }

.storify-spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.22);
  border-top-color: #ffffff;
  animation: storifySpin 900ms linear infinite;
}

@keyframes storifySpin {
  to { transform: rotate(360deg); }
}

.storify-status {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.storify-status-text {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.storify-progress {
  font-size: 15px;
  font-weight: 500;
  opacity: 0.85;
}
