/* ==========================================================================
   TEMA TECPÁN GUATEMALA - BIBLIOTECA DIGITAL COJTICUXIL
   Inspirado en los textiles tradicionales de Tecpán Guatemala, Chimaltenango.
   Cumplimiento de accesibilidad: WCAG 2.2 nivel AA (Contraste >= 4.5:1)
   ========================================================================== */

:root {
  /* Propuesta A (Predeterminada): Institucional Tecpán */
  --color-bg: #FAF8F5;
  --color-surface: #FFFFFF;
  --color-surface-hover: #F3EFEA;
  --color-text-main: #231E19;
  --color-text-muted: #59534C;
  --color-primary: #8C232C; /* Carmesí / Tinto tradicional Tecpán */
  --color-primary-hover: #6E1A22;
  --color-secondary: #C07D23; /* Ocre / Maíz maduro */
  --color-accent: #1D4354; /* Azul añil textil */
  --color-border: #E5DDD3;
  --color-border-dark: #C9BDB0;
  --header-bg: #322521; /* Café corte tradicional */
  --header-text: #FFFFFF;
  --font-family-headings: "Merriweather", "Georgia", "Times New Roman", serif;
  --font-family-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --card-shadow: 0 4px 12px rgba(40, 25, 20, 0.06);
  --border-radius: 8px;
}

/* Propuesta B: Editorial Textil (Acentos Brocado Tecpaneco) */
[data-theme="propuesta-b"] {
  --color-bg: #F4EFEB;
  --color-surface: #FFFFFF;
  --color-surface-hover: #EBE3DB;
  --color-text-main: #1D1815;
  --color-text-muted: #4F4741;
  --color-primary: #9E2A2B; /* Rojo ladrillo tecpaneco */
  --color-primary-hover: #7D1F20;
  --color-secondary: #D4A373; /* Ocre de hilaza */
  --color-accent: #264653; /* Azul profundo */
  --color-border: #D8CCC0;
  --color-border-dark: #B7A493;
  --header-bg: #412A22;
  --header-text: #FFF9F2;
  --font-family-headings: "Cinzel", "Georgia", serif;
  --card-shadow: 0 6px 18px rgba(65, 42, 34, 0.09);
  --border-radius: 4px;
}

/* Propuesta C: Biblioteca Digital Minimalista Kaqchikel */
[data-theme="propuesta-c"] {
  --color-bg: #F8F9FA;
  --color-surface: #FFFFFF;
  --color-surface-hover: #F0F4F8;
  --color-text-main: #1A202C;
  --color-text-muted: #4A5568;
  --color-primary: #0F4C81; /* Azul Classic Pantone / Añil maya */
  --color-primary-hover: #093256;
  --color-secondary: #B45309; /* Ámbar / Ocre */
  --color-accent: #8C232C;
  --color-border: #E2E8F0;
  --color-border-dark: #CBD5E1;
  --header-bg: #0F172A;
  --header-text: #FFFFFF;
  --font-family-headings: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  --border-radius: 12px;
}

/* Reseteo y Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: var(--font-family-sans);
  background-color: var(--color-bg);
  /* Patrón textil de fondo con transparencia controlada de los tejidos de Tecpán */
  background-image: 
    linear-gradient(rgba(250, 248, 245, 0.94), rgba(250, 248, 245, 0.94)),
    url('/images/fondo/bg2.jpg');
  background-repeat: repeat;
  background-attachment: fixed;
  color: var(--color-text-main);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
}

[data-theme="propuesta-b"] body {
  background-image: 
    linear-gradient(rgba(244, 239, 235, 0.92), rgba(244, 239, 235, 0.92)),
    url('/images/fondo/bg2.jpg');
}

[data-theme="propuesta-c"] body {
  background-image: none;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s ease, text-decoration 0.2s ease;
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--color-secondary);
  outline-offset: 2px;
}

/* Contenedores */
.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* Cenefa y Cinta Textil Tradicional de Tecpán Guatemala */
.cenefa-tecpan {
  height: 20px;
  width: 100%;
  background-image: url('/images/fondo/cinta_tecpan.jpg');
  background-repeat: repeat-x;
  background-position: center;
  background-size: auto 20px;
  border-bottom: 2px solid var(--color-secondary);
  box-shadow: 0 2px 5px rgba(0,0,0,0.22);
}

/* Cinta textil de transición bajo la cabecera principal */
.cinta-subnav-tecpan {
  height: 15px;
  width: 100%;
  background-image: url('/images/fondo/cinta_tecpan.jpg');
  background-repeat: repeat-x;
  background-position: center;
  background-size: auto 15px;
  border-top: 1px solid rgba(0,0,0,0.25);
  border-bottom: 2px solid var(--color-secondary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

/* Cinta textil discreta utilitaria */
.cinta-textil {
  height: 8px;
  width: 100%;
  background-image: url('/images/fondo/cinta_tecpan.jpg');
  background-repeat: repeat-x;
  background-position: center;
  background-size: auto 8px;
}

/* Barra Superior e Idiomas */
.top-bar {
  background-color: #1A1412;
  color: #E6DED8;
  font-size: 0.875rem;
  padding: 6px 0;
}

.top-bar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.cultural-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.cultural-badge span {
  color: var(--color-secondary);
}

.lang-selector {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.lang-btn {
  color: #D6CCC2;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.lang-btn.active {
  background-color: var(--color-primary);
  color: #FFFFFF;
  text-decoration: none;
}

/* Cabecera Principal */
.site-header {
  background-color: var(--header-bg);
  color: var(--header-text);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: inherit;
}

.brand-emblem {
  width: 48px;
  height: 48px;
  background: var(--color-primary);
  color: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family-headings);
  font-weight: bold;
  font-size: 1.4rem;
  border: 2px solid var(--color-secondary);
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: var(--font-family-headings);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  color: #FFFFFF;
}

.brand-text p {
  font-size: 0.825rem;
  color: #D6CCC2;
  margin-top: 2px;
}

/* Menú de Navegación */
.nav-menu {
  display: flex;
  gap: 20px;
  align-items: center;
  list-style: none;
}

.nav-link {
  color: #F4EFEB;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--border-radius);
  transition: background-color 0.2s, color 0.2s;
}

.nav-link:hover, .nav-link.active {
  background-color: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  text-decoration: none;
}

/* Hero / Presentación */
.hero-banner {
  background: linear-gradient(135deg, rgba(50, 37, 33, 0.94), rgba(75, 42, 32, 0.90)), url('/images/fondo/bg2.jpg');
  background-size: cover;
  background-position: center;
  color: #FFFFFF;
  padding: 48px 0;
  border-bottom: 3px solid var(--color-secondary);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 36px;
  align-items: center;
}

.hero-content h2 {
  font-family: var(--font-family-headings);
  font-size: 2.2rem;
  line-height: 1.25;
  margin-bottom: 16px;
  color: #FFF9F2;
}

.hero-content p {
  font-size: 1.1rem;
  line-height: 1.7;
  color: #EADBCE;
  margin-bottom: 24px;
}

.hero-photo-wrap {
  text-align: center;
}

.hero-photo {
  width: 220px;
  height: 220px;
  object-fit: cover;
  border-radius: 50%;
  border: 5px solid var(--color-secondary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.hero-photo-caption {
  font-size: 0.85rem;
  color: #D6CCC2;
  margin-top: 10px;
  font-style: italic;
}

/* Buscador y Filtros */
.catalog-controls {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 24px;
  margin-bottom: 32px;
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}

.catalog-controls::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background-image: url('/images/fondo/cinta_tecpan.jpg');
  background-repeat: repeat-x;
  background-position: center;
  background-size: auto 6px;
}

.search-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  align-items: center;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 1rem;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--border-radius);
  background-color: var(--color-bg);
  color: var(--color-text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--color-primary);
  background-color: #FFFFFF;
}

/* Cuadrícula de Obras */
.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 28px;
  margin-bottom: 48px;
}

.work-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
}

/* Cinta textil discreta superior en cada libro */
.work-card::before {
  content: "";
  display: block;
  height: 6px;
  width: 100%;
  background-image: url('/images/fondo/cinta_tecpan.jpg');
  background-repeat: repeat-x;
  background-position: center;
  background-size: auto 6px;
  flex-shrink: 0;
}

.work-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(40, 25, 20, 0.12);
}

.work-cover-wrap {
  height: 240px;
  background-color: #EFE9E2;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--color-border);
}

.work-cover {
  max-height: 90%;
  max-width: 90%;
  object-fit: contain;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

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

.work-badge-year {
  position: absolute;
  top: 12px;
  right: 12px;
  background-color: var(--color-primary);
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.work-badge-year-inline {
  background-color: var(--color-primary);
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.work-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.work-category {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-secondary);
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.work-title {
  font-family: var(--font-family-headings);
  font-size: 1.15rem;
  line-height: 1.35;
  margin-bottom: 10px;
  color: var(--color-text-main);
}

.work-meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.work-meta p {
  margin-bottom: 4px;
}

.work-summary {
  font-size: 0.9rem;
  color: var(--color-text-main);
  line-height: 1.5;
  margin-bottom: 18px;
  flex-grow: 1;
}

.work-footer {
  border-top: 1px solid var(--color-border);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Botones de Documentos con Iconos Diferenciados */
.btn-doc {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--border-radius);
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

/* 1. Icono PDF Drive */
.btn-doc-drive {
  background-color: #DC2626;
  color: #FFFFFF !important;
}

.btn-doc-drive:hover {
  background-color: #B91C1C;
  text-decoration: none;
}

/* 2. Icono PDF Local */
.btn-doc-local {
  background-color: #8C232C;
  color: #FFFFFF !important;
}

.btn-doc-local:hover {
  background-color: #6E1A22;
  text-decoration: none;
}

/* 3. Icono Hipervínculo Externo */
.btn-doc-external {
  background-color: #0284C7;
  color: #FFFFFF !important;
}

.btn-doc-external:hover {
  background-color: #0369A1;
  text-decoration: none;
}

.btn-details {
  background-color: var(--color-surface-hover);
  color: var(--color-text-main);
  border: 1px solid var(--color-border);
  padding: 8px 12px;
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  font-weight: 600;
}

.btn-details:hover {
  background-color: var(--color-border);
  text-decoration: none;
}

/* Vista Individual de Obra */
.work-single {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 36px;
  margin-top: 32px;
  margin-bottom: 48px;
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}

/* Cinta textil superior en la ficha bibliográfica */
.work-single::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background-image: url('/images/fondo/cinta_tecpan.jpg');
  background-repeat: repeat-x;
  background-position: center;
  background-size: auto 8px;
}

.single-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 40px;
}

.single-cover-wrap {
  text-align: center;
}

.single-cover {
  width: 100%;
  max-width: 260px;
  border-radius: var(--border-radius);
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
  border: 1px solid var(--color-border);
}

.single-title {
  font-family: var(--font-family-headings);
  font-size: 2rem;
  line-height: 1.25;
  margin-bottom: 16px;
  color: var(--color-text-main);
}

.single-meta-table {
  width: 100%;
  margin: 20px 0;
  border-collapse: collapse;
}

.single-meta-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.95rem;
}

.single-meta-table td.label-col {
  font-weight: 700;
  color: var(--color-text-muted);
  width: 180px;
}

.single-actions {
  display: flex;
  gap: 16px;
  margin: 24px 0;
  flex-wrap: wrap;
}

.single-content {
  font-size: 1.05rem;
  line-height: 1.8;
  margin-top: 24px;
}

.single-content p {
  margin-bottom: 16px;
}

.single-content h2 {
  font-family: var(--font-family-headings);
  font-size: 1.5rem;
  color: var(--color-primary);
  margin-top: 32px;
  margin-bottom: 14px;
  border-bottom: 2px solid rgba(122, 32, 33, 0.15);
  padding-bottom: 6px;
}

.single-content h3 {
  font-family: var(--font-family-headings);
  font-size: 1.25rem;
  color: var(--color-primary-dark);
  margin-top: 24px;
  margin-bottom: 10px;
}

.single-content blockquote {
  border-left: 4px solid var(--color-secondary);
  padding: 12px 20px;
  margin: 20px 0;
  background: rgba(184, 80, 66, 0.05);
  font-style: italic;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.single-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.95rem;
}

.single-content th,
.single-content td {
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  text-align: left;
}

.single-content th {
  background-color: rgba(122, 32, 33, 0.08);
  color: var(--color-primary-dark);
  font-weight: 700;
}

.single-content tr:nth-child(even) td {
  background-color: rgba(0, 0, 0, 0.02);
}

/* Párrafo Introductorio Destacado (Lead) */
.work-lead-text {
  font-size: 1.2rem;
  line-height: 1.8;
  color: var(--color-primary-dark);
  font-weight: 500;
  border-left: 4px solid var(--color-primary);
  padding: 14px 20px;
  background: rgba(122, 32, 33, 0.04);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  margin: 24px 0;
}

.work-lead-text p:last-child {
  margin-bottom: 0;
}

/* Frase Célebre / Cita Destacada */
.work-quote-box {
  margin: 28px 0;
  padding: 24px 28px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-secondary);
  border-bottom: 3px solid var(--color-secondary);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.03);
}

.work-quote-text {
  font-family: var(--font-family-headings);
  font-size: 1.25rem;
  font-style: italic;
  color: var(--color-primary-dark);
  line-height: 1.7;
  margin-bottom: 12px !important;
}

.work-quote-cite {
  display: block;
  text-align: right;
  font-size: 0.88rem;
  color: var(--color-secondary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Pie de Página */
.site-footer {
  background-color: #1A1412;
  color: #D6CCC2;
  margin-top: auto;
  padding: 48px 0 24px;
  border-top: 4px solid var(--color-secondary);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 36px;
  margin-bottom: 36px;
}

.footer-brand h3 {
  font-family: var(--font-family-headings);
  color: #FFFFFF;
  margin-bottom: 12px;
}

.footer-links h4 {
  color: var(--color-secondary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.footer-links ul {
  list-style: none;
}

.footer-links li {
  margin-bottom: 8px;
}

.footer-links a {
  color: #D6CCC2;
}

.footer-links a:hover {
  color: #FFFFFF;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: #9C9189;
}

/* Conmutador de Propuestas Visuales (Herramienta interactiva) */
.theme-switcher-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #1A1412;
  color: #FFFFFF;
  padding: 10px 14px;
  border-radius: 30px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  border: 1px solid var(--color-secondary);
}

.theme-switcher-widget select {
  background-color: #2D2420;
  color: #FFFFFF;
  border: 1px solid var(--color-secondary);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

/* Responsive */
@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .hero-photo-wrap {
    order: -1;
  }
  .single-grid {
    grid-template-columns: 1fr;
  }
  .footer-grid {
    grid-template-columns: 1fr;
  }
  .search-grid {
    grid-template-columns: 1fr;
  }
  .cenefa-tecpan {
    height: 16px;
    background-size: auto 16px;
  }
  .cinta-subnav-tecpan {
    height: 12px;
    background-size: auto 12px;
  }
}
