/* ============================================================
   Flashcards — Anki + Notion inspired
   ============================================================ */

.flashcards-dashboard,
.fc-viewer,
.fc-study {
  animation: fadeInUp var(--duration-slow) var(--ease-out) both;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* ─── Header ─── */
.fc-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.fc-header__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.fc-header__back:hover {
  background: var(--color-bg-hover);
}

.fc-header__text {
  flex: 1;
  min-width: 180px;
}

.fc-header__breadcrumb {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  margin-bottom: 4px;
}

.fc-header__title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin: 0;
}

.fc-header__actions {
  display: flex;
  gap: 8px;
}

/* ─── Stats ─── */
.fc-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.fc-stat {
  padding: 16px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.fc-stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.fc-stat__value {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin: 0 0 4px;
}

.fc-stat__label {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin: 0;
}

.fc-stat--forest .fc-stat__value { color: var(--color-accent); }
.fc-stat--amber .fc-stat__value { color: #b8860b; }
.fc-stat--sage .fc-stat__value { color: #4e6b5c; }
.fc-stat--olive .fc-stat__value { color: #5c6b4e; }
.fc-stat--gold .fc-stat__value { color: #c4a035; }

/* ─── Progress ─── */
.fc-progress-panel {
  margin-bottom: 24px;
}

.fc-progress {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 20px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.fc-progress__item {
  text-align: center;
}

.fc-progress__value {
  display: block;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-accent);
}

.fc-progress__label {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
}

/* ─── Toolbar ─── */
.fc-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.fc-toolbar__search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.fc-toolbar__search svg {
  color: var(--color-text-tertiary);
  flex-shrink: 0;
}

.fc-toolbar__input {
  flex: 1;
  padding: 10px 0;
  font-family: inherit;
  font-size: var(--font-size-sm);
  border: none;
  background: transparent;
  color: var(--color-text-primary);
}

.fc-toolbar__input:focus {
  outline: none;
}

.fc-toolbar__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fc-toolbar__select {
  padding: 8px 12px;
  font-family: inherit;
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.fc-count {
  font-size: var(--font-size-sm);
  color: var(--color-text-tertiary);
  margin-bottom: 12px;
}

/* ─── Card list ─── */
.fc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.fc-row:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-accent);
  transform: translateX(4px);
}

.fc-row__type {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.fc-row__body {
  flex: 1;
  min-width: 0;
}

.fc-row__question {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fc-row__meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
}

.fc-row__status--mastered { color: #4e6b5c; }
.fc-row__status--learning { color: #b8860b; }
.fc-row__status--new { color: var(--color-text-tertiary); }

.fc-row__due {
  flex-shrink: 0;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
}

.fc-empty {
  text-align: center;
  padding: 48px 24px;
}

.fc-empty__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin-bottom: 8px;
}

.fc-empty__text {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* ─── 3D Flip Card ─── */
.fc-viewer__stage,
.fc-study .fc-viewer__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 24px 0;
  perspective: 1200px;
}

.fc-flip {
  width: 100%;
  max-width: 520px;
  height: 280px;
  cursor: pointer;
  outline: none;
}

.fc-flip__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.fc-flip--flipped .fc-flip__inner {
  transform: rotateY(180deg);
}

.fc-flip__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 28px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
}

.fc-flip__face--front {
  background: var(--color-bg-elevated);
}

.fc-flip__face--back {
  background: linear-gradient(145deg, var(--color-accent-soft), var(--color-bg-elevated));
  transform: rotateY(180deg);
}

.fc-flip__label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
  margin-bottom: 12px;
}

.fc-flip__text {
  font-size: var(--font-size-md);
  line-height: var(--line-height-relaxed);
  color: var(--color-text-primary);
  text-align: center;
  max-height: 160px;
  overflow-y: auto;
}

.fc-flip__hint {
  margin-top: 16px;
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
}

.fc-flip__badge {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 4px 10px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  text-transform: capitalize;
  border-radius: 999px;
  background: var(--color-bg-subtle);
  color: var(--color-text-secondary);
}

/* ─── Viewer controls ─── */
.fc-viewer__header,
.fc-study__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.fc-viewer__back,
.fc-study__exit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.fc-viewer__counter,
.fc-study__queue {
  margin-left: auto;
  font-size: var(--font-size-sm);
  color: var(--color-text-tertiary);
}

.fc-viewer__meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
}

.fc-viewer__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 16px;
}

.fc-viewer__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: var(--font-size-sm);
  font-family: inherit;
  color: var(--color-text-primary);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.fc-viewer__btn:hover:not(:disabled) {
  background: var(--color-bg-hover);
}

.fc-viewer__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.fc-viewer__btn--primary {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  border-color: var(--color-accent);
}

.fc-viewer__btn--icon.is-active {
  color: #c4a035;
}

.fc-viewer__btn--danger {
  color: #a0522d;
}

/* ─── Study mode ─── */
.fc-study__reveal {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.btn--lg {
  padding: 14px 32px;
  font-size: var(--font-size-md);
}

.fc-study__rating {
  padding: 16px 0 24px;
}

.fc-study__rating-label {
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

.fc-study__rating-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.fc-rating {
  padding: 14px 8px;
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  line-height: 1.3;
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.fc-rating span {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-normal);
  opacity: 0.8;
  margin-top: 4px;
}

.fc-rating:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.fc-rating--again {
  background: #fde8e8;
  color: #8b4513;
  border-color: #e8c4c4;
}

.fc-rating--hard {
  background: #fef3e0;
  color: #9a6b2f;
  border-color: #f0d9b8;
}

.fc-rating--good {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.fc-rating--easy {
  background: #e8f5e9;
  color: #2d5a47;
  border-color: #b8dcc4;
}

[data-theme="dark"] .fc-rating--again { background: #3d2828; color: #e8a898; }
[data-theme="dark"] .fc-rating--hard { background: #3d3528; color: #e8c898; }
[data-theme="dark"] .fc-rating--easy { background: #283d30; color: #98e8b8; }

.fc-study__done {
  text-align: center;
  padding: 64px 24px;
}

.fc-study__done h2 {
  margin-bottom: 12px;
}

/* ─── Edit modal ─── */
.fc-modal {
  max-width: 480px;
}

.fc-edit-form {
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fc-edit__label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
}

.fc-edit__input {
  font-family: inherit;
  font-size: var(--font-size-sm);
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  color: var(--color-text-primary);
  resize: vertical;
}

.fc-edit__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
}

/* ─── Note editor button ─── */
.note-editor__gen-fc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.note-editor__gen-fc-btn:hover {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.note-editor__gen-test-btn {
  color: var(--color-success, #1a7f4b);
  background: color-mix(in srgb, var(--color-success, #1a7f4b) 12%, transparent);
  border-color: var(--color-success, #1a7f4b);
}
.note-editor__gen-test-btn:hover {
  background: var(--color-success, #1a7f4b);
  color: #fff;
}

.note-editor__mem-btn {
  color: #7c3aed;
  background: color-mix(in srgb, #7c3aed 12%, transparent);
  border-color: #7c3aed;
}
.note-editor__mem-btn:hover {
  background: #7c3aed;
  color: #fff;
}

.note-editor__story-btn {
  color: #c2410c;
  background: color-mix(in srgb, #c2410c 12%, transparent);
  border-color: #c2410c;
}
.note-editor__story-btn:hover {
  background: #c2410c;
  color: #fff;
}

.note-editor__podcast-btn {
  color: #9333ea;
  background: color-mix(in srgb, #9333ea 12%, transparent);
  border-color: #9333ea;
}
.note-editor__podcast-btn:hover {
  background: #9333ea;
  color: #fff;
}

/* Highlight toolbar actions when a valid text section is selected */
.note-editor__gen-fc-btn.is-scoped {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 35%, transparent);
  font-weight: var(--font-weight-semibold, 600);
}

.note-editor__gen-test-btn.is-scoped {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-success, #1a7f4b) 35%, transparent);
}

.note-editor__mem-btn.is-scoped {
  box-shadow: 0 0 0 2px color-mix(in srgb, #7c3aed 35%, transparent);
}

.note-editor__story-btn.is-scoped {
  box-shadow: 0 0 0 2px color-mix(in srgb, #c2410c 35%, transparent);
}

.note-editor__podcast-btn.is-scoped {
  box-shadow: 0 0 0 2px color-mix(in srgb, #9333ea 35%, transparent);
}

.note-editor__revise-btn {
  color: #0d9488;
  background: color-mix(in srgb, #0d9488 12%, transparent);
  border-color: #0d9488;
}
.note-editor__revise-btn:hover {
  background: #0d9488;
  color: #fff;
}

.note-editor__revise-btn.is-scoped {
  box-shadow: 0 0 0 2px color-mix(in srgb, #0d9488 35%, transparent);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .fc-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .fc-progress {
    grid-template-columns: repeat(2, 1fr);
  }

  .fc-toolbar__filters {
    flex-direction: column;
  }

  .fc-toolbar__select {
    width: 100%;
  }

  .fc-study__rating-btns {
    grid-template-columns: repeat(2, 1fr);
  }

  .fc-flip {
    height: 260px;
  }

  .fc-viewer__actions {
    gap: 6px;
  }

  .fc-viewer__btn {
    padding: 8px 12px;
    font-size: var(--font-size-xs);
  }
}

@media (max-width: 480px) {
  .fc-stats {
    grid-template-columns: 1fr 1fr;
  }

  .fc-header__actions {
    width: 100%;
  }

  .fc-header__actions .btn {
    flex: 1;
  }
}
