/* ============================================================
   Murales Culturales Ecuador — Estética Museográfica Académica
   Galería Permanente — Museo de Valdivia
   ============================================================ */

/* --- Fonts --- */
@font-face {
  font-family: 'Optima LT Pro';
  src: url('../fonts/Optima-Bold.otf') format('opentype');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

/* --- Design Tokens --- */
:root {
  /* Primary palette — Tierra Cálida + Bronce Antiguo */
  --primary-color: #2A1F14;
  --accent-color: #B8860B;
  --accent-light: #D4A843;
  --bg-color: #F0EBE3;
  --card-bg: #FAF6F0;
  --text-color: #1C1208;
  --text-light: #7A6544;
  --text-muted: #9C8B6E;

  /* Typography */
  --font-heading: 'Optima LT Pro', Georgia, 'Times New Roman', serif;
  --font-body: 'Times New Roman', Georgia, serif;
  --font-ui: 'Optima LT Pro', Georgia, serif;

  /* Spacing */
  --shadow-sm: 0 1px 3px rgba(42, 31, 20, 0.06);
  --shadow-md: 0 4px 12px rgba(42, 31, 20, 0.10);
  --shadow-lg: 0 8px 30px rgba(42, 31, 20, 0.14);
  --radius: 2px;
  --radius-lg: 4px;
  --container-width: 1200px;

  /* Scrollytelling tokens */
  --story-bg: rgba(26, 18, 10, 0.88);
  --story-heading: #D4A843;
  --story-border: rgba(184, 134, 11, 0.20);
  --story-text: #EDE5D8;
}

/* --- Reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Base --- */
html {
  /* Smooth scrolling sin bloquear el hilo principal */
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.7;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Evita reflows al aparecer scrollbar */
  overflow-y: scroll;
}

/* Typography hierarchy */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: bold;
  line-height: 1.25;
  color: var(--primary-color);
}

p, li, span, a, td, th, label {
  font-family: var(--font-body);
}

/* --- Layout --- */
.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* --- Header --- */
header {
  background-color: var(--card-bg);
  border-bottom: 2px solid var(--accent-color);
  padding: 1.25rem 0;
  margin-bottom: 2.5rem;
  /* Evitar repaint al hacer scroll */
  contain: layout style;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.35rem;
  color: var(--primary-color);
  letter-spacing: 0.02em;
}

header h1 a {
  text-decoration: none;
  color: inherit;
}

/* --- Grid for Murals --- */
.mural-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  padding-bottom: 3rem;
  /* Permite al navegador skip render de tarjetas fuera del viewport */
  contain: layout;
}

@media (min-width: 640px) {
  .mural-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .mural-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --- Cards --- */
.card {
  background: var(--card-bg);
  border: 1px solid rgba(42, 31, 20, 0.08);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  /* Solo animar transform y box-shadow — no layout */
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  display: flex;
  flex-direction: column;
  /* Aislar repaint de cada card */
  contain: layout style;
  /* Promover a su propio compositor layer solo al hover */
  will-change: transform;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-color);
}

.card-img-container {
  width: 100%;
  height: 220px;
  background-color: #D6CCBF;
  overflow: hidden;
  border-bottom: 3px solid var(--accent-color);
  /* Aislar el repaint de la imagen del resto de la card */
  contain: strict;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Solo transform — no filter — en hover del grid */
  transition: transform 0.4s ease;
  /* La imagen es siempre visible; no promover con will-change aquí
     para no desperdiciar GPU memory en 10 imágenes simultáneas */
}

.card:hover .card-img {
  transform: scale(1.03);
}

.card-content {
  padding: 1.5rem 1.25rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
  letter-spacing: 0.02em;
}

.card-desc {
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  flex-grow: 1;
  line-height: 1.65;
}

/* --- Culture Tag --- */
.culture-tag {
  display: inline-block;
  background-color: var(--accent-color);
  color: #FAF6F0;
  padding: 0.2rem 0.7rem;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: bold;
}

/* --- Buttons --- */
.btn {
  display: inline-block;
  background-color: var(--primary-color);
  color: var(--card-bg);
  padding: 0.55rem 1.2rem;
  border: 1px solid var(--accent-color);
  border-radius: var(--radius);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  text-align: center;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.btn:hover {
  background-color: var(--accent-color);
  color: var(--primary-color);
}

/* --- Mural Detail Page --- */
.mural-detail {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2.5rem;
  border: 1px solid rgba(42, 31, 20, 0.08);
}

.mural-header {
  margin-bottom: 2rem;
}

.mural-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.mural-media {
  margin-bottom: 2rem;
}

.mural-img-large {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
  border: 1px solid rgba(42, 31, 20, 0.06);
}

.video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: #0A0704;
}

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

.mural-info {
  display: grid;
  gap: 2rem;
}

@media (min-width: 768px) {
  .mural-info {
    grid-template-columns: 2fr 1fr;
  }
}

.info-section h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: bold;
  margin-bottom: 1rem;
  color: var(--primary-color);
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 0.5rem;
}

/* --- Sources List --- */
.sources-list {
  list-style: none;
  padding: 0;
}

.sources-list li {
  margin-bottom: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-light);
}

.sources-list li::before {
  content: "—";
  color: var(--accent-color);
  display: inline-block;
  width: 1em;
  margin-left: -1em;
  font-weight: bold;
}

/* --- Footer --- */
footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.88rem;
  border-top: 1px solid rgba(42, 31, 20, 0.10);
  margin-top: 2rem;
  contain: layout style;
}


/* ============================================================
   SCROLLYTELLING MODE — Oscuro Cinematográfico + Bronce
   ============================================================ */

.scrolly-mode {
  background-color: #0A0704;
  color: var(--story-text);
}

/* Hide standard header/footer in scrolly mode */
.scrolly-mode header,
.scrolly-mode footer {
  display: none !important;
}

/* Reset container constraints for full screen */
.scrolly-mode .container {
  max-width: 100%;
  padding: 0;
  margin: 0;
}

.scrolly-mode .mural-detail {
  background: transparent;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  border: none;
  margin: 0;
  max-width: 100%;
}

.scrolly-container {
  position: relative;
  min-height: 100vh;
}

.sticky-background {
  position: sticky;
  top: 0;
  left: 0;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  z-index: 1;
  /* Promover a compositor layer para que el sticky no cause repaints */
  transform: translateZ(0);
  will-change: transform;
}

.bg-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Usar solo transform para movimiento; filter se aplica desde JS
     y solo cuando cambia el step, no en cada frame de scroll */
  transition: filter 0.6s ease, transform 0.6s ease;
  /* GPU layer para la imagen de fondo */
  will-change: filter, transform;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, rgba(10, 7, 4, 0) 40%, rgba(10, 7, 4, 0.85) 100%);
  z-index: 2;
  /* Solo transición en opacity para el overlay */
  transition: opacity 0.5s ease;
  will-change: opacity;
}

.content-layer {
  position: relative;
  z-index: 10;
  padding: 2rem;
  margin-top: -80vh;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.intro-title {
  position: fixed;
  bottom: 10vh;
  left: 0;
  width: 100%;
  z-index: 5;
  text-align: center;
  color: var(--story-text);
  transition: opacity 0.5s ease;
  padding: 0 2rem;
  pointer-events: none;
  will-change: opacity;
}

.intro-title h1 {
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: bold;
  text-shadow: 0 2px 8px rgba(10, 7, 4, 0.7);
  margin-bottom: 1rem;
  color: var(--story-text);
  letter-spacing: 0.02em;
}

.intro-title .culture-tag {
  background-color: var(--accent-color);
  color: #FAF6F0;
  border: none;
}

.scroll-indicator {
  animation: bounce 2s infinite;
  font-size: 0.9rem;
  opacity: 0.7;
  font-family: var(--font-body);
  letter-spacing: 0.05em;
}

/* --- Story Cards --- */
.story-card {
  /* Reemplazar backdrop-filter:blur por fondo semiopaco sólido en el estado base.
     backdrop-filter es muy costoso: fuerza un repaint de todo lo que está detrás.
     Usamos un fondo sólido semiopaco que visualmente es casi idéntico pero sin costo GPU. */
  background: var(--story-bg);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  margin-bottom: 80vh;
  border: 1px solid var(--story-border);
  /* Estado inicial: oculto hacia abajo */
  transform: translateY(50px);
  opacity: 0;
  /* Transiciones específicas, NO "all" */
  transition: transform 0.8s ease, opacity 0.8s ease;
  box-shadow: 0 10px 40px rgba(10, 7, 4, 0.6);
  color: var(--story-text);
  /* Promover a compositor layer solo cuando está a punto de animar */
  will-change: transform, opacity;
}

.story-card:last-of-type {
  margin-bottom: 20vh;
}

.story-card.visible {
  transform: translateY(0);
  opacity: 1;
  /* Una vez visible, liberar el compositor layer para ahorrar GPU memory */
  will-change: auto;
}

.story-card h2 {
  font-family: var(--font-heading);
  color: var(--story-heading);
  margin-bottom: 1.25rem;
  font-size: 1.7rem;
  font-weight: bold;
  letter-spacing: 0.02em;
}

.story-card h3 {
  font-family: var(--font-heading);
  color: var(--story-heading);
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
  font-weight: bold;
}

.story-card .culture-tag {
  background-color: var(--accent-color);
  color: #FAF6F0;
  border: 1px solid var(--accent-light);
}

.story-card p {
  font-family: var(--font-body);
  line-height: 1.75;
  margin-bottom: 1rem;
  font-size: 1.05rem;
  color: var(--story-text);
}

.story-card .btn {
  background: var(--accent-color);
  color: var(--primary-color);
  border: 1px solid var(--accent-light);
  margin-top: 1rem;
}

.story-card .btn:hover {
  background: var(--accent-light);
  color: var(--primary-color);
}

.story-card .sources-list li {
  color: var(--story-text);
  opacity: 0.8;
}

.story-card .sources-list li::before {
  color: var(--accent-color);
}

/* --- Bounce Animation ---
   Usar transform en lugar de top/margin para animar en el compositor */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

/* --- Desktop Scrollytelling --- */
@media (min-width: 768px) {
  .scrolly-container {
    display: flex;
    flex-direction: column;
  }

  .video-hero {
    width: 100%;
    height: 100vh;
  }

  .scrolly-inner {
    display: flex;
    flex-direction: row;
  }

  .sticky-background {
    position: sticky;
    width: 50%;
    height: 100vh;
    z-index: 1;
  }

  .content-layer {
    width: 50%;
    padding-top: 90vh;
    margin-top: 0;
    margin-left: 0;
    margin-right: 0;
  }

  .intro-title {
    width: 50%;
    left: 0;
    right: auto;
  }
}

/* --- Video Hero (Mobile & Desktop) --- */
.video-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  background: #0A0704;
  position: relative;
  z-index: 100;
  /* Aislar este bloque del resto de la página */
  contain: layout style;
}

.video-hero video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-hero .scroll-indicator {
  position: absolute;
  bottom: 3vh;
  color: rgba(237, 229, 216, 0.7);
  font-family: var(--font-body);
  font-size: 0.95rem;
  text-shadow: 0 2px 6px rgba(10, 7, 4, 0.9);
  animation: bounce 2s infinite;
  z-index: 102;
  pointer-events: none;
  letter-spacing: 0.05em;
}

/* --- Mobile Scrollytelling --- */
@media (max-width: 767px) {
  .video-hero video {
    object-fit: contain;
  }

  .scrolly-mode .intro-title {
    display: none !important;
  }

  .title-card-mobile {
    display: block !important;
    text-align: center;
    margin-bottom: 80vh;
  }

  .title-card-mobile h3 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: bold;
    color: var(--story-text);
    margin-top: 0.5rem;
    text-shadow: 0 2px 6px rgba(10, 7, 4, 0.7);
  }

  .title-card-mobile .culture-tag {
    margin-bottom: 0.5rem;
  }

  .title-card-mobile p {
    text-align: justify;
  }

  .scrolly-container {
    display: flex;
    flex-direction: column;
  }

  .content-layer {
    margin-top: 0;
    padding-top: 2rem;
  }

  .story-card {
    padding: 1.75rem;
  }
}

/* --- Error state --- */
.error {
  color: #8B2500;
  font-family: var(--font-body);
}
