/* Global theme using provided palette */
:root {
  --c1: #0388A6;
  /* primary */
  --c2: #03A6A6;
  /* secondary */
  --c3: #A0A603;
  /* accent 1 */
  --c4: #D9A407;
  /* accent 2 (warning) */
  --c5: #D97925;
  /* accent 3 */

  /* translucent tints */
  --c1-10: rgba(3, 136, 166, 0.10);
  --c1-20: rgba(3, 136, 166, 0.20);
  --c2-10: rgba(3, 166, 166, 0.10);
  --c2-20: rgba(3, 166, 166, 0.20);
  --c3-10: rgba(160, 166, 3, 0.10);
  --c3-20: rgba(160, 166, 3, 0.20);
  --c4-10: rgba(217, 164, 7, 0.10);
  --c4-20: rgba(217, 164, 7, 0.20);
  --c5-10: rgba(217, 121, 37, 0.10);
  --c5-20: rgba(217, 121, 37, 0.20);

  --bg: #f4f7f6;
  /* Neutral calm light gray */
  --text: #000000;
}

/* Base text + background */
html,
body {
  background: var(--bg);
  color: var(--text);
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Force Tailwind gray text utilities to black (per requirement that all text is black) */
.text-gray-900,
.text-gray-800,
.text-gray-700,
.text-gray-600,
.text-gray-500,
.text-gray-400 {
  color: var(--text) !important;
}

/* Enhanced video button animations */
#videoPanelToggle {
  animation: videoPulse 2s infinite;
  box-shadow: 0 4px 15px var(--c5-20);
}

#videoPanelToggle:hover {
  animation: none;
  box-shadow: 0 6px 20px var(--c5-20);
  filter: brightness(1.1);
}

@keyframes videoPulse {

  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 4px 15px var(--c5-20);
  }

  50% {
    transform: scale(1.05);
    box-shadow: 0 6px 20px var(--c5-20);
  }
}

/* Video thumbnail hover effects */
.video-thumbnail {
  transition: all 0.3s ease;
}

.video-thumbnail:hover {
  transform: scale(1.05);
}

/* Minimal fallback for Tailwind sizing utilities used by inline SVG icons
  Ensures icons remain visible if the Tailwind CDN fails to load */
.w-4 {
  width: 1rem;
}

.h-4 {
  height: 1rem;
}

.w-6 {
  width: 1.5rem;
}

.h-6 {
  height: 1.5rem;
}

/* Map common Tailwind backgrounds/borders (for generated content) to theme tints */
.bg-gray-50 {
  background: var(--c1-10) !important;
}

.bg-gray-100 {
  background: var(--c2-10) !important;
}

.hover\:bg-gray-200:hover {
  background: var(--c2-20) !important;
}

.border-gray-200,
.border-gray-300 {
  border-color: var(--c1-20) !important;
}

.text-gray-100 {
  color: #f8f8f2 !important;
}

/* align with Prism Tomorrow */
.bg-gray-900 {
  background: #2d2d2d !important;
}

/* align with Prism Tomorrow */

/* Links should be black by default; show underline on hover */
a {
  color: var(--text);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Themed link helper (explicit) */
.theme-link {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  font-weight: 600;
}

.theme-link:hover {
  text-decoration-color: var(--c1);
  background: var(--c1-10);
  border-radius: 4px;
}

.theme-link:focus {
  outline: 2px solid var(--c1-20);
  outline-offset: 2px;
}

/* Add a subtle external-link indicator for absolute links */
a.theme-link[href^="http"],
a.theme-link[href^="https"] {
  position: relative;
  padding-right: 0.15rem;
}

a.theme-link[href^="http"]::after,
a.theme-link[href^="https"]::after {
  content: "↗";
  font-size: 0.8em;
  margin-left: 0.25rem;
}

/* Hero + feature styles using palette (kept light so black text remains readable) */
.hero-gradient {
  background: linear-gradient(135deg, var(--c1-10), var(--c2-10));
  border: 1px solid var(--c1);
}

.feature-icon {
  background: linear-gradient(135deg, var(--c3-20), var(--c5-20));
  color: var(--text);
}

/* Hero emoji/container box */
.hero-box {
  background: var(--c2-10);
  border: 1px solid var(--c1-20);
}

/* Topic cards */
.topic-card {
  background: #fff;
  border: 1px solid var(--c2);
  color: var(--text);
}

.topic-card:hover {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.10), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: translateY(-4px);
}

/* Topic card typography (smaller so multiple cards fit neatly side-by-side) */
.topic-card h3 {
  font-size: 1.125rem;
  line-height: 1.5rem;
}

.topic-card .caption {
  font-size: 0.875rem;
}

.topic-card p {
  font-size: 0.9375rem;
  line-height: 1.4;
}

/* Navigation links */
.nav-link {
  background: #fff;
  color: var(--text);
  border: 2px solid var(--c1);
}

.nav-link:hover {
  background: var(--c1-10);
}

.nav-link--active {
  background: var(--c1);
  color: #fff;
  border-color: var(--c1);
}

/* Small colored dot/badge helpers */
.dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--c3);
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  background: var(--c4-10);
  color: var(--text);
  border: 1px solid var(--c4);
  font-size: 0.75rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--c1-20);
}

th {
  background: var(--c2-10);
  font-weight: 600;
}

/* Theme table helpers (for HTML emitted by markdown loader) */
.theme-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--c1-20);
}

.theme-table-head {
  background: var(--c2-10);
}

.theme-table-th {
  padding: 0.5rem 1rem;
  text-align: left;
  border: 1px solid var(--c1-20);
  font-weight: 600;
  color: var(--text);
}

.theme-table-td {
  padding: 0.5rem 1rem;
  border: 1px solid var(--c1-20);
  color: var(--text);
}

/* Alerts */
.alert-box {
  padding: 1rem;
  border-radius: 0.5rem;
  margin: 1.5rem 0;
  border-left: 4px solid;
}

.alert-warning {
  background: var(--c4-10);
  border-color: var(--c4);
  color: var(--text);
}

.alert-info {
  background: var(--c1-10);
  border-color: var(--c1);
  color: var(--text);
}

/* Theme alert helpers */
.theme-alert-error {
  background: var(--c5-10);
  border-left: 4px solid var(--c5);
  color: var(--text);
  border-radius: 0.5rem;
}

.theme-alert-error-title {
  font-weight: 600;
  color: var(--text);
}

.theme-alert-error-desc {
  color: var(--text);
  opacity: 0.9;
}

/* Inline code (regular text is black; code highlight colors are controlled by Prism) */
code {
  background: var(--c1-10);
  color: var(--text);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
}

/* Explicit inline code helper */
.theme-inline-code {
  background: var(--c1-10);
  color: var(--text);
}

/* Code blocks: don't force our own colors; let Prism theme handle syntax colors. Just spacing and radius. */
pre {
  border-radius: 0.5rem;
  margin: 0;
}

pre code {
  font-size: 0.875rem;
  line-height: 1.5;
}

.code-container {
  background: transparent;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--c1-20);
}

/* Optional explicit codeblock wrapper if used */
.theme-codeblock {
  background: transparent;
  color: inherit;
}

/* Copy button uses palette and black text */
.copy-button {
  background: var(--c5-20);
  color: var(--text);
  border: 1px solid var(--c5);
}

.copy-button:hover {
  background: var(--c5-20);
  filter: brightness(0.98);
}

.copy-success {
  background: var(--c3) !important;
  color: var(--text) !important;
}

/* Blockquotes override Tailwind yellows */
blockquote {
  background: var(--c4-10) !important;
  border-color: var(--c4) !important;
  color: var(--text) !important;
}

/* Explicit blockquote helper */
.theme-blockquote {
  background: var(--c4-10);
  border-left: 4px solid var(--c4);
  padding: 1rem;
  color: var(--text);
}

/* Tables (generated) header override class */
.table-head {
  background: var(--c2-10);
}

/* Captions */
.caption {
  color: var(--text);
  opacity: 0.8;
}

.theme-caption {
  color: var(--text);
  opacity: 0.8;
}

.theme-paragraph {
  color: var(--text);
}

.theme-text-heading {
  color: var(--text);
}

.theme-image-border {
  border-color: var(--c1-20) !important;
}

/* Lists */
.theme-list-item {
  color: var(--text);
}

.theme-ul {
  list-style: disc inside;
}

.theme-ol {
  list-style: decimal inside;
}

/* Video panel */
#videoPanel {
  background: #fff;
}

#videoPanel .panel-header {
  background: var(--c1-10);
}

/* Terminal presentation (use light theme and black text) */
.terminal-container {
  background: var(--c1-10);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--c1);
}

.terminal-header {
  background: var(--c1-20);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--c1);
}

.terminal-buttons {
  display: flex;
  gap: 6px;
}

.terminal-button {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.terminal-button.close {
  background: var(--c5);
}

.terminal-button.minimize {
  background: var(--c4);
}

.terminal-button.maximize {
  background: var(--c3);
}

.terminal-title {
  color: #000;
  font-size: 12px;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.terminal-body {
  padding: 16px;
  background: var(--c1-10);
}

.terminal-output {
  color: #000;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Optional theme-terminal alias classes (if used by JS) */
.theme-terminal-header {
  background: var(--c1-20);
  border-bottom: 1px solid var(--c1);
}

.theme-terminal-body {
  background: var(--c1-10);
}

/* Elegant section separator */
.section-separator {
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, transparent 0%, var(--c4) 20%, var(--c4) 80%, transparent 100%);
  margin: 3rem 0 2rem 0;
  border: none;
  border-radius: 2px;
  box-shadow: 0 2px 4px var(--c4-20);
}

/* Uppgifts-sektion med subtil bakgrund */
.uppgifter-section {
  background: var(--c3-10);
  padding: 2rem;
  border-radius: 12px;
  margin-top: 1rem;
  border: 1px solid var(--c3-20);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Kollapsbara demo-block för react:demo kodblock */
.collapsible-demo {
  margin: 1rem 0;
  border: 1px solid var(--c1-20);
  border-radius: 0.5rem;
  overflow: hidden;
  background: #fff;
}

.collapsible-demo-header {
  background: var(--c1-10);
  padding: 0.75rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--c1-20);
  transition: background-color 0.2s ease;
}

.collapsible-demo-header:hover {
  background: var(--c1-20);
}

.collapsible-demo-title {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
}

.collapsible-demo-toggle {
  background: var(--c5);
  color: white;
  border: none;
  border-radius: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.collapsible-demo-toggle:hover {
  background: var(--c5);
  filter: brightness(0.9);
}

.collapsible-demo-toggle:active {
  transform: scale(0.95);
}

.collapsible-demo-content {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background: #f8f9fa;
}

.collapsible-demo-content.expanded {
  max-height: 2000px;
  transition: max-height 0.3s ease-out;
}

.collapsible-demo-content.collapsed {
  max-height: 0;
  transition: max-height 0.3s ease-in;
}

.collapsible-demo-content pre {
  margin: 0;
  border-radius: 0;
  background: transparent;
}

.collapsible-demo-content .code-container {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* Ikon för expand/collapse */
.collapsible-demo-icon {
  transition: transform 0.2s ease;
  font-size: 0.8rem;
}

.collapsible-demo-icon.expanded {
  transform: rotate(180deg);
}

/* Information section wrapper */
.info-section {
  background: #eef5f9;
  /* Very light calm blue-gray */
  padding: 2rem;
  border-radius: 12px;
  margin-bottom: 2rem;
  border: 1px solid var(--c1-20);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Uppgifts-sektion med subtil bakgrund */
.uppgifter-section {
  background: #fdfbe6;
  /* Light warm beige/yellow tint (calm) */
  padding: 2rem;
  border-radius: 12px;
  margin-top: 1rem;
  border: 1px solid var(--c4-20);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Persistent programming-language selector */
.language-switcher {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 50;
}

.language-switcher--embedded {
  position: relative;
  top: auto;
  left: auto;
}

.language-switcher-trigger {
  width: 4rem;
  height: 4rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  color: #fff;
  background: var(--c1);
  border: 2px solid var(--c1);
  border-radius: 9999px;
  box-shadow: 0 4px 15px var(--c1-20);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
}

.language-switcher-trigger:hover,
.language-switcher-trigger:focus-visible,
.language-switcher.is-open .language-switcher-trigger {
  transform: scale(1.1);
  box-shadow: 0 6px 20px var(--c1-20);
  filter: brightness(1.08);
}

.language-switcher-trigger:focus-visible {
  outline: 3px solid var(--c1-20);
  outline-offset: 3px;
}

.language-switcher-symbol {
  width: 1.1rem;
  height: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

.language-switcher-symbol svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.language-switcher-current {
  max-width: 3.3rem;
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-switcher-menu {
  position: absolute;
  top: calc(100% + 0.75rem);
  left: 0;
  width: 12rem;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--c1);
  border-radius: 0.75rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.5rem) scale(0.96);
  transform-origin: top left;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.language-switcher.is-open .language-switcher-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.language-switcher-heading {
  margin: 0;
  padding: 0.4rem 0.55rem 0.55rem;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
}

.language-switcher-option {
  width: 100%;
  padding: 0.6rem 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.language-switcher-option:hover,
.language-switcher-option:focus-visible {
  background: var(--c1-10);
  outline: none;
}

.language-switcher-option.is-active {
  background: var(--c1-20);
}

.language-switcher-check {
  color: var(--c1);
  opacity: 0;
}

.language-switcher-option.is-active .language-switcher-check {
  opacity: 1;
}

/* Balanced controls around the heading on the course overview page */
.course-hero {
  position: relative;
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr) 4rem;
  align-items: center;
  gap: 1.25rem;
}

.course-hero h1 {
  min-width: 0;
  margin: 0 !important;
  text-align: center;
}

.course-hero-language-slot {
  min-width: 4rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.course-hero .language-switcher-menu {
  text-align: left;
}

.course-hero-video-button {
  width: 4rem;
  height: 4rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  justify-self: end;
  color: #fff;
  background: var(--c5);
  border: 2px solid var(--c5);
  border-radius: 9999px;
  box-shadow: 0 4px 15px var(--c5-20);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
}

.course-hero-video-button:hover,
.course-hero-video-button:focus-visible {
  animation: none !important;
  transform: scale(1.1);
  box-shadow: 0 6px 20px var(--c5-20);
  filter: brightness(1.08);
}

.course-hero-video-button:focus-visible {
  outline: 3px solid var(--c5-20);
  outline-offset: 3px;
}

.course-hero-video-button svg {
  width: 1.25rem;
  height: 1.25rem;
}

.course-hero-video-label {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.1;
}

.home-video-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 70;
  width: min(24rem, 100%);
  height: 100dvh;
  overflow-y: auto;
  background: #fff;
  border-left: 1px solid var(--c1-20);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.18);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s ease, visibility 0.3s ease;
}

.home-video-panel.is-open {
  transform: translateX(0);
  visibility: visible;
}

.home-video-panel-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--c1-10);
  border-bottom: 1px solid var(--c1-20);
}

.home-video-panel-close {
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: #fff;
  border: 1px solid var(--c1-20);
  border-radius: 9999px;
  cursor: pointer;
}

.home-video-panel-close:hover,
.home-video-panel-close:focus-visible {
  background: var(--c1-10);
  outline: 2px solid var(--c1-20);
  outline-offset: 2px;
}

.home-video-panel-content {
  padding: 1rem;
}

.home-video-panel-intro {
  margin: 0 0 1rem;
  line-height: 1.55;
}

.home-video-links {
  display: grid;
  gap: 0.65rem;
}

.home-video-link {
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text);
  background: var(--c1-10);
  border: 1px solid var(--c1-20);
  border-radius: 0.75rem;
  font-weight: 700;
  text-decoration: none;
}

.home-video-link:hover,
.home-video-link:focus-visible {
  background: var(--c1-20);
  outline: 2px solid var(--c1-20);
  outline-offset: 2px;
}

.home-video-playlist-link {
  margin-top: 1rem;
  background: var(--c5);
  border-color: var(--c5);
  color: #fff;
}

.home-video-playlist-link:hover,
.home-video-playlist-link:focus-visible {
  background: var(--c5);
  filter: brightness(1.08);
}

.home-video-panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.35);
  border: 0;
  opacity: 0;
  visibility: hidden;
  cursor: pointer;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.home-video-panel-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}

body.home-video-panel-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .language-switcher-trigger {
    width: 3.5rem;
    height: 3.5rem;
  }

  .language-switcher-menu {
    width: 11rem;
  }

  .course-hero {
    grid-template-columns: 3.5rem minmax(0, 1fr) 3.5rem;
    gap: 0.5rem;
  }

  .course-hero-language-slot {
    min-width: 3.5rem;
  }

  .course-hero-video-button {
    width: 3.5rem;
    height: 3.5rem;
  }

  .course-hero .language-switcher-menu {
    position: fixed;
    top: 5.25rem;
    left: 1rem;
  }
}
