/* === MARTINA · CUENTOS PARA DORMIR === */
/* Modernized, magical, kid-friendly aesthetic */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@700;800&family=Quicksand:wght@400;500;600&display=swap');

:root {
  --ink: #2b2d42;
  --paper: #f4f1de;
  --warm-white: #ffffff;
  --gold: #f4a261;
  --gold-light: #e9c46a;
  --rose: #e76f51;
  --rose-light: #f4a261;
  --magic-blue: #2a6f97;
  --magic-dark: #012a4a;
  --sage: #2a9d8f;
  --board-light: #e0e1dd;
  --board-dark: #8d99ae;
  --shadow: 0 8px 24px rgba(0,0,0,0.06);
  --shadow-hover: 0 12px 32px rgba(42, 111, 151, 0.15);
  --radius: 20px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Quicksand', sans-serif;
  background: var(--paper);
  background-image: radial-gradient(circle at top right, rgba(233, 196, 106, 0.1), transparent 400px),
                    radial-gradient(circle at bottom left, rgba(42, 111, 151, 0.1), transparent 400px);
  color: var(--ink);
  line-height: 1.75;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* === TYPOGRAPHY === */

h1, h2, h3, h4 {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  line-height: 1.3;
  color: var(--magic-dark);
}

h1 { font-size: 2.5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.4rem; }

p { margin-bottom: 1.2em; font-weight: 500; }

a {
  color: var(--rose);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.3s ease;
}
a:hover, a:focus { color: var(--magic-blue); }

/* === COMPACT HEADER & NAVIGATION === */

.site-header-compact {
  background: var(--warm-white);
  padding: 1rem 2rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--gold);
}

.header-content-compact {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-title-compact {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--magic-dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-piece-compact {
  color: var(--gold);
  font-size: 1.8rem;
}

.nav-bar-compact {
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--magic-dark);
  text-transform: capitalize;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  transition: all 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
  background: var(--magic-blue);
  color: var(--warm-white);
}

/* Make sure header links are unstyled initially */
.site-title-compact a {
  text-decoration: none;
  color: inherit;
}

/* === MAIN CONTENT === */

main {
  flex: 1;
  padding: 2rem 1.25rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* === HERO / INTRO === */

.hero {
  text-align: center;
  padding: 2.5rem 0 1rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .hero {
    flex-direction: row;
    text-align: left;
    justify-content: center;
    gap: 3rem;
  }
}

.hero-image-container {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  overflow: hidden;
  border: 6px solid var(--warm-white);
  box-shadow: var(--shadow-hover);
  background: var(--magic-blue);
  flex-shrink: 0;
}

.hero-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s;
}

.hero-image-container:hover img {
  transform: scale(1.05);
}

.hero h1 {
  font-size: 2rem;
  color: var(--magic-dark);
  margin-bottom: 0.5rem;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--magic-blue);
  font-weight: 600;
  max-width: 400px;
}

/* === CARDS & STORY GRID === */

.card {
  background: var(--warm-white);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(233, 196, 106, 0.3);
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.story-card {
  background: var(--warm-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  border: 2px solid transparent;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
  overflow: hidden;
}

.story-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-hover);
  border-color: var(--gold);
}

.story-thumbnail {
  width: 100%;
  height: 140px;
  background: var(--magic-dark);
  overflow: hidden;
}

.story-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.story-card:hover .story-thumbnail img {
  transform: scale(1.05);
}

.story-card-content {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.story-card.story-locked {
  opacity: 0.7;
  cursor: not-allowed;
}

.story-card.story-locked:hover {
  transform: none;
  box-shadow: var(--shadow);
  border-color: transparent;
}

.locked-bg {
  background: var(--board-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-title {
  font-size: 1.25rem;
  color: var(--magic-dark);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.card-meta {
  display: inline-block;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--warm-white);
  background: var(--magic-blue);
  padding: 0.3rem 0.8rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-excerpt {
  font-size: 1.05rem;
  color: var(--ink);
  line-height: 1.6;
}

/* === STORY CONTENT === */

.story-header {
  text-align: center;
  padding: 2rem 0;
  border-bottom: 3px dashed var(--gold-light);
  margin-bottom: 3rem;
}

.story-number {
  display: inline-block;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--warm-white);
  background: var(--rose);
  padding: 0.4rem 1.2rem;
  border-radius: 20px;
  margin-bottom: 1rem;
  box-shadow: 0 4px 10px rgba(231, 111, 81, 0.3);
}

.story-header h1 {
  margin-bottom: 1rem;
  font-size: 2.8rem;
  color: var(--magic-dark);
}

.story-subtitle {
  font-size: 1.2rem;
  color: var(--magic-blue);
  font-weight: 600;
}

.story-body {
  max-width: 720px;
  margin: 0 auto;
  font-size: 1.15rem;
}

.story-body p {
  margin-bottom: 1.5em;
}

.story-body .dropcap::first-letter {
  font-family: 'Nunito', sans-serif;
  font-size: 4.5rem;
  float: left;
  line-height: 0.8;
  padding-right: 0.1em;
  color: var(--magic-blue);
  font-weight: 800;
  text-shadow: 2px 2px 0px var(--gold-light);
}

/* Images within stories */
.story-image-wrapper {
  margin: 2.5rem 0;
  text-align: center;
}

.story-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 4px solid var(--warm-white);
  transition: transform 0.3s;
}

.story-image:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-hover);
}

.chess-diagram {
  text-align: center;
  margin: 2rem 0;
  font-family: monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  background: var(--ink);
  color: var(--paper);
  padding: 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: pre;
}

.story-divider {
  text-align: center;
  margin: 3rem 0;
  color: var(--gold);
  font-size: 2rem;
  letter-spacing: 1rem;
}

/* === ABOUT SECTION === */

.about-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 650px) {
  .about-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.about-trait {
  background: var(--warm-white);
  padding: 1.5rem;
  border-radius: var(--radius);
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: transform 0.3s, border-color 0.3s;
}

.about-trait:hover {
  transform: translateY(-3px);
  border-color: var(--magic-blue);
}

.about-trait-icon {
  font-size: 2rem;
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  background: var(--paper);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.about-trait-text h4 {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
  color: var(--magic-dark);
}

.about-trait-text p {
  font-size: 0.95rem;
  margin-bottom: 0;
  color: var(--ink);
}

/* === FOOTER === */

.site-footer {
  background: var(--magic-dark);
  color: var(--paper);
  text-align: center;
  padding: 2rem 1.25rem;
  font-size: 0.9rem;
  margin-top: 3rem;
  border-top: 4px solid var(--gold);
}

.site-footer::before {
  content: '♔ ♕ ♖ ♗ ♘ ♙';
  display: block;
  font-size: 1.5rem;
  letter-spacing: 0.5rem;
  margin-bottom: 1rem;
  color: var(--gold-light);
}

.site-footer p {
  opacity: 0.8;
  font-weight: 500;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gold-light);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: 'Nunito', sans-serif;
  margin-bottom: 1rem;
  transition: color 0.3s ease, transform 0.3s ease;
}

.github-link:hover {
  color: var(--warm-white);
  transform: translateY(-2px);
}

.github-link svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* === BUTTON === */

.btn {
  display: inline-block;
  padding: 0.8rem 2rem;
  border-radius: 30px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  text-align: center;
  border: none;
  color: var(--warm-white);
  background: linear-gradient(135deg, var(--rose), var(--gold));
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(231, 111, 81, 0.4);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn:hover, .btn:focus {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 20px rgba(231, 111, 81, 0.6);
  color: var(--warm-white);
}

.btn-block {
  display: block;
  width: 100%;
  margin-top: 1rem;
}

/* === RESPONSIVE ENHANCEMENTS === */

@media (max-width: 400px) {
  html { font-size: 16px; }
  .site-title { font-size: 2rem; }
  .story-header h1 { font-size: 2.2rem; }
}

@media (min-width: 768px) {
  html { font-size: 20px; }
  main { padding: 3rem 2rem; }
  .hero { padding: 4rem 0 3rem; }
  .site-header { padding: 3rem; }
  
  .story-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
  
  .btn-block {
    width: auto;
    align-self: flex-start;
  }
}

/* === ANIMATIONS === */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(1.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  opacity: 0;
}

.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }

/* === HISTORICAL EPILOGUE === */

.jump-to-game {
  display: inline-flex;
  align-items: center;
  background: var(--paper);
  color: var(--magic-blue);
  padding: 0.5rem 1rem;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  margin-top: 1rem;
  border: 2px solid var(--magic-blue);
  transition: all 0.3s ease;
}

.jump-to-game:hover {
  background: var(--magic-blue);
  color: var(--warm-white);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(42, 111, 151, 0.2);
}

.historical-epilogue {
  background: rgba(233, 196, 106, 0.15);
  border-left: 5px solid var(--gold);
  padding: 2rem;
  margin: 4rem 0 2rem 0;
  border-radius: 0 12px 12px 0;
}

.historical-epilogue h3 {
  color: var(--magic-dark);
  font-size: 1.5rem;
  margin-top: 0;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.historical-epilogue p {
  font-size: 1.05rem;
  color: var(--ink);
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* === GALLERY === */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3rem;
}

.gallery-item {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--magic-dark);
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  aspect-ratio: 1 / 1;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.gallery-item:hover img {
  transform: scale(1.06);
}

.gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.6rem 0.8rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: var(--warm-white);
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .gallery-caption {
    font-size: 0.7rem;
    padding: 0.4rem 0.5rem;
  }
}

/* Lightbox */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(1, 42, 74, 0.96);
  z-index: 1000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}

.lightbox.open {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox-img {
  max-width: 90vw;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  transition: opacity 0.2s ease;
}

.lightbox-caption {
  color: var(--gold-light);
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 1rem;
  text-align: center;
  max-width: 80vw;
}

.lightbox-counter {
  color: var(--board-dark);
  font-family: 'Quicksand', sans-serif;
  font-size: 0.85rem;
  margin-top: 0.4rem;
}

.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--warm-white);
  font-size: 2.2rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.3s ease;
  z-index: 1001;
}

.lightbox-close:hover {
  background: rgba(255,255,255,0.25);
}

.lightbox-prev,
.lightbox-next {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--warm-white);
  font-size: 3rem;
  width: 54px;
  height: 80px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
  z-index: 1001;
  user-select: none;
  -webkit-user-select: none;
}

.lightbox-prev {
  left: 0.5rem;
}

.lightbox-next {
  right: 0.5rem;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255,255,255,0.25);
}

@media (max-width: 768px) {
  .lightbox-img {
    max-width: 95vw;
    max-height: 60vh;
  }

  .lightbox-prev,
  .lightbox-next {
    font-size: 2rem;
    width: 40px;
    height: 60px;
  }

  .lightbox-prev {
    left: 0.25rem;
  }

  .lightbox-next {
    right: 0.25rem;
  }

  .lightbox-close {
    top: 0.5rem;
    right: 0.5rem;
    width: 42px;
    height: 42px;
    font-size: 1.8rem;
  }

  .lightbox-caption {
    font-size: 0.95rem;
    max-width: 90vw;
  }
}
