/* ━━━ CSS for SAIA — Modelado en Música y Sonido ━━━ */

/* ─── Variables ─── */
:root {
  --bg: #fafafa;
  --fg: #1a1a2e;
  --muted: #64748b;
  --border: #e5e7eb;
  --card-bg: #ffffff;
  --blue: #3b82f6;
  --teal: #0d9488;
  --amber: #d97706;
  --purple: #7c3aed;
  --red: #dc2626;
  --green: #16a34a;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --nav-w: 220px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 19px;
  scroll-snap-type: y proximity;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.65;
  overflow-x: hidden;
}

/* ─── Progress Bar ─── */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--teal));
  width: 0%;
  z-index: 1000;
  transition: width 0.15s var(--ease);
}

/* ─── Presentation Toggle ─── */
.pres-toggle {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 999;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: all 0.2s var(--ease);
}
.pres-toggle:hover { border-color: var(--blue); color: var(--blue); }
.pres-toggle.active { background: var(--blue); color: white; border-color: var(--blue); }

/* ─── Side Navigation ─── */
.sidenav {
  position: fixed;
  left: 0; top: 0;
  width: var(--nav-w);
  height: 100vh;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s var(--ease);
  overflow-y: auto;
}

.sidenav-logo {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0 24px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidenav ul {
  list-style: none;
  padding: 0 8px;
}

.sidenav > ul > li { margin-bottom: 2px; }

.nav-link {
  display: block;
  padding: 8px 16px;
  color: var(--muted);
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.15s var(--ease);
  position: relative;
}

.nav-link:hover { color: var(--fg); background: rgba(59,130,246,0.04); }

.nav-link.active {
  color: var(--blue);
  background: rgba(59,130,246,0.08);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--blue);
  border-radius: 0 3px 3px 0;
}

.subnav {
  list-style: none;
  padding-left: 12px;
}

.subnav .nav-link {
  font-size: 15px;
  padding: 5px 16px;
  font-weight: 400;
}

/* Section dots */
.section-dots {
  margin-top: auto;
  padding: 16px 24px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.section-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.2s var(--ease);
  cursor: pointer;
}
.section-dot.active { background: var(--blue); transform: scale(1.3); }

/* ─── Main Content ─── */
.content {
  margin-left: var(--nav-w);
  min-height: 100vh;
}

/* ─── Slides ─── */
.slide {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 48px;
  scroll-snap-align: start;
  position: relative;
}

.slide-inner {
  max-width: 1100px;
  width: 100%;
  animation: fadeUp 0.6s var(--ease) both;
}

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

/* ─── Section Headers ─── */
.slide-header { text-align: center; }
.slide-header h2 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}
.section-desc {
  font-size: 1.25rem;
  color: var(--muted);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.7;
}

.section-tag {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 100px;
  margin-bottom: 12px;
}
.tag-gen { background: rgba(59,130,246,0.1); color: var(--blue); }
.tag-disc { background: rgba(13,148,136,0.1); color: var(--teal); }

/* ─── Hero ─── */
.hero-title {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-align: center;
  margin-bottom: 16px;
}
.hero-sub {
  font-size: 1.25rem;
  color: var(--muted);
  text-align: center;
  max-width: 550px;
  margin: 0 auto 40px;
  line-height: 1.7;
}
.hero-diagram {
  max-width: 840px;
  margin: 0 auto;
}
.hint {
  text-align: center;
  margin-top: 40px;
  font-size: 15px;
  color: var(--muted);
  opacity: 0.7;
}

/* ─── Diagrams ─── */
.diagram-hero, .diagram-full svg {
  width: 100%;
  height: auto;
}
.card-hero-diagram {
  width: 100%;
  margin-top: 20px;
  padding: 16px 12px 12px;
  background: radial-gradient(ellipse at 50% 40%, rgba(59,130,246,0.035), transparent 70%);
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.04);
}
.card-hero-diagram svg {
  width: 100%;
  height: auto;
  display: block;
  max-height: 200px;
}

.d-label { font-family: var(--font); font-size: 16px; font-weight: 600; fill: var(--fg); }
.d-label-sm { font-family: var(--font); font-size: 14px; font-weight: 500; fill: var(--fg); }
.d-tiny { font-family: var(--mono); font-size: 12px; fill: var(--fg); }

/* Diagram animations */
.anim-fade-up {
  opacity: 0;
  animation: fadeUp 0.5s var(--ease) forwards;
  animation-delay: var(--delay, 0s);
}

/* ─── Cards ─── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: box-shadow 0.3s var(--ease);
}
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.06); }

.card-header {
  display: flex;
  flex-direction: column;
  padding: 28px 32px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.card-header:hover { background: rgba(59,130,246,0.02); }

.card-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

.card-header h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.card-summary {
  font-size: 1.05rem;
  color: var(--muted);
  line-height: 1.6;
}

.expand-icon {
  font-size: 22px;
  color: var(--muted);
  transition: transform 0.3s var(--ease);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg);
  flex-shrink: 0;
  margin-top: 4px;
}

.card.expanded .expand-icon {
  transform: rotate(45deg);
  color: var(--blue);
}

/* ─── Card Body (collapsible) ─── */
.card-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s var(--ease), padding 0.3s var(--ease);
  padding: 0 32px;
}

.card.expanded .card-body {
  max-height: 5000px;
  padding: 0 32px 32px;
}

.card-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.card-col h4 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 20px 0 8px;
}
.card-col h4:first-child { margin-top: 0; }

.card-col p {
  font-size: 1.05rem;
  color: var(--fg);
  line-height: 1.65;
}

.card-col ol, .card-col ul {
  padding-left: 18px;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--fg);
}

.card-col ol li::marker { color: var(--blue); font-weight: 600; }

/* ─── Audio Examples ─── */
.audio-examples {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.audio-examples h4 {
  font-size: 1rem !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--fg) !important;
  margin-bottom: 16px !important;
}

/* ─── Model Chips ─── */
.models-list { margin-bottom: 24px; }

.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.model-chip {
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.model-chip:hover { border-color: var(--blue); }

.model-chip-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
}
.model-chip-year {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
}
.model-chip-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}

.curated-examples { margin-top: 8px; }

.audio-list { display: flex; flex-direction: column; gap: 10px; }

.audio-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}
.audio-item:hover { border-color: var(--border); }

.audio-item-info {
  flex: 1;
  min-width: 0;
}
.audio-item-title {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-item-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.audio-item audio {
  width: 220px;
  height: 32px;
  flex-shrink: 0;
}

.audio-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 16px;
  background: var(--bg);
  border-radius: 10px;
}

/* ─── Discriminative Plots ─── */
.disc-plots {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.plot-method-note {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.5;
}
.plot-method-note a { color: var(--blue); }

.plots-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-bottom: 0;
}

.plot-container {
  background: var(--bg);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border);
}
.plot-container-full {
  border-radius: 14px;
  margin-bottom: 24px;
}
.plot-container h5 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--muted);
}
.plot-container canvas {
  width: 100% !important;
  height: auto !important;
}



/* ─── Presentation Mode ─── */
body.presentation-mode .sidenav { transform: translateX(-100%); }
body.presentation-mode .content { margin-left: 0; }
body.presentation-mode .slide {
  min-height: 100vh;
  scroll-snap-align: center;
}
body.presentation-mode html { scroll-snap-type: y mandatory; }
body.presentation-mode .card { box-shadow: none; border: none; background: transparent; }
body.presentation-mode .card.expanded .card-body { max-height: 3000px; }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .plots-gallery { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidenav {
    transform: translateX(-100%);
    width: 260px;
    z-index: 200;
  }
  .sidenav.open { transform: translateX(0); }

  .content { margin-left: 0; }

  .slide { padding: 40px 20px; }

  .card-header { padding: 20px; }
  .card-header-top { flex-wrap: wrap; }
  .card-hero-diagram { margin-top: 12px; padding: 10px 4px 8px; }

  .card.expanded .card-body { padding: 0 20px 20px; }

  .hero-title { font-size: 2rem; }

  .audio-item { flex-direction: column; align-items: flex-start; }
  .audio-item audio { width: 100%; }

  /* Mobile hamburger */
  .mobile-menu-btn {
    display: block !important;
    position: fixed;
    top: 16px; left: 16px;
    z-index: 300;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    color: var(--fg);
  }
}

.mobile-menu-btn { display: none; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── Animations for scroll reveal ─── */
.slide-inner {
  opacity: 0;
  transform: translateY(24px);
  transition: all 0.6s var(--ease);
}
.slide.visible .slide-inner {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Tooltip ─── */
.tooltip {
  position: absolute;
  background: var(--fg);
  color: white;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 500;
  max-width: 200px;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.15s;
}
.tooltip.show { opacity: 1; }

/* ─── Embedding Heatmaps ─── */
.embedding-heatmaps {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.embedding-heatmaps h4 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.heatmap-gallery {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1rem;
}

.heatmap-img {
  width: 100%;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

@media (max-width: 768px) {
  .heatmap-gallery {
    gap: 1rem;
  }
}

/* ─── Layer Carousel ─── */
.layer-carousel {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.layer-carousel h4 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}
.layer-carousel-audio {
  margin: 1rem 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.layer-carousel-audio label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.layer-carousel-audio audio {
  flex: 1;
  min-width: 200px;
}
.carousel-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.carousel-img-container {
  position: relative;
  width: 100%;
  max-width: 700px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  background: transparent;
}
.carousel-img-container img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  z-index: 0;
  transition: none;
}
.carousel-img-container img.active {
  opacity: 1;
  z-index: 1;
}
.carousel-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.carousel-btn {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.carousel-btn:hover {
  background: var(--border);
  border-color: var(--blue);
}
.carousel-label {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  min-width: 120px;
  text-align: center;
  color: var(--fg);
}
.carousel-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 260px;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
}
.carousel-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.carousel-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  border: 2px solid var(--bg);
}

/* ─── Accessibility: Focus States ─── */
*:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, .carousel-btn:focus-visible, .expand-icon:focus-visible {
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.15);
}

/* Constrain line length for readability */
.card-col p, .card-col li, .plot-method-note {
  max-width: 72ch;
}

/* ─── Listening Criteria ─── */
.listening-criteria {
  margin-top: 24px;
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(217,119,6,0.04), rgba(59,130,246,0.04));
  border: 1px solid rgba(217,119,6,0.15);
  border-radius: 12px;
  border-left: 3px solid var(--amber);
}
.listening-criteria h4 {
  font-size: 0.95rem !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--amber) !important;
  margin-bottom: 10px !important;
  margin-top: 0 !important;
}
.listening-criteria ul {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
}
.listening-criteria li {
  font-size: 0.9rem;
  color: var(--fg);
  line-height: 1.5;
  padding-left: 1.4em;
  text-indent: -1.4em;
}

/* ─── Method Box ─── */
.method-box {
  margin: 24px 0;
  padding: 20px 24px;
  background: rgba(59,130,246,0.03);
  border: 1px solid rgba(59,130,246,0.12);
  border-radius: 12px;
  border-left: 3px solid var(--blue);
}
.method-box h4 {
  font-size: 1rem !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--blue) !important;
  margin-bottom: 10px !important;
  margin-top: 0 !important;
}
.method-box ul {
  list-style: none;
  padding: 0;
}
.method-box li {
  font-size: 0.9rem;
  margin-bottom: 6px;
  line-height: 1.5;
}
.method-box a { color: var(--blue); }
.method-disclaimer {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(217,119,6,0.06);
  border-radius: 8px;
  font-size: 0.85rem;
  color: #92400e;
  line-height: 1.5;
}

/* ─── Sources Drawer ─── */
.sources-drawer {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.sources-drawer summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
.sources-drawer summary::-webkit-details-marker { display: none; }
.sources-drawer[open] summary { color: var(--blue); }
.sources-drawer ul {
  padding: 10px 0 0 0;
  list-style: none;
}
.sources-drawer li {
  font-size: 0.82rem;
  margin-bottom: 6px;
  line-height: 1.4;
}
.sources-drawer a {
  color: var(--blue);
  text-decoration: none;
}
.sources-drawer a:hover { text-decoration: underline; }

/* ─── Section Progress ─── */
.section-progress {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 100px;
  border: 1px solid var(--border);
  margin-left: 8px;
  vertical-align: middle;
}

/* ─── Presenter Mode Improvements ─── */
body.presentation-mode .card-col p,
body.presentation-mode .card-col li {
  font-size: 1.15rem;
}
body.presentation-mode .card-header h3 {
  font-size: 1.8rem;
}
body.presentation-mode .card-summary {
  font-size: 1.2rem;
}
body.presentation-mode .listening-criteria ul {
  grid-template-columns: 1fr;
}
body.presentation-mode .sources-drawer {
  display: none;
}
body.presentation-mode .section-progress {
  font-size: 0.85rem;
  padding: 4px 14px;
}

/* ─── Responsive: Listening Criteria ─── */
@media (max-width: 768px) {
  .listening-criteria ul {
    grid-template-columns: 1fr;
  }
}
