:root {
  /* Paleta Editorial Premium */
  --c-paper: #f4f1ee;
  --c-ink: #1c1c1c;
  --c-subtle: #7a7a7a;
  --c-line: rgba(28, 28, 28, 0.08);

  /* Tipografía */
  --f-serif: "Cormorant Garamond", serif;
  --f-sans: "Inter", sans-serif;

  /* Dimensiones */
  --sidebar-w: 280px;
  --gutter: 4rem;

  /* Animación */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

html {
  scroll-behavior: smooth;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--c-paper);
  color: var(--c-ink);
  font-family: var(--f-serif);
  line-height: 1.6;
  overflow-x: hidden;
}

.grain-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("https://grainy-gradients.vercel.app/noise.svg");
  opacity: 0.035;
  pointer-events: none;
  z-index: 900;
}

/* --- LAYOUT --- */
.layout-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  padding: 3rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--c-line);
  z-index: 50;
  background-color: var(--c-paper);
}

.author-name {
  font-family: var(--f-serif);
  font-size: 1.8rem;
  font-weight: 400;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.author-tagline {
  font-family: var(--f-sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--c-subtle);
}

.toc-nav {
  margin-top: 4rem;
  flex-grow: 1;
}

.nav-list {
  list-style: none;
}

.nav-list li {
  margin-bottom: 1.2rem;
}

.nav-link {
  text-decoration: none;
  color: var(--c-subtle);
  font-family: var(--f-sans);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  transition: color 0.4s ease, padding-left 0.4s var(--ease-out);
  display: inline-block;
  position: relative;
}

.nav-link:hover,
.nav-link.active {
  color: var(--c-ink);
  padding-left: 10px;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 4px;
  height: 1px;
  background: var(--c-ink);
}

.sidebar-footer {
  font-family: var(--f-sans);
  font-size: 0.65rem;
  color: var(--c-subtle);
}

/* CONTENT */
.main-content {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  padding: 6rem var(--gutter) 10rem;
  max-width: 1400px;
}

.content-section {
  margin-bottom: 15rem;
  scroll-margin-top: 10vh;
}

.section-header {
  margin-bottom: 4rem;
  border-bottom: 1px solid var(--c-line);
  padding-bottom: 1rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.section-number {
  font-family: var(--f-sans);
  color: var(--c-subtle);
  font-size: 0.8rem;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--c-ink);
}

/* GRID POEMAS */
.editorial-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4rem 6rem;
}

.poem-card {
  cursor: pointer;
  transition: opacity 0.4s ease;
}

.poem-card:hover {
  opacity: 0.7;
}

.poem-card h3 {
  font-size: 2.2rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
}

.poem-meta {
  font-family: var(--f-sans);
  font-size: 0.75rem;
  color: var(--c-subtle);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* PAGINACIÓN */
.pagination-wrapper {
  margin-top: 6rem;
  padding-top: 2rem;
  border-top: 1px solid var(--c-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pagination-btn {
  background: none;
  border: none;
  font-family: var(--f-sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--c-subtle);
  cursor: pointer;
  transition: color 0.3s ease;
  padding: 10px 0;
}

.pagination-btn:hover:not(:disabled) {
  color: var(--c-ink);
}

.pagination-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.pagination-info {
  font-family: var(--f-sans);
  font-size: 0.7rem;
  color: var(--c-subtle);
  letter-spacing: 0.1em;
}

/* ARTÍCULOS */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.article-item {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  cursor: pointer;
  align-items: center;
  padding: 2rem 0;
  border-top: 1px solid transparent;
  transition: border-color 0.4s ease;
}

.article-item:hover {
  border-top: 1px solid var(--c-line);
}

.article-thumb-wrapper {
  overflow: hidden;
  height: 200px;
  background-color: #eee;
}

.article-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(100%) contrast(0.9);
  transition: transform 0.8s var(--ease-out), filter 0.5s ease;
}

.article-item:hover .article-thumb {
  transform: scale(1.05);
  filter: grayscale(0%);
}

.article-content h3 {
  font-size: 2rem;
  line-height: 1.2;
  margin-bottom: 1rem;
}

.article-excerpt {
  color: var(--c-subtle);
  font-size: 1rem;
  max-width: 500px;
}

/* LIBROS */
.book-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 4rem;
}

.book-item {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.book-cover-wrapper {
  background-color: #e8e5e1;
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.5s ease;
}

.book-item:hover .book-cover-wrapper {
  background-color: #dedbd7;
}

.book-cover {
  width: 160px;
  box-shadow: 5px 10px 20px rgba(0, 0, 0, 0.1);
  transform: translateY(0);
  transition: transform 0.5s var(--ease-out);
}

.book-item:hover .book-cover {
  transform: translateY(-5px);
}

.book-info h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  font-style: italic;
}

.book-desc {
  font-size: 0.95rem;
  color: var(--c-subtle);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.book-link {
  font-family: var(--f-sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--c-ink);
  border-bottom: 1px solid var(--c-line);
  padding-bottom: 3px;
  letter-spacing: 0.1em;
  transition: border-color 0.3s;
}

.book-link:hover {
  border-color: var(--c-ink);
}

/* SECCIÓN SOBRE MÍ */
.about-layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 5rem;
  align-items: start;
}

.about-portrait-wrapper {
  position: relative;
}

.about-portrait {
  width: 100%;
  height: auto;
  display: block;
  filter: grayscale(100%) contrast(1.1);
  transition: filter 0.6s var(--ease-out);
  opacity: 0.9;
}

.about-portrait-wrapper:hover .about-portrait {
  filter: grayscale(0%) contrast(1);
}

.image-caption {
  margin-top: 1rem;
  font-family: var(--f-sans);
  font-size: 0.65rem;
  color: var(--c-subtle);
  letter-spacing: 0.05em;
  text-align: right;
}

.narrative-lead {
  font-family: var(--f-serif);
  font-size: 1.8rem;
  font-weight: 400;
  line-height: 1.3;
  margin-bottom: 2rem;
  color: var(--c-ink);
  font-style: italic;
}

.narrative-body p {
  font-family: var(--f-serif);
  font-size: 1.1rem;
  color: var(--c-subtle);
  margin-bottom: 1.5rem;
  max-width: 90%;
}

.social-separator {
  width: 40px;
  height: 1px;
  background-color: var(--c-ink);
  margin: 3rem 0 2rem;
  opacity: 0.3;
}

.social-nav {
  display: flex;
  gap: 1.5rem;
}

.social-link {
  color: var(--c-subtle);
  transition: color 0.3s ease, transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.social-link:hover {
  color: var(--c-ink);
  transform: translateY(-2px);
}

/* READER OVERLAY */
.reader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 100;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s var(--ease-out), visibility 0.6s;
  background: var(--c-paper);
}

.reader-overlay.active {
  opacity: 1;
  visibility: visible;
}

.close-reader {
  position: fixed;
  top: 2rem;
  right: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--f-sans);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 110;
  color: var(--c-subtle);
}

.close-reader:hover {
  color: var(--c-ink);
}

.reader-container {
  width: 100%;
  max-width: 700px;
  padding: 10vh 2rem 10vh;
}

.reader-header {
  text-align: center;
  margin-bottom: 4rem;
}

.reader-title {
  font-size: 3rem;
  font-weight: 400;
  margin: 1rem 0;
}

.reader-meta {
  font-family: var(--f-sans);
  font-size: 0.8rem;
  color: var(--c-subtle);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.reader-hero-image img {
  width: 100%;
  height: auto;
  margin-top: 2rem;
  filter: grayscale(100%);
}

.reader-body {
  font-size: 1.4rem;
  line-height: 1.8;
}

.reader-body p {
  margin-bottom: 1.5rem;
}

.text-reveal {
  display: block;
  opacity: 0;
  transform: translateY(15px);
  filter: blur(5px);
  transition: opacity 1s ease, transform 1s ease, filter 1s ease;
}

.text-reveal.visible {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

.reader-end-mark {
  text-align: center;
  margin-top: 4rem;
  color: var(--c-subtle);
}

.main-footer {
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--c-line);
  font-family: var(--f-sans);
  font-size: 0.75rem;
  color: var(--c-subtle);
}

/* BOTÓN VOLVER ARRIBA */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 45px;
  height: 45px;
  background-color: var(--c-paper);
  border: 1px solid var(--c-line);
  color: var(--c-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  z-index: 1000;
  transition: all 0.4s var(--ease-out);
  opacity: 0;
  visibility: hidden;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  border-color: var(--c-ink);
  transform: translateY(-5px);
}

/* =========================================
   DISEÑO RESPONSIVE (MÓVILES Y TABLETS)
   Agrupado en un solo bloque para evitar errores
   ========================================= */
@media (max-width: 900px) {
  .layout-wrapper {
    flex-direction: column;
  }

  /* 1. La barra lateral pasa a ser una cabecera superior */
  .sidebar {
    width: 100%;
    height: auto;
    position: relative; /* Quita el comportamiento "fijo" o "escondido" */
    border-right: none;
    border-bottom: 1px solid var(--c-line);
    padding: 3rem 1.5rem;
    align-items: center;
    text-align: center;
  }

  /* 2. El menú de navegación se coloca en horizontal */
  .toc-nav {
    margin-top: 2rem;
  }
  
  .nav-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
  }
  
  .nav-list li {
    margin-bottom: 0;
  }

  /* 3. Ajuste de contenido principal (menos márgenes gigantes) */
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 3rem 1.5rem;
  }

  .content-section {
    margin-bottom: 6rem;
    scroll-margin-top: 2rem;
  }

  .section-header {
    margin-bottom: 2rem;
  }

  /* 4. Las columnas (Poemas, Artículos, Sobre Mí) pasan a ser 1 sola columna */
  .editorial-grid,
  .article-item,
  .about-layout {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .reader-title {
    font-size: 2.2rem;
  }

  .pagination-wrapper {
    flex-direction: column;
    gap: 1rem;
  }

  .narrative-lead {
    font-size: 1.5rem;
  }

  .narrative-body p {
    max-width: 100%;
  }

  .social-separator {
    margin: 2rem auto;
  }

  .social-nav {
    justify-content: center;
  }

  .main-footer {
    text-align: center;
  }

  /* 5. Ajuste del botón flotante */
  .back-to-top {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 40px;
    height: 40px;
  }
}