/* =========================================================
   1. RESET GENERAL Y VARIABLES DEL PROYECTO
   Esta sección limpia estilos por defecto del navegador
   y define colores, tamaños, sombras y tipografías base.
========================================================= */

:root {
  --color-bg-top: #b7efff;
  --color-bg-mid: #8fd9ff;
  --color-bg-bottom: #4f9de0;

  --color-surface: rgba(255, 255, 255, 0.78);
  --color-surface-strong: rgba(255, 255, 255, 0.93);
  --color-card-soft: rgba(255, 248, 255, 0.9);

  --color-text: #17395a;
  --color-text-soft: #355c7c;
  --color-title: #0d5b97;
  --color-title-alt: #ff5da8;

  --color-primary: #ff71b8;
  --color-primary-dark: #eb4f9f;

  --color-secondary: #69c8ff;
  --color-secondary-dark: #319ce1;

  --color-accent: #ffd86b;
  --color-accent-dark: #ffbf2d;

  --color-success: #6fe0b0;
  --color-success-dark: #38c38a;

  --color-coral: #ff8d88;
  --color-purple-soft: #d8c5ff;
  --color-blue-soft: #dff7ff;
  --color-pink-soft: #ffe2f0;

  --color-border: rgba(23, 57, 90, 0.1);
  --color-shadow: rgba(20, 58, 91, 0.18);
  --color-overlay: rgba(9, 30, 53, 0.78);

  --radius-xs: 0.6rem;
  --radius-sm: 0.9rem;
  --radius-md: 1.2rem;
  --radius-lg: 1.7rem;
  --radius-xl: 2.2rem;
  --radius-pill: 999px;

  --space-xs: 0.35rem;
  --space-sm: 0.7rem;
  --space-md: 1rem;
  --space-lg: 1.4rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  --shadow-soft: 0 10px 24px rgba(38, 96, 146, 0.14);
  --shadow-card: 0 16px 38px rgba(28, 79, 125, 0.18);
  --shadow-strong: 0 20px 44px rgba(23, 60, 95, 0.22);

  --font-main: "Trebuchet MS", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  --font-title: "Trebuchet MS", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;

  --container-width: 1120px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-main);
  color: var(--color-text);
  line-height: 1.5;
  background:
    linear-gradient(180deg, var(--color-bg-top) 0%, var(--color-bg-mid) 42%, var(--color-bg-bottom) 100%);
  overflow-x: hidden;
  position: relative;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
}

figure,
p,
h1,
h2,
h3 {
  margin-top: 0;
}


/* =========================================================
   2. ACCESIBILIDAD
   Esta sección contiene ayudas para lectores de pantalla
   y el enlace de salto rápido al contenido principal.
========================================================= */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  clip: rect(0, 0, 0, 0);
}

.skip-link {
  position: absolute;
  top: -120%;
  left: 1rem;
  z-index: 9999;
  background: #ffffff;
  color: var(--color-title);
  text-decoration: none;
  font-weight: 800;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
}

.skip-link:focus {
  top: 1rem;
}


/* =========================================================
   3. FONDO DECORATIVO GENERAL
   Esta sección crea ambiente submarino con luces suaves,
   burbujas y profundidad visual agradable para niños.
========================================================= */

.background-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.background-decor::before,
.background-decor::after {
  content: "";
  position: absolute;
  inset: 0;
}

.background-decor::before {
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.55) 0, rgba(255, 255, 255, 0) 16%),
    radial-gradient(circle at 82% 8%, rgba(255, 255, 255, 0.48) 0, rgba(255, 255, 255, 0) 18%),
    radial-gradient(circle at 55% 2%, rgba(255, 255, 255, 0.28) 0, rgba(255, 255, 255, 0) 22%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 28%);
}

.background-decor::after {
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.34) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(255, 255, 255, 0.24) 0 3px, transparent 4px),
    radial-gradient(circle, rgba(255, 255, 255, 0.22) 0 1.5px, transparent 2.5px);
  background-size: 180px 180px, 240px 240px, 130px 130px;
  background-position: 0 0, 40px 60px, 100px 30px;
  opacity: 0.45;
}


/* =========================================================
   4. HEADER PRINCIPAL
   Esta sección estiliza el encabezado superior con
   apariencia suave, moderna y flotante.
========================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.site-header__inner {
  width: min(100% - 2rem, var(--container-width));
  margin: 0 auto;
  padding: 0.9rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-title {
  margin: 0;
  font-family: var(--font-title);
  font-size: clamp(1.25rem, 2.5vw, 2rem);
  color: var(--color-title);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.38);
}

.top-nav {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}


/* =========================================================
   5. ESTRUCTURA PRINCIPAL DEL LIBRO
   Esta sección define el área central donde se ve
   el cuento y le da un marco general atractivo.
========================================================= */

.main-content {
  padding: 1.25rem 1rem 2rem;
}

.book-shell {
  width: min(100%, var(--container-width));
  margin: 0 auto;
  padding: 1rem;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}

.book-status {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.book-status__text {
  margin: 0;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.8);
  color: var(--color-title);
  font-weight: 800;
  border: 1px solid rgba(23, 57, 90, 0.08);
  box-shadow: var(--shadow-soft);
}

.book-viewer {
  position: relative;
}


/* =========================================================
   6. PÁGINAS DEL LIBRO
   Esta sección controla el estilo base de cada página,
   su visibilidad y su apariencia como tarjeta de cuento.
========================================================= */

.book-page {
  display: none;
  position: relative;
  overflow: hidden;
  padding: 1.1rem;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(23, 57, 90, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 252, 255, 0.92));
  box-shadow: var(--shadow-card);
}

.book-page.is-active {
  display: block;
  animation: pageFade 0.35s ease;
}

@keyframes pageFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.book-page::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.5), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 35%);
}

.page__header,
.page__content,
.page__footer {
  position: relative;
  z-index: 1;
}

.page__header {
  margin-bottom: 1rem;
  text-align: center;
}

.page__title {
  margin-bottom: 0.5rem;
  font-family: var(--font-title);
  font-size: clamp(1.75rem, 3.4vw, 2.8rem);
  font-weight: 900;
  color: var(--color-title);
  text-shadow:
    0 2px 0 rgba(255, 255, 255, 0.72),
    0 5px 14px rgba(88, 151, 200, 0.16);
}

.page__subtitle {
  margin: 0 auto;
  max-width: 42rem;
  color: var(--color-text-soft);
  font-weight: 700;
  font-size: 1rem;
}

.page__content {
  display: grid;
  gap: 1rem;
}

.page__footer {
  margin-top: 1.25rem;
}


/* =========================================================
   7. ESTILOS DE TIPOS DE PÁGINA
   Esta sección diferencia portada, créditos, narrativa,
   personaje y final sin romper la estructura base.
========================================================= */

.page--cover {
  text-align: center;
  min-height: 72vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(237, 248, 255, 0.96));
}

.page--cover .page__title {
  color: var(--color-title);
}

.page--cover .page__subtitle {
  max-width: 34rem;
}

.page__figure--cover {
  max-width: 460px;
  margin: 0 auto;
}

.page--credits {
  min-height: 58vh;
}

.page--credits .page__content--text-only {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.4rem;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 240, 248, 0.92), rgba(230, 247, 255, 0.92));
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(23, 57, 90, 0.08);
}

.page--story,
.page--character,
.page--final {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(242, 250, 255, 0.94));
}

.page--story .page__content,
.page--character .page__content,
.page--final .page__content {
  grid-template-columns: 1fr;
}

.page--final {
  border: 2px solid rgba(255, 216, 107, 0.55);
  background:
    linear-gradient(180deg, rgba(255, 252, 242, 0.98), rgba(245, 250, 255, 0.94));
}


/* =========================================================
   8. BLOQUES DE TEXTO DEL CUENTO
   Esta sección hace que el texto se vea más cálido,
   infantil, suave y conectado con la temática marina.
========================================================= */

.text-block {
  position: relative;
  padding: 1.3rem 1rem;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(23, 57, 90, 0.08);
  background:
    linear-gradient(135deg, var(--color-pink-soft), var(--color-blue-soft) 60%, #ffffff);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.text-block::before {
  content: "";
  position: absolute;
  top: -24px;
  right: -24px;
  width: 90px;
  height: 90px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.6), transparent 70%);
  pointer-events: none;
}

.text-block::after {
  content: "✦";
  position: absolute;
  bottom: 0.7rem;
  right: 1rem;
  font-size: 1rem;
  color: rgba(255, 111, 181, 0.32);
  pointer-events: none;
}

.story-text {
  margin: 0;
  text-align: center;
  font-size: clamp(1.05rem, 2.1vw, 1.18rem);
  line-height: 1.9;
  font-weight: 800;
  color: var(--color-text);
  text-wrap: balance;
}


/* =========================================================
   9. BLOQUES DE IMAGEN
   Esta sección integra mejor la ilustración al diseño,
   dándole marco cálido, sombra y un botón de apoyo.
========================================================= */

.image-block {
  padding: 0.9rem;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(23, 57, 90, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(228, 245, 255, 0.82));
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 0.9rem;
}

.page__image {
  width: 100%;
  border-radius: var(--radius-lg);
  object-fit: cover;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(30, 81, 126, 0.18);
}


/* =========================================================
   10. BOTONES GENERALES
   Esta sección crea botones más divertidos, coloridos
   y amables para niños, con hover y cursor claro.
========================================================= */

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-pill);
  padding: 0.82rem 1.2rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    background 0.22s ease,
    color 0.22s ease,
    opacity 0.22s ease,
    filter 0.22s ease;
  box-shadow: 0 10px 20px rgba(32, 82, 126, 0.16);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0) 20%,
    rgba(255, 255, 255, 0.38) 50%,
    rgba(255, 255, 255, 0) 80%
  );
  transform: translateX(-120%);
  transition: transform 0.4s ease;
}

.btn:hover::after {
  transform: translateX(120%);
}

.btn:hover {
  transform: translateY(-3px) scale(1.02);
  filter: saturate(1.05);
}

.btn:active {
  transform: translateY(0) scale(0.99);
}

.btn:focus-visible {
  outline: 3px solid rgba(105, 200, 255, 0.55);
  outline-offset: 3px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn--primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--color-primary), #ff9ec9);
}

.btn--primary:hover {
  background: linear-gradient(135deg, var(--color-primary-dark), #ff82b8);
}

.btn--secondary {
  color: #644300;
  background: linear-gradient(135deg, var(--color-accent), #ffe69b);
}

.btn--secondary:hover {
  background: linear-gradient(135deg, var(--color-accent-dark), #ffd55f);
}

.btn--ghost {
  color: var(--color-title);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(23, 57, 90, 0.08);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 1);
}

.btn--nav {
  min-width: 116px;
  color: #0f4775;
  background: linear-gradient(135deg, var(--color-secondary), #a0e3ff);
}

.btn--nav:hover {
  color: #ffffff;
  background: linear-gradient(135deg, var(--color-secondary-dark), #56b8f1);
}

.btn--image {
  justify-self: center;
  min-width: 150px;
  color: #0f5b39;
  background: linear-gradient(135deg, var(--color-success), #acf0cb);
}

.btn--image:hover {
  color: #ffffff;
  background: linear-gradient(135deg, var(--color-success-dark), #58d59c);
}

.btn--close {
  color: #6d1212;
  background: linear-gradient(135deg, #ff9b9b, #ffc5c5);
}

.btn--close:hover {
  background: linear-gradient(135deg, #ff7d7d, #ffaaaa);
}


/* =========================================================
   11. GRUPOS DE ACCIONES
   Esta sección organiza los botones según el contexto:
   portada, navegación interna y final del cuento.
========================================================= */

.page__actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.page__actions--cover,
.page__actions--final {
  margin-top: 0.3rem;
}


/* =========================================================
   12. NAVEGACIÓN DEL LIBRO
   Esta sección deja la navegación general atractiva,
   centrada y lista para mostrarse solo cuando toque.
========================================================= */

.book-navigation {
  display: none;
  margin-top: 1rem;
  padding: 1rem;
  justify-content: center;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(235, 247, 255, 0.82));
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(23, 57, 90, 0.08);
}

.book-navigation.is-visible {
  display: flex;
}


/* =========================================================
   13. MODAL / VISOR DE IMAGEN
   Esta sección da estilo a la vista ampliada para que
   se vea elegante, clara y enfocada en la ilustración.
========================================================= */

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
}

.image-modal[hidden] {
  display: none;
}

.image-modal__overlay {
  position: absolute;
  inset: 0;
  background: var(--color-overlay);
  backdrop-filter: blur(6px);
}

.image-modal__content {
  position: relative;
  width: min(100% - 2rem, 960px);
  max-height: calc(100vh - 3rem);
  margin: 1.5rem auto;
  padding: 1rem;
  overflow: auto;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 250, 255, 0.95));
  box-shadow: var(--shadow-strong);
}

.image-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.image-modal__title {
  margin: 0;
  color: var(--color-title);
  font-size: 1.55rem;
  font-weight: 900;
}

.image-modal__figure {
  margin: 0;
}

.image-modal__img {
  width: 100%;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}


/* =========================================================
   14. FOOTER DEL SITIO
   Esta sección presenta los créditos finales con
   un estilo limpio y discreto, pero bonito.
========================================================= */

.site-footer {
  width: min(100% - 2rem, var(--container-width));
  margin: 1.4rem auto 2rem;
  padding: 1rem 1.2rem;
  text-align: center;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(238, 248, 255, 0.8));
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(23, 57, 90, 0.08);
}

.site-footer__text {
  margin: 0.25rem 0;
  color: var(--color-text-soft);
  font-weight: 700;
}

.site-footer__text--small {
  font-size: 0.92rem;
  font-weight: 600;
}


/* =========================================================
   15. CLASE AUXILIAR PARA OCULTAR
   Esta sección permite ocultar elementos con JavaScript
   sin romper el flujo visual del diseño.
========================================================= */

.is-hidden {
  display: none !important;
}


/* =========================================================
   16. RESPONSIVE TABLET
   Esta sección mejora la experiencia en pantallas
   medianas y organiza mejor los espacios internos.
========================================================= */

@media (min-width: 768px) {
  .main-content {
    padding: 1.5rem 1.4rem 2.2rem;
  }

  .book-shell {
    padding: 1.3rem;
  }

  .book-page {
    padding: 1.45rem;
  }

  .story-text {
    font-size: 1.14rem;
  }

  .page__figure--cover {
    max-width: 500px;
  }
}


/* =========================================================
   17. RESPONSIVE ESCRITORIO
   Esta sección da una apariencia más refinada en
   pantallas grandes, con más aire visual.
========================================================= */

@media (min-width: 1024px) {
  .site-header__inner {
    padding: 1rem 0;
  }

  .book-shell {
    padding: 1.5rem;
  }

  .book-page {
    padding: 1.7rem;
  }

  .page__header {
    margin-bottom: 1.2rem;
  }

  .page__title {
    font-size: clamp(2rem, 3vw, 3rem);
  }

  .page__subtitle {
    font-size: 1.05rem;
  }

  .page__figure--cover {
    max-width: 520px;
  }

  .image-modal__content {
    padding: 1.2rem;
  }
}


/* =========================================================
   18. RESPONSIVE MÓVIL PEQUEÑO
   Esta sección evita que la interfaz se sienta apretada
   en pantallas muy pequeñas.
========================================================= */

@media (max-width: 480px) {
  .site-header__inner {
    width: min(100% - 1rem, var(--container-width));
    flex-direction: column;
    align-items: stretch;
  }

  .site-title {
    text-align: center;
  }

  .top-nav {
    justify-content: center;
  }

  .main-content {
    padding: 0.85rem 0.75rem 1.4rem;
  }

  .book-shell {
    padding: 0.7rem;
    border-radius: var(--radius-lg);
  }

  .book-page {
    padding: 0.95rem;
    border-radius: var(--radius-lg);
  }

  .book-status {
    justify-content: center;
  }

  .page__actions,
  .book-navigation,
  .top-nav {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .image-modal__content {
    width: min(100% - 1rem, 960px);
    margin: 0.5rem auto;
    max-height: calc(100vh - 1rem);
    border-radius: var(--radius-lg);
  }

  .image-modal__header {
    flex-direction: column;
    align-items: stretch;
  }
}
