/* ===================================================================
   ATQAN — frontend/css/features/mushaf.css
   Modern Quranic Manuscript Framework & Stepper Nodes
   =================================================================== */

.mushaf-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  gap: 16px;
}

.surah-badge {
  background-color: var(--md-tertiary-container);
  color: var(--md-on-tertiary-container);
  padding: 6px 20px;
  border-radius: var(--radius-full);
  font-size: 18px;
  font-weight: 700;
  font-family: 'Amiri', serif;
  box-shadow: none;
}

.m3-stepper {
  position: relative;
  margin-bottom: 32px;
  padding: 8px 16px;
}

.progress-line {
  position: absolute;
  top: 50%; left: 16px; right: 16px;
  height: 4px;
  background-color: var(--md-surface-low);
  transform: translateY(-50%);
  z-index: 1;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-line-fill {
  height: 100%;
  width: 0%;
  background-color: var(--md-primary);
  border-radius: var(--radius-full);
  transition: width var(--md-motion-duration-medium) var(--md-motion-easing-emphasized);
}

.step-dots {
  display: flex;
  justify-content: space-between;
  position: relative;
  z-index: 2;
}

.step-dot {
  width: 16px; height: 16px;
  background-color: var(--md-surface);
  border: none;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0 !important;
  color: transparent !important;
  box-shadow: none;
  transition: var(--transition);
}

.step-dot.active {
  background-color: var(--md-primary);
  transform: scale(1.2);
  box-shadow: none;
}

.step-dot.completed,
.step-dot.done {
  background-color: var(--md-primary);
  border: none;
  box-shadow: none;
}

.mushaf-container {
  background-color: transparent !important;
  padding: 16px 0 !important;
  position: relative;
  border: none !important;
  box-shadow: none !important;
  margin-bottom: 16px !important;
  transition: var(--transition);
}

.mushaf-loading-state {
  position: relative;
  z-index: 3;
  display: grid;
  gap: 12px;
  min-height: 220px;
  align-content: center;
  padding: 20px 0;
  color: var(--md-text-sub);
}

.mushaf-loading-state.hide {
  display: none !important;
}

.mushaf-loading-lines {
  display: grid;
  gap: 14px;
  width: 100%;
}

.mushaf-loading-lines span {
  display: block;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--md-surface-low);
  border: 1px solid var(--md-outline-variant);
  animation: mushaf-loading-pulse 1.6s ease-in-out infinite;
}

.mushaf-loading-lines span:nth-child(1) {
  width: 92%;
  justify-self: end;
}

.mushaf-loading-lines span:nth-child(2) {
  width: 76%;
  justify-self: end;
  animation-delay: 120ms;
}

.mushaf-loading-lines span:nth-child(3) {
  width: 84%;
  justify-self: end;
  animation-delay: 240ms;
}

.mushaf-loading-text {
  margin: 0;
  color: var(--md-text-sub);
  font-size: var(--md-type-body-medium-size);
  line-height: var(--md-type-body-medium-lh);
  text-align: center;
}

.mushaf-loading-state.error {
  min-height: 160px;
  padding: 20px;
  border: 1px solid color-mix(in srgb, var(--md-error) 32%, var(--md-outline-variant));
  border-radius: var(--radius-card);
  background: color-mix(in srgb, var(--md-error) 8%, var(--md-surface));
}

.mushaf-loading-state.error .mushaf-loading-lines {
  display: none;
}

.mushaf-loading-state.error .mushaf-loading-text {
  color: var(--md-error);
  font-weight: 600;
}

@keyframes mushaf-loading-pulse {
  0%, 100% {
    opacity: 0.42;
  }
  50% {
    opacity: 0.78;
  }
}

.m3-segmented-progress-container {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-bottom: 24px;
}

.progress-segment {
  flex: 1;
  height: 6px;
  border-radius: var(--radius-full);
  background-color: var(--md-surface-low);
  cursor: pointer;
  transition: background-color var(--md-motion-duration-medium) var(--md-motion-easing-emphasized),
              transform var(--md-motion-duration-short) var(--md-motion-easing-emphasized);
}

.progress-segment:hover {
  transform: scaleY(1.3);
}

.progress-segment.active {
  background-color: var(--md-primary) !important;
  transform: scaleY(1.3);
}

.progress-segment.completed {
  background-color: var(--md-primary) !important;
  opacity: 0.45;
}

#highlight-canvas {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 1;
}

#mushaf-text-layer {
  position: relative;
  z-index: 2;
  text-align: justify;
  text-justify: inter-word;
  color: var(--md-mushaf-text);
}

.font-mushaf {
  font-family: var(--font-mushaf-kfgqpc) !important;
  line-height: 4.5rem !important;
  font-size: 2.75rem !important;
  text-align: justify;
  text-justify: inter-word;
  direction: rtl;
}

[dir="rtl"], .quran-text, .ayah-display, [class*="arabic"] {
    font-family: var(--font-mushaf-kfgqpc) !important;
    font-weight: normal !important;
}

.font-mushaf.kfgqpc-active {
  font-family: var(--font-mushaf-kfgqpc) !important;
}

.quran-text, .ayah-display {
  font-family: var(--font-mushaf-kfgqpc) !important;
  font-weight: 400 !important;
  text-transform: none;
  font-size: 2.5rem;
  line-height: 2.6;
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.ayah-number, .qpc-symbol {
  font-family: 'QPC Symbols', sans-serif;
  font-size: 1.8rem;
  font-weight: normal;
  display: inline-block;
  text-align: center;
}

.ayat-row-wrapper {
  display: inline;
}

.mushaf-ayat {
  transition: background-color 400ms cubic-bezier(0.2, 0, 0, 1), color 400ms cubic-bezier(0.2, 0, 0, 1), opacity 400ms cubic-bezier(0.2, 0, 0, 1);
  padding: 0;
  border-radius: 8px;
  display: inline;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  opacity: 0.45;
  color: var(--md-text);
  background-color: transparent;
  direction: rtl;
  unicode-bidi: plaintext;
  white-space: normal;
}

.mushaf-word {
  display: inline;
  transition: background-color var(--md-motion-duration-medium) var(--md-motion-easing-standard),
              opacity var(--md-motion-duration-medium) var(--md-motion-easing-standard);
  border-radius: var(--radius-sm);
  padding: 0;
  margin: 0;
  background-color: transparent;
}

.mushaf-word.active {
  background-color: var(--mushaf-highlight);
}

.mushaf-word.completed {
  opacity: 0.65;
}

.mushaf-letter {
  display: inline;
  transition: color var(--md-motion-duration-short) var(--md-motion-easing-standard),
              background-color var(--md-motion-duration-short) var(--md-motion-easing-standard);
  border-radius: 4px;
  padding: 0;
  margin: 0;
  background-color: transparent;
}

.mushaf-letter.active {
  background-color: color-mix(in srgb, var(--md-surface-low) 72%, transparent);
  box-shadow: inset 0 -0.14em 0 var(--md-primary-container);
}

.mushaf-letter.status-correct {
  color: var(--md-success);
}

.mushaf-letter.status-warning {
  color: var(--md-warning);
}

.mushaf-letter.status-error {
  color: var(--md-error);
}

.mushaf-letter.status-uncertain {
  color: var(--md-uncertain);
}

.ayah-marker {
  color: var(--md-text-sub);
}

.mushaf-ayat.active {
  background-color: var(--md-primary-container) !important;
  color: var(--md-on-primary-container) !important;
  opacity: 1;
}

.mushaf-ayat.completed {
  color: var(--md-text-sub);
  opacity: 0.3;
}

.surah-header-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  margin-bottom: 32px;
  border: none;
  border-radius: var(--radius-lg);
  background-color: var(--md-surface-low);
  font-family: var(--font-family);
  color: var(--md-text);
  box-shadow: none;
}

.surah-info-name {
  font-size: var(--md-type-title-medium-size);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--md-primary);
}

.surah-info-verses, .surah-info-type {
  font-size: var(--md-type-label-medium-size);
  font-weight: var(--md-type-label-medium-weight);
  text-transform: uppercase;
  color: var(--md-text-sub);
}

/* ─── MUSHAF TAJWEED LEGEND ────────────────────────────────────── */
.mushaf-legend-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin: 0 auto 12px auto;
  padding: 8px 16px;
  background-color: var(--md-surface-low);
  border-radius: var(--radius-sm);
  border: 1px solid var(--md-outline-variant);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--md-motion-duration-medium) var(--md-motion-easing-standard),
              transform var(--md-motion-duration-medium) var(--md-motion-easing-standard);
  pointer-events: none;
  max-width: max-content;
  flex-wrap: wrap;
  z-index: 10;
}

.mushaf-legend-container.show-legend {
  opacity: 0.9; /* subtle minimalist opacity */
  transform: translateY(0);
}

.mushaf-legend-container.hide {
  display: none !important;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-family);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--md-text-sub);
}

.legend-dot-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot-indicator.color-yellow {
  background-color: #eab308; /* flat muted yellow */
}

.legend-dot-indicator.color-purple {
  background-color: #a78bfa; /* flat muted purple */
}

.legend-dot-indicator.color-red {
  background-color: var(--md-error); /* semantic system error red */
}

.legend-dot-indicator.color-green {
  background-color: #10b981; /* flat muted emerald */
}

@media (max-width: 600px) {
  .mushaf-legend-container {
    gap: 8px;
    padding: 4px 12px;
  }
}

@media (max-width: 360px) {
  .mushaf-legend-container {
    gap: 6px;
    padding: 4px 10px;
    transform: scale(0.95);
  }
  .legend-item {
    font-size: 8px;
  }
}
