/**
 * H5P Styles for Docusaurus
 */

/* H5P Container Base Styles */
.h5p-container {
  position: relative;
  margin: 20px auto;
  max-width: 100%;
  border: 1px solid var(--ifm-color-emphasis-200);
  border-radius: 8px;
  overflow: hidden;
  background: var(--ifm-background-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Loading State */
.h5p-loading {
  padding: 40px 20px;
  text-align: center;
  color: var(--ifm-color-emphasis-600);
  font-style: italic;
}

.h5p-loading::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--ifm-color-emphasis-300);
  border-top: 2px solid var(--ifm-color-primary);
  border-radius: 50%;
  animation: h5p-spin 1s linear infinite;
  margin-right: 10px;
  vertical-align: middle;
}

@keyframes h5p-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error State */
.h5p-error {
  padding: 20px;
  text-align: center;
  color: var(--ifm-color-danger);
  background: var(--ifm-color-danger-contrast-background);
  border-left: 4px solid var(--ifm-color-danger);
}

.h5p-error p {
  margin: 0 0 10px 0;
  font-weight: 600;
}

.h5p-error small {
  color: var(--ifm-color-emphasis-700);
  font-family: var(--ifm-font-family-monospace);
}

/* Fallback Content */
.h5p-content-fallback {
  padding: 30px 20px;
  text-align: center;
  border: 2px dashed var(--ifm-color-emphasis-300);
  border-radius: 8px;
  margin: 10px;
}

.h5p-content-fallback h3 {
  margin: 0 0 15px 0;
  color: var(--ifm-color-primary);
}

.h5p-content-fallback p {
  margin: 0 0 10px 0;
  color: var(--ifm-color-emphasis-700);
}

.h5p-content-fallback small {
  color: var(--ifm-color-emphasis-600);
  font-family: var(--ifm-font-family-monospace);
}

/* H5P Content Wrapper */
.h5p-content {
  position: relative;
  background: #fff;
}

/* H5P Frame */
.h5p-frame {
  border: none;
  width: 100%;
  height: auto;
  min-height: 400px;
}

/* External H5P iframe styling */
.h5p-container iframe {
  width: 100%;
  min-height: 400px;
  border: none;
  border-radius: 8px;
  background: #fff;
  transition: all 0.3s ease;
}

.h5p-container iframe:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* External H5P loading state */
.h5p-container.external-loading {
  background: var(--ifm-color-emphasis-100);
  border: 2px dashed var(--ifm-color-emphasis-300);
  padding: 20px;
  text-align: center;
}

.h5p-container.external-loading::before {
  content: 'Loading external H5P content...';
  color: var(--ifm-color-emphasis-600);
  font-style: italic;
}

/* H5P Actions (fullscreen, download, etc.) */
.h5p-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 100;
}

.h5p-actions button {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--ifm-color-emphasis-300);
  border-radius: 4px;
  padding: 5px 10px;
  margin-left: 5px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.h5p-actions button:hover {
  background: var(--ifm-color-primary);
  color: white;
  border-color: var(--ifm-color-primary);
}

/* Dark Mode Support */
[data-theme='dark'] .h5p-container {
  border-color: var(--ifm-color-emphasis-300);
  background: var(--ifm-background-color);
}

[data-theme='dark'] .h5p-content {
  background: var(--ifm-background-color);
}

[data-theme='dark'] .h5p-actions button {
  background: rgba(0, 0, 0, 0.8);
  color: white;
  border-color: var(--ifm-color-emphasis-400);
}

/* Responsive Design */
@media (max-width: 768px) {
  .h5p-container {
    margin: 10px 0;
    border-radius: 4px;
  }

  .h5p-actions {
    position: relative;
    top: auto;
    right: auto;
    text-align: center;
    margin: 10px 0;
  }

  .h5p-actions button {
    margin: 2px;
    padding: 8px 12px;
    font-size: 14px;
  }
}

/* H5P Question Set Specific Styles */
.h5p-question-set {
  font-family: var(--ifm-font-family-base);
}

.h5p-question-set .h5p-question {
  padding: 20px;
}

.h5p-question-set .h5p-question-header {
  margin-bottom: 15px;
  font-size: 1.1em;
  font-weight: 600;
  color: var(--ifm-color-emphasis-900);
}

/* H5P MultiChoice Specific Styles */
.h5p-multichoice .h5p-question {
  margin-bottom: 10px;
}

.h5p-multichoice .h5p-alternative {
  margin: 8px 0;
  padding: 10px;
  border: 1px solid var(--ifm-color-emphasis-300);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.h5p-multichoice .h5p-alternative:hover {
  background: var(--ifm-color-emphasis-100);
  border-color: var(--ifm-color-primary);
}

.h5p-multichoice .h5p-alternative.h5p-selected {
  background: var(--ifm-color-primary-light);
  border-color: var(--ifm-color-primary);
}

/* H5P Button Styles */
.h5p-question-set .h5p-button {
  background: var(--ifm-color-primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.h5p-question-set .h5p-button:hover {
  background: var(--ifm-color-primary-dark);
  transform: translateY(-1px);
}

.h5p-question-set .h5p-button:disabled {
  background: var(--ifm-color-emphasis-400);
  cursor: not-allowed;
  transform: none;
}

/* Accessibility Improvements */
.h5p-container:focus-within {
  outline: 2px solid var(--ifm-color-primary);
  outline-offset: 2px;
}

/* Iframe Container Styling */
.iframe-container {
  position: relative;
  margin: 20px auto;
  max-width: 100%;
}

.iframe-container iframe {
  transition: all 0.3s ease;
}

.iframe-container iframe:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
}

/* Lumi.education specific styling */
.lumi-embed-container {
  position: relative;
  transition: all 0.3s ease;
  font-family: 'Inter', 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  line-height: 1.6;
}

.lumi-embed-container:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.lumi-embed iframe {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  transition: all 0.3s ease;
}

/* Enhanced H5P content styling within LumiEmbed */
.lumi-embed-container iframe {
  font-family: 'Inter', 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif !important;
}

/* Auto-resize functionality */
.lumi-embed-container.auto-resize .lumi-embed {
  height: auto !important;
  min-height: 600px;
}

/* Expandable container for feedback content */
.lumi-embed-container.expandable {
  overflow: visible;
}

.lumi-embed-container.expandable .lumi-embed {
  resize: vertical;
  overflow: auto;
}

/* Fullscreen mode */
.lumi-embed-container.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  margin: 0;
  border-radius: 0;
  max-width: none;
  height: 100vh;
}

.lumi-embed-container.fullscreen .lumi-embed {
  height: calc(100vh - 40px) !important;
  border-radius: 0;
}

.lumi-error {
  font-family: var(--ifm-font-family-base);
  background: var(--ifm-color-danger-contrast-background);
  margin: 20px auto;
  max-width: 600px;
}

/* Responsive iframe handling */
@media (max-width: 768px) {
  .iframe-container {
    margin: 10px 0;
  }

  .iframe-container iframe {
    width: 100% !important;
    min-height: 400px;
  }
}

/* Dark mode support for iframes */
[data-theme='dark'] .iframe-container iframe {
  border-color: var(--ifm-color-emphasis-300);
}

[data-theme='dark'] .lumi-embed iframe {
  background: linear-gradient(135deg, var(--ifm-background-color) 0%, var(--ifm-color-emphasis-100) 100%);
}

/* Print Styles */
@media print {
  .h5p-container {
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  .h5p-actions {
    display: none;
  }

  .iframe-container {
    page-break-inside: avoid;
  }

  .iframe-container iframe {
    border: 1px solid #ccc;
  }
}