*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #050507;
  --fg: #ffffff;
  --fg-dim: #8a8780;
  --accent: #ffffff;
  --serif: 'Cormorant Garamond', serif;
  --sans: 'Inter', system-ui, sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 300;
  overflow: hidden;
  cursor: none;
  -webkit-font-smoothing: antialiased;
}

#webgl {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
}

/* ================================
   LOADER
================================ */
.loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease;
}

.loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader__inner {
  text-align: center;
}

.loader__text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  color: var(--accent);
  margin-bottom: 2rem;
}

.loader__logo {
  max-width: 300px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.loader__bar {
  width: 240px;
  height: 1px;
  background: rgba(212, 201, 168, 0.15);
  overflow: hidden;
}

.loader__fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.loader__count {
  margin-top: 1rem;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  color: var(--fg-dim);
}

/* ================================
   UI
================================ */
.ui-header,
.ui-footer,
.specimen-info,
.hint {
  position: fixed;
  z-index: 10;
  pointer-events: none;
}

.ui-header {
  top: 2rem;
  left: 2rem;
  right: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  mix-blend-mode: difference;
}

.ui-header__logo {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  letter-spacing: 0.05em;
  color: var(--fg);
}

.ui-header__meta {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.ui-header__meta .divider {
  margin: 0 0.5rem;
  opacity: 0.4;
}

/* Info del espécimen */
.specimen-info {
  bottom: 6rem;
  left: 2rem;
  max-width: 360px;
  transition: opacity 0.5s ease;
}

.specimen-info__family {
  font-size: 0.65rem;
  letter-spacing: 0.4em;
  color: var(--accent);
  margin-bottom: 1rem;
}

.specimen-info__name {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  font-weight: 300;
  line-height: 1.1;
  margin-bottom: 0.5rem;
}

.specimen-info__common {
  font-size: 0.85rem;
  color: var(--fg-dim);
  margin-bottom: 1.5rem;
  letter-spacing: 0.02em;
}

.specimen-info__taxa {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.8rem;
  color: var(--fg-dim);
  letter-spacing: 0.05em;
}

/* Hint */
.hint {
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  opacity: 0.6;
}

.hint__line {
  width: 40px;
  height: 1px;
  background: var(--fg-dim);
}

.hint__text {
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  color: var(--fg-dim);
}

/* Footer */
.ui-footer {
  bottom: 2rem;
  left: 2rem;
  right: 2rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--fg-dim);
}

.ui-footer__left {
  display: none;
}

/* Cursor custom */
.cursor {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  z-index: 50;
  mix-blend-mode: difference;
  transition: transform 0.15s ease, width 0.3s ease, height 0.3s ease;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 20px rgba(212, 201, 168, 0.5);
}

.cursor.hover {
  width: 60px;
  height: 60px;
  background: transparent;
  border: 1px solid var(--accent);
}

/* ================================
   BOTÓN DE SONIDO
================================ */
.sound-toggle {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(5, 5, 7, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(212, 201, 168, 0.2);
  color: var(--fg-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30;
  transition: all 0.3s ease;
}

.sound-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.05);
}

.sound-toggle.active {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 768px) {
  .sound-toggle {
    bottom: 1.5rem;
    left: 1.5rem;
    top: auto;
    right: auto;
    width: 40px;
    height: 40px;
  }
}

/* ================================
   DISCOVERIES COUNTER
================================ */
.discoveries {
  position: fixed;
  top: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--sans);
  pointer-events: none;
  mix-blend-mode: difference;
}

.discoveries__label {
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-right: 0.5rem;
}

.discoveries__num {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.5rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.discoveries__sep {
  color: var(--fg-dim);
  font-size: 1rem;
}

.discoveries__total {
  font-size: 0.85rem;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}

/* ================================
   DETAIL PANEL LATERAL
================================ */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 90vw;
  background: rgba(5, 5, 7, 0.92);
  backdrop-filter: blur(20px);
  border-left: 1px solid rgba(212, 201, 168, 0.15);
  padding: 5rem 2.5rem 2.5rem;
  z-index: 20;
  transform: translateX(100%);
  transition: transform 0.6s cubic-bezier(0.7, 0, 0.3, 1);
  overflow-y: auto;
  cursor: default;
}

.detail-panel.open {
  transform: translateX(0);
}

.detail-panel__close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(212, 201, 168, 0.3);
  color: var(--fg-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.3s;
  font-family: var(--sans);
}

.detail-panel__close:hover {
  border-color: var(--accent);
  color: var(--fg);
  transform: rotate(90deg);
}

.detail-panel__num {
  font-family: var(--sans);
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  color: var(--accent);
  margin-bottom: 1rem;
}

.detail-panel__family {
  font-size: 0.65rem;
  letter-spacing: 0.4em;
  color: var(--fg-dim);
  margin-bottom: 1.5rem;
}

.detail-panel__name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 2.4rem;
  font-weight: 300;
  line-height: 1.1;
  margin-bottom: 0.5rem;
}

.detail-panel__common {
  font-size: 0.9rem;
  color: var(--fg-dim);
  margin-bottom: 2.5rem;
  font-style: italic;
}

.detail-panel__taxa {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1.5rem;
  margin-bottom: 2.5rem;
  padding: 1.5rem 0;
  border-top: 1px solid rgba(212, 201, 168, 0.1);
  border-bottom: 1px solid rgba(212, 201, 168, 0.1);
}

.detail-panel__taxa dt {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.detail-panel__taxa dd {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--fg);
}

.detail-panel__desc {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--fg);
  margin-bottom: 2.5rem;
}

.detail-panel__release {
  display: block;
  width: 100%;
  padding: 1rem;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s;
}

.detail-panel__release:hover {
  background: var(--accent);
  color: var(--bg);
}

@media (max-width: 768px) {
  .ui-header { top: 1.5rem; left: 1.5rem; right: 1.5rem; }
  .specimen-info { display: none; }
  .ui-footer { bottom: 1.5rem; left: 1.5rem; right: 1.5rem; }
  .cursor { display: none; }
  html, body { cursor: default; }
  .hint { bottom: 5rem; opacity: 0.4; }
  .ui-footer__right { font-size: 0.55rem; }
  .detail-panel { width: 100vw; max-width: 100vw; padding: 4.5rem 1.5rem 2rem; }
  .detail-panel__name { font-size: 1.8rem; }
  .discoveries { top: 4rem; }
}
