/* Marine Life — Card Flip & Learn (Depth Dive hi-fi) */
:root {
  /* depth tints */
  --z-fresh:    #eef3ea;
  --z-fresh-2:  #d8e6d2;
  --z-sun-1:    #f4f8e9;     /* surface (warm pale) */
  --z-sun-2:    #cfe7f1;     /* shallow blue */
  --z-twi-1:    #6fa3bd;
  --z-twi-2:    #3d6f8f;
  --z-mid-1:    #1f3550;
  --z-mid-2:    #0b1a2c;

  --ink: #0d2238;
  --ink-soft: #4a5b6e;
  --paper: #fafaf6;

  --accent: oklch(0.58 0.13 230);
  --shadow-sm: 0 2px 8px rgba(13, 34, 56, 0.08);
  --shadow-md: 0 8px 28px rgba(13, 34, 56, 0.12);
  --shadow-lg: 0 24px 60px rgba(13, 34, 56, 0.25);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--z-sun-1);
  min-height: 100vh;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }

/* App container */
#root { min-height: 100vh; }
.app {
  position: relative;
  min-height: 100vh;
  background:
    linear-gradient(to bottom,
      var(--z-fresh) 0%,
      var(--z-sun-1) 8%,
      var(--z-sun-2) 22%,
      var(--z-twi-1) 50%,
      var(--z-twi-2) 65%,
      var(--z-mid-1) 80%,
      var(--z-mid-2) 100%
    );
}

/* ---------- Top app bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: rgba(250,250,246,0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(13,34,56,0.08);
}
.appbar.dark {
  background: rgba(11,26,44,0.55);
  border-bottom-color: rgba(255,255,255,0.1);
}
.appbar.dark .brand,
.appbar.dark .home-btn { color: #fff; }
.brand {
  display: flex; align-items: baseline; gap: 10px;
  font-weight: 800; font-size: 18px; letter-spacing: 0.3px;
}
.brand .sub { font-weight: 600; font-size: 13px; opacity: 0.6; }

.home-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 999px;
  font-weight: 700; font-size: 14px;
  background: rgba(13,34,56,0.06);
}
.home-btn:hover { background: rgba(13,34,56,0.12); }
.appbar.dark .home-btn { background: rgba(255,255,255,0.12); }
.appbar.dark .home-btn:hover { background: rgba(255,255,255,0.2); }

/* ---------- Language pill ---------- */
.lang-pill {
  display: inline-flex; padding: 3px;
  background: rgba(13,34,56,0.08);
  border-radius: 999px;
  font-weight: 800; font-size: 13px;
  user-select: none;
}
.appbar.dark .lang-pill { background: rgba(255,255,255,0.15); }
.lang-pill button {
  padding: 6px 14px; border-radius: 999px;
  color: var(--ink-soft);
  transition: all 160ms;
}
.appbar.dark .lang-pill button { color: rgba(255,255,255,0.7); }
.lang-pill button.on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(13,34,56,0.15);
}
.appbar.dark .lang-pill button.on { color: var(--ink); }

/* ---------- Splash ---------- */
.splash {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  padding: 40px 24px 0;
  position: relative;
  overflow: hidden;
}
.splash .top-row {
  position: absolute; top: 16px; left: 0; right: 0;
  display: flex; justify-content: flex-end; padding: 0 24px;
  z-index: 5;
}
.splash .hero {
  margin: auto 0;
  display: flex; flex-direction: column; align-items: center; gap: 28px;
  text-align: center;
  z-index: 4;
}
.splash .logo-wrap {
  width: min(560px, 88vw);
}
.splash .logo-wrap img {
  width: 100%; height: auto; display: block;
}
.splash .tagline {
  font-weight: 700; font-size: clamp(15px, 2.3vw, 18px);
  color: var(--ink-soft);
  margin: 0;
}
.splash .start-btn {
  padding: 18px 48px;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  font-weight: 800; font-size: 20px;
  box-shadow: 0 6px 0 #03182c, 0 14px 30px rgba(13,34,56,0.25);
  transition: transform 120ms, box-shadow 120ms;
  letter-spacing: 0.3px;
}
.splash .start-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #03182c, 0 18px 36px rgba(13,34,56,0.3); }
.splash .start-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #03182c, 0 6px 12px rgba(13,34,56,0.2); }

/* peek carousel */
.peek-carousel {
  width: 100%;
  display: flex; gap: 14px; overflow: hidden;
  padding: 0 0 0 0;
  margin-top: 24px;
  align-items: flex-end;
  justify-content: center;
  perspective: 1000px;
  z-index: 2;
}
.peek-carousel .peek {
  width: clamp(160px, 22vw, 240px);
  aspect-ratio: 5/3;
  border-radius: 18px 18px 0 0;
  overflow: hidden;
  box-shadow: 0 -6px 24px rgba(13,34,56,0.15);
  transform: translateY(20%);
  transition: transform 600ms cubic-bezier(.2,.8,.2,1);
}
.peek-carousel .peek:hover { transform: translateY(8%); }
.peek-carousel .peek img { width: 100%; height: 100%; object-fit: cover; display: block; }
.peek-carousel .peek:nth-child(odd) { transform: translateY(28%) rotate(-2deg); }
.peek-carousel .peek:nth-child(odd):hover { transform: translateY(12%) rotate(-2deg); }

@media (max-width: 600px) {
  .peek-carousel .peek:nth-child(n+4) { display: none; }
}

/* ---------- Gallery ---------- */
.gallery { padding-bottom: 100px; }

.zone-section { padding: 32px 20px 24px; position: relative; }
.zone-header {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 18px;
  padding: 0 8px;
}
.zone-header .icon {
  font-size: 28px; line-height: 1;
}
.zone-header h2 {
  margin: 0;
  font-weight: 800;
  font-size: clamp(22px, 3.2vw, 30px);
  letter-spacing: -0.3px;
}
.zone-header .depth {
  font-weight: 700; font-size: 14px; opacity: 0.65;
}
.zone-section.zone-twilight, .zone-section.zone-midnight {
  color: #fff;
}
.zone-section.zone-twilight .zone-header .depth,
.zone-section.zone-midnight .zone-header .depth { opacity: 0.8; color: rgba(255,255,255,0.85); }

/* horizontal row (sunlight + freshwater) */
.row-scroll {
  display: flex; gap: 14px;
  overflow-x: auto; overflow-y: hidden;
  padding: 6px 20px 18px;
  margin: 0 -20px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.row-scroll::-webkit-scrollbar { height: 8px; }
.row-scroll::-webkit-scrollbar-thumb { background: rgba(13,34,56,0.2); border-radius: 4px; }
.row-scroll .card { flex: 0 0 auto; scroll-snap-align: start; }

/* grid (twilight + midnight) */
.grid {
  display: grid;
  gap: 16px;
}
.grid.density-small  { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.grid.density-medium { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.density-large  { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }

/* row card width follows density */
.row-scroll.density-small  .card { width: 200px; }
.row-scroll.density-medium .card { width: 260px; }
.row-scroll.density-large  .card { width: 340px; }

/* ---------- Card ---------- */
.card {
  position: relative;
  aspect-ratio: 5/3;
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 200ms cubic-bezier(.2,.8,.2,1), box-shadow 200ms;
  outline: none;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.card img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; display: block;
  pointer-events: none;
}
.card .info-btn {
  position: absolute; top: 10px; right: 10px;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
  box-shadow: 0 2px 8px rgba(13,34,56,0.18);
  z-index: 2;
  transition: transform 120ms, background 120ms;
}
.card .info-btn:hover { transform: scale(1.08); background: #fff; }
.card .info-btn:active { transform: scale(0.95); }

/* depth ribbon (right edge, fades on idle) */
.depth-ribbon {
  position: fixed; right: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 60vh; max-height: 480px;
  border-radius: 8px;
  background: linear-gradient(to bottom,
    var(--z-fresh) 0%,
    var(--z-sun-2) 22%,
    var(--z-twi-1) 50%,
    var(--z-twi-2) 65%,
    var(--z-mid-1) 80%,
    var(--z-mid-2) 100%);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2), inset 0 0 0 1px rgba(255,255,255,0.2);
  opacity: 0;
  transition: opacity 600ms ease;
  z-index: 25;
  pointer-events: none;
}
.depth-ribbon.visible { opacity: 1; }
.depth-ribbon .marker {
  position: absolute; left: -6px; right: -6px;
  height: 4px; background: #fff;
  border-radius: 2px;
  box-shadow: 0 0 0 2px rgba(13,34,56,0.4);
  transition: top 200ms;
}
.depth-ribbon .label {
  position: absolute; right: 22px; top: 50%; transform: translateY(-50%);
  background: rgba(13,34,56,0.85); color: #fff;
  font-weight: 700; font-size: 12px;
  padding: 4px 10px; border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Detail (full-screen card view) ---------- */
.detail-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  animation: fadeIn 240ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.detail-overlay .hero-img-wrap {
  flex: 1;
  position: relative;
  display: grid; place-items: center;
  padding: 80px 24px 40px;
  overflow: hidden;
}
.detail-overlay .hero-img-wrap img {
  max-width: min(100%, 920px);
  max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 18px 40px rgba(0,0,0,0.18));
  animation: heroIn 500ms cubic-bezier(.2,.8,.2,1);
}
@keyframes heroIn {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.detail-name {
  position: absolute; left: 24px; bottom: 24px;
  text-align: left;
  pointer-events: none;
  z-index: 2;
}
.detail-name .en {
  font-weight: 800; letter-spacing: -0.5px;
  font-size: clamp(28px, 5vw, 52px);
  margin: 0; line-height: 1;
}
.detail-name .es {
  font-weight: 600;
  font-size: clamp(18px, 3vw, 28px);
  opacity: 0.7; margin-top: 6px;
}
.detail-overlay.dark .detail-name { color: #fff; }
.detail-overlay.dark .detail-name .es { color: rgba(255,255,255,0.8); }

/* nav buttons */
.nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,0.85);
  color: var(--ink);
  display: grid; place-items: center;
  font-size: 24px; font-weight: 700;
  box-shadow: var(--shadow-md);
  z-index: 4;
  transition: transform 120ms;
}
.nav-btn.prev { left: 16px; }
.nav-btn.next { right: 16px; }
.nav-btn:hover { transform: translateY(-50%) scale(1.05); }
.nav-btn:active { transform: translateY(-50%) scale(0.95); }
.nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.detail-actions {
  position: absolute; bottom: 28px; right: 24px;
  display: flex; gap: 12px;
  z-index: 4;
}
.action-btn {
  padding: 14px 22px;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  font-weight: 800; font-size: 15px;
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-md);
  transition: transform 120ms;
}
.action-btn:hover { transform: translateY(-2px); }
.action-btn:active { transform: translateY(1px); }
.action-btn.light { background: #fff; color: var(--ink); }

/* ---------- Stat sheet drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.35);
  animation: fadeIn 200ms ease;
}
.drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  background: #fff;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 14px 24px 36px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 -20px 60px rgba(0,0,0,0.25);
  animation: slideUp 360ms cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 720px) {
  .drawer {
    left: 50%; right: auto; bottom: 0;
    transform: translateX(-50%);
    width: min(680px, 92vw);
    border-radius: var(--r-xl);
    margin-bottom: 24px;
  }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@media (min-width: 720px) {
  @keyframes slideUp {
    from { transform: translate(-50%, 100%); }
    to   { transform: translate(-50%, 0); }
  }
}
.drawer .grabber {
  width: 44px; height: 5px; border-radius: 999px;
  background: rgba(13,34,56,0.18);
  margin: 4px auto 14px;
}
.drawer .head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 18px;
}
.drawer .head h3 {
  margin: 0; font-size: 22px; font-weight: 800;
  letter-spacing: -0.3px;
}
.drawer .head .es-name {
  font-weight: 600; font-size: 15px; opacity: 0.6; margin-top: 2px;
}
.drawer .close {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(13,34,56,0.06);
  display: grid; place-items: center;
  font-size: 20px;
}
.drawer .close:hover { background: rgba(13,34,56,0.12); }

.stats {
  display: flex; flex-direction: column; gap: 14px;
}
.stat {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px;
  background: var(--z-sun-1);
  border-radius: var(--r-md);
}
.stat .icon-wrap {
  width: 40px; height: 40px; border-radius: 12px;
  background: #fff;
  display: grid; place-items: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.stat .body { flex: 1; min-width: 0; }
.stat .label {
  font-weight: 800; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--ink-soft);
  margin-bottom: 3px;
}
.stat .value {
  font-weight: 600; font-size: 16px; line-height: 1.4;
  color: var(--ink);
}
.stat.fact { background: #fff8d8; }
.stat.fact .icon-wrap { background: #ffeb8a; }

/* ---------- Quiz ---------- */
.quiz-cta {
  margin: 40px auto 0;
  width: fit-content;
  padding: 16px 32px;
  background: rgba(255,255,255,0.95);
  color: var(--ink);
  border-radius: 999px;
  font-weight: 800; font-size: 16px;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  transition: transform 120ms;
}
.quiz-cta:hover { transform: translateY(-2px); }

.quiz-screen {
  min-height: 100vh;
  display: flex; flex-direction: column;
  background: linear-gradient(to bottom, var(--z-sun-2), var(--z-twi-1));
  color: var(--ink);
  padding: 0;
}
.quiz-menu {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px; text-align: center; gap: 24px;
}
.quiz-menu h2 {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800; margin: 0;
  letter-spacing: -0.5px;
}
.quiz-menu p {
  font-size: 18px; opacity: 0.75; margin: 0; max-width: 28em;
}
.length-options {
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: center;
}
.length-btn {
  padding: 14px 26px;
  background: #fff;
  border-radius: 999px;
  font-weight: 800; font-size: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 120ms;
}
.length-btn:hover { transform: translateY(-2px); }
.length-btn.primary { background: var(--ink); color: #fff; }

.quiz-game {
  flex: 1; padding: 24px;
  display: flex; flex-direction: column; gap: 18px;
  max-width: 720px; margin: 0 auto; width: 100%;
}
.quiz-progress {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 14px; opacity: 0.85;
}
.quiz-progress .bar {
  flex: 1; margin: 0 14px;
  height: 8px; border-radius: 4px;
  background: rgba(13,34,56,0.15);
  overflow: hidden;
}
.quiz-progress .bar .fill {
  height: 100%; background: var(--ink);
  transition: width 300ms;
}

.clue-card {
  background: rgba(255,255,255,0.95);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
}
.clue-card h3 {
  margin: 0 0 14px;
  font-size: 14px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1px;
  opacity: 0.6;
}
.clues { display: flex; flex-direction: column; gap: 12px; }

.choices {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.choice {
  background: rgba(255,255,255,0.95);
  border: 3px solid transparent;
  border-radius: var(--r-md);
  padding: 18px;
  font-weight: 700; font-size: 16px;
  text-align: center;
  transition: all 200ms;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.choice:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.choice.correct {
  background: #c6f6d5; border-color: #38a169; color: #1a4731;
}
.choice.wrong {
  background: #fed7d7; border-color: #e53e3e; color: #742a2a;
}
.choice.disabled { cursor: not-allowed; }
.choice.faded { opacity: 0.4; }

.feedback {
  text-align: center;
  font-size: 24px; font-weight: 800;
  margin: 8px 0;
  letter-spacing: -0.3px;
}
.feedback.correct { color: #1a4731; }
.feedback.wrong { color: #742a2a; }

.quiz-end {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 18px;
}
.quiz-end .score {
  font-size: clamp(48px, 10vw, 80px);
  font-weight: 900; line-height: 1;
  letter-spacing: -2px;
}
.quiz-end h2 { font-size: clamp(24px, 4vw, 32px); margin: 0; }
.quiz-end .actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ---------- Tweaks panel hooks (we use the starter component) ---------- */

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Tablet landscape tweak: cards a bit taller in twilight/midnight */
@media (min-width: 900px) {
  .zone-section { padding: 40px 32px 32px; }
  .row-scroll { padding: 6px 32px 18px; margin: 0 -32px; }
}
