/**
 * Dark Material theme for the public labs site.
 * Layered over Bootstrap's native dark mode (data-bs-theme="dark"): we override
 * Bootstrap's design tokens with Material ones, then add Material elevation,
 * shape, and typography on the key surfaces.
 */

@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('/fonts/roboto-light.ttf') format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/roboto-regular.ttf') format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/roboto-medium.ttf') format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/roboto-bold.ttf') format('truetype');
}

:root {
  /* Material dark surfaces (base + elevation overlays get progressively lighter) */
  --md-bg: #121212;
  --md-surface-1: #1e1e1e;
  --md-surface-2: #242424;
  --md-surface-3: #2c2c2c;
  --md-surface-4: #333333;
  /* Desaturated primary, per Material dark guidance */
  --md-primary: #82b1ff;
  --md-primary-hover: #a6c8ff;
  --md-on-primary: #0a1a33;
  --md-on-surface: rgba(255, 255, 255, 0.87);
  --md-on-surface-medium: rgba(255, 255, 255, 0.60);
  --md-on-surface-disabled: rgba(255, 255, 255, 0.38);
  --md-outline: rgba(255, 255, 255, 0.12);
  --md-radius: 8px;
  --md-radius-lg: 12px;
  --md-elev-1: 0 1px 3px rgba(0, 0, 0, 0.5);
  --md-elev-2: 0 3px 8px rgba(0, 0, 0, 0.5);
  --md-elev-4: 0 10px 24px rgba(0, 0, 0, 0.55);
}

/* Map Material tokens onto Bootstrap's variables so all components inherit them. */
[data-bs-theme="dark"] {
  --bs-body-bg: var(--md-bg);
  --bs-body-color: var(--md-on-surface);
  --bs-secondary-color: var(--md-on-surface-medium);
  --bs-tertiary-color: var(--md-on-surface-disabled);
  --bs-emphasis-color: #ffffff;
  --bs-border-color: var(--md-outline);
  --bs-border-radius: var(--md-radius);
  --bs-border-radius-lg: var(--md-radius-lg);
  --bs-primary: var(--md-primary);
  --bs-primary-rgb: 130, 177, 255;
  --bs-link-color: var(--md-primary);
  --bs-link-color-rgb: 130, 177, 255;
  --bs-link-hover-color: var(--md-primary-hover);
  --bs-card-bg: var(--md-surface-1);
  --bs-card-border-color: transparent;
  --bs-tertiary-bg: var(--md-surface-2);
  --bs-secondary-bg: var(--md-surface-2);
}

body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--md-bg);
  color: var(--md-on-surface);
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  letter-spacing: 0.15px;
}

.text-muted {
  color: var(--md-on-surface-medium) !important;
}

/* ---- App bar (navbar) ---- */
.navbar {
  background-color: var(--md-surface-2) !important;
  box-shadow: var(--md-elev-2);
  border-bottom: none;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.navbar-brand {
  color: #fff !important;
  font-weight: 500;
}

.navbar-logo {
  height: 40px;
  width: auto;
}

@media (max-width: 575.98px) {
  .navbar-logo {
    height: 28px;
  }
}

/* Header menu */
#header-menu .nav-link {
  color: #fff !important;
  text-decoration: none;
  padding: 10px 14px;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.25px;
  border-radius: var(--md-radius);
  transition: background-color 0.15s ease;
}

#header-menu .nav-link:hover,
#header-menu .nav-link:focus {
  color: #fff !important;
  background-color: rgba(255, 255, 255, 0.08);
}

#header-menu .dropdown-toggle::after {
  display: none;
}

#header-menu .dropdown-chevron {
  display: none;
  font-size: 0.75em;
  transition: transform 0.2s ease;
}

@media (max-width: 991.98px) {
  #header-menu .dropdown-chevron {
    display: inline;
  }
  #header-menu .dropdown-toggle[aria-expanded="true"] .dropdown-chevron {
    transform: rotate(180deg);
  }
}

.dropdown-menu {
  background-color: var(--md-surface-3);
  border: none;
  border-radius: var(--md-radius);
  box-shadow: var(--md-elev-4);
}

.dropdown-item {
  color: var(--md-on-surface);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* ---- Search bar (below header) ---- */
.lab-search-form {
  flex: 0 1 280px;
  min-width: 0;
}

.lab-search-input {
  width: 100%;
  padding: 12px 18px;
  font-size: 15px;
  color: var(--md-on-surface);
  background-color: var(--md-surface-3);
  border: 1px solid transparent;
  border-radius: var(--md-radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.lab-search-input::placeholder {
  color: var(--md-on-surface-disabled);
}

.lab-search-input:focus {
  outline: none;
  border-color: var(--md-primary);
  box-shadow: 0 0 0 0.15rem rgba(130, 177, 255, 0.25);
}

/* ---- Cards ---- */
.card {
  background-color: var(--md-surface-1);
  border: none;
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elev-1);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.card:hover {
  transform: translateY(-3px);
  background-color: var(--md-surface-2);
  box-shadow: var(--md-elev-4);
}

.card-title {
  font-weight: 500;
  color: #fff;
}

.card-footer {
  background-color: transparent;
  border-top: 1px solid var(--md-outline);
  color: var(--md-on-surface-medium);
}

.lab-card-img {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  width: 100%;
}

.lab-card-img-placeholder {
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--md-on-surface-disabled);
  background-color: var(--md-surface-3);
}

/* Project card: description overlay revealed on hover. */
.project-card-media {
  position: relative;
  overflow: hidden;
}

.project-card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0.85rem;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.35;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.project-card-overlay span {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card:hover .project-card-overlay {
  opacity: 1;
}

.project-card-lab-icon {
  width: 18px;
  height: 18px;
  object-fit: cover;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---- Buttons (Material) ---- */
.btn {
  border-radius: var(--md-radius);
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-size: 0.875rem;
}

.btn-primary {
  --bs-btn-bg: var(--md-primary);
  --bs-btn-border-color: var(--md-primary);
  --bs-btn-color: var(--md-on-primary);
  --bs-btn-hover-bg: var(--md-primary-hover);
  --bs-btn-hover-border-color: var(--md-primary-hover);
  --bs-btn-hover-color: var(--md-on-primary);
  box-shadow: var(--md-elev-1);
}

/* ---- Breadcrumbs ---- */
.breadcrumb {
  --bs-breadcrumb-divider: '\203A';
  font-size: 1.25rem;
  margin-bottom: 1.75rem;
}

.breadcrumb-item a {
  color: var(--md-primary);
  text-decoration: none;
}

.breadcrumb-item.active {
  color: var(--md-on-surface-medium);
}

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--md-on-surface-disabled);
}

/* ---- Layout bits ---- */
.page-hero {
  padding: 0.5rem 0 2rem;
}

.page-hero h1 {
  font-weight: 500;
}

.section-heading {
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--md-outline);
}

.hero-img {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  width: 100%;
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elev-2);
}

/* Update image: keeps its natural aspect ratio, fit within the column width
   AND a max height so portrait images don't become absurdly tall. Centered. */
.update-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 80vh;
  margin: 0 auto;
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elev-2);
}

/* Vertical divider between the project sidebar and the content (wide screens). */
@media (min-width: 992px) {
  .project-sidebar-col {
    border-right: 1px solid var(--md-outline);
  }
}

/* Sticky footer bar (project + update pages): nav + slideshow controls. */
.lab-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1030;
  padding: 0.6rem 0;
  background: #0a0a0a;
  border-top: 1px solid var(--md-outline);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.6);
}

.lab-footer-spacer {
  height: 4.5rem;
}

.prose {
  color: var(--md-on-surface);
  line-height: 1.65;
}

.alert {
  border-radius: var(--md-radius);
  border: none;
}

/* ---- Slideshow (project update images) ---- */
.modal-fullscreen .carousel,
.modal-fullscreen .carousel-inner,
.modal-fullscreen .carousel-item {
  height: 100vh;
}

/* Fill the fullscreen modal's real height (not 100vh, which overflows past
   mobile browser chrome and pushes the caption off-screen). */
#slideshowCarousel,
#slideshowCarousel .carousel-inner,
#slideshowCarousel .carousel-item {
  height: 100%;
}

.slideshow-slide {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slideshow-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.slideshow-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  padding: 0.75rem;
}

.slideshow-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 1.5rem;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
}

.slideshow-caption h5 {
  font-weight: 500;
}

.slideshow-caption p {
  max-width: 960px;
  margin: 0 auto;
  color: rgba(255, 255, 255, 0.8);
}

/* TOAST UI markdown viewer — blend into the dark page */
.markdown-viewer .toastui-editor-contents {
  background: transparent;
  font-size: inherit;
}
.markdown-viewer .toastui-editor-contents p:last-child {
  margin-bottom: 0;
}
