/* ============================================
   SelfEvo Project Website — Custom Styles
   ============================================ */

/* --- Charts --- */
.chart-wrap {
  position: relative;
  height: 300px;
}

.chart-subtitle {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #444;
  margin-bottom: 8px;
}

.dir-hint {
  font-size: 10px;
  font-weight: 500;
  color: #7c3aed;
  margin-left: 2px;
}

.chart-legend {
  font-size: 13px;
  color: #555;
  margin-bottom: 1rem;
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}

/* --- Experiments Analysis Section --- */
.exp-block {
  margin-bottom: 3rem;
}

.exp-heading {
  font-size: 1.1rem;
  font-weight: 700;
  color: #222;
  margin-bottom: 0.5rem;
  text-align: center;
}

.exp-desc {
  font-size: 1rem;
  color: #555;
  margin-bottom: 1.5rem;
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
  text-align: justify;
}

.recipe-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  margin-bottom: 1.8rem;
  font-size: 0.85rem;
  color: #444;
}
.recipe-legend-item {
  background: #f1f5f9;
  border-radius: 6px;
  padding: 3px 10px;
  white-space: nowrap;
}
.recipe-legend-item code {
  font-weight: 600;
  color: #0c4a6e;
  background: none;
  padding: 0;
  font-size: inherit;
}

.chart-note {
  font-size: 11.5px;
  color: #666;
  font-style: italic;
  margin-bottom: 6px;
  line-height: 1.4;
}

.exp-analysis-row {
  margin-bottom: 2.5rem;
}

.chart-group-head {
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: #374151;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin: 1.2rem 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1.5px solid #e5e7eb;
}

/* --- Base --- */
body {
  font-family: 'Inter', 'Noto Sans', sans-serif;
}

/* --- Typography --- */
.publication-title {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
}

.publication-authors {
  font-family: 'Inter', sans-serif;
}

.publication-authors a {
  color: hsl(204, 86%, 53%) !important;
}
.publication-authors a:hover {
  text-decoration: underline;
}

.author-block {
  display: inline-block;
}

/* SelfEvo logo text */
.selfevo-self {
  font-weight: 700;
  color: #111827;
}
@keyframes evo-gradient {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.selfevo-evo {
  font-weight: 700;
  background: linear-gradient(90deg, #0891b2, #7c3aed, #db2777, #d97706, #16a34a, #0891b2);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: evo-gradient 4s ease infinite;
}

/* --- Links --- */
.link-block a {
  margin-top: 5px;
  margin-bottom: 5px;
}

.footer .icon-link {
  font-size: 25px;
  color: #000;
}

/* --- TL;DR Banner --- */
.tldr-banner {
  text-align: justify;
  padding: 12px 20px;
  background-color: #e0f2fe;
  border-radius: 8px;
  color: #0c4a6e;
  font-size: 16px;
  line-height: 1.6;
}

/* --- Teaser --- */
.teaser .hero-body {
  padding-top: 0;
  padding-bottom: 1rem;
}

/* --- Teaser Video Carousel --- */
.teaser-carousel {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
}
.teaser-slides {
  display: flex;
  transition: transform 0.4s ease;
}
.teaser-slide {
  min-width: 100%;
  aspect-ratio: 16 / 9;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.teaser-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.teaser-btn:hover {
  background: rgba(0, 0, 0, 0.70);
}
.teaser-btn-prev { left: 12px; }
.teaser-btn-next { right: 12px; }
.teaser-dots {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10;
}
.teaser-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: background 0.2s;
}
.teaser-dot.active {
  background: #fff;
}

/* --- Alternating section backgrounds --- */
.section-alt {
  background-color: #f9fafb;
}

/* --- Side-by-side viewer labels --- */
.viewer-label {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  padding: 5px 18px;
  display: inline-block;
  border-radius: 20px;
}
.pretrained-label {
  background: #f3f4f6;
  color: #6b7280;
  border: 1.5px solid #d1d5db;
}
.selfevo-label {
  background: linear-gradient(90deg, #0891b2, #7c3aed, #db2777, #d97706, #16a34a, #0891b2);
  background-size: 300% 300%;
  animation: evo-gradient 4s ease infinite;
  color: #fff;
  border: none;
}

/* --- Three-column viewer row --- */
.viewer-row {
  align-items: flex-start;
  gap: 12px;
}
.viewer-row .viewer-container {
  width: 100%;
  max-width: 100%;
}

/* --- Input frame panel --- */
.input-frame-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  background: #111;
}
.input-frame-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* --- WebGL Viewer Container --- */
.viewer-container {
  position: relative;
  display: inline-block;
  width: 768px;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  background: #000;
}

.viewer-container canvas {
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.viewer-overlay {
  display: none;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.viewer-overlay[id$="-glfailed"] {
  color: #f88;
  background: black;
  align-items: center;
  justify-content: center;
}

.viewer-loading {
  color: #fff;
  font-size: 24px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
}

.viewer-buttons {
  position: absolute;
  left: 8px;
  bottom: 8px;
  text-transform: uppercase;
  text-align: left;
}

.viewer-buttons button {
  padding: 4px 10px;
  margin-bottom: 4px;
  border: none;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.85);
  color: #333;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
}

.viewer-buttons button:hover {
  background: rgba(255, 255, 255, 1);
}

/* --- Shared Viewer Controls --- */
.shared-viewer-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.shared-viewer-controls button {
  padding: 6px 18px;
  border: 2px solid #ccc;
  border-radius: 6px;
  background: #f5f5f5;
  color: #444;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.shared-viewer-controls button:hover {
  background: #e8e8e8;
  border-color: #aaa;
}

.shared-viewer-controls button.active {
  background: #3273dc;
  border-color: #3273dc;
  color: #fff;
}

/* --- Movie Pagination --- */
.movie-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.movie-btn {
  padding: 7px 22px;
  border: 2px solid #e5e7eb;
  border-radius: 20px;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.movie-btn:hover {
  border-color: #3273dc;
  color: #3273dc;
}

.movie-btn.active {
  border-color: #3273dc;
  background: #3273dc;
  color: #fff;
}

/* --- Viewer Controls Legend --- */
.viewer-controls-legend {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6em 1.4em;
  margin-top: 10px;
  font-size: 11px;
  color: #888;
}

.viewer-controls-legend .ctrl-item {
  display: flex;
  align-items: center;
  gap: 0.4em;
  white-space: nowrap;
}

.viewer-controls-legend kbd {
  display: inline-block;
  padding: 1px 5px;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-bottom: 2px solid #bbb;
  border-radius: 3px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  color: #444;
  line-height: 1.5;
}

/* --- Scene Selector Thumbnails --- */
.scene-selector {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

/* Force 7-per-row for the 14-scene generalization selector */
#gen-scenes {
  display: grid;
  grid-template-columns: repeat(7, 100px);
  justify-content: center;
}

.scene-selector .scene-thumb {
  width: 100px;
  height: 70px;
  object-fit: cover;
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0.8;
}

.scene-selector .scene-thumb:hover {
  border-color: #0891b2;
  opacity: 1;
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.3);
}

.scene-selector .scene-thumb.active {
  border-color: #0891b2;
  opacity: 1;
  box-shadow: 0 0 0 2px #0891b2;
}

/* Scene label pills (fallback if no thumbnails) */
.scene-selector .scene-pill {
  padding: 6px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 20px;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.scene-selector .scene-pill:hover {
  border-color: #0891b2;
  color: #0891b2;
}

.scene-selector .scene-pill.active {
  border-color: #0891b2;
  background: #0891b2;
  color: #fff;
}


/* --- Publication video embed --- */
.publication-video {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%;
  overflow: hidden;
  border-radius: 10px;
}

.publication-video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* --- BibTeX --- */
section#bibtex pre {
  background: #f9fafb;
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
  overflow-x: auto;
}

/* --- Footer --- */
.footer {
  padding: 2rem 1.5rem;
  background-color: #f9fafb;
}

.footer a {
  color: #0891b2;
}

/* --- Timeline Demo --- */
.timeline-controls {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 14px;
  margin-bottom: 4px;
}

.tl-play-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid #3273dc;
  background: #fff;
  color: #3273dc;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  transition: background 0.2s, color 0.2s;
}
.tl-play-btn:hover,
.tl-play-btn.playing {
  background: #3273dc;
  color: #fff;
}
.tl-play-btn:active {
  transform: scale(0.92);
}

.tl-morph-icon { display: block; overflow: visible; }

.tl-morph-icon .icon-play,
.tl-morph-icon .icon-pause {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.tl-play-btn:not(.playing) .icon-play  { transform: scaleX(1); opacity: 1; }
.tl-play-btn:not(.playing) .icon-pause { transform: scaleX(0); opacity: 0; }

.tl-play-btn.playing .icon-play  { transform: scaleX(0); opacity: 0; }
.tl-play-btn.playing .icon-pause { transform: scaleX(1); opacity: 1; }

.timeline-track-wrapper {
  flex: 1;
  position: relative;
  padding-bottom: 24px;
}

.timeline-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #e5e7eb;
  outline: none;
  cursor: pointer;
}
.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3273dc;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(50,115,220,0.35);
}
.timeline-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3273dc;
  cursor: pointer;
  border: none;
}

.timeline-labels {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 9.5px;
  color: #aaa;
  user-select: none;
  pointer-events: none;
}
.timeline-labels span {
  text-align: center;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
  cursor: pointer;
  transition: color 0.15s;
}
.timeline-labels span:hover { color: #3273dc; }
.timeline-labels span.tl-active {
  color: #3273dc;
  font-weight: 700;
}

/* --- Timeline Video Carousel --- */
.tl-carousel {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: #fff;
  margin-bottom: 2rem;
}
.tl-carousel-track {
  display: flex;
  transition: transform 0.45s ease;
}
.tl-carousel-slide {
  min-width: 100%;
  position: relative;
}
.tl-carousel-slide video {
  width: 100%;
  display: block;
}
.tl-carousel-slide video:first-of-type {
  border-radius: 10px 10px 0 0;
}
.tl-carousel-slide video:last-of-type {
  border-radius: 0 0 10px 10px;
}
.tl-input-wrap {
  text-align: center;
  padding: 10px 0;
  background: #f8f8f8;
}
.tl-input-img {
  max-width: 220px;
  height: 120px;
  object-fit: contain;
  border-radius: 6px;
}
.tl-slide-label {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  z-index: 5;
  pointer-events: none;
}
.tl-carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.4);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.tl-carousel-btn:hover { background: rgba(0,0,0,0.7); }
.tl-carousel-prev { left: 10px; }
.tl-carousel-next { right: 10px; }
.tl-carousel-dots {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10;
}
.tl-carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  cursor: pointer;
  transition: background 0.2s;
}
.tl-carousel-dot.active { background: #fff; }

/* --- Responsive --- */
@media screen and (max-width: 768px) {
  .viewer-container {
    width: 100%;
  }

  .toggle-btn {
    padding: 6px 14px;
    font-size: 12px;
  }

  .scene-selector .scene-thumb {
    width: 70px;
    height: 50px;
  }

  .scene-selector .scene-pill {
    padding: 4px 10px;
    font-size: 11px;
  }

  .tldr-banner {
    font-size: 13px;
    padding: 10px 14px;
  }
}
