:root {
  --cream: #f7ecd9;
  --cream-2: #fbf5e8;
  --brown-dark: #2c1c12;
  --brown: #4a2f1c;
  --tan: #c9a15a;
  --rust: #b64a24;
  --jungle-1: #0f2b16;
  --jungle-2: #1c4a26;
  --jungle-3: #2f6b3a;
  --jungle-4: #4f8a4a;
  --jungle-5: #7bb35f;
  --sage: #8ba07d;
  --sage-dark: #5f7657;
  --sage-light: #b7c6a9;
  --paper: #f2ead2;
  --paper-blob: #e9c98f;
  --ink: #22190f;
  --shadow: rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--brown-dark);
  color: var(--ink);
  font-family: "Segoe UI", -apple-system, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  perspective: 1800px;
}

.book {
  position: absolute;
  inset: 0;
}

.page {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  will-change: transform;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page.flip-out-next { transition: transform 0.65s cubic-bezier(.55,.06,.68,.19); transform: rotateY(-118deg); }
.page.flip-out-prev { transform-origin: right center; transition: transform 0.65s cubic-bezier(.55,.06,.68,.19); transform: rotateY(118deg); }
.page.instant { transition: none !important; }

.page::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0.5), transparent 35%);
  opacity: 0;
  transition: opacity 0.65s ease;
  pointer-events: none;
}
.page.flip-out-next::after,
.page.flip-out-prev::after { opacity: 1; }

/* ---------- Portada (estilo carta fisica: papel crema + hojas en las esquinas) ---------- */
.cover-page {
  background:
    radial-gradient(ellipse 70% 40% at 50% 45%, rgba(233,201,143,0.35), transparent 70%),
    var(--paper);
  align-items: center;
  justify-content: space-between;
  padding: 6vh 0 4vh;
}

.jungle-leaves { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.leaf {
  position: absolute;
  border-radius: 0 100% 0 100%;
  opacity: 0.8;
}
.leaf-1 { top: -8%; left: -16%; width: 52vw; height: 22vh; background: var(--sage); transform: rotate(28deg); }
.leaf-2 { top: -6%; right: -20%; width: 48vw; height: 20vh; background: var(--sage-dark); transform: rotate(-32deg) scaleX(-1); }
.leaf-3 { bottom: -10%; left: -18%; width: 54vw; height: 24vh; background: var(--sage-dark); transform: rotate(-20deg); }
.leaf-4 { bottom: -12%; right: -16%; width: 50vw; height: 22vh; background: var(--sage); transform: rotate(24deg) scaleX(-1); opacity: 0.7; }

.cover-title-block {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  margin-top: 2vh;
}
.cover-logo-block {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.cover-logo { width: 46vw; max-width: 220px; filter: drop-shadow(0 6px 14px rgba(74,47,28,0.25)); }
.cover-title {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: clamp(22px, 6vw, 30px);
  color: var(--brown);
}
.cover-sub {
  color: var(--sage-dark);
  font-size: clamp(12px, 3.4vw, 14px);
  letter-spacing: 0.06em;
  font-weight: 600;
}

.cover-instagram {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.5);
  padding: 7px 16px 7px 8px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(74,47,28,0.15);
}
.cover-instagram svg { width: 26px; height: 26px; flex-shrink: 0; }
.cover-instagram span {
  font-size: 13px;
  font-weight: 700;
  color: var(--brown);
  letter-spacing: 0.01em;
}

.cover-hint {
  position: relative;
  z-index: 3;
  color: var(--brown);
  font-size: 12px;
  opacity: 0.6;
  letter-spacing: 0.08em;
}

/* ---------- Mascotas ---------- */
.mascot {
  position: absolute;
  width: 78px;
  height: auto;
  z-index: 5;
  transition: top 0.9s cubic-bezier(.2,.8,.3,1), left 0.9s cubic-bezier(.2,.8,.3,1), transform 0.9s ease;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.35));
}
.mascot.toucan-mascot { width: 84px; }
.mascot.hummingbird-mascot { width: 54px; }
.mascot-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.toucan-svg { transform: rotate(-13deg); }
.mascot .hb-wing {
  transform-box: fill-box;
  transform-origin: 85% 20%;
}
.mascot .toucan-wing { transform-origin: 0 0; color: #111111; }
.mascot .toucan-wing path { fill: currentColor; }
.mascot.idle .toucan-wing,
.mascot.idle .hb-wing { animation: mascotIdleBob 3.6s ease-in-out infinite; }
.mascot.flying .toucan-wing { animation: wingFlapOpen 0.2s ease-in-out infinite alternate; }
.mascot.flying .hb-wing-front { animation: wingFlapFast 0.07s ease-in-out infinite alternate; }
.mascot.flying .hb-wing-back { animation: wingFlapFast 0.07s ease-in-out infinite alternate-reverse; }
.mascot.flying { animation: mascotBob 0.32s ease-in-out infinite alternate; }
.mascot.facing-left { transform: scaleX(-1); }
.mascot { cursor: pointer; }

@keyframes mascotIdleBob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(-4deg); }
}
@keyframes mascotBob {
  from { translate: 0 0; }
  to { translate: 0 -10px; }
}
@keyframes wingFlapOpen {
  from { transform: rotate(15deg) scale(0.9); color: #111111; }
  to { transform: rotate(-75deg) scale(1.05); color: #00AEEF; }
}
@keyframes wingFlapFast {
  from { transform: rotate(10deg) scaleY(1); }
  to { transform: rotate(-52deg) scaleY(0.72); }
}

/* ---------- Paginas de categoria ---------- */
.category-page { background: var(--cream); }
.category-header {
  padding: 18px 20px 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 2px solid var(--tan);
  background: var(--cream-2);
}
.category-header h2 {
  font-family: Georgia, "Times New Roman", serif;
  margin: 0;
  padding-right: 46px;
  color: var(--brown);
  font-size: clamp(20px, 5.6vw, 26px);
  letter-spacing: 0.02em;
}
.category-header h2 .sub-index {
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--rust);
  letter-spacing: 0;
}
.category-counter { font-size: 12px; color: var(--rust); font-weight: 600; }

.group-heading {
  grid-column: 1 / -1;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--rust);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 4px 2px 0;
  border-bottom: 1px solid var(--tan);
  margin-bottom: 2px;
}

.dish-grid {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  align-content: start;
}
.dish-card {
  position: relative;
  background: var(--cream-2);
  border-radius: 13px 13px 13px 3px;
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.7) inset,
    0 -3px 5px rgba(74,47,28,0.14) inset,
    0 6px 12px rgba(74,47,28,0.25),
    0 1px 2px rgba(74,47,28,0.2);
  border: 1px solid rgba(74,47,28,0.18);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.dish-card::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 18px; height: 18px;
  background: linear-gradient(135deg, transparent 50%, rgba(74,47,28,0.16) 51%, rgba(74,47,28,0.16) 58%, transparent 59%);
  pointer-events: none;
}
.dish-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: var(--tan);
}
.dish-card .dish-name {
  padding: 7px 8px 9px;
  font-size: clamp(11.5px, 3.2vw, 13px);
  font-weight: 600;
  color: var(--brown);
  line-height: 1.25;
}

/* ---------- Boton de sonido (fijo, abajo a la derecha) ---------- */
.sound-toggle {
  position: absolute;
  bottom: 3%;
  right: 4%;
  z-index: 300;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(44, 28, 18, 0.82);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  user-select: none;
}

/* ---------- Nav: siguiente / anterior (fijos, siempre visibles) ---------- */
.nav-tab {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(44, 28, 18, 0.75);
  color: var(--cream-2);
  padding: 12px 6px;
  border-radius: 10px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  user-select: none;
  opacity: 0.75;
  transition: opacity 0.25s ease, background 0.25s ease;
}
.nav-tab:hover,
.nav-tab:active,
.nav-tab.near {
  opacity: 1;
  background: rgba(44, 28, 18, 0.88);
}
.nav-next { right: 0; border-radius: 10px 0 0 10px; }
.nav-prev { left: 0; border-radius: 0 10px 10px 0; }
.nav-tab .arrow { writing-mode: horizontal-tb; font-size: 15px; }

/* ---------- Indice de categorias (pestanas arriba a la derecha) ---------- */
.index-bar {
  position: absolute;
  top: 6%;
  right: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 50%;
  /* zona de "acercamiento" mas ancha que las pestañas para revelarlas */
  padding-left: 22px;
  margin-right: -6px;
}
.index-tab {
  background: rgba(95, 118, 87, 0.4);
  color: var(--cream-2);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 6px 9px 6px 12px;
  border-radius: 60% 6px 6px 60% / 50% 8px 8px 50%;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.18);
  user-select: none;
  opacity: 0.55;
  transform: translateX(6px);
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.25s ease;
}
.index-bar:hover .index-tab,
.index-bar.near .index-tab {
  opacity: 1;
  transform: translateX(0);
  background: rgba(95, 118, 87, 0.92);
}
.index-tab:hover,
.index-tab:active {
  opacity: 1 !important;
  transform: translateX(0) !important;
  background: var(--rust) !important;
}
.index-tab.active {
  background: var(--rust);
  opacity: 0.85;
}
.index-bar.near .index-tab.active,
.index-bar:hover .index-tab.active { opacity: 1; }

/* ---------- Modal de descripcion ---------- */
.dish-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 6, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.dish-modal {
  background: var(--cream-2);
  border-radius: 16px;
  max-width: 380px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
}
.dish-modal img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.dish-modal-body { padding: 16px 18px 20px; }
.dish-modal-body h3 {
  font-family: Georgia, "Times New Roman", serif;
  margin: 0 0 8px;
  color: var(--brown);
  font-size: 20px;
}
.dish-modal-body p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-line;
}
.dish-modal-close {
  position: sticky;
  top: 8px;
  float: right;
  margin: 8px 8px 0 0;
  background: rgba(44,28,18,0.75);
  color: #fff;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
