/* the game page: a photo stage, answer pills, an action row and a lightbox.
   The site stylesheet keeps the chrome (title strip, footer, fonts); this is
   only what the page under it needs. Ported from the Reef Check detective. */
:root {
  --surface-1: #0a1118;
  --surface-2: #111c26;

  --text: #f0f3f5;
  --text-dim: #9ba6b0;

  --border-default: rgba(255, 255, 255, 0.10);
  --border-quiet: rgba(95, 181, 201, 0.30);
  --border-hover: rgba(95, 181, 201, 1.0);

  --accent-cool: #5fb5c9;
  --success: #4ade80;
  --error: #ef4444;

  --pill-radius: 999px;
  --stage-h: clamp(320px, 60vh, 540px);
}

/* the site sizes boxes by content; padding and borders here would push
   width: 100% elements past the edge of a phone */
.wrapper,
.game,
.game *,
.lightbox,
.lightbox * {
  box-sizing: border-box;
}

.wrapper {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* control row */
#control {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.5rem 1.25rem;
  justify-content: center;
  align-items: center;
  margin: 1rem 0 1.25rem;
}

#control select {
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-default);
  border-radius: var(--pill-radius);
  font-size: 0.9rem;
  padding: 0 2em 0 1em;
  height: 2.4em;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 1.1em) 50%, calc(100% - 0.75em) 50%;
  background-size: 0.35em 0.35em, 0.35em 0.35em;
  background-repeat: no-repeat;
}

#control select:hover {
  border-color: var(--border-hover);
}

#control select:focus-visible {
  outline: 2px solid var(--accent-cool);
  outline-offset: 2px;
}

.scoring {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}

.scoring h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

/* game layout, single column by default */
.game {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 0.5rem;
}

.answer-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* photo stage */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: 0.5rem;
  padding: 0.6rem;
  aspect-ratio: 3 / 2;
  min-height: 280px;
  max-height: var(--stage-h);
  width: 100%;
  max-width: 720px;
  justify-self: center;
  overflow: hidden;
  isolation: isolate;
}

/* the same photo, blurred, fills the space the photo's aspect ratio leaves */
.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--photo-bg, none);
  background-size: cover;
  background-position: center;
  filter: blur(28px) saturate(1.15);
  transform: scale(1.18);
  opacity: 0.55;
  z-index: -1;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.stage > * {
  position: relative;
}

.stage img {
  flex: 1 1 0;
  min-height: 0;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: 0.25rem;
  cursor: zoom-in;
}

/* answer pills */
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.55rem;
}

.pill {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: 0.55em 1.1em;
  border-radius: var(--pill-radius);
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-quiet);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.pill:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
}

/* state classes win over hover */
.pill--correct,
.pill--correct:hover {
  border-color: var(--success);
  background: rgba(74, 222, 128, 0.14);
}

.pill--wrong,
.pill--wrong:hover {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.14);
}

.pill h4 {
  margin: 0;
  font: inherit;
}

/* action row: Zoom / Skip / New Example */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 0.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-default);
}

.action {
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-default);
  border-radius: var(--pill-radius);
  padding: 0.5em 1.25em;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.action:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
}

.action:focus-visible {
  outline: 2px solid var(--accent-cool);
  outline-offset: 2px;
}

/* lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  cursor: zoom-out;
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  width: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0.25rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  cursor: default;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--surface-1);
  color: var(--text-dim);
  border: 1px solid var(--border-default);
  border-radius: var(--pill-radius);
  padding: 0.45em 1em;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.lightbox-close:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

/* split layout on a wide desktop */
@media (min-width: 1100px) {
  :root {
    --stage-h: clamp(440px, 72vh, 640px);
  }

  .game {
    grid-template-columns: minmax(0, 1.35fr) minmax(360px, 1fr);
    align-items: start;
    gap: 1.5rem;
  }

  .stage {
    max-width: none;
  }

  .answer-panel {
    position: sticky;
    top: 4rem;
  }
}

/* phones: score and difficulty stack */
@media (max-width: 600px) {
  :root {
    --stage-h: 52vh;
  }

  #control {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .scoring {
    justify-content: center;
  }
}

@media (max-width: 380px) {
  .options-grid {
    grid-template-columns: 1fr;
  }
}
