:root {
  --forest: #17201a;
  --forest-2: #223027;
  --moss: #4a6b4d;
  --sage: #a9bba3;
  --cream: #f6f2e9;
  --paper: #fbf9f4;
  --ink: #1c231e;
  --muted: #5d685f;
  --line: #e3ddd0;
  --gold: #e3a83f;
  --gold-2: #c98b2b;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(23, 32, 26, .06), 0 8px 28px rgba(23, 32, 26, .08);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
img { display: block; max-width: 100%; }
a { color: inherit; }
.wrap { width: min(1240px, 100% - 40px); margin-inline: auto; }

.eyebrow {
  font-size: .76rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--gold);
  margin: 0 0 .7rem;
}
.eyebrow.dark { color: var(--moss); }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; line-height: 1.1; margin: 0; }
h2 { font-size: clamp(2rem, 4vw, 3rem); }

/* ---------- Nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  color: #fff;
  transition: background .3s, box-shadow .3s, color .3s, padding .3s;
}
.nav.solid {
  background: rgba(251, 249, 244, .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  box-shadow: 0 1px 0 var(--line);
  padding-block: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.brand svg { width: 30px; height: 30px; fill: var(--gold); }
.nav-links { display: flex; align-items: center; gap: clamp(12px, 2.4vw, 30px); }
.nav-links a { white-space: nowrap; text-decoration: none; font-size: .93rem; font-weight: 500; opacity: .9; }
.nav-links a:hover { opacity: 1; color: var(--gold); }
.nav-links .ig { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border: 1px solid currentColor; border-radius: 999px; }
.admin-link { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 999px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.35); }
.nav.solid .admin-link { background: rgba(74,107,77,.1); border-color: rgba(74,107,77,.35); }
.admin-link svg, .footer-actions svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; }
body.is-admin .admin-link { background: var(--gold); border-color: var(--gold); color: var(--forest); opacity: 1; }
.footer-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.edit-btn { display: inline-flex; align-items: center; gap: 6px; margin: -.6rem 0 1.4rem; padding: 8px 16px; border-radius: 999px; background: var(--gold); color: var(--forest); font-weight: 600; font-size: .9rem; text-decoration: none; }
.edit-btn:hover { background: #f0b955; }
.edit-btn[hidden] { display: none; }
.ig svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.ig svg .dot { fill: currentColor; stroke: none; }

/* ---------- Hero ---------- */
.hero { position: relative; min-height: 100svh; display: flex; align-items: flex-end; color: #fff; overflow: hidden; background: var(--forest); }
.hero-media { position: absolute; inset: 0; }
.hero-media img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transform: scale(1.06);
  transition: opacity 1.6s ease, transform 8s ease;
}
.hero-media img.on { opacity: 1; transform: scale(1); }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,14,11,.55) 0%, rgba(10,14,11,0) 28%, rgba(10,14,11,.15) 55%, rgba(10,14,11,.82) 100%); }
.hero-content .eyebrow { text-shadow: 0 1px 10px rgba(0,0,0,.6); }
.hero-content { position: relative; z-index: 2; padding: 0 clamp(20px, 6vw, 80px) clamp(70px, 12vh, 120px); max-width: 900px; }
.hero h1 { font-size: clamp(2.8rem, 9vw, 7rem); font-weight: 600; letter-spacing: -.03em; }
.hero-sub { font-family: var(--serif); font-style: italic; font-size: clamp(1.1rem, 2.2vw, 1.5rem); margin: .8rem 0 2rem; opacity: .92; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-caption { position: absolute; right: clamp(16px, 4vw, 40px); bottom: 24px; z-index: 2; margin: 0; font-size: .8rem; opacity: .8; font-family: var(--serif); font-style: italic; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 13px 24px; border-radius: 999px; font-weight: 600; font-size: .95rem; text-decoration: none; transition: transform .2s, background .2s, color .2s; }
.btn:hover { transform: translateY(-2px); }
.btn.primary { background: var(--gold); color: var(--forest); }
.btn.primary:hover { background: #f0b955; }
.btn.ghost { border: 1px solid rgba(255,255,255,.6); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.12); }

/* ---------- Intro ---------- */
.intro { padding: clamp(70px, 10vw, 130px) 0 0; background: var(--cream); }
.intro-grid { display: grid; grid-template-columns: 1fr 1.35fr; gap: clamp(30px, 6vw, 90px); align-items: start; }
.intro-head { position: sticky; top: 100px; }
.intro-head h2 { font-size: clamp(1.9rem, 3.4vw, 2.8rem); }
.intro-text p { font-size: 1.06rem; color: #2d362f; margin: 0 0 1.15rem; }
.intro-text p:first-child::first-letter { font-family: var(--serif); float: left; font-size: 3.6rem; line-height: .9; padding: 6px 10px 0 0; color: var(--moss); }
.stats { list-style: none; padding: 0; margin: 2.2rem 0 0; display: flex; gap: 34px; flex-wrap: wrap; }
.stats li { display: flex; flex-direction: column; }
.stats b { font-family: var(--serif); font-size: 2.5rem; font-weight: 600; color: var(--moss); line-height: 1; }
.stats span { font-size: .85rem; color: var(--muted); margin-top: 6px; }

.mosaic { margin: clamp(60px, 8vw, 110px) auto 0; padding: 0 6px 6px; columns: 4 260px; column-gap: 6px; }
.mosaic button { display: block; width: 100%; padding: 0; margin: 0 0 6px; border: 0; cursor: pointer; overflow: hidden; position: relative; background: var(--forest); break-inside: avoid; }
.mosaic img { width: 100%; height: auto; display: block; transition: transform .7s ease, opacity .3s; }
.mosaic button:hover img { transform: scale(1.04); opacity: .88; }
.mosaic button span { position: absolute; left: 12px; bottom: 10px; color: #fff; font-family: var(--serif); font-size: 1rem; text-shadow: 0 1px 8px rgba(0,0,0,.6); opacity: 0; transform: translateY(6px); transition: .3s; }
.mosaic button:hover span, .mosaic button:focus-visible span { opacity: 1; transform: none; }

/* ---------- Catalog ---------- */
.catalog { padding: clamp(70px, 9vw, 120px) 0 30px; }
.catalog.mammals { padding-bottom: clamp(70px, 9vw, 120px); }
.catalog-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; flex-wrap: wrap; margin-bottom: 34px; }
.tools { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; min-width: min(320px, 100%); box-shadow: var(--shadow); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { border: 0; outline: 0; font: inherit; width: 100%; background: transparent; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { width: 18px; height: 18px; accent-color: var(--moss); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px; align-items: start; }
.card {
  position: relative; display: flex; flex-direction: column; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; padding: 0; font: inherit; color: inherit;
  transition: transform .25s ease, box-shadow .25s ease;
}
.card:hover, .card:focus-visible { transform: translateY(-4px); box-shadow: var(--shadow); outline: none; }
.card .ph { aspect-ratio: 4 / 3; height: auto; overflow: hidden; background: var(--cream); }
.card .ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.card:hover .ph img { transform: scale(1.05); }
.card .meta { padding: 14px 16px 16px; }
.card h3 { font-size: 1.15rem; }
.card .lat { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: .92rem; margin-top: 2px; }
.card .count { position: absolute; top: 10px; right: 10px; background: rgba(23,32,26,.72); color: #fff; font-size: .74rem; padding: 3px 9px; border-radius: 999px; backdrop-filter: blur(4px); }
.card.nophoto .ph {
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 30% 20%, rgba(169,187,163,.45), transparent 55%),
    linear-gradient(135deg, var(--cream), #ece5d4);
}
.card.nophoto .ph svg { width: 64px; height: 64px; fill: var(--sage); opacity: .8; }
.card.nophoto .ph em { position: absolute; top: 12px; left: 14px; font-style: normal; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.more { margin-top: clamp(40px, 6vw, 70px); }
.more[hidden] { display: none; }
.more h3 { font-size: 1.5rem; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.chip {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 11px 15px;
  font: inherit; color: inherit; cursor: pointer; transition: border-color .2s, transform .2s;
}
.chip:hover, .chip:focus-visible { border-color: var(--moss); transform: translateY(-2px); outline: none; }
.chip b { font-family: var(--serif); font-weight: 600; font-size: 1.02rem; }
.chip i { font-family: var(--serif); color: var(--muted); font-size: .86rem; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.mammals { background: var(--cream); }
.mammal-intro { max-width: 760px; margin: -10px 0 34px; color: #2d362f; font-size: 1.05rem; }

/* ---------- Footer ---------- */
.footer { background: var(--forest); color: #dfe6dc; padding: 60px 0 28px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.footer p { margin: 0; }
.brand-foot { font-family: var(--serif); font-size: 1.8rem; color: #fff; margin-bottom: 4px !important; }
.copy { text-align: center; font-size: .82rem; opacity: .6; margin-top: 40px !important; padding-inline: 16px; }

/* ---------- Species sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: center; align-items: stretch; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(12,17,13,.6); backdrop-filter: blur(3px); animation: fade .25s ease; }
.sheet-panel {
  position: relative; width: min(1180px, 100%); margin: 3vh 20px; background: var(--paper);
  border-radius: 22px; overflow: auto; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  box-shadow: 0 30px 80px rgba(0,0,0,.35); animation: rise .35s cubic-bezier(.2,.8,.2,1);
}
.sheet-gallery { min-width: 0; background: var(--forest); position: sticky; top: 0; align-self: start; height: 94vh; display: flex; flex-direction: column; }
.sheet-gallery .main { flex: 1; min-height: 0; position: relative; cursor: zoom-in; }
.sheet-gallery .main img { width: 100%; height: 100%; object-fit: contain; }
.sheet-gallery .thumbs { display: flex; gap: 6px; padding: 6px; background: var(--forest); }
.sheet-gallery .thumbs button { flex: 1 1 0; min-width: 0; height: 82px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: none; opacity: .6; transition: .2s; }
.sheet-gallery .thumbs button.on, .sheet-gallery .thumbs button:hover { opacity: 1; border-color: var(--gold); }
.sheet-gallery .thumbs img { width: 100%; height: 100%; object-fit: cover; }
.sheet-gallery.empty-g { display: grid; place-items: center; color: var(--sage); text-align: center; padding: 30px; }
.sheet-gallery.empty-g svg { width: 110px; height: 110px; fill: var(--moss); margin: 0 auto 14px; }
.sheet-gallery.empty-g p { font-family: var(--serif); font-style: italic; margin: 0; }
.zoom-hint { position: absolute; right: 12px; top: 12px; background: rgba(0,0,0,.45); color: #fff; font-size: .75rem; padding: 4px 10px; border-radius: 999px; pointer-events: none; }
.sheet-body { padding: clamp(28px, 4vw, 54px); }
.sheet-body h2 { font-size: clamp(2rem, 3.4vw, 2.9rem); }
.latin { font-family: var(--serif); font-style: italic; font-size: 1.2rem; color: var(--moss); margin: .4rem 0 1.6rem; }
.sheet-text { font-size: 1.02rem; color: #2d362f; }
.sheet-text p, .sheet-text ul { margin: 0 0 1.05rem; }
.sheet-text a, .intro-text a { color: var(--moss); }
.sheet-text h4 { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; margin: 1.8rem 0 .6rem; color: var(--ink); }
.sheet-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 2.4rem; padding-top: 1.4rem; border-top: 1px solid var(--line); }
.pager { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font: inherit; font-size: .9rem; cursor: pointer; color: var(--ink); display: inline-flex; gap: 8px; align-items: center; max-width: 48%; }
.pager em { font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pager:hover { border-color: var(--moss); color: var(--moss); }
.icon-btn { border: 0; background: rgba(255,255,255,.92); color: var(--ink); width: 44px; height: 44px; border-radius: 50%; font-size: 1.7rem; line-height: 1; cursor: pointer; display: grid; place-items: center; box-shadow: var(--shadow); }
.sheet .close { position: fixed; top: calc(3vh + 14px); right: max(34px, calc((100vw - 1180px) / 2 + 14px)); z-index: 5; }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(8,10,9,.96); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 94vw; max-height: 86vh; object-fit: contain; border-radius: 4px; animation: fade .3s; }
.lightbox .close { position: absolute; top: 18px; right: 18px; }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); font-size: 2rem; }
.lb-prev { left: 18px; } .lb-next { right: 18px; }
.lb-cap { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; color: #cfd6cc; font-family: var(--serif); font-style: italic; margin: 0; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .intro-grid { grid-template-columns: 1fr; }
  .intro-head { position: static; }
  .sheet-panel { grid-template-columns: minmax(0, 1fr); margin: 0; border-radius: 0; animation: none; }
  .sheet-gallery { position: relative; height: auto; }
  .sheet-gallery .main { flex: none; }
  .sheet-gallery .main img { height: auto; max-height: 75vh; }
  .sheet-body { padding: 24px 20px 40px; }
  .zoom-hint { top: auto; bottom: 10px; right: 10px; }
  .pager { padding: 8px 12px; }
  .sheet-gallery .thumbs button { height: 64px; }
  .sheet .close { top: 12px; right: 12px; }
  .nav-links .ig span { display: none; }
  .nav-links .ig { padding: 7px; }
  .nav-links a[href="#territorio"] { display: none; }
  .brand { white-space: nowrap; }
}
@media (max-width: 640px) {
  .nav-links a:not(.ig):not(.admin-link) { display: none; }
  .nav-links .ig span { display: none; }
  .nav-links .ig { padding: 7px; }
  .admin-link { padding: 7px 12px; }
  .admin-link span { font-size: .85rem; font-weight: 600; white-space: nowrap; }
  .nav-links .ig { display: none; }
  .brand { font-size: 1.05rem; }
  .brand svg { width: 24px; height: 24px; }
  .nav-links { gap: 8px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card h3 { font-size: 1rem; }
  .card .lat { font-size: .82rem; }
  .card .meta { padding: 10px 12px 12px; }
  .mosaic { columns: 2; }
  .mosaic button span { opacity: 1; transform: none; font-size: .85rem; }
  .hero-caption { display: none; }
  .hero { min-height: 0; flex-direction: column; align-items: stretch; }
  .hero-media { position: relative; aspect-ratio: 4 / 3; margin-top: 60px; }
  .hero-media img { object-fit: contain; }
  .hero-shade { display: none; }
  .hero-content { width: 100%; min-width: 0; padding: 22px 20px 40px; }
  .hero h1 { font-size: 10vw; overflow-wrap: anywhere; }
  .hero-cta .btn { padding: 12px 18px; font-size: .9rem; }
  .lb-prev, .lb-next { top: auto; bottom: 14px; transform: none; }
  .lb-prev { left: 14px; } .lb-next { right: 14px; }
  .lightbox img { max-width: 100vw; max-height: 78vh; border-radius: 0; }
  .lb-cap { bottom: 28px; padding: 0 70px; }
  .wrap { width: calc(100% - 32px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}
