/* style.css */

/* The container for the highlighted word and its tooltip */
.tooltip-container {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted #007bff; /* Dotted underline to indicate interactivity */
  cursor: help;
}

/* The tooltip text bubble */
.tooltip-text {
  display:none;
  visibility: hidden;
  opacity: 0;
  width: min(320px, calc(100vw - 32px));   /* Increased padding for edge clearance */
  background-color: #333;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 10px;
  position: absolute;
  z-index: 100;
  bottom: 125%;
  left: 50%;
  transform: translateX(calc(-50% + var(--tooltip-shift, 0px)));
  transition: opacity 0.3s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  font-size: 1.25rem; /* Changed from 14px to 1.25rem */
  line-height: 1.4;
  margin-bottom: 5px; /* Add small gap to bridge the space */
  pointer-events: auto; /* Ensure tooltip can receive mouse events */
  max-width: min(320px, calc(100vw - 32px)); /* Ensure tooltip doesn't exceed viewport */
  min-width: 200px; /* Ensure tooltip has reasonable minimum width */
}

/* Constrain tooltips within .light-block boundaries */
.light-block .tooltip-text {
  max-width: min(320px, calc(100% - 16px)); /* Constrain to light-block width minus padding */
}

/* Tooltip positioned below the word */
.tooltip-text.tooltip-below {
  bottom: auto;
  top: 125%;
  margin-bottom: 0;
  margin-top: 5px;
}

/* Tooltip arrow - default (above) */
.tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: calc(50% - var(--tooltip-shift, 0px));
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #333 transparent transparent transparent;
  pointer-events: none; /* Arrow doesn't need pointer events */
}

/* Tooltip arrow - when below */
.tooltip-text.tooltip-below::after {
  top: auto;
  bottom: 100%;
  border-color: transparent transparent #333 transparent;
}

/* Show the tooltip on hover */
.tooltip-container:hover .tooltip-text {
    display: block; 
  visibility: visible;
  opacity: 1;
}

/* Also show the tooltip when it has the .tooltip-visible class (for tap/click) */
.tooltip-text.tooltip-visible {
    display: block; 
  visibility: visible;
  opacity: 1;
}

/* Style for the tooltip title */
.tooltip-text strong {
  display: block;
  margin-bottom: 5px;
  color: #00BFA5; /* Teal to match site styling */
  font-size: 1.25rem; /* Changed from 16px to 1.25rem */
}

/* Review Lesson button */
.tooltip-review-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  background-color: #00BFA5; /* Teal to match site styling */
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.25rem; /* Changed from 13px to 1.25rem */
  font-weight: 500;
  text-align: center;
  transition: background-color 0.2s;
}

.tooltip-review-btn:hover {
  background-color: #00a693; /* Darker teal on hover */
}

.tooltip-review-btn:active {
  background-color: #008f7e; /* Even darker teal on active */
}

/* Mini-Lesson Modal Styles */
.mini-lesson-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.mini-lesson-modal {
  position: relative;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
}

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

.mini-lesson-modal-header {
  background: #FB8C00;
  color: #ffffff;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  flex-shrink: 0;
}

.mini-lesson-modal-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #ffffff;
}

.mini-lesson-modal-close-x {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  padding: 0;
}

.mini-lesson-modal-close-x:hover {
  background: rgba(255, 255, 255, 0.2);
}

.mini-lesson-modal-close-x:focus {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.mini-lesson-modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  background: #ffffff;
}

/* Hide quiz forms in mini lessons only */
.mini-lesson-modal-content form {
  display: none !important;
}

.mini-lesson-modal-content .practice-game-link-panel {
  display: none;
}

.mini-lesson-loading,
.mini-lesson-error {
  text-align: center;
  padding: 2rem;
  color: #666;
  font-size: 1rem;
}

.mini-lesson-error {
  color: #d32f2f;
}

.mini-lesson-modal-footer {
  padding: 1rem 1.5rem;
  background: #f5f5f5;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

.mini-lesson-modal-close-btn {
  padding: 0.75rem 2rem;
  background: #FB8C00;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.mini-lesson-modal-close-btn:hover {
  background: #e67c00;
}

.mini-lesson-modal-close-btn:focus {
  outline: 2px solid #FB8C00;
  outline-offset: 2px;
}

/* Responsive: Full screen on mobile */
@media (max-width: 768px) {
  .mini-lesson-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  
  .mini-lesson-modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: 16px 16px 0 0;
    animation: slideUpMobile 0.3s ease-out;
  }
  
  @keyframes slideUpMobile {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
  
  .mini-lesson-modal-header {
    padding: 1rem;
  }
  
  .mini-lesson-modal-title {
    font-size: 1.25rem;
  }
  
  .mini-lesson-modal-content {
    padding: 1.5rem 1rem;
  }
  
  .mini-lesson-modal-footer {
    padding: 1rem;
  }
  
  .mini-lesson-modal-close-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
  }
}

/* Legacy: Keep old #mini-lesson styles for backwards compatibility (if needed) */
#mini-lesson {
  display: none;
}

/* Constrain tooltips within .light-block boundaries */
/* The JavaScript handles precise width calculation and positioning based on .light-block boundaries */
/* No CSS override needed - JavaScript sets max-width via inline styles */

/* Mobile: Match .light-block font size */
@media screen and (max-width: 600px) {
  .tooltip-text {
    font-size: 1.125rem !important; /* Match .light-block mobile size */
  }
  
  .tooltip-text strong {
    font-size: 1.125rem !important; /* Match .light-block mobile size */
  }
  
  .tooltip-review-btn {
    font-size: 1.125rem !important; /* Match .light-block mobile size */
  }
  
  .light-block .tooltip-text {
    max-width: min(320px, calc(100% - 16px)) !important; /* Constrain on mobile too */
  }
}