/* The opening: one dark, still world with the envelope lying in a pool of warm light.
   [data-state] follows the stage (sealed or open). js/light.js writes --lx and --ly (each -1 to 1): where the light is. */

.opening {
  --fg: #fbf6ea;
  --stage-w: min(100vw - 1.25rem, 30rem, (100svh - 31rem) / 0.72);
  position: relative; isolation: isolate; overflow: clip;
  display: flex; flex-direction: column; min-height: 100svh;
  color: var(--fg);
  background: radial-gradient(120% 75% at 50% 46%, #1b3b30, #07120f 72%);
}
/* The pool of light under the envelope, and a little grain so the dark does not band. */
.opening::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 50%; width: min(130vw, 74rem); aspect-ratio: 1.3; translate: -50% -50%;
  background: radial-gradient(closest-side, rgba(255, 190, 110, 0.3), transparent);
  transition: scale 1.4s var(--ease-out) 0.5s;
}
.opening[data-state="open"]::before { scale: 1.25; }
.opening::after { content: ""; position: absolute; z-index: -1; inset: 0; background-image: url("../img/grain.png"); background-size: 160px; opacity: 0.45; pointer-events: none; }

.top { padding: 1.1rem var(--gutter) 0; text-align: center; }
.top .wordmark { color: var(--fg); }
.top .wordmark .wax { color: #e58088; }

/* On a tall phone the spare height goes above the headline, as padding, so nothing shifts when the envelope opens. */
.hero { flex: 1; display: grid; align-content: start; padding: clamp(0.9rem, (100svh - 50rem) * 0.5, 6rem) var(--gutter) 2rem; }
.hero-grid { display: grid; gap: 0.7rem; width: 100%; max-width: 76rem; margin-inline: auto; }
.hero-copy { text-align: center; transition: opacity 0.4s linear 0.15s, visibility 0s; }
/* The heading is a full sentence, so it is set to be read, not to shout. */
.hero-copy h1 { font-size: clamp(1.7rem, 0.9rem + 3.6vw, 3.6rem); line-height: 1.08; }
.lede { max-width: 31rem; margin: 0.7rem auto 0; font-size: 0.95rem; line-height: 1.45; text-wrap: pretty; color: color-mix(in srgb, var(--fg) 86%, transparent); }
.hero-stage { position: relative; min-width: 0; margin-inline: calc(var(--gutter) * -1 + 0.625rem); }

/* ---------- names, and the one button ---------- */
.names { display: grid; gap: 1rem; justify-items: center; max-width: 26rem; width: 100%; margin-inline: auto; }
.names-ask { margin-bottom: -0.4rem; font-style: italic; font-size: 0.95rem; color: color-mix(in srgb, var(--fg) 86%, transparent); }
.names-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 0.6rem; width: 100%; }
.names-row .amp { font-style: italic; font-size: 1.7rem; line-height: 1.4; color: color-mix(in srgb, var(--fg) 60%, transparent); }
.field input {
  width: 100%; min-width: 0; padding: 0.15rem 0 0.25rem; text-align: center; color: var(--fg); background: transparent; caret-color: var(--fg);
  border: 0; border-bottom: 1px solid color-mix(in srgb, var(--fg) 40%, transparent); border-radius: 0;
  font-family: var(--text); font-style: italic; font-size: 1.45rem; line-height: 1.3; transition: border-color 0.2s, box-shadow 0.2s;
}
.field input::placeholder { color: color-mix(in srgb, var(--fg) 50%, transparent); opacity: 1; }
.field input:focus { outline: 0; border-bottom-color: var(--fg); box-shadow: 0 1px 0 var(--fg); }
.opening .btn { background: var(--paper); color: var(--ink); box-shadow: 0 14px 30px -14px rgba(0, 0, 0, 0.7); }
.act { display: flex; align-items: center; justify-content: center; gap: 1.4rem; }
.act-open { display: none; }
/* Open, the form is two things: start, or seal it again. */
.opening[data-state="open"] :is(.names-ask, .names-row, .act-sealed, .terms) { display: none; }
.opening[data-state="open"] .act-open { display: flex; animation: rise-in 0.6s var(--ease-out) 2.5s backwards; }
.opening.is-instant .act-open { animation: none; }
@keyframes rise-in { from { opacity: 0; translate: 0 0.6rem; } }
.terms { font-size: 0.86rem; line-height: 1.45; text-align: center; text-wrap: balance; color: color-mix(in srgb, var(--fg) 72%, transparent); }

/* A phone: the pop-up world rises into the space the headline held, so nothing below it has to move. */
@media (max-width: 61.99rem) {
  .opening[data-state="open"] .hero-copy { opacity: 0; visibility: hidden; transition: opacity 0.3s linear, visibility 0s linear 0.3s; }
  .opening[data-state="open"] .names { margin-top: 1.2rem; }
  .stage { --scene-scale: 0.86; }
}

@media (min-width: 62rem) {
  .opening { --stage-w: min(43vw, 39rem, (100svh - 9rem) / 1.02); }
  /* Sized to stay inside its column: the open scene reaches past the stage towards it. */
  .hero-copy h1 { font-size: clamp(2.4rem, 3.4vw, 3.1rem); }
  .opening::before { left: 72%; top: 54%; }
  .top { padding: 1.6rem var(--gutter) 0; text-align: left; }
  .wordmark { font-size: 1.5rem; }
  .hero { align-content: center; padding-top: 1rem; padding-bottom: 4rem; }
  .hero-grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); column-gap: 4rem; row-gap: 2.2rem;
    grid-template-areas: "copy stage" "names stage"; align-items: center;
  }
  .hero-copy { grid-area: copy; align-self: end; text-align: left; }
  .lede { margin: 1.4rem 0 0; max-width: 29rem; font-size: var(--lead); line-height: 1.5; }
  .names-ask { font-size: var(--body); }
  .hero-stage { grid-area: stage; margin-inline: 0; padding-block: calc(var(--stage-w) * 0.13); }
  .names { grid-area: names; align-self: start; justify-items: start; margin-inline: 0; gap: 1.3rem; }
  .act { justify-content: flex-start; }
  .terms { text-align: left; }
}
