/* ═══════════════════════════════════════════════════════
   Quran Practice Studio — Garden of Recitation
   Distinct bright identity, mobile-first, fully responsive
   ═══════════════════════════════════════════════════════ */

/* ── Design tokens ── */
:root {
  --qp-emerald: #059669;
  --qp-emerald-light: #d1fae5;
  --qp-sky: #0ea5e9;
  --qp-sky-light: #e0f2fe;
  --qp-gold: #f59e0b;
  --qp-gold-light: #fef3c7;
  --qp-purple: #7c4dff;
  --qp-rose: #e040fb;
  --qp-ink: #1e293b;
  --qp-ink-soft: #475569;
  --qp-paper: #fefce8;
  --qp-radius: 16px;
  --qp-radius-sm: 10px;
  --qp-shadow: 0 4px 14px rgba(0,0,0,.08);
  --qp-shadow-lg: 0 8px 30px rgba(0,0,0,.12);
}

/* ── Screen-state safety ── */
.qp-screen[hidden] { display: none !important; }
.qp-screen:not([hidden]) { display: flex; flex-direction: column; }

/* ── Shell ── */
.qp-shell {
  min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(180deg, var(--qp-sky-light) 0%, #f0fdf4 50%, var(--qp-emerald-light) 100%);
  position: relative; overflow-x: hidden;
}
.qp-shell::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle, rgba(14,165,233,.06) 1.5px, transparent 1.5px);
  background-size: 28px 28px; z-index: 0;
}

/* ── Top bar ── */
.qp-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(14,165,233,.12);
  position: sticky; top: 0; z-index: 10; gap: 8px;
}
.qp-home, .qp-progress-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: 'Nunito', system-ui, sans-serif; font-weight: 700;
  font-size: 14px; color: var(--qp-ink-soft); text-decoration: none;
  min-height: 44px; padding: 8px 12px; border-radius: var(--qp-radius-sm);
  transition: background .2s, color .2s;
}
.qp-home:hover, .qp-progress-link:hover { background: var(--qp-sky-light); color: var(--qp-sky); }
.qp-brand {
  display: flex; align-items: center; gap: 8px;
  font-family: 'Nunito', system-ui, sans-serif; font-weight: 900;
  font-size: 16px; color: var(--qp-emerald);
}
.qp-brand-mark { font-size: 22px; }
@media (max-width: 360px) {
  .qp-home span, .qp-progress-link span { display: none; }
}

/* ── Stage ── */
.qp-stage { flex: 1; position: relative; z-index: 1; }

/* ── Home screen ── */
.home-screen { padding: 16px; align-items: center; }
.home-grid {
  max-width: 880px; width: 100%;
  display: grid; gap: 24px;
}
@media (min-width: 768px) { .home-grid { grid-template-columns: 1fr 1fr; } }

.home-hero {
  background: linear-gradient(135deg, #fff 0%, var(--qp-sky-light) 100%);
  border-radius: var(--qp-radius); padding: 24px 20px;
  box-shadow: var(--qp-shadow); text-align: center;
  border: 2px solid rgba(14,165,233,.1);
}
.hero-art { font-size: 48px; margin-bottom: 8px; }
.eyebrow {
  font-family: 'Nunito', system-ui, sans-serif; font-weight: 700;
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--qp-emerald); margin: 0 0 4px;
}
#page-title {
  font-family: 'Nunito', system-ui, sans-serif; font-weight: 900;
  font-size: 24px; color: var(--qp-ink); margin: 0 0 8px; text-wrap: balance;
}
.hero-copy {
  font-family: 'Nunito', system-ui, sans-serif; font-size: 14px;
  color: var(--qp-ink-soft); line-height: 1.5; margin: 0 0 12px;
}
.care-note {
  font-size: 13px; color: var(--qp-ink-soft);
  background: var(--qp-gold-light); border-radius: var(--qp-radius-sm);
  padding: 8px 12px; margin: 0 0 16px; display: flex; gap: 6px; align-items: center;
}
.quick-start {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 100%; min-height: 56px; padding: 12px 20px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--qp-emerald) 0%, #047857 100%);
  color: #fff; border-radius: var(--qp-radius); font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 800; font-size: 18px; box-shadow: var(--qp-shadow);
  transition: transform .15s, box-shadow .2s;
}
.quick-start:hover { transform: translateY(-1px); box-shadow: var(--qp-shadow-lg); }
.quick-start:active { transform: translateY(0); }
.quick-start small { font-size: 11px; font-weight: 600; opacity: .85; }
.quick-start:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.practice-summary {
  display: flex; gap: 12px; justify-content: center; margin-top: 16px;
}
.summary-cell {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,.6); border-radius: var(--qp-radius-sm);
  padding: 8px 16px; min-width: 80px;
}
.summary-cell strong {
  font-family: 'Nunito', system-ui, sans-serif; font-size: 22px;
  color: var(--qp-emerald); font-weight: 900;
}
.summary-cell span { font-size: 11px; color: var(--qp-ink-soft); font-weight: 600; }

/* ── Library ── */
.library { background: #fff; border-radius: var(--qp-radius); padding: 16px; box-shadow: var(--qp-shadow); }
.library-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.library-head h2 { font-family: 'Nunito', system-ui, sans-serif; font-weight: 900; font-size: 18px; color: var(--qp-ink); margin: 0; }
.library-head p { font-size: 12px; color: var(--qp-ink-soft); margin: 2px 0 0; }
.search-wrap { flex-shrink: 0; }
.surah-search {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 2px solid rgba(14,165,233,.2); border-radius: var(--qp-radius-sm);
  font-family: 'Nunito', system-ui, sans-serif; font-size: 14px;
  background: var(--qp-sky-light); color: var(--qp-ink);
}
.surah-search:focus { outline: 2px solid var(--qp-sky); border-color: var(--qp-sky); }

.filter-row { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-chip {
  min-height: 44px; padding: 8px 12px; border: 2px solid transparent;
  border-radius: 20px; font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 700; font-size: 12px; cursor: pointer;
  background: var(--qp-emerald-light); color: var(--qp-emerald);
  transition: background .2s, color .2s;
}
.filter-chip:hover { background: var(--qp-emerald); color: #fff; }
.filter-chip[aria-pressed="true"] { background: var(--qp-emerald); color: #fff; border-color: #047857; }

.surah-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  max-height: 420px; overflow-y: auto; padding-right: 4px;
}
.surah-card {
  display: flex; flex-direction: column; gap: 2px;
  min-height: 64px; padding: 10px 12px; border: 2px solid rgba(5,150,105,.12);
  border-radius: var(--qp-radius-sm); background: #fff; cursor: pointer;
  text-align: left; transition: all .2s;
}
.surah-card:hover { border-color: var(--qp-emerald); background: var(--qp-emerald-light); transform: translateY(-1px); }
.surah-card.has-practice { border-color: rgba(245,158,11,.3); background: linear-gradient(135deg, #fff 0%, var(--qp-gold-light) 100%); }
.surah-number { font-size: 11px; font-weight: 700; color: var(--qp-ink-soft); }
.surah-card strong { font-family: 'Nunito', system-ui, sans-serif; font-size: 14px; color: var(--qp-ink); }
.surah-card small { font-size: 11px; color: var(--qp-ink-soft); }
.practice-mark { font-size: 10px; color: var(--qp-gold); font-weight: 700; margin-top: 2px; }
.empty-library { text-align: center; padding: 24px; color: var(--qp-ink-soft); font-size: 14px; }

/* ── Studio screen ── */
.studio-screen { padding: 12px 16px; gap: 12px; }
.studio-hud {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #fff; border-radius: var(--qp-radius); padding: 10px 14px;
  box-shadow: var(--qp-shadow);
}
.close-studio, .finish-button {
  min-height: 44px; padding: 8px 14px; border: none; border-radius: var(--qp-radius-sm);
  font-family: 'Nunito', system-ui, sans-serif; font-weight: 700; font-size: 14px; cursor: pointer;
  transition: all .2s;
}
.close-studio { background: #fee2e2; color: #991b1b; }
.close-studio:hover { background: #fecaca; }
.finish-button { background: var(--qp-gold-light); color: #92400e; }
.finish-button:hover { background: var(--qp-gold); color: #fff; }
.surah-heading { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 0; }
.surah-heading strong { font-family: 'Nunito', system-ui, sans-serif; font-size: 16px; color: var(--qp-ink); font-weight: 900; }
.surah-heading span { font-size: 12px; color: var(--qp-ink-soft); }

/* ── Mode tabs ── */
.mode-tabs { display: flex; gap: 4px; background: #fff; border-radius: var(--qp-radius); padding: 4px; box-shadow: var(--qp-shadow); }
.mode-tab {
  flex: 1; min-height: 44px; padding: 8px; border: none; border-radius: var(--qp-radius-sm);
  font-family: 'Nunito', system-ui, sans-serif; font-weight: 700; font-size: 12px;
  background: transparent; color: var(--qp-ink-soft); cursor: pointer; transition: all .2s;
  white-space: nowrap;
}
.mode-tab[aria-selected="true"] { background: var(--qp-emerald); color: #fff; }
.mode-tab:hover:not([aria-selected="true"]) { background: var(--qp-emerald-light); }
@media (max-width: 380px) { .mode-tab { font-size: 11px; padding: 6px 4px; } }

/* ── Mode stage ── */
.mode-stage { flex: 1; }
.qp-mode-panel[hidden] { display: none !important; }

/* ── Listen & Follow ── */
.listen-layout { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 768px) { .listen-layout { flex-direction: row; } }
.ayah-focus {
  flex: 1; background: linear-gradient(135deg, #fff 0%, var(--qp-paper) 100%);
  border-radius: var(--qp-radius); padding: 20px 16px;
  box-shadow: var(--qp-shadow); border: 2px solid rgba(245,158,11,.1);
  text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.bismillah { font-family: 'Amiri', serif; font-size: 18px; color: var(--qp-gold); margin: 0; }
.ayah-ref { font-size: 12px; font-weight: 700; color: var(--qp-ink-soft); }
.ayah-arabic {
  font-family: 'Amiri', serif; font-size: 28px; line-height: 2;
  color: var(--qp-ink); direction: rtl; margin: 8px 0; width: 100%;
}
@media (min-width: 768px) { .ayah-arabic { font-size: 34px; } }
@media (max-width: 380px) { .ayah-arabic { font-size: 22px; } }
.ayah-meaning {
  font-family: 'Nunito', system-ui, sans-serif; font-size: 14px;
  color: var(--qp-ink-soft); line-height: 1.6; margin: 0; max-width: 420px;
}

.listen-controls {
  display: flex; flex-direction: column; gap: 8px; min-width: 200px;
}
@media (min-width: 768px) { .listen-controls { width: 240px; } }
.audio-button {
  min-height: 44px; padding: 10px 16px; border: none; border-radius: var(--qp-radius-sm);
  font-family: 'Nunito', system-ui, sans-serif; font-weight: 700; font-size: 14px;
  background: var(--qp-sky); color: #fff; cursor: pointer; transition: all .2s;
}
.audio-button:hover { background: #0284c7; }
.audio-button.is-playing { background: #ef4444; }
.audio-button.is-playing:hover { background: #dc2626; }
.audio-status { font-size: 12px; color: var(--qp-ink-soft); text-align: center; padding: 4px; border-radius: 6px; min-height: 20px; }
.step-nav { display: flex; gap: 8px; }
.secondary-button, .primary-button {
  flex: 1; min-height: 44px; padding: 10px 14px; border: none; border-radius: var(--qp-radius-sm);
  font-family: 'Nunito', system-ui, sans-serif; font-weight: 700; font-size: 14px; cursor: pointer; transition: all .2s;
}
.secondary-button { background: #f1f5f9; color: var(--qp-ink-soft); }
.secondary-button:hover { background: #e2e8f0; }
.secondary-button:disabled { opacity: .4; cursor: not-allowed; }
.primary-button { background: var(--qp-emerald); color: #fff; }
.primary-button:hover { background: #047857; }
.ayah-dots { text-align: center; font-size: 12px; color: var(--qp-ink-soft); font-weight: 600; }

/* ── Word Recall ── */
.recall-panel, .echo-panel { display: flex; justify-content: center; }
.practice-card {
  max-width: 560px; width: 100%;
  background: linear-gradient(135deg, #fff 0%, var(--qp-paper) 100%);
  border-radius: var(--qp-radius); padding: 20px 16px;
  box-shadow: var(--qp-shadow); border: 2px solid rgba(5,150,105,.1);
  display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center;
}
.practice-kicker { font-size: 12px; font-weight: 700; color: var(--qp-emerald); margin: 0; }
.recall-line {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  font-family: 'Amiri', serif; font-size: 24px; line-height: 2; width: 100%;
}
@media (min-width: 768px) { .recall-line { font-size: 28px; } }
@media (max-width: 380px) { .recall-line { font-size: 20px; } }
.recall-word { color: var(--qp-ink); }
.recall-blank {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 60px; padding: 2px 8px; border-radius: 6px;
  background: var(--qp-gold-light); border: 2px dashed var(--qp-gold);
  font-size: 12px; color: var(--qp-gold); font-family: 'Nunito', sans-serif;
  font-weight: 700; transition: all .3s;
}
.recall-blank.arabic { border-style: solid; border-color: var(--qp-emerald); background: var(--qp-emerald-light); color: var(--qp-ink); font-family: 'Amiri', serif; font-size: inherit; }
.word-options {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px;
}
.word-option {
  min-height: 44px; padding: 8px 16px; border: 2px solid rgba(5,150,105,.15);
  border-radius: var(--qp-radius-sm); font-family: 'Amiri', serif; font-size: 18px;
  background: #fff; color: var(--qp-ink); cursor: pointer; transition: all .2s;
}
.word-option:hover { border-color: var(--qp-emerald); background: var(--qp-emerald-light); }
.word-option.correct { background: var(--qp-emerald); color: #fff; border-color: #047857; }
.word-option.wrong { opacity: .4; text-decoration: line-through; }
.feedback { font-size: 13px; color: var(--qp-ink-soft); margin: 0; min-height: 20px; }
.practice-actions { display: flex; gap: 8px; width: 100%; }
.gentle-button {
  flex: 1; min-height: 44px; padding: 10px 14px; border: 2px solid rgba(245,158,11,.3);
  border-radius: var(--qp-radius-sm); font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 700; font-size: 13px; background: var(--qp-gold-light); color: #92400e;
  cursor: pointer; transition: all .2s;
}
.gentle-button:hover { background: var(--qp-gold); color: #fff; }

/* ── Ayah Echo ── */
.echo-arabic {
  font-family: 'Amiri', serif; font-size: 26px; line-height: 2;
  color: var(--qp-ink); direction: rtl; margin: 8px 0; width: 100%;
  transition: filter .4s, opacity .4s;
}
@media (min-width: 768px) { .echo-arabic { font-size: 32px; } }
@media (max-width: 380px) { .echo-arabic { font-size: 22px; } }
.echo-arabic.covered { filter: blur(7px); opacity: .3; }
.echo-instruction { font-size: 13px; color: var(--qp-ink-soft); margin: 0; }
.self-check { display: flex; gap: 8px; width: 100%; }

/* ── Complete screen ── */
.complete-screen { padding: 12px 16px; align-items: center; justify-content: center; overflow-y: auto; }
.complete-card {
  max-width: 440px; width: 100%;
  background: linear-gradient(135deg, #fff 0%, var(--qp-emerald-light) 100%);
  border-radius: var(--qp-radius); padding: 20px 16px; text-align: center;
  box-shadow: var(--qp-shadow-lg); border: 2px solid rgba(5,150,105,.15);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.complete-art { font-size: 44px; }
#complete-title {
  font-family: 'Nunito', system-ui, sans-serif; font-weight: 900; font-size: 20px;
  color: var(--qp-emerald); margin: 0;
}
.session-stats { display: flex; gap: 8px; justify-content: center; margin: 8px 0; }
.session-stat { display: flex; flex-direction: column; align-items: center; background: rgba(255,255,255,.7); border-radius: var(--qp-radius-sm); padding: 6px 12px; min-width: 70px; }
.session-stat strong { font-family: 'Nunito', system-ui, sans-serif; font-size: 20px; color: var(--qp-emerald); font-weight: 900; }
.session-stat span { font-size: 10px; color: var(--qp-ink-soft); font-weight: 600; }
.teacher-note { font-size: 11px; color: var(--qp-ink-soft); line-height: 1.4; margin: 0; padding: 6px 10px; background: var(--qp-gold-light); border-radius: var(--qp-radius-sm); }
.complete-actions { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; justify-content: center; margin-top: 4px; }
.complete-actions > * { min-width: 110px; }
@media (max-width: 380px) {
  .complete-card { padding: 12px 10px; gap: 4px; }
  .complete-art { font-size: 28px; }
  #complete-title { font-size: 16px; }
  .complete-card > p { font-size: 12px; margin: 0; }
  .session-stats { gap: 4px; margin: 4px 0; }
  .session-stat { min-width: 50px; padding: 3px 6px; }
  .session-stat strong { font-size: 16px; }
  .session-stat span { font-size: 9px; }
  .teacher-note { font-size: 10px; padding: 4px 8px; line-height: 1.3; }
  .complete-actions { gap: 4px; margin-top: 2px; }
  .complete-actions > * { min-width: 100%; min-height: 40px; font-size: 13px; padding: 8px 10px; }
}

/* ── Confetti ── */
.qp-confetti {
  position: fixed; top: -10px; z-index: 9999; pointer-events: none;
  font-size: 14px; animation: qp-fall 3s ease-in forwards;
}
@keyframes qp-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(360deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .qp-confetti { animation: none; display: none; }
  .quick-start, .surah-card, .word-option { transition: none !important; }
  .quick-start:hover, .surah-card:hover { transform: none; }
}

/* ── Accessibility ── */
.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;
}
.skip-link {
  position: absolute; top: -40px; left: 8px; z-index: 100;
  background: var(--qp-emerald); color: #fff; padding: 8px 12px;
  border-radius: 6px; font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 14px;
  text-decoration: none; transition: top .2s;
}
.skip-link:focus { top: 8px; }

/* ── Scrollbar ── */
.surah-grid::-webkit-scrollbar { width: 6px; }
.surah-grid::-webkit-scrollbar-track { background: transparent; }
.surah-grid::-webkit-scrollbar-thumb { background: rgba(5,150,105,.2); border-radius: 3px; }
.surah-grid::-webkit-scrollbar-thumb:hover { background: rgba(5,150,105,.4); }

/* ── Print ── */
@media print { .qp-topbar, .quick-start, .filter-row, .step-nav, .practice-actions { display: none !important; } }
