/* ============================================
   ENHANCEMENTS.CSS - Innovative additions
   InterSystems IRIS Arabic Academy
   ============================================ */

/* ====== PRINT STYLES ====== */
@media print {
  body { background: #fff; color: #000; }
  .main-nav, .scroll-progress, .theme-toggle, .mobile-menu-btn,
  .mobile-menu, .skip-link, .quiz-submit, .course-navigation,
  .footer, .nav-back, .codelab-toolbar, .lab-hint-btn { display: none !important; }
  .course-content-wrapper { display: block; }
  .course-sidebar { display: none; }
  .course-main { max-width: 100%; padding: 0; }
  .lesson { page-break-inside: avoid; }
  .code-block { border: 1px solid #ccc; background: #f5f5f5; }
  .code-block code { color: #333; }
  a { color: #0066cc; text-decoration: underline; }
  .quiz-question { page-break-inside: avoid; }
  h1, h2, h3, h4 { page-break-after: avoid; }
  .hero { min-height: auto; padding: 2rem; }
  .path-card, .feature-card { break-inside: avoid; }
}

/* ====== BACK TO TOP BUTTON ====== */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--gold);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--transition-base);
  z-index: 900;
  backdrop-filter: blur(10px);
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
}
.back-to-top:hover {
  background: var(--gold);
  color: var(--bg-deep);
  box-shadow: var(--shadow-glow-gold);
  transform: translateY(-3px);
}

/* ====== READING PROGRESS BAR ====== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 1001;
  background: transparent;
}
.reading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--teal), var(--blue));
  width: 0%;
  transition: width 100ms linear;
  border-radius: 0 2px 2px 0;
}

/* ====== SCROLL REVEAL ANIMATIONS ====== */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}
.reveal-left {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal-left.revealed {
  opacity: 1;
  transform: translateX(0);
}
.reveal-scale {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal-scale.revealed {
  opacity: 1;
  transform: scale(1);
}

/* ====== KEYBOARD SHORTCUT HINTS ====== */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15em 0.5em;
  font-family: var(--font-mono);
  font-size: 0.75em;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  box-shadow: 0 2px 0 var(--border-default);
  line-height: 1;
  min-width: 1.5em;
  text-align: center;
}

/* ====== TOOLTIP ====== */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  padding: 0.4em 0.8em;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-primary);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
  z-index: 100;
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ====== NOTIFICATION TOAST ====== */
.toast-container {
  position: fixed;
  top: 5rem;
  right: 1.5rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.8rem 1.2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.toast-success { border-right: 3px solid var(--green); }
.toast-info { border-right: 3px solid var(--blue); }
.toast-warning { border-right: 3px solid var(--gold); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateX(50px); }
}

/* ====== COURSE COMPLETION BADGE ====== */
.completion-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  background: linear-gradient(135deg, rgba(6, 214, 160, 0.15), rgba(46, 196, 182, 0.1));
  border: 1px solid rgba(6, 214, 160, 0.3);
  border-radius: var(--radius-full);
  color: var(--green);
  font-weight: 600;
  font-size: var(--text-sm);
  animation: badgePop 0.5s var(--transition-spring);
}
@keyframes badgePop {
  0% { transform: scale(0); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ====== ESTIMATED READ TIME ====== */
.read-time {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  direction: ltr;
}

/* ====== CODE BLOCK ENHANCEMENTS ====== */
.code-block {
  position: relative;
}
.code-copy-btn {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.3rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-xs);
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition-fast);
  font-family: var(--font-mono);
  direction: ltr;
}
.code-block:hover .code-copy-btn {
  opacity: 1;
}
.code-copy-btn:hover {
  background: var(--gold);
  color: var(--bg-deep);
  border-color: var(--gold);
}
.code-copy-btn.copied {
  background: var(--green);
  color: var(--bg-deep);
  border-color: var(--green);
}

/* ====== TABLE OF CONTENTS ACTIVE STATE ====== */
.toc-link.active {
  color: var(--gold);
  background: rgba(212, 168, 67, 0.08);
  border-right: 2px solid var(--gold);
}
.toc-link {
  border-right: 2px solid transparent;
  transition: all var(--transition-fast);
}

/* ====== LESSON COMPLETED INDICATOR ====== */
.lesson.completed .lesson-title::after {
  content: '✓';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--green);
  color: var(--bg-deep);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  margin-right: 0.5rem;
  animation: badgePop 0.3s ease;
}

/* ====== FOCUS VISIBLE STYLES ====== */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ====== SELECTION STYLES ====== */
::selection {
  background: rgba(212, 168, 67, 0.3);
  color: var(--text-heading);
}

/* ====== SMOOTH PAGE TRANSITIONS ====== */
@view-transition {
  navigation: auto;
}
::view-transition-old(root) {
  animation: fadeOut 0.2s ease;
}
::view-transition-new(root) {
  animation: fadeIn 0.3s ease;
}

/* ====== RESPONSIVE ENHANCEMENTS ====== */
@media (max-width: 768px) {
  .back-to-top {
    bottom: 1rem;
    left: 1rem;
    width: 40px;
    height: 40px;
  }
  .toast-container {
    right: 0.5rem;
    left: 0.5rem;
  }
  .toast {
    max-width: 100%;
  }
}

/* ====== REDUCED MOTION ====== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal, .reveal-left, .reveal-scale {
    opacity: 1;
    transform: none;
  }
}

/* ====== HIGH CONTRAST MODE ====== */
@media (forced-colors: active) {
  .btn-primary {
    border: 2px solid ButtonText;
  }
  .path-card, .feature-card {
    border: 1px solid CanvasText;
  }
}
