/* plane — contact CTA + footer.
   A sheet of paper the visitor drags; it folds itself into a dart
   stage by stage and flies off, leaving the email behind.
   Owns: sections/plane.html, js/plane.js. Prefix: .plane- only. */

/* ---------- section ---------- */

.plane {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  /* keep the "Start a project" kicker clear of the sticky header on
     anchor navigation to #contact */
  scroll-margin-top: 96px;
}

.plane-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px clamp(24px, 5vw, 72px) 96px;
}

.plane-kicker {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: var(--ls-kicker);
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 22px;
}

.plane-headline {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(36px, 4.5vw, 80px);
  line-height: 0.95;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-wrap: balance;
  max-width: 16ch;
}
.plane-headline em {
  font-style: italic;
  font-weight: 500;
  color: var(--paper);
}

/* ---------- stage: sheet and payoff share one grid cell ---------- */

.plane-stage {
  display: grid;
  place-items: center;
  margin-top: clamp(48px, 9vh, 88px);
  min-height: min(340px, 68vw);
}
.plane-stage > * { grid-area: 1 / 1; }

/* The drag wrapper carries the pointer-follow translate and the flight.
   The paper-rest shadow lives here as drop-shadow so it hugs the clipped
   fold silhouette instead of staying rectangular. */
.plane-sheet-drag {
  transform: translate3d(var(--plane-dx, 0px), var(--plane-dy, 0px), 0);
  /* drop-shadow blur is a Gaussian stdev — 24px here renders like a
     48px box-shadow blur, i.e. the spec'd paper-rest shadow */
  filter: drop-shadow(0 24px 24px rgba(77, 69, 55, 0.10));
  will-change: transform, opacity;
}
.plane-sheet-drag--launch { pointer-events: none; }

/* ---------- the sheet ---------- */

.plane-sheet {
  position: relative;
  width: min(420px, 84vw);
  height: min(300px, 60vw);
  background: #ffffff;
  border: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3.5vh, 28px);
  padding: 0 clamp(28px, 8%, 52px);
  /* full-rect polygon so the dart clip in stage 3 can interpolate */
  clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
  transform: rotate(0deg) scaleX(1);
  cursor: grab;
  touch-action: pan-y;
  will-change: transform, clip-path;
}
.plane-sheet--grab { cursor: grabbing; }

/* ---------- the written lines ---------- */

.plane-fields {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.6vh, 22px);
  width: 100%;
}
.plane-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
}
.plane-field-tag {
  font-size: 10px;
  letter-spacing: var(--ls-kicker);
  text-transform: uppercase;
  color: var(--ink-soft);
}
.plane-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink);
  padding: 4px 0;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  transition: border-color 0.2s ease-out;
}
.plane-input:focus { outline: none; border-color: var(--ink); }
/* darker than a faint hint so it stays legible; the always-visible
   .plane-field-tag label carries the required field info regardless */
.plane-input::placeholder { color: rgba(77, 69, 55, 0.55); }
/* error state uses ink emphasis + shake — never the reserved accent */
.plane-field--invalid .plane-input { border-color: var(--ink); }

.plane-send {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: var(--ls-kicker);
  text-transform: uppercase;
  color: var(--ink);
  padding: 6px 2px;
  cursor: pointer;
}
.plane-send:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 4px;
}

/* the writing folds away once the sheet starts narrowing */
.plane-fields,
.plane-send { transition: opacity 0.2s ease-out; }
.plane-sheet--f2 .plane-fields,
.plane-sheet--f2 .plane-send { opacity: 0; pointer-events: none; }

.plane-sheet-arrow { display: block; overflow: visible; }
.plane-sheet-arrow path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
}

/* corner-fold flaps (stage 1) — two paper-tinted triangles */
.plane-sheet::before,
.plane-sheet::after {
  content: "";
  position: absolute;
  top: 0;
  width: 50%;
  height: 62%;
  background: rgba(141, 125, 98, 0.14);
  opacity: 0;
  transform: scaleY(0.35);
  transform-origin: top center;
  pointer-events: none;
}
.plane-sheet::before { left: 0; clip-path: polygon(0% 0%, 100% 0%, 100% 100%); }
.plane-sheet::after { right: 0; clip-path: polygon(0% 0%, 100% 0%, 0% 100%); }

/* center crease (stage 2) */
.plane-sheet-crease {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--hairline);
  opacity: 0;
  pointer-events: none;
}

/* ---------- fold stages (classes are cumulative: f2 implies f1 …) ---------- */

/* stage 1 — top corners fold in */
.plane-sheet--f1::before,
.plane-sheet--f1::after { opacity: 1; transform: scaleY(1); }

/* stage 2 — sheet narrows, center crease appears */
.plane-sheet--f2 { transform: rotate(0deg) scaleX(0.7); }
.plane-sheet--f2 .plane-sheet-crease { opacity: 1; }

/* stage 3 — sharpens into a dart silhouette */
.plane-sheet--f3 {
  clip-path: polygon(0% 10%, 100% 50%, 12% 50%, 0% 90%);
  background: #f3eee5;
}
.plane-sheet--f3::before,
.plane-sheet--f3::after {
  height: 100%;
  background: rgba(141, 125, 98, 0.26);
}
.plane-sheet--f3 .plane-sheet-crease { background: rgba(77, 69, 55, 0.35); }

/* stage 4 — tilts, ready for launch (after --f2 so its transform wins) */
.plane-sheet--f4 { transform: rotate(-12deg) scaleX(0.7); }

/* ---------- payoff ---------- */

.plane-payoff {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  opacity: 0;
  transform: translateY(16px);
}
.plane-payoff[hidden] { display: none; }
.plane-payoff--in { opacity: 1; transform: translateY(0); }

.plane-payoff-headline {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(28px, 3.5vw, 48px);
  line-height: 1;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.plane-payoff-note {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 200;
  color: var(--ink-soft);
  margin-top: -6px;
}
.plane-payoff-note[hidden] { display: none; }

.plane-payoff-mail {
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--ink);
  text-decoration: none;
}
.plane-payoff-mail:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

.plane-reset {
  margin-top: 10px;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: var(--ls-kicker);
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 8px 2px;
  cursor: pointer;
  transition: color 0.2s ease-out, border-color 0.2s ease-out;
}
.plane-reset:hover { color: var(--ink); border-color: var(--ink); }

/* ---------- secondary path: book a call ---------- */

.plane-alt {
  margin-top: clamp(28px, 5vh, 48px);
  text-align: center;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 200;
  color: var(--ink-soft);
}
.plane-call {
  border: 0;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  padding: 6px 2px;
  border-bottom: 1px solid var(--ink);
  transition: opacity 0.2s ease-out;
}
.plane-call:hover { opacity: 0.62; }
.plane-call:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 4px;
}

/* ---------- footer ---------- */

.plane-footer {
  border-top: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 30px clamp(24px, 5vw, 72px) 38px;
  font-size: 12px;
  color: var(--ink-soft);
}
.plane-footer a {
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.2s ease-out;
}
.plane-footer a:hover { color: var(--ink); }
.plane-footer-brand { justify-self: start; }
.plane-footer-social {
  justify-self: end;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.plane-footer-legal {
  grid-column: 1 / -1;
  justify-self: center;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

/* ---------- motion (all nonessential animation lives here) ---------- */

@media (prefers-reduced-motion: no-preference) {
  .plane-sheet {
    transition:
      transform 0.2s ease-out,
      clip-path 0.2s ease-out,
      background-color 0.2s ease-out;
  }
  .plane-sheet::before,
  .plane-sheet::after {
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
  }
  .plane-sheet-label,
  .plane-sheet-crease { transition: opacity 0.2s ease-out; }

  /* early release: spring back */
  .plane-sheet-drag--spring { transition: transform 0.35s ease-out; }

  /* successful release: the dart flies off up-right */
  .plane-sheet-drag--launch {
    animation: plane-launch 900ms cubic-bezier(0.3, 0, 0.2, 1) both;
  }
  @keyframes plane-launch {
    0% {
      transform: translate(-20px, 10px) rotate(0deg) scale(1);
      opacity: 1;
    }
    80% { opacity: 1; }
    100% {
      transform: translate(40vw, -60vh) rotate(8deg) scale(0.5);
      opacity: 0;
    }
  }

  .plane-payoff { transition: opacity 0.45s ease-out, transform 0.45s ease-out; }

  /* missing/invalid email: nudge the line rather than firing a blank send */
  .plane-field--invalid { animation: plane-shake 0.4s ease; }
  @keyframes plane-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
  }
}

@media (prefers-reduced-motion: reduce) {
  /* no flight arc — simple cross-fade sheet -> payoff */
  .plane-sheet-drag { transition: opacity 0.3s ease-out; }
  .plane-sheet-drag--launch { opacity: 0; }
  .plane-payoff { transform: none; transition: opacity 0.3s ease-out; }
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .plane-inner { padding: 88px 24px 48px; }

  /* roomier tap height for the written lines on touch */
  .plane-input { padding: 8px 0; font-size: 16px; }
  .plane-send { padding: 10px 2px; }
  .plane-stage {
    margin-top: clamp(40px, 7vh, 64px);
    min-height: min(300px, 64vw);
  }

  /* payoff links: 44px+ touch targets without changing the type size.
     Negative margins keep the visual rhythm; padding grows the hit area. */
  .plane-payoff { gap: 22px; }
  .plane-payoff-mail { padding: 12px 8px; margin: -8px 0; }
  .plane-reset { padding: 14px 12px; margin-top: 4px; }

  .plane-footer {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 16px;
    padding: 28px 24px 40px;
  }
  .plane-footer-brand,
  .plane-footer-social { justify-self: center; }
  .plane-footer-social { gap: 18px; }
  /* bare 12px inline links -> 44px-class hit areas, same rendered size */
  .plane-footer a {
    display: inline-block;
    padding: 12px 10px;
    margin: -8px 0;
  }
}
