/* ============================================================
   MAX EXAM LAB — IELTS VOCABULARY HUB ENGINE
   Strict Design-System Compliance (Dark & Light Themes)
   ============================================================ */

/* --- Entry Point Layout next to Cambridge IELTS 16 Card --- */
.ielts-book-row-with-vocab {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  width: 100%;
}

.ielts-vocab-entry-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  font-family: var(--font-system);
  background: linear-gradient(145deg, rgba(16, 38, 34, 0.82), rgba(14, 25, 23, 0.88));
  border: 1px solid rgba(0, 245, 196, 0.34);
  border-radius: 18px;
  padding: 20px 22px;
  cursor: pointer;
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 18px rgba(0, 245, 196, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.ielts-vocab-entry-card:hover,
.ielts-vocab-entry-card:focus-visible {
  border-color: var(--neon-emerald, #00f5c4);
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 12px 34px rgba(0, 245, 196, 0.22);
  outline: none;
}

.ielts-vocab-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.ielts-vocab-entry-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(0, 245, 196, 0.14);
  border: 1px solid rgba(0, 245, 196, 0.3);
  color: var(--neon-emerald, #00f5c4);
  flex-shrink: 0;
}

.ielts-vocab-entry-count {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 245, 196, 0.12);
  border: 1px solid rgba(0, 245, 196, 0.28);
  color: var(--neon-emerald, #00f5c4);
  white-space: nowrap;
}

.ielts-vocab-entry-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 6px;
  line-height: 1.25;
}

.ielts-vocab-entry-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0 0 14px;
}

.ielts-vocab-entry-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--neon-emerald, #00f5c4);
}

@media (max-width: 860px) {
  .ielts-book-row-with-vocab {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .ielts-vocab-entry-card {
    order: 2;
  }
  .ielts-book-row-with-vocab > .max-ielts-book-card {
    order: 1;
  }
}

/* --- Vocabulary Hub Main Shell --- */
.view-vocab-hub {
  width: 100%;
  max-width: 1660px;
  margin: 0 auto;
  padding: 24px 24px 64px;
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .view-vocab-hub {
    padding: 16px 12px 48px;
  }
}

.vh-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.vh-header-left {
  min-width: 0;
  flex: 1 1 320px;
}

.vh-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.vh-back-btn:hover,
.vh-back-btn:focus-visible {
  border-color: var(--neon-emerald);
  color: var(--neon-emerald);
  outline: none;
}

.vh-eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--neon-emerald);
  margin-bottom: 4px;
}

.vh-title {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 6px;
  line-height: 1.15;
}

.vh-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.vh-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.vh-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-muted);
}

.vh-stat-pill strong {
  color: var(--neon-emerald);
  font-weight: 800;
}

.vh-primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--emerald-cta-bg);
  color: var(--emerald-cta-color);
  border: var(--emerald-cta-border);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.vh-primary-btn:hover,
.vh-primary-btn:focus-visible {
  background: var(--emerald-cta-hover-bg);
  color: var(--emerald-cta-hover-color);
  border-color: var(--emerald-cta-hover-border);
  box-shadow: var(--emerald-cta-hover-shadow);
  outline: none;
}

.vh-secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.vh-secondary-btn:hover,
.vh-secondary-btn:focus-visible {
  border-color: var(--neon-emerald);
  color: var(--neon-emerald);
  outline: none;
}

/* --- Dashboard: Components A, B, C --- */
.vh-dashboard-top {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(320px, 1.3fr);
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 960px) {
  .vh-dashboard-top {
    grid-template-columns: 1fr;
  }
}

.vh-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.vh-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.vh-panel-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.vh-panel-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* Component A: Doughnut Chart */
.vh-doughnut-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 22px;
}

.vh-doughnut-svg-wrap {
  position: relative;
  width: 190px;
  height: 190px;
  flex-shrink: 0;
  margin: 0 auto;
}

.vh-doughnut-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}

.vh-doughnut-seg {
  fill: none;
  stroke-width: 24;
  cursor: pointer;
  transition: stroke-width 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}

.vh-doughnut-seg:hover,
.vh-doughnut-seg:focus-visible {
  stroke-width: 28;
  filter: drop-shadow(0 0 8px rgba(0, 245, 196, 0.45));
  outline: none;
}

.vh-doughnut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}

.vh-doughnut-total {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.vh-doughnut-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.vh-type-legend {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vh-type-legend-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--glass-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease, transform 0.15s ease, background 0.2s ease;
}

.vh-type-legend-btn:hover,
.vh-type-legend-btn:focus-visible {
  border-color: var(--neon-emerald);
  background: var(--glass-card-active);
  transform: translateX(2px);
  outline: none;
}

.vh-type-legend-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.vh-type-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex-shrink: 0;
}

.vh-type-name {
  font-size: 13.5px;
  font-weight: 700;
}

.vh-type-meta {
  font-size: 13px;
  font-weight: 700;
  color: var(--neon-emerald);
  white-space: nowrap;
}

/* Component B: CEFR Horizontal Distribution */
.vh-cefr-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vh-cefr-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto 20px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--glass-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease, transform 0.15s ease, background 0.2s ease;
}

.vh-cefr-row:hover,
.vh-cefr-row:focus-visible {
  border-color: var(--neon-emerald);
  background: var(--glass-card-active);
  transform: translateX(3px);
  outline: none;
}

.vh-cefr-badge {
  font-size: 12.5px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 8px;
  text-align: center;
  background: rgba(0, 245, 196, 0.14);
  color: var(--neon-emerald);
  border: 1px solid rgba(0, 245, 196, 0.28);
}

.vh-cefr-bar-track {
  display: block;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.vh-cefr-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0d9488, #00f5c4);
  transition: width 0.25s ease;
}

.vh-cefr-metrics {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.vh-cefr-metrics span {
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 4px;
}

.vh-cefr-arrow {
  color: var(--neon-emerald);
  font-weight: 700;
}

/* Component C: 12 Categories Grid */
.vh-categories-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1200px) {
  .vh-categories-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .vh-categories-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .vh-categories-grid {
    grid-template-columns: 1fr;
  }
}

.vh-category-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  background: var(--glass-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.vh-category-card:hover,
.vh-category-card:focus-visible {
  border-color: var(--neon-emerald);
  background: var(--glass-card-active);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 245, 196, 0.15);
  outline: none;
}

.vh-category-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.vh-category-icon {
  font-size: 22px;
  line-height: 1;
}

.vh-category-count {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 245, 196, 0.12);
  color: var(--neon-emerald);
  white-space: nowrap;
}

.vh-category-name {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
}

.vh-category-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.vh-category-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
}

.vh-category-progress-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.vh-category-progress-fill {
  height: 100%;
  background: var(--neon-emerald);
  border-radius: 999px;
}

/* --- Collection & Study Toolbar --- */
.vh-toolbar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vh-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.vh-search-input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 9px 14px;
  border-radius: 10px;
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 13.5px;
}

.vh-search-input:focus {
  border-color: var(--neon-emerald);
  outline: none;
}

.vh-select {
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 13px;
  max-width: 100%;
}

.vh-select:focus {
  border-color: var(--neon-emerald);
  outline: none;
}

.vh-status-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.vh-tab-btn {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--glass-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.vh-tab-btn.is-active,
.vh-tab-btn:hover {
  border-color: var(--neon-emerald);
  color: var(--neon-emerald);
  background: rgba(0, 245, 196, 0.12);
}

.vh-results-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.vh-results-count strong {
  color: var(--text-primary);
}

.vh-session-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* --- Responsive Flashcard Grid ---
   Large desktop: 6-7, Laptop: 5, Landscape tablet: 4, Portrait tablet: 3, Mobile: 2 */
.vh-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 640px) {
  .vh-card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (min-width: 900px) {
  .vh-card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .vh-card-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (min-width: 1440px) {
  .vh-card-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (min-width: 1720px) {
  .vh-card-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

/* --- Two-Sided 3D Flashcard --- */
.vh-flashcard {
  perspective: 1100px;
  min-height: 270px;
  position: relative;
}

.vh-flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 270px;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
}

.vh-flashcard.is-flipped .vh-flashcard-inner {
  transform: rotateY(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .vh-flashcard-inner {
    transition: none;
  }
}

.vh-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  overflow: hidden;
  box-sizing: border-box;
}

.vh-flashcard.is-known .vh-face {
  border-color: rgba(0, 245, 196, 0.45);
}

.vh-face-front {
  z-index: 2;
}

.vh-face-back {
  transform: rotateY(180deg);
  background: var(--bg-surface-elevated);
  overflow-y: auto;
  gap: 8px;
}

.vh-card-top-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
}

.vh-front-orbit-icon {
  justify-self: center;
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(0, 245, 196, 0.35));
}

.vh-cefr-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(0, 245, 196, 0.14);
  color: var(--neon-emerald);
  border: 1px solid rgba(0, 245, 196, 0.28);
}

.vh-pos-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vh-front-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  margin: auto 0;
  padding: 6px 0;
}

.vh-term {
  font-size: clamp(16px, 1.5vw, 19px);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin: 0;
}

.vh-audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(0, 245, 196, 0.12);
  border: 1px solid rgba(0, 245, 196, 0.3);
  color: var(--neon-emerald);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.vh-audio-btn:hover,
.vh-audio-btn:focus-visible {
  background: rgba(0, 245, 196, 0.24);
  transform: scale(1.04);
  outline: none;
}

.vh-tap-hint {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

.vh-back-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.vh-back-term {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.vh-ipa {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--neon-cyan, #38bdf8);
  overflow-wrap: anywhere;
}

.vh-definition {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-primary);
  margin: 0;
}

.vh-example {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0;
}

.vh-highlight {
  background: rgba(0, 245, 196, 0.16);
  color: var(--neon-emerald);
  font-weight: 700;
  padding: 0 3px;
  border-radius: 4px;
}

.vh-source-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.vh-back-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
}

.vh-card-ctrl-btn {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border-subtle);
  background: var(--glass-card);
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.vh-card-ctrl-btn.is-active {
  background: rgba(0, 245, 196, 0.16);
  border-color: var(--neon-emerald);
  color: var(--neon-emerald);
}

.vh-card-ctrl-btn:hover,
.vh-card-ctrl-btn:focus-visible {
  border-color: var(--neon-emerald);
  color: var(--neon-emerald);
  outline: none;
}

.vh-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

.vh-empty-state {
  text-align: center;
  padding: 48px 20px;
  border-radius: 18px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-subtle);
  color: var(--text-muted);
}

/* --- Light Theme Compliance --- */
html[data-theme="light"] .ielts-vocab-entry-card,
html[data-theme="light"] .vh-panel,
html[data-theme="light"] .vh-toolbar,
html[data-theme="light"] .vh-face,
html[data-theme="light"] .vh-face-back,
html[data-theme="light"] .vh-type-legend-btn,
html[data-theme="light"] .vh-cefr-row,
html[data-theme="light"] .vh-category-card {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(13, 148, 136, 0.24);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .vh-search-input,
html[data-theme="light"] .vh-select {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(13, 148, 136, 0.3);
}

html[data-theme="light"] .vh-cefr-bar-track,
html[data-theme="light"] .vh-category-progress-bar {
  background: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .vh-highlight {
  background: rgba(13, 148, 136, 0.14);
  color: #0f766e;
}
