/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Flashcard 3D flip styles */
.perspective-1000 {
  perspective: 1000px;
}

.transform-style-preserve-3d {
  transform-style: preserve-3d;
}

.backface-hidden {
  backface-visibility: hidden;
}

.rotate-y-180 {
  transform: rotateY(180deg);
}

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

/* Quiz feedback styles */
.feedback-correct {
  background-color: #d1fae5;
  border: 1px solid #10b981;
  color: #065f46;
}

.feedback-incorrect {
  background-color: #fee2e2;
  border: 1px solid #ef4444;
  color: #991b1b;
}

.option-btn.correct {
  background-color: #d1fae5 !important;
  border-color: #10b981 !important;
  color: #065f46 !important;
}

.option-btn.incorrect {
  background-color: #fee2e2 !important;
  border-color: #ef4444 !important;
  color: #991b1b !important;
}

/* Utility classes */
.hidden {
  display: none !important;
}

/* Prose styling for summary */
.prose p {
  margin-bottom: 1rem;
  line-height: 1.75;
}

.prose strong {
  font-weight: 600;
}

/* Tab styles */
.tab {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #57534e;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  background: none;
  outline: none;
}

.tab:hover {
  color: #1c1917;
  border-bottom-color: #d6d3d1;
}

.tab:focus-visible {
  outline: 2px solid #7c5cff;
  outline-offset: -2px;
  border-radius: 0.25rem;
}

.tab-active {
  color: #7c5cff;
  border-bottom-color: #7c5cff;
}

.tab-badge {
  margin-left: 0.375rem;
  padding: 0.125rem 0.375rem;
  font-size: 0.75rem;
  border-radius: 9999px;
  background-color: #f5f5f4;
  color: #57534e;
}

.tab-active .tab-badge {
  background-color: rgba(124, 92, 255, 0.1);
  color: #7c5cff;
}

/* Tab panel transitions */
.tab-panel {
  animation: fadeIn 0.2s ease-out;
}

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

/* Tabs navigation container - centered with full width */
.tabs-nav {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.tabs-nav::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

/* Mobile responsiveness for tabs */
@media (max-width: 640px) {
  .tab {
    padding: 0.625rem 1rem;
    font-size: 0.8125rem;
    flex-shrink: 0; /* Prevent tabs from shrinking */
  }

  .tab-badge {
    font-size: 0.6875rem;
    padding: 0.0625rem 0.25rem;
  }

  /* Hide icons on very small screens to save space */
  .tab svg {
    display: none;
  }
}

/* ========================================
   Table of Contents (TOC) Styles
   Task 22.2: Summary with dynamic TOC
   ======================================== */

/* TOC + Content layout container */
.summary-with-toc {
  display: flex;
  gap: 2rem;
}

/* TOC Sidebar */
.summary-toc-sidebar {
  display: none;
  flex-shrink: 0;
  width: 12rem;
}

/* Show TOC sidebar on large screens */
@media (min-width: 1024px) {
  .summary-toc-sidebar {
    display: block;
  }
}

/* Summary content area (takes remaining space) */
.summary-content-area {
  flex: 1;
  min-width: 0; /* Prevent flex item from overflowing */
}

/* TOC Navigation - No longer sticky, scrolls with content */
.toc {
  /* Removed sticky positioning for better UX */
}

.toc-header {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #78716c;
  margin-bottom: 0.75rem;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

/* TOC Link styles */
.toc-link {
  display: block;
  padding: 0.375rem 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #57534e;
  text-decoration: none;
  border-radius: 0.25rem;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.toc-link:hover {
  color: #7c5cff;
  background-color: rgba(124, 92, 255, 0.05);
}

/* Active TOC link */
.toc-active {
  color: #7c5cff;
  font-weight: 500;
  background-color: rgba(124, 92, 255, 0.08);
}

/* Nested TOC items (h3) */
.toc-item-nested .toc-link {
  padding-left: 1rem;
  font-size: 0.75rem;
}

/* Left border indicator for active section */
.toc-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 0;
  background-color: #7c5cff;
  transition: height 0.15s ease;
}

.toc-active::before {
  height: 1rem;
}

/* Make TOC links relative for ::before positioning */
.toc-link {
  position: relative;
}

/* Smooth scroll behavior for the entire page */
html {
  scroll-behavior: smooth;
}

/* Scroll margin for anchored headers (to account for sticky header) */
.prose h2[id],
.prose h3[id] {
  scroll-margin-top: 6rem;
}

/* ========================================
   Summary Parts Styles
   Task 22.3: Summary with Parts pagination
   ======================================== */

.summary-parts-container {
  scroll-margin-top: 5rem;
}

/* Navigation bar */
.summary-parts-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background-color: #fafaf9;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.summary-parts-nav-bottom {
  margin-top: 2rem;
  margin-bottom: 0;
  border-top: 1px solid #e7e5e4;
  padding-top: 1.5rem;
  background-color: transparent;
}

/* Navigation buttons */
.summary-parts-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #57534e;
  background-color: white;
  border: 1px solid #e7e5e4;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.summary-parts-btn:hover:not(:disabled) {
  color: #7c5cff;
  border-color: #7c5cff;
  background-color: rgba(124, 92, 255, 0.05);
}

.summary-parts-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Counter display */
.summary-parts-counter {
  font-size: 0.875rem;
  font-weight: 500;
  color: #78716c;
}

.summary-parts-counter-bottom {
  font-size: 0.75rem;
  color: #a8a29e;
}

.summary-parts-counter-bottom .kbd {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  font-size: 0.6875rem;
  font-family: ui-monospace, monospace;
  background-color: #f5f5f4;
  border: 1px solid #d6d3d1;
  border-radius: 0.25rem;
}

/* Part selector dropdown */
.summary-parts-selector {
  margin-bottom: 1rem;
}

.summary-parts-select {
  width: 100%;
  padding: 0.625rem 2.5rem 0.625rem 0.75rem;
  font-size: 0.875rem;
  color: #1c1917;
  background-color: white;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2378716c' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  border: 1px solid #e7e5e4;
  border-radius: 0.375rem;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.summary-parts-select:hover {
  border-color: #d6d3d1;
}

.summary-parts-select:focus {
  outline: none;
  border-color: #7c5cff;
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.1);
}

/* Progress bar with clickable dots */
.summary-parts-progress {
  display: flex;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
}

.summary-parts-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.summary-parts-dot:hover {
  transform: scale(1.5);
  background-color: #7c5cff !important;
}

.summary-parts-dot:focus {
  outline: none;
  box-shadow: 0 0 0 2px white, 0 0 0 4px #7c5cff;
}

/* Part content wrapper */
.summary-part {
  animation: fadeInPart 0.3s ease-out;
}

@keyframes fadeInPart {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Part header */
.summary-part-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #e7e5e4;
}

.summary-part-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1c1917;
  margin: 0;
}

.summary-part-meta {
  font-size: 0.75rem;
  color: #a8a29e;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
  .summary-parts-nav {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .summary-parts-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
  }

  .summary-parts-btn svg {
    display: none;
  }

  .summary-parts-counter {
    order: -1;
    width: 100%;
    text-align: center;
    margin-bottom: 0.25rem;
  }

  .summary-parts-progress {
    gap: 0.25rem;
  }

  .summary-parts-dot {
    width: 0.375rem;
    height: 0.375rem;
  }

  .summary-parts-counter-bottom {
    display: none;
  }
}

/* ========================================
   Immersive Flashcards Styles
   Task 22.4: Self-rating buttons
   ======================================== */

/* Rating button base styles */
.rating-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  min-width: 4rem;
  border-radius: 0.75rem;
  border: 2px solid transparent;
  background-color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

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

.rating-btn:focus {
  outline: none;
}

.rating-btn:focus-visible {
  outline: 2px solid #7c5cff;
  outline-offset: 2px;
}

/* Hard rating (red) */
.rating-hard:hover {
  border-color: #fca5a5;
  background-color: #fef2f2;
}

.rating-hard:active,
.rating-hard.selected {
  border-color: #ef4444;
  background-color: #fee2e2;
}

/* Okay rating (yellow) */
.rating-okay:hover {
  border-color: #fcd34d;
  background-color: #fffbeb;
}

.rating-okay:active,
.rating-okay.selected {
  border-color: #f59e0b;
  background-color: #fef3c7;
}

/* Good rating (green) */
.rating-good:hover {
  border-color: #86efac;
  background-color: #f0fdf4;
}

.rating-good:active,
.rating-good.selected {
  border-color: #22c55e;
  background-color: #dcfce7;
}

/* Easy rating (blue) */
.rating-easy:hover {
  border-color: #93c5fd;
  background-color: #eff6ff;
}

.rating-easy:active,
.rating-easy.selected {
  border-color: #3b82f6;
  background-color: #dbeafe;
}

/* Notion primary color for progress dots */
.bg-notion-primary {
  background-color: #2383E2;
}

/* Mobile responsiveness for rating buttons */
@media (max-width: 640px) {
  .rating-btn {
    padding: 0.5rem 0.75rem;
    min-width: 3.5rem;
  }

  .rating-btn span.text-xl {
    font-size: 1.25rem;
  }
}

/* ========================================
   Quiz Pagination Styles
   Task 22.5: Quiz with pagination, filters, progress
   ======================================== */

/* Filter buttons */
.quiz-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  outline: none;
}

.quiz-filter-btn:focus-visible {
  outline: 2px solid #7c5cff;
  outline-offset: 2px;
}

.quiz-filter-btn.filter-active {
  color: #7c5cff;
  background-color: rgba(124, 92, 255, 0.1);
}

.quiz-filter-btn:not(.filter-active):hover {
  background-color: #e7e5e4;
}

/* Pagination buttons */
.quiz-pagination-btn {
  user-select: none;
}

.quiz-pagination-btn:focus-visible {
  outline: 2px solid #7c5cff;
  outline-offset: 2px;
}

/* Keyboard shortcut hint */
.kbd {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  font-size: 0.6875rem;
  font-family: ui-monospace, monospace;
  background-color: #f5f5f4;
  border: 1px solid #d6d3d1;
  border-radius: 0.25rem;
  box-shadow: 0 1px 0 #d6d3d1;
}

/* kbd variant for dark backgrounds (e.g., primary buttons) */
.kbd-light {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  font-size: 0.6875rem;
  font-family: ui-monospace, monospace;
  background-color: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 0.25rem;
  color: white;
}

/* Progress bar animation */
.quiz-progress-bar {
  transition: width 0.3s ease-out, background-color 0.3s ease;
}

/* Question fade animation */
.quiz-question-enter {
  animation: quizFadeIn 0.2s ease-out;
}

@keyframes quizFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile responsiveness for quiz pagination */
@media (max-width: 640px) {
  .quiz-filter-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
  }

  .quiz-pagination-btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
  }

  .quiz-pagination-btn svg {
    width: 0.875rem;
    height: 0.875rem;
  }
}

/* ========================================
   Sticky Tabs Navigation
   Study Pack - Tabs stay fixed while scrolling
   ======================================== */

.tabs-nav-sticky {
  position: sticky;
  top: 3.5rem; /* Below the fixed header (h-14 = 56px = 3.5rem) */
  background-color: white;
  z-index: 40;
  padding-top: 0.5rem;
  padding-bottom: 0;
}

/* Mobile adjustments for sticky tabs */
@media (max-width: 640px) {
  .tabs-nav-sticky {
    top: 3.5rem;
  }
}

/* ========================================
   Tabs Container - Unified tabs + content
   Makes tabs visually connect with content panel
   ======================================== */

.tabs-container {
  background-color: white;
  border: 1px solid #e7e5e4;
  border-radius: 0.5rem;
  overflow: hidden;
}

.tabs-container .tabs-nav {
  border-bottom: 1px solid #e7e5e4;
  background-color: #fafaf9;
  padding: 0.75rem 1rem 0;
}

.tabs-container .tab-panel {
  padding: 1.5rem;
}

/* Remove card styling from tab panel content when inside tabs-container */
.tabs-container .tab-panel .card {
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

/* But keep nested cards styled (like in flashcards) */
.tabs-container .tab-panel .card .card {
  border: 1px solid #e7e5e4;
  border-radius: 0.5rem;
  padding: 1.5rem;
}
