/* ============================================
   Accessible Book Reader — tool-style.css
   Extends style.css — accessibility first
============================================ */

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================
   High-visibility focus (critical for a11y)
============================================ */
:focus-visible {
  outline: 3px solid var(--primary) !important;
  outline-offset: 3px !important;
  border-radius: 6px !important;
}

/* ============================================
   Upload Screen
============================================ */
.upload-screen {
  min-height: calc(100vh - 65px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 0 4rem;
  background:
    radial-gradient(ellipse 70% 60% at 80% 10%, rgba(5,150,105,0.06), transparent),
    radial-gradient(ellipse 50% 40% at 10% 90%, rgba(37,99,235,0.05), transparent),
    #fff;
}

.upload-header {
  text-align: center;
  margin-bottom: 2rem;
}

.upload-header h1 {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.upload-header h1 i { color: #059669; }

.upload-subtitle {
  color: var(--subtext);
  font-size: 1rem;
  max-width: 52ch;
  margin: 0 auto;
  line-height: 1.7;
}

/* Drop Zone */
.drop-zone {
  border: 2.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--muted-bg);
  max-width: 560px;
  margin: 0 auto 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: #059669;
  background: rgba(5, 150, 105, 0.04);
  outline: 3px solid #059669 !important;
  outline-offset: 3px !important;
}

.drop-zone.drag-over {
  border-color: #059669;
  background: rgba(5, 150, 105, 0.08);
  transform: scale(1.01);
}

.drop-zone-icon {
  font-size: 3rem;
  color: #059669;
  line-height: 1;
}

.drop-zone-text {
  font-size: 1.05rem;
  color: var(--text);
  font-weight: 500;
}

.drop-zone-text strong { font-weight: 900; color: #059669; }

.drop-zone-formats {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--subtext);
}

.format-pill {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(5, 150, 105, 0.1);
  border: 1px solid rgba(5, 150, 105, 0.2);
  color: #059669;
  font-weight: 800;
  font-size: 0.78rem;
}

/* Voice hint */
.voice-hint {
  text-align: center;
  font-size: 0.88rem;
  color: var(--subtext);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  max-width: 560px;
  margin: 0 auto 2rem;
}

.voice-hint i { color: var(--primary); }

/* Processing state */
.processing-state {
  max-width: 560px;
  margin: 0 auto 1.5rem;
  text-align: center;
  padding: 2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.processing-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: #059669;
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.9s linear infinite;
}

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

.processing-state p {
  color: var(--subtext);
  font-weight: 600;
}

/* Keyboard shortcuts */
.shortcuts-hint {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.shortcuts-title {
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--subtext);
  margin-bottom: 0.85rem;
}

.shortcuts-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem 1.5rem;
}

.shortcuts-list li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  color: var(--subtext);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #f8fafc;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text);
  box-shadow: 0 2px 0 #d1d5db;
  line-height: 1.4;
  flex-shrink: 0;
}

/* ============================================
   Reader Screen
============================================ */
.reader-screen {
  height: calc(100vh - 65px);
  display: flex;
  overflow: hidden;
}

.reader-layout {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ---- Sidebar ---- */
.chapter-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--muted-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chapter-sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.18s;
}

.back-btn:hover {
  border-color: rgba(10,102,194,0.3);
  color: var(--primary);
}

.chapter-sidebar-title {
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--subtext);
  margin: 0;
}

.chapter-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0.5rem;
}

.chapter-btn {
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--subtext);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}

.chapter-btn:hover {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.chapter-btn.chapter-active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-color: transparent;
  font-weight: 900;
}

/* ---- Main reading area ---- */
.reader-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1.25rem 1.5rem 0;
}

.reader-book-header {
  margin-bottom: 0.75rem;
}

.reader-chapter-num {
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 0.3rem;
}

.reader-book-title {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* Controls bar */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.18s;
  flex-shrink: 0;
}

.ctrl-btn:hover:not(:disabled) {
  border-color: rgba(10,102,194,0.3);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(10,102,194,0.12);
}

.ctrl-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ctrl-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-color: transparent;
  width: 46px;
  height: 46px;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(10,102,194,0.25);
}

.ctrl-primary:hover:not(:disabled) {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(10,102,194,0.35);
}

.ctrl-sm { width: 34px; height: 34px; font-size: 0.75rem; }

.ctrl-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 0.1rem;
}

.ctrl-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.speed-display {
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--text);
  min-width: 3rem;
  text-align: center;
}

.voice-group { flex-wrap: nowrap; }

.voice-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--subtext);
  white-space: nowrap;
}

.voice-label i { color: var(--primary); }

.voice-select {
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-family: var(--font);
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
  max-width: 200px;
}

/* Download button */
.ctrl-download {
  color: #059669;
  border-color: rgba(5,150,105,0.3);
}
.ctrl-download:hover:not(:disabled) {
  background: rgba(5,150,105,0.08);
  border-color: #059669;
  color: #059669;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5,150,105,0.2);
}
.ctrl-download.recording {
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.4);
  color: #ef4444;
  animation: pulse-red 1.2s ease-in-out infinite;
}
@keyframes pulse-red {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* Download hint bar */
.download-hint {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 1rem;
  background: rgba(14,165,233,0.07);
  border: 1px solid rgba(14,165,233,0.25);
  border-radius: 10px;
  font-size: 0.85rem;
  color: #0c4a6e;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}
.download-hint i { color: #0ea5e9; flex-shrink: 0; }

/* Arabic gender toggle */
.arabic-gender-btn {
  font-size: 1rem;
  font-weight: 700;
}
.arabic-gender-btn.arabic-gender-active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-color: transparent;
}

/* Progress bar */
.reading-progress {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}

.progress-bar-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 999px;
  transition: width 0.4s ease;
  width: 0%;
}

.progress-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--subtext);
  white-space: nowrap;
}

/* Arabic warning banner */
.arabic-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  color: #92400e;
  line-height: 1.6;
}

.arabic-warning i {
  color: #f59e0b;
  font-size: 1rem;
  margin-top: 0.1rem;
  flex-shrink: 0;
}

/* Text display */
.text-display {
  flex: 1;
  overflow-y: auto;
  font-size: 1.08rem;
  line-height: 1.9;
  color: var(--text);
  padding: 0.5rem 0 2rem;
  outline: none;
}

.text-display:focus-visible {
  outline: 2px solid var(--primary) !important;
  outline-offset: -2px !important;
  border-radius: 8px !important;
}

.sentence {
  display: inline;
  border-radius: 4px;
  padding: 0 2px;
  transition: background 0.15s, color 0.15s;
}

.sentence-active {
  background: rgba(5, 150, 105, 0.15);
  color: #065f46;
  outline: 2px solid rgba(5, 150, 105, 0.4);
  border-radius: 4px;
}

/* ============================================
   Responsive
============================================ */
@media (max-width: 767px) {
  .chapter-sidebar {
    display: none; /* On mobile: sidebar hides, add a drawer later */
  }

  .reader-main {
    padding: 1rem;
  }

  .controls-bar {
    gap: 0.35rem;
  }

  .voice-label { display: none; }
  .voice-select { max-width: 130px; }

  .shortcuts-list { grid-template-columns: 1fr; }
}

@media (min-width: 768px) {
  .upload-header h1 { font-size: 2.4rem; }
  .upload-subtitle   { font-size: 1.05rem; }
}
