/* Spoonbill supper · 3D study */

:root {
  --paper: #f7f5ed;
  --ink: #2b2823;
  --moss: #5e7a4f;
  --water: #7aa9b8;
  --rose: #e08da6;
  --rose-dark: #b85e79;
  --sun: #f3d88a;
  --shadow: rgba(43, 40, 35, 0.22);
  --focus: #4b8bbd;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 50% 20%, #e7faff 0%, #f2f8e4 55%, #e0ecc2 100%);
}

.experiment {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.75rem;
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.scene-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.25rem;
}

.eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--moss);
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  line-height: 1.1;
  font-weight: 800;
}

.silent-note {
  font-size: 0.75rem;
  color: #6d665c;
  background: rgba(255, 255, 255, 0.55);
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  aspect-ratio: 640 / 420;
  background: linear-gradient(180deg, #a8e6ff 0%, #d0f3a3 65%, #9cd86e 100%);
  border-radius: 1rem;
  box-shadow: 0 18px 50px var(--shadow);
  overflow: hidden;
  outline: none;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: 1rem;
  color: var(--moss);
  background: rgba(247, 245, 237, 0.85);
  z-index: 2;
  transition: opacity 0.25s ease;
}

.loading[hidden] {
  display: none;
}

.scene-label {
  position: absolute;
  top: 0.75rem;
  left: 0.9rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(43, 40, 35, 0.55);
  pointer-events: none;
  z-index: 1;
}

.feed-button {
  position: absolute;
  bottom: 0.9rem;
  right: 0.9rem;
  z-index: 3;
  appearance: none;
  border: none;
  background: var(--rose);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.55rem 1rem;
  border-radius: 0.6rem;
  box-shadow: 0 4px 0 var(--rose-dark), 0 8px 18px rgba(184, 94, 121, 0.35);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}

.feed-button:hover:not(:disabled) {
  background: #e79ab2;
}

.feed-button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--rose-dark), 0 3px 8px rgba(184, 94, 121, 0.35);
}

.feed-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.feed-button:disabled {
  background: #a89f93;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.75;
}

.scene-caption {
  position: absolute;
  bottom: 0.85rem;
  left: 0.9rem;
  right: 10rem;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.35;
  color: rgba(43, 40, 35, 0.88);
  background: rgba(247, 245, 237, 0.78);
  padding: 0.35rem 0.6rem;
  border-radius: 0.45rem;
  pointer-events: none;
  z-index: 2;
}

.click-affordance {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.45);
  opacity: 0;
  animation: pulse-ring 2.2s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

.stage.is-playing .click-affordance {
  display: none;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
  color: #6d665c;
  padding: 0 0.25rem;
}

footer a {
  color: var(--moss);
  text-decoration: none;
  font-weight: 600;
}

footer a:hover {
  text-decoration: underline;
}

.no-script {
  padding: 1rem;
  margin: 1rem;
  background: #fff3cd;
  border-radius: 0.5rem;
  color: #5d4a1f;
  font-size: 0.9rem;
}

@media (max-width: 560px) {
  .experiment {
    padding: 0.75rem;
    gap: 0.5rem;
  }

  .scene-heading {
    flex-direction: column;
    gap: 0.5rem;
  }

  .silent-note {
    align-self: flex-start;
  }

  .feed-button {
    font-size: 0.8rem;
    padding: 0.45rem 0.75rem;
  }

  .scene-caption {
    font-size: 0.75rem;
    right: 9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .click-affordance {
    animation: none;
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(1);
  }
}

.feed-button { min-height: 44px; }
html.embedded .experiment { min-height: 100svh; display: flex; padding: 8px; }
html.embedded .scene-heading,
html.embedded footer { display: none; }
html.embedded .stage { width: min(100%, 960px, calc((100svh - 24px) * 1.5238)); margin: auto; flex: none; }
