/* Codex card + organism still (photo + idle motion) */
.wrap--wide {
  max-width: 56rem;
}

.card-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  margin: 0 0 0.75rem;
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
  color: var(--muted);
}

.chk {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  cursor: pointer;
}

.focus-mode {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  cursor: pointer;
}

.focus-mode__label {
  color: var(--muted);
}

.focus-mode select {
  font: inherit;
  color: var(--ink);
  background: rgba(12, 26, 20, 0.55);
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  padding: 0.28rem 0.5rem;
  max-width: 11rem;
}

.codex-card {
  min-height: 22rem;
  margin-bottom: 1rem;
}

.codex-card__layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 1rem 1.25rem;
  padding: clamp(1.1rem, 3vw, 1.75rem);
  align-items: start;
  min-width: 0;
}

/* Phone / narrow: stack photo above facts so the right column is never cut off */
@media (max-width: 768px) {
  .wrap--wide {
    max-width: 100%;
    padding-left: clamp(0.85rem, 3.5vw, 1.25rem);
    padding-right: clamp(0.85rem, 3.5vw, 1.25rem);
  }

  .codex-card {
    min-height: 0;
  }

  .codex-card__layout {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    padding: clamp(0.85rem, 3vw, 1.15rem);
  }

  .codex-card__callouts {
    min-height: 0;
    width: 100%;
    min-width: 0;
  }

  .organism-still-wrap {
    width: min(11rem, 52vw);
    min-height: min(11rem, 52vw);
  }

  .organism-still {
    height: min(11rem, 52vw);
  }

  .card-toolbar {
    gap: 0.55rem 0.75rem;
  }

  .card-toolbar .btn {
    flex: 1 1 auto;
    min-width: 0;
  }
}

@media (min-width: 769px) {
  .codex-card__layout {
    grid-template-columns: minmax(12rem, 0.95fr) minmax(14rem, 1.05fr);
  }
}

.codex-card__art {
  text-align: center;
  padding-top: 0.35rem;
  min-width: 0;
}

.codex-card__names {
  margin: 0.85rem 0 0;
  font-family: system-ui, sans-serif;
}

.codex-card__names strong {
  display: block;
  color: rgba(230, 245, 250, 0.95);
  font-size: 1.05rem;
}

.codex-card__names span {
  display: block;
  margin-top: 0.2rem;
  font-style: italic;
  color: rgba(180, 210, 220, 0.8);
  font-size: 0.9rem;
}

.codex-card__credit {
  margin: 0.45rem 0 0;
  font-family: system-ui, sans-serif;
  font-size: 0.68rem;
  color: rgba(160, 190, 200, 0.65);
  line-height: 1.35;
}

/* Real still — static subject cutout on blueprint (no shake) */
.organism-still-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(14rem, 72vw);
  height: auto;
  min-height: min(14rem, 72vw);
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(120, 190, 210, 0.4);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  background:
    radial-gradient(circle at 50% 45%, rgba(30, 70, 90, 0.35), transparent 65%),
    rgba(10, 28, 40, 0.55);
}

.organism-still {
  display: block;
  width: 100%;
  height: min(14rem, 72vw);
  flex: 0 0 auto;
  object-fit: contain;
  object-position: center center;
}

.organism-still-meta {
  margin: 0;
  padding: 0.35rem 0.45rem 0.45rem;
  font-family: system-ui, sans-serif;
  font-size: 0.62rem;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: rgba(190, 220, 230, 0.78);
  text-align: center;
  background: rgba(4, 18, 28, 0.72);
  border-top: 1px solid rgba(120, 190, 210, 0.22);
}

.organism-still-meta[hidden] {
  display: none !important;
}

/* Keep class for older markup, but no bob/sway — stills stay fixed. */
.organism-still--alive {
  animation: none;
  transform: none;
}

.codex-card__callouts {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 12rem;
}

.callout-empty {
  margin: 0;
  padding: 1rem;
  font-family: system-ui, sans-serif;
  font-size: 0.92rem;
  color: rgba(180, 210, 220, 0.75);
  border: 1px dashed rgba(120, 190, 210, 0.35);
  border-radius: 10px;
}

.callout {
  display: grid;
  grid-template-columns: 0.55rem 1fr;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: rgba(0, 20, 30, 0.35);
  border: 1px solid rgba(120, 190, 210, 0.28);
  font-family: system-ui, sans-serif;
}

.callout__tick {
  width: 0.35rem;
  margin-top: 0.35rem;
  border-radius: 2px;
  background: #7ec8d8;
  align-self: stretch;
}

.callout__label {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(160, 210, 220, 0.9);
}

.callout__fact {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  color: rgba(230, 245, 250, 0.95);
}

.disclaimer {
  margin: 0 0 1.25rem;
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Learned shelf (device-local + Google account sync) */
.codex-sync {
  margin: 0 0 0.85rem;
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  color: rgba(180, 210, 220, 0.85);
  line-height: 1.4;
}

.codex-sync a {
  color: #7ec8d8;
}

.codex-shelf {
  margin: 0 0 1.15rem;
}

.codex-shelf__title {
  margin: 0 0 0.55rem;
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(160, 200, 210, 0.85);
  font-weight: 600;
}

.codex-shelf__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.55rem;
}

.codex-shelf__item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 0;
  padding: 0.35rem;
  border: 1px solid rgba(120, 190, 210, 0.28);
  border-radius: 10px;
  background: rgba(0, 20, 30, 0.4);
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.codex-shelf__item:hover,
.codex-shelf__item:focus-visible {
  border-color: rgba(126, 200, 216, 0.75);
  background: rgba(10, 40, 55, 0.55);
  outline: none;
}

.codex-shelf__item.is-active {
  border-color: rgba(107, 196, 138, 0.85);
  box-shadow: 0 0 0 1px rgba(107, 196, 138, 0.25);
}

.codex-shelf__thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 7px;
  background: rgba(8, 24, 34, 0.65);
}

.codex-shelf__thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: rgba(160, 190, 200, 0.55);
}

.codex-shelf__name {
  margin: 0.35rem 0 0;
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  line-height: 1.25;
  color: rgba(230, 245, 250, 0.95);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.codex-shelf__facts {
  margin: 0.2rem 0 0;
  font-family: system-ui, sans-serif;
  font-size: 0.62rem;
  color: rgba(160, 210, 220, 0.8);
}

/* Fact book (Splash Aquapedia–style progress; separate from mission levels) */
.fact-book {
  margin: 0 0 1rem;
}

.fact-book__cover {
  padding: 1rem 1.1rem 1.05rem;
  border-radius: 14px;
  border: 1px solid rgba(120, 190, 210, 0.35);
  background:
    linear-gradient(145deg, rgba(18, 48, 62, 0.92), rgba(8, 24, 34, 0.88)),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 11px,
      rgba(126, 200, 216, 0.04) 11px,
      rgba(126, 200, 216, 0.04) 12px
    );
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.fact-book__eyebrow {
  margin: 0 0 0.35rem;
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(160, 210, 220, 0.85);
}

.fact-book__progress {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  color: rgba(235, 248, 252, 0.98);
  letter-spacing: 0.02em;
}

.fact-book__level {
  margin: 0.35rem 0 0;
  font-family: system-ui, sans-serif;
  font-size: 0.95rem;
  color: rgba(126, 200, 216, 0.95);
}

.fact-book__next {
  margin: 0.25rem 0 0;
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  color: rgba(190, 220, 230, 0.88);
}

.fact-book__kinds {
  margin: 0.55rem 0 0;
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  color: rgba(180, 210, 220, 0.82);
  line-height: 1.4;
}

.fact-book__note {
  margin: 0.65rem 0 0;
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  line-height: 1.4;
  color: rgba(160, 190, 200, 0.72);
}

.fact-book__note a {
  color: #7ec8d8;
}

.fact-book__page-progress {
  margin: 0 0 0.75rem;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  color: rgba(180, 210, 220, 0.9);
}

.fact-book__collected {
  margin: 0 0 1.15rem;
}

.fact-book__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.fact-book__item {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(120, 190, 210, 0.22);
  background: rgba(0, 20, 30, 0.32);
  font-family: system-ui, sans-serif;
}

.fact-book__item-meta {
  margin: 0 0 0.2rem;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(160, 210, 220, 0.85);
}

.fact-book__item-fact {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: rgba(230, 245, 250, 0.95);
}

.callout--help .callout__tick {
  background: #6bc48a;
}

.callout--wonder .callout__tick {
  background: #e0b56a;
}

.callout--builds-on .callout__kind {
  color: rgba(190, 220, 180, 0.9);
}

.callout__kind {
  margin: 0 0 0.15rem;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(160, 210, 220, 0.7);
}

/* Scan page — EcoLens frame */
.scan-stage {
  position: relative;
  width: 100%;
  max-width: 26rem;
  margin: 0 auto 1rem;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  background: #0a1210;
  border: 1px solid var(--line);
  /* Pinch zooms the camera, not the browser page */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.scan-stage video,
.scan-stage canvas.scan-stage__freeze {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  display: block;
  transform-origin: center center;
}

.scan-stage canvas.scan-stage__freeze {
  z-index: 1;
}

.scan-stage--processing .scan-stage__guide {
  border-color: rgba(107, 196, 138, 0.35);
  border-style: solid;
}

.scan-stage--processing .scan-stage__hint {
  background: linear-gradient(transparent, rgba(0, 20, 12, 0.82));
}

.scan-stage__guide {
  position: absolute;
  inset: 12% 10%;
  border: 2px dashed rgba(107, 196, 138, 0.55);
  border-radius: 12px;
  pointer-events: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.scan-stage--wait .scan-stage__guide {
  border-color: rgba(180, 190, 185, 0.45);
}

.scan-stage--bad .scan-stage__guide {
  border-color: rgba(220, 120, 100, 0.75);
  box-shadow: inset 0 0 0 1px rgba(220, 120, 100, 0.2);
}

.scan-stage--soft .scan-stage__guide {
  border-color: rgba(230, 190, 90, 0.8);
}

.scan-stage--good .scan-stage__guide {
  border-color: rgba(107, 196, 138, 0.95);
  box-shadow: inset 0 0 0 1px rgba(107, 196, 138, 0.25);
}

.scan-stage__hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0.65rem 0.85rem;
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  color: #e8f2ea;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
}

.scan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1rem;
}

/* EcoLens assists — native <details> collapse for Drive / Night / Camo */
.ecolens-assists {
  margin: 0 auto 0.85rem;
  max-width: 22rem;
}

.ecolens-assists__toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  margin: 0;
  padding: 0.42rem 0.7rem 0.42rem 0.55rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(107, 196, 138, 0.32);
  background:
    linear-gradient(135deg, rgba(18, 42, 32, 0.92), rgba(10, 24, 18, 0.88));
  box-shadow: inset 0 1px 0 rgba(180, 230, 200, 0.08);
  color: #d7ebe0;
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  line-height: 1.2;
  cursor: pointer;
  text-align: left;
  list-style: none;
  -webkit-user-select: none;
  user-select: none;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.ecolens-assists__toggle::-webkit-details-marker {
  display: none;
}

.ecolens-assists__toggle::marker {
  content: "";
  display: none;
}

.ecolens-assists__toggle:hover {
  border-color: rgba(107, 196, 138, 0.55);
}

.ecolens-assists__toggle:focus-visible {
  outline: 2px solid rgba(107, 196, 138, 0.75);
  outline-offset: 2px;
}

.ecolens-assists[open] .ecolens-assists__toggle,
.ecolens-assists--active .ecolens-assists__toggle {
  border-color: rgba(107, 196, 138, 0.62);
  background:
    linear-gradient(135deg, rgba(28, 62, 46, 0.95), rgba(14, 34, 26, 0.9));
}

.ecolens-assists__chev {
  flex: 0 0 auto;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 1.5px solid rgba(180, 220, 195, 0.75);
  border-bottom: 1.5px solid rgba(180, 220, 195, 0.75);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  margin: 0 0.15rem 0 0.2rem;
}

.ecolens-assists[open] .ecolens-assists__chev {
  transform: rotate(45deg);
  margin-top: -0.12rem;
}

.ecolens-assists__title {
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #e8f6ee;
}

.ecolens-assists__summary {
  margin-left: auto;
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
  opacity: 0.78;
  color: #b9d6c6;
}

.ecolens-assists--active .ecolens-assists__summary {
  opacity: 0.95;
  color: #9ee0b4;
}

.ecolens-assists__panel {
  display: none;
  margin-top: 0.4rem;
  padding: 0.55rem 0.55rem 0.45rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(107, 196, 138, 0.22);
  background: rgba(8, 20, 16, 0.55);
}

.ecolens-assists[open] .ecolens-assists__panel {
  display: block;
  animation: ecolensAssistsIn 0.18s ease;
}

@keyframes ecolensAssistsIn {
  from {
    opacity: 0;
    transform: translateY(-0.25rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ecolens-assists[open] .ecolens-assists__panel {
    animation: none;
  }
  .ecolens-assists__chev {
    transition: none;
  }
}

.ecolens-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  margin: 0;
}

.ecolens-mode {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(107, 196, 138, 0.35);
  background: rgba(12, 28, 22, 0.72);
  color: #d7ebe0;
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  cursor: pointer;
  user-select: none;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.ecolens-mode input {
  accent-color: #6bc48a;
  margin: 0;
}

.ecolens-mode:has(input:checked) {
  border-color: rgba(107, 196, 138, 0.85);
  background: rgba(30, 70, 52, 0.85);
  color: #eaf8ef;
}

.ecolens-mode-note {
  max-width: none;
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: 0.74rem;
  line-height: 1.35;
}

.scan-stage--night video {
  filter: brightness(1.75) contrast(1.45) saturate(0.35) hue-rotate(72deg);
}

.scan-stage--camo video {
  filter: contrast(1.65) brightness(1.12) saturate(1.35);
}

.scan-stage--night.scan-stage--camo video {
  filter: brightness(1.85) contrast(1.7) saturate(0.55) hue-rotate(55deg);
}

.scan-stage--drive .scan-stage__guide {
  border-style: solid;
  border-color: rgba(120, 170, 220, 0.55);
}

.scan-stage--night .scan-stage__guide {
  border-color: rgba(90, 220, 120, 0.65);
}

.scan-stage--camo .scan-stage__guide {
  border-color: rgba(230, 200, 110, 0.7);
}
