/* ============================================================
   recording.css — 5-state mic button + integrated player
   Step 1+2: UI scaffolding (state machine + render).
   Audio analyser / waveform / silence detection wired in Step 3.
   ============================================================ */

.rec-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 96px;
  width: 100%;
  padding: 0 16px;
  position: relative;
}

.rec-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* ---- Big circular button (idle / recording / play / pause) ---- */
.rec-circle {
  width: 90px;
  height: 90px;
  min-width: 90px;
  border-radius: 50%;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  position: relative;
  color: #fff;
  transition: background-color 200ms ease, transform 120ms ease;
  -webkit-tap-highlight-color: transparent;
}

.rec-circle svg { display: block; pointer-events: none; }
.rec-circle:active { transform: scale(0.97); }
.rec-circle[disabled] { opacity: 0.5; cursor: not-allowed; }

/* --- Idle: green breathing (the mic button) --- */
.rec-circle--idle {
  background: #1D9E75;
  box-shadow: 0 8px 22px rgba(29, 158, 117, 0.35);
  animation: rec-breath 2s ease-in-out infinite;
}
@keyframes rec-breath {
  0%, 100% { transform: scale(0.97); }
  50%      { transform: scale(1.03); }
}

/* --- Recording: red + pulse ring --- */
.rec-circle--recording {
  background: #E24B4A;
  box-shadow: 0 8px 22px rgba(226, 75, 74, 0.35);
}
.rec-circle--recording::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid #F09595;
  opacity: 0.6;
  animation: rec-pulse 1.4s ease-out infinite;
  pointer-events: none;
}
@keyframes rec-pulse {
  0%   { transform: scale(0.9); opacity: 0.7; }
  70%  { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}

/* Stop square inside the recording circle */
.rec-stop-square {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: #fff;
}

/* --- Play (green) --- */
.rec-circle--play {
  background: #1D9E75;
  box-shadow: 0 8px 22px rgba(29, 158, 117, 0.35);
}
.rec-circle--pause {
  background: #1D9E75;
  box-shadow: 0 8px 22px rgba(29, 158, 117, 0.35);
}

/* SVG ring container for playback progress */
.rec-ring-wrap {
  position: relative;
  width: 90px;
  height: 90px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rec-ring-wrap .rec-circle {
  position: relative;
  z-index: 1;
}
.rec-ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}
.rec-ring-svg .rec-ring-track {
  fill: none;
  stroke: rgba(29, 158, 117, 0.18);
  stroke-width: 4;
}
.rec-ring-svg .rec-ring-fill {
  fill: none;
  stroke: #1D9E75;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 60ms linear;
}

/* ---- Side buttons (refresh, next-arrow) ---- */
.rec-side-btn {
  width: 54px;
  height: 54px;
  min-width: 54px;
  border-radius: 50%;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: background-color 160ms ease, transform 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.rec-side-btn:active { transform: scale(0.95); }
.rec-side-btn svg { display: block; pointer-events: none; }

/* Enlarge tap target without changing visual size */
.rec-side-btn::before {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
}

.rec-side-btn--refresh {
  background: #F1EFE8;
  color: #4B5563;
  overflow: hidden;
}
.rec-side-btn--refresh .rec-refresh-progress {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(rgba(125, 211, 252, 0.45) calc(var(--press, 0) * 360deg), transparent 0);
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}
.rec-side-btn--refresh[data-pressing="1"] .rec-refresh-progress { opacity: 1; }

.rec-side-btn--next {
  background: #7F77DD;
  color: #fff;
  box-shadow: 0 6px 14px rgba(127, 119, 221, 0.32);
}

/* Recording review actions — delete (secondary red), confirm (green). */
.rec-side-btn--delete {
  background: rgba(226, 75, 74, 0.2);
  color: #E24B4A;
}
.rec-side-btn--confirm {
  width: 65px;
  height: 65px;
  min-width: 65px;
  background: #1D9E75;
  color: #fff;
  box-shadow: 0 8px 22px rgba(29, 158, 117, 0.35);
  animation: rec-breath 2s ease-in-out infinite;
}
.rec-side-btn--confirm svg { width: 26px; height: 26px; }

/* Hover tooltip for delete + confirm buttons — desktop only (no touch). */
@media (hover: hover) {
  .rec-side-btn--delete::after,
  .rec-side-btn--confirm::after {
    content: attr(aria-label);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 7px 12px;
    background: #1f2937;
    color: #fff;
    border-radius: 10px;
    font-family: 'Quicksand', sans-serif;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    z-index: 2;
  }
  .rec-side-btn--delete:hover::after,
  .rec-side-btn--confirm:hover::after {
    opacity: 1;
  }
}

/* Review/Playing footer row — delete + (larger) confirm sitting close together. */
.rec-row--actions {
  gap: 16px;
}

/* ---- Floating listen overlay (centered on the book during review/playing) ---- */
.rec-listen-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 108px;
  height: 108px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: transparent;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 6;
  -webkit-tap-highlight-color: transparent;
}
.rec-listen-overlay.visible { display: inline-flex; }
.rec-listen-overlay svg { display: block; pointer-events: none; }
.rec-listen-overlay-ico {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.rec-listen-overlay:active .rec-listen-overlay-ico { transform: scale(0.96); }

/* Hover tooltip — desktop only (no touch). Reads localized aria-label. */
@media (hover: hover) {
  .rec-listen-overlay::after {
    content: attr(aria-label);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 7px 12px;
    background: #1f2937;
    color: #fff;
    border-radius: 10px;
    font-family: 'Quicksand', sans-serif;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  }
  .rec-listen-overlay::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1f2937;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }
  .rec-listen-overlay:hover::after,
  .rec-listen-overlay:hover::before {
    opacity: 1;
  }
}
/* Hide tooltip while playing (icon is pause, not headphones). */
.rec-listen-overlay--playing::after,
.rec-listen-overlay--playing::before {
  display: none;
}

/* Progress ring around the overlay (only present in playing mode). */
.rec-listen-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}
.rec-listen-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 6;
}
.rec-listen-ring-fill {
  fill: none;
  stroke: #ffffff;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 60ms linear;
}

/* ---- Equalizer (footer-left) — mirrors student-panel header EQ ---- */
.rec-equalizer {
  position: absolute;
  left: var(--footer-pad-x, 20px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 36px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.rec-equalizer.active { opacity: 1; }
.rec-equalizer span {
  display: block;
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background-color: #E24B4A;
  opacity: 0.22;
  transition: height 90ms linear, opacity 90ms linear;
}

@media (max-width: 480px) {
  .rec-equalizer { left: 12px; gap: 2px; }
  .rec-equalizer span { width: 2px; }
}

/* ---- Transitioning: green check overlay ---- */
.rec-transition {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #EAF3DE;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #3B6D11;
  animation: rec-check-pop 500ms cubic-bezier(0.2, 0.8, 0.3, 1.2) both;
}
@keyframes rec-check-pop {
  0%   { transform: scale(0);   opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1);   opacity: 1; }
}

/* ---- Tooltip (silence detection — wired in Step 3) ---- */
.rec-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}
.rec-tooltip.show { opacity: 1; }
.rec-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1f2937;
}

/* ---- Mobile tweaks ---- */
@media (max-width: 480px) {
  .rec-controls { padding: 0 16px; }
  .rec-circle { width: 84px; height: 84px; }
  .rec-ring-wrap { width: 84px; height: 84px; }
}

/* ============================================================
   Stage-side page arrows (left/right of the book viewport).
   Hidden on first page (left) / last page (right) via JS.
   ============================================================ */
.stage-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 14px rgba(20, 10, 50, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  z-index: 5;
  transition: background-color 160ms ease, transform 120ms ease, opacity 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.stage-arrow:hover { background: #fff; }
.stage-arrow:active { transform: translateY(-50%) scale(0.94); }
.stage-arrow svg { display: block; pointer-events: none; }

.stage-arrow--left  { left: 8px; }
.stage-arrow--right { right: 8px; }

.stage-arrow.hidden,
.stage-arrow[hidden] {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

@media (max-width: 480px) {
  .stage-arrow { width: 40px; height: 40px; }
  .stage-arrow--left  { left: 6px; }
  .stage-arrow--right { right: 6px; }
}

/* ============================================================
   Footer layout override — prev/next buttons removed, center is
   absolutely centered so right-side progress doesn't shift it.
   ============================================================ */
.reader-footer {
  display: flex !important;
  align-items: center;
  justify-content: flex-end;
  grid-template-columns: none !important;
  column-gap: 0 !important;
}

.reader-footer .footer-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  pointer-events: none;
}
.reader-footer .footer-center > * {
  pointer-events: auto;
}

.reader-footer .footer-nav-right {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: auto;
  min-width: 0;
}

/* Page number (top, right-aligned) + clickable per-page dots (below).
   Gray = not visited. Red = visited but no recording. Green = recorded.
   Ring outline = current page. Now lives in the topbar, right-aligned. */
.reader-progress {
  width: auto;
  max-width: none;
  margin: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  padding: 0;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.reader-topbar .reader-progress {
  grid-column: 3;
  justify-self: end;
  align-self: center;
  padding-right: 6px;
  flex-shrink: 0;
}
.reader-progress.hidden {
  visibility: hidden;
  pointer-events: none;
}
.rec-progress-label {
  font-family: 'Nunito', sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: rgba(31, 42, 68, 0.78);
  white-space: nowrap;
}
.rec-dots {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}
/* Each .rec-dot is a 12×22 transparent hit cell with the visible 6px dot
   centered inside (::after). Cells abut with no gap, so adjacent tap zones
   never overlap and the visible gap is exactly the cell padding (≈6px). */
.rec-dot {
  width: 12px;
  height: 22px;
  min-width: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.rec-dot::after {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d1d5db;
  transition: background-color 160ms ease, transform 120ms ease, box-shadow 160ms ease;
}
.rec-dot:hover::after { transform: scale(1.25); }
.rec-dot--done::after { background: #1D9E75; }
.rec-dot--missed::after { background: #E24B4A; }
.rec-dot--current::after {
  box-shadow: 0 0 0 2px rgba(127, 119, 221, 0.45);
  transform: scale(1.4);
}

@media (max-width: 480px) {
  .rec-progress-label { font-size: 10px; }
  .rec-dot { width: 11px; min-width: 11px; height: 20px; }
  .rec-dot::after { width: 5px; height: 5px; }
  .rec-dot--current::after { box-shadow: 0 0 0 1.5px rgba(127, 119, 221, 0.45); }
}
