/* ========================================
   Study Session — Illuminated Codex
   ======================================== */

/* Queue overview bar */
.queue-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.queue-counts {
  display: flex;
  gap: 24px;
}

.queue-count {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.queue-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 4px currentColor;
}

.queue-dot--new { background: var(--btn-easy); color: var(--btn-easy); }
.queue-dot--learning { background: var(--btn-hard); color: var(--btn-hard); }
.queue-dot--due { background: var(--btn-good); color: var(--btn-good); }

.queue-progress {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ========================================
   Study Card — the manuscript page
   ======================================== */

.study-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Decorative corner ornaments */
.study-card::before,
.study-card::after {
  content: '';
  position: absolute;
  width: 40px;
  height: 40px;
  border: 2px solid var(--border-ornament);
  opacity: 0.15;
  pointer-events: none;
}

.study-card::before {
  top: 12px;
  left: 12px;
  border-right: none;
  border-bottom: none;
  border-radius: 4px 0 0 0;
}

.study-card::after {
  bottom: 12px;
  right: 12px;
  border-left: none;
  border-top: none;
  border-radius: 0 0 4px 0;
}

.study-card__front {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  animation: cardFadeIn 0.35s ease-out;
  position: relative;
  overflow: hidden;
}

/* Subtle Islamic geometric lattice — diamond grid behind the Arabic word */
.study-card__front::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image:
    repeating-linear-gradient(
      45deg,
      var(--border-ornament) 0,
      var(--border-ornament) 1px,
      transparent 0,
      transparent 50%
    ),
    repeating-linear-gradient(
      -45deg,
      var(--border-ornament) 0,
      var(--border-ornament) 1px,
      transparent 0,
      transparent 50%
    );
  background-size: 28px 28px;
}

/* Centered radial vignette to fade out the lattice at the edges */
.study-card__front::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 70% 70% at 50% 50%,
    transparent 40%,
    var(--bg-card) 100%
  );
}

/* Ensure content appears above the decorative pseudo-elements */
.study-card__root,
.study-card__meta,
.hint-area,
.front-actions {
  position: relative;
  z-index: 1;
}

.study-card__back {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 36px;
  animation: cardFadeIn 0.35s ease-out;
}

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: perspective(700px) rotateX(6deg) translateY(14px) scale(0.97);
    filter: blur(0.5px);
  }
  to {
    opacity: 1;
    transform: perspective(700px) rotateX(0deg) translateY(0) scale(1);
    filter: blur(0);
  }
}

/* Root word — hero element (2.5x rule: massive for recognition) */
.study-card__root {
  font-family: var(--arabic-font);
  font-size: calc(var(--arabic-size) * 2.2);
  color: var(--text-arabic);
  direction: rtl;
  line-height: 1.4;
  margin-bottom: 14px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  animation: rootReveal 0.5s ease-out;
}

@keyframes rootReveal {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.study-card__meta {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 36px;
  font-style: italic;
  letter-spacing: 0.5px;
}

.study-card__meaning {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.study-card__transliteration {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-style: italic;
}

/* Section headers */
.study-section-header {
  width: 100%;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding-bottom: 8px;
  margin-bottom: 14px;
  margin-top: 4px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.study-section-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 40px;
  height: 1px;
  background: var(--border-ornament);
}

/* Word family section */
.study-word-family {
  width: 100%;
  margin-bottom: 24px;
}

/* Family pills */
.family-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.family-pill {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 16px;
  background: var(--bg-accent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.family-pill:hover {
  border-color: var(--border-ornament);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.family-pill--active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.family-pill__arabic {
  font-family: var(--arabic-font);
  font-size: calc(var(--arabic-size) * 0.55);
  color: var(--accent);
  font-weight: 700;
  direction: rtl;
}

.family-pill__meaning {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.family-pill__meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* Family detail */
.family-detail {
  position: relative;
  margin-top: 14px;
  padding: 18px;
  background: var(--bg-accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  animation: detailReveal 0.25s ease-out;
}

@keyframes detailReveal {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.family-detail__close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 4px;
}

.family-detail__close:hover {
  color: var(--text-primary);
  background: var(--border);
}

.family-detail__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.family-detail__arabic {
  font-family: var(--arabic-font);
  font-size: calc(var(--arabic-size) * 0.7);
  color: var(--accent);
  font-weight: 700;
  direction: rtl;
}

.family-detail__meaning {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.family-detail__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.family-detail__pos {
  font-family: var(--font-body);
  font-size: 11px;
  padding: 1px 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-weight: 500;
}

.family-detail__freq {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Forms table */
.family-detail__table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
}

.family-detail__table th {
  text-align: left;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 6px 8px;
  border-bottom: 2px solid var(--border);
}

.family-detail__table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.family-detail__table tr:last-child td { border-bottom: none; }

.family-detail__td-arabic {
  font-family: var(--arabic-font);
  font-size: calc(var(--arabic-size) * 0.55);
  color: var(--text-primary);
  direction: rtl;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

:root[dir="rtl"] .family-detail__td-arabic {
  text-align: right;
}

.family-detail__td-meaning { font-size: 13px; color: var(--text-primary); }
.family-detail__td-grammar { font-size: 12px; color: var(--text-muted); }
.family-detail__td-grammar a { color: var(--text-muted); text-decoration: underline dotted; }
.family-detail__td-grammar a:hover { color: var(--accent); }
.family-detail__td-freq { font-size: 12px; color: var(--text-muted); text-align: right; white-space: nowrap; }

.family-detail__ayahs { border-top: 1px solid var(--border); padding-top: 14px; }
.family-detail__ayah-count { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; font-style: italic; }
.family-detail__loading { font-size: 13px; color: var(--text-muted); padding: 4px 0; }
.family-detail__more { font-size: 12px; color: var(--text-muted); text-align: center; padding: 8px 0; font-style: italic; }

/* Verse cards */
.study-card .verse-card {
  padding: 16px 18px;
  background: var(--bg-accent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  border-left: 3px solid var(--border-ornament);
}

.study-card .verse-card:last-child { margin-bottom: 0; }

.study-card .verse-card__ref {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.audio-btn--verse {
  width: 24px;
  height: 24px;
  font-size: 10px;
}

.study-card .verse-card__arabic {
  font-family: var(--arabic-font);
  font-size: var(--arabic-size);
  direction: rtl;
  text-align: right;
  line-height: 2.1;
  margin-bottom: 10px;
}

.study-card .verse-card__translation {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.6;
}

/* Highlighted word meanings */
.verse-card__highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.verse-card__hw {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--accent-light);
  border-radius: 4px;
  border: 1px solid var(--border-ornament);
  border-opacity: 0.2;
}

.verse-card__hw-arabic {
  font-family: var(--arabic-font);
  font-size: calc(var(--arabic-size) * 0.45);
  color: var(--accent);
  font-weight: 700;
  direction: rtl;
}

.verse-card__hw-meaning {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
}

/* ========================================
   Rating Buttons — jewel-toned
   ======================================== */

.rating-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  padding: 0 36px 36px;
}

.rating-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 8px;
  min-height: 52px;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-weight: 600;
  color: white;
  transition: all 0.2s ease;
  font-family: var(--font-body);
  position: relative;
  overflow: hidden;
}

/* Subtle inner glow */
.rating-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 50%);
  pointer-events: none;
}

.rating-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.rating-btn:active {
  transform: translateY(0);
}

.rating-btn--again { background: var(--btn-again); }
.rating-btn--again:hover { background: var(--btn-again-hover); }
.rating-btn--hard { background: var(--btn-hard); }
.rating-btn--hard:hover { background: var(--btn-hard-hover); }
.rating-btn--good { background: var(--btn-good); }
.rating-btn--good:hover { background: var(--btn-good-hover); }
.rating-btn--easy { background: var(--btn-easy); }
.rating-btn--easy:hover { background: var(--btn-easy-hover); }

.rating-btn__key {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 9px;
  font-weight: 700;
  opacity: 0.5;
  letter-spacing: 0.3px;
  background: rgba(255, 255, 255, 0.18);
  padding: 1px 5px;
  border-radius: 3px;
  line-height: 1.5;
  font-family: var(--font-body);
}

.rating-btn__label { font-size: 14px; }
.rating-btn__interval { font-size: 11px; opacity: 0.8; font-weight: 400; }

/* ========================================
   Hint Area
   ======================================== */

.hint-area {
  width: 100%;
  background: var(--bg-accent);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
  text-align: center;
  border: 1px dashed var(--border);
  border-left: 3px solid var(--border-ornament);
}

.hint-verse {
  font-family: var(--arabic-font);
  font-size: calc(var(--arabic-size) * 0.9);
  direction: rtl;
  line-height: 2.1;
}

.hint-blur {
  filter: blur(6px);
  transition: filter 0.3s;
  cursor: default;
  user-select: none;
}

/* Front actions */
.front-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

.hint-btn {
  padding: 14px 28px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  background: var(--bg-accent);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.hint-btn:hover { background: var(--border); }
.hint-btn:disabled { opacity: 0.4; cursor: default; }

.show-answer-btn {
  padding: 14px 44px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  background: var(--accent);
  color: #faf7f0;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  animation: ctaPulse 3.5s ease-in-out infinite;
}

@keyframes ctaPulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(139, 105, 20, 0.25); }
  50%       { box-shadow: 0 4px 22px rgba(139, 105, 20, 0.45), 0 0 0 4px rgba(139, 105, 20, 0.08); }
}

.show-answer-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  animation: none;
  box-shadow: 0 4px 14px rgba(139, 105, 20, 0.3);
}

/* ========================================
   Session Complete & Empty State
   ======================================== */

.session-complete {
  text-align: center;
  padding: 52px 24px;
  animation: cardFadeIn 0.5s ease-out;
}

.session-complete__icon {
  font-size: 52px;
  margin-bottom: 16px;
  animation: celebratePop 0.5s ease-out 0.2s both;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -2px;
  text-shadow: 0 0 24px var(--accent-glow), 0 2px 8px rgba(139, 105, 20, 0.2);
}

@keyframes celebratePop {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    transform: scale(1.15);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.session-complete__title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.session-complete__subtitle {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-style: italic;
}

.session-stats {
  display: flex;
  justify-content: center;
  gap: 36px;
  margin-bottom: 32px;
}

.session-stat { text-align: center; }

.session-stat__value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.session-stat__label {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.empty-state {
  text-align: center;
  padding: 64px 24px;
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state__text {
  font-family: var(--font-body);
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-style: italic;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 640px) {
  .study-card__front,
  .study-card__back {
    padding: 32px 20px;
  }

  .study-card__root {
    font-size: calc(var(--arabic-size) * 1.5);
  }

  .study-card::before,
  .study-card::after {
    width: 24px;
    height: 24px;
  }

  .rating-buttons {
    grid-template-columns: repeat(2, 1fr);
    padding: 0 20px 24px;
  }

  .rating-btn {
    min-height: 56px;
    padding: 20px 8px;
  }

  .front-actions {
    flex-direction: column;
    width: 100%;
  }

  .hint-btn,
  .show-answer-btn {
    width: 100%;
  }
}

/* ========================================
   Study Queue List
   ======================================== */

.study-queue-list {
  margin-top: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  animation: pageReveal 0.5s ease-out;
}

.study-queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.study-queue-header h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.study-queue-count {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 10px;
  border-radius: 12px;
}

.study-queue-items {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-left: 10px;
  position: relative;
}

/* Vertical timeline track connecting all items */
.study-queue-items::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 18px;
  bottom: 18px;
  width: 1px;
  background: linear-gradient(180deg, var(--border-ornament) 0%, var(--border) 60%, transparent 100%);
  opacity: 0.4;
  pointer-events: none;
}

.study-queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 10px 20px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  transition: background 0.15s ease, opacity 0.2s ease;
  position: relative;
  margin-bottom: 2px;
}

.study-queue-item:hover {
  background: var(--bg-accent);
}

/* Timeline dot */
.study-queue-item::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  z-index: 1;
  transition: all 0.2s ease;
}

/* Upcoming items — hollow dot, subtle */
.study-queue-item:not(.study-queue-item--active):not(.study-queue-item--past)::before {
  border-color: var(--border);
}

/* Active item */
.study-queue-item--active {
  background: var(--accent-light);
  border-radius: var(--radius);
}

.study-queue-item--active::before {
  border-color: var(--accent);
  background: var(--accent);
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%       { box-shadow: 0 0 0 5px var(--accent-glow); }
}

/* Past items — filled muted dot, faded row */
.study-queue-item--past {
  opacity: 0.38;
}

.study-queue-item--past::before {
  background: var(--text-muted);
  border-color: var(--text-muted);
}

.study-queue-item__left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.study-queue-item__index {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--text-muted);
  width: 20px;
  text-align: right;
}

.study-queue-item__arabic {
  font-family: var(--arabic-font);
  font-size: 20px;
  color: var(--text-arabic);
  direction: rtl;
  min-width: 60px;
}

.study-queue-item__latin {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.study-queue-item__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.study-queue-item__type {
  font-family: var(--font-body);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.study-queue-item__type--new {
  background: var(--btn-easy);
  color: white;
}

.study-queue-item__type--due {
  background: var(--btn-good);
  color: white;
}

.study-queue-item__words {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}
