/* Contact postcard — matches Website Screens/Contact form (Desktop: empty, filled,
   submit hover, stamped, flipped; Mobile: Variables).
   It lives inside the Pricing stage: the park photo that grows to fill the screen
   is its background, and js/pricing.js raises the card in (opacity/transform) as the photo
   finishes expanding. js/contact.js handles the stamp press and the flip; the
   animation styles are picked with data-stamp / data-flip on .postcard. */

/* ---------- Postcard ---------- */

.postcard {
  position: absolute;
  z-index: 4; /* above the park photo and the split paragraph */
  will-change: transform, opacity; /* rises on its own GPU layer */
  top: 50%;
  left: 50%;
  width: min(58.2vw, 1040px, (100vh - 150px) * 1.496);
  perspective: 2400px;
  /* Shadow (filter), edge shape and paper settings come from js/postcard-paper.js */
  /* Starting state; js/pricing.js writes opacity (solid early in the rise, never a
     see-through ghost) and transform directly as you scroll */
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -50%) translateY(40vh);
}

/* Hand-placed tilt, plus a gentle 3D lean toward the pointer (--rx/--ry, js/contact.js) */
.postcard__tilt {
  --rx: 0deg;
  --ry: 0deg;
  transform-style: preserve-3d;
  transform: rotate(var(--tilt, -0.8deg)) rotateX(var(--rx)) rotateY(var(--ry));
}

.postcard__inner {
  position: relative;
  display: grid;
  transform-style: preserve-3d;
}

/* Flipped state. The motion itself comes from js/contact.js (data-flip). */
.postcard.is-flipped .postcard__inner {
  transform: rotateY(180deg);
}

/* "toss" flips top-over-bottom, so the back is laid out for that axis */
.postcard[data-flip="toss"].is-flipped .postcard__inner {
  transform: rotateX(180deg);
}

.postcard[data-flip="toss"] .postcard__back {
  transform: rotateX(180deg) rotate(1.2deg);
}

.postcard__face {
  grid-area: 1 / 1;
  position: relative;
  aspect-ratio: 838 / 560;
  container-type: inline-size;
  isolation: isolate;
  color: var(--black);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  filter: var(--paper-shadow, none); /* follows the cut edge; set by js/postcard-paper.js */
}

/* The paper: beige card stock with grain, texture and edges darkened with
   handling, cut to the chosen edge shape. Drawn on a layer behind the content so
   the text and fields stay crisp. All values are set by js/postcard-paper.js. */
.postcard__face::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    var(--grain, none) 0 0 / var(--grain-size, auto) repeat,
    var(--texture, none) 0 0 / var(--texture-size, auto) repeat,
    radial-gradient(ellipse 75% 70% at 50% 46%, rgb(0 0 0 / 0) 62%, rgb(0 0 0 / calc(var(--age, 0.11) * 0.45)) 88%, rgb(0 0 0 / var(--age, 0.11)) 100%),
    linear-gradient(115deg, rgb(255 255 255 / 0.18), rgb(255 255 255 / 0) 40%),
    var(--beige);
  background-blend-mode: multiply, multiply, normal, normal, normal;
  -webkit-mask: var(--edge-mask, linear-gradient(#000 0 0)) 0 0 / 100% 100% no-repeat;
  mask: var(--edge-mask, linear-gradient(#000 0 0)) 0 0 / 100% 100% no-repeat;
}

/* A thin printed border just inside the edge, like a real postcard */
.postcard__face::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: calc(max(9px, 1.5cqw) + var(--border-inset, 0px));
  border: 1px solid rgb(0 0 0 / var(--border-alpha, 0.08));
  pointer-events: none;
}

.postcard__back {
  transform: rotateY(180deg) rotate(-1.2deg);
}

/* ---------- Front: left side ---------- */

.postcard__front {
  display: flex;
  margin: 0;
}

.postcard__left {
  display: flex;
  flex-direction: column;
  width: 46.8cqw;
  padding: 6.4cqw 4.65cqw 5cqw;
}

.postcard__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: max(22px, 4.55cqw);
  line-height: 1.13;
  letter-spacing: -0.01em;
}

.postcard__lede {
  max-width: 30em;
  margin: 3.6cqw 0 0;
  font-family: var(--font-display);
  font-size: max(13px, 1.91cqw);
  line-height: 1.38;
}

.postcard__lede a {
  color: inherit;
  text-decoration: none;
}

.postcard__lede a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Stamp box (the submit button) ---------- */

.postcard__stamp-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3.4cqw;
  margin-top: auto;
}

.stamp-box {
  position: relative;
  width: 16cqw;
  aspect-ratio: 134 / 172;
  padding: 0;
  border: 0;
  background:
    repeating-linear-gradient(90deg, rgb(0 0 0 / 0.3) 0 5px, transparent 5px 9px) top / 100% 1px no-repeat,
    repeating-linear-gradient(90deg, rgb(0 0 0 / 0.3) 0 5px, transparent 5px 9px) bottom / 100% 1px no-repeat,
    repeating-linear-gradient(180deg, rgb(0 0 0 / 0.3) 0 5px, transparent 5px 9px) left / 1px 100% no-repeat,
    repeating-linear-gradient(180deg, rgb(0 0 0 / 0.3) 0 5px, transparent 5px 9px) right / 1px 100% no-repeat;
  cursor: pointer;
}

.stamp-box:focus-visible {
  outline: 1px solid var(--black);
  outline-offset: 4px;
}

.stamp-box__stamp {
  --s: 0.68;
  --o: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 91%;
  height: auto;
  max-width: none;
  opacity: var(--o);
  transform: translate(-50%, -50%) scale(var(--s));
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

/* Hover / keyboard focus: a pale stamp hovers over the box, ready to press */
.stamp-box:hover .stamp-box__stamp,
.stamp-box:focus-visible .stamp-box__stamp {
  --o: 0.35;
  --s: 0.72;
}

.postcard.is-stamped .stamp-box__stamp {
  --o: 1;
  --s: 1;
  transition: none;
}

.postcard.is-stamped .stamp-box {
  cursor: default;
}

.stamp-box__hint {
  min-height: 1.4em;
  margin: 0;
  font-family: var(--font-display);
  font-size: max(13px, 1.91cqw);
  line-height: 1.2;
  opacity: 0;
  transform: rotate(-3deg);
  transition: opacity 0.3s ease;
}

/* The hint appears once the form is filled in */
.postcard.is-ready .stamp-box__hint,
.postcard.is-stamped .stamp-box__hint,
.postcard.has-error .stamp-box__hint {
  opacity: 1;
}

/* ---------- Front: fields ---------- */

.postcard__fields {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 3.1cqw;
  padding: 4cqw 8.7cqw 4cqw 4.9cqw;
}

/* Dashed line down the middle of the postcard */
.postcard__fields::before {
  content: "";
  position: absolute;
  top: 4.4cqw;
  bottom: 5.1cqw;
  left: 0;
  width: 1px;
  background: repeating-linear-gradient(180deg, rgb(0 0 0 / 0.3) 0 6px, transparent 6px 11px);
}

.field {
  --line: rgb(0 0 0 / 0.3);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.3cqw;
  padding-bottom: 1cqw;
}

.field::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--line) 0 8px, transparent 8px 14px);
}

.field:has(.field__input:not(:placeholder-shown)) {
  --line: rgb(0 0 0 / 0.8);
}

/* Typing: the line turns solid */
.field:focus-within::after {
  background: var(--black);
}

.field__label {
  font-family: var(--font-display);
  font-size: max(13px, 1.91cqw);
  line-height: 1.2;
}

.field__input {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--black);
  font-family: var(--font-hand);
  font-size: max(14px, 1.85cqw);
  line-height: 1.45;
  outline: none;
  resize: none;
}

.field__input::placeholder {
  color: rgb(0 0 0 / 0.35);
  opacity: 1;
}

textarea.field__input {
  height: calc(4 * 1.45em);
  overflow-y: auto;
}

/* A missing answer gives a little shake */
.field.is-invalid {
  --line: var(--black);
  animation: field-shake 0.4s ease;
}

@keyframes field-shake {
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* ---------- Back: thank-you note ---------- */

.postcard__back {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3cqw 8cqw 4cqw;
  text-align: center;
}

.postcard__clip {
  position: absolute;
  top: -2.6cqw;
  right: 0.6cqw;
  width: 4.6cqw;
  overflow: visible;
  transform: rotate(-38deg);
}

.postcard__clip path {
  fill: none;
  stroke: var(--black);
  stroke-width: 2;
  stroke-linecap: round;
}

.postcard__address {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  padding-bottom: 2.4cqw;
}

.postcard__address > div {
  display: flex;
  flex-direction: column;
  gap: 0.6cqw;
}

/* Dashed lines: between From and To, and underneath */
.postcard__address::before {
  content: "";
  position: absolute;
  top: 0.4cqw;
  bottom: 3.4cqw;
  left: 50%;
  width: 1px;
  background: repeating-linear-gradient(180deg, rgb(0 0 0 / 0.3) 0 5px, transparent 5px 9px);
}

.postcard__address::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: repeating-linear-gradient(90deg, rgb(0 0 0 / 0.3) 0 7px, transparent 7px 12px);
}

.postcard__address-label {
  font-family: var(--font-display);
  font-size: max(13px, 1.91cqw);
}

.postcard__address-name {
  font-family: var(--font-hand);
  font-size: max(13px, 1.9cqw);
  color: rgb(0 0 0 / 0.65);
}

.postcard__note {
  margin: auto 0;
  font-family: var(--font-hand);
  font-size: max(18px, 4.4cqw);
  line-height: 0.9;
  outline: none;
}

.postcard__note p {
  margin: 0 0 1.1em;
}

.postcard__note p:last-child {
  margin-bottom: 0;
}

.postcard__logo {
  width: 32cqw;
  height: auto;
}

.postcard__contacts {
  display: flex;
  gap: 3cqw;
  margin: 2.2cqw 0 0;
  font-family: var(--font-display);
  font-size: max(13px, 2.1cqw);
  color: rgb(0 0 0 / 0.5);
}

.postcard__contacts a {
  color: inherit;
  text-decoration: none;
}

.postcard__contacts a:hover {
  color: var(--black);
}

/* ---------- Phones and tablets: portrait postcard ---------- */

@media (max-width: 959px) {
  .postcard {
    width: min(100vw - 48px, 560px);
  }

  .postcard__face {
    aspect-ratio: auto;
    min-height: 70svh; /* 70% of the screen height, chosen with the slider */
  }

  .postcard__front {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-areas:
      "intro intro intro intro intro intro"
      "name name name company company company"
      "email email email email email email"
      "message message message message stamp stamp";
    gap: 26px 16px;
    padding: 24px 20px 26px;
  }

  .postcard__left,
  .postcard__fields {
    display: contents;
  }

  .postcard__fields::before {
    display: none;
  }

  .postcard__intro { grid-area: intro; margin-bottom: 8px; }
  .field--name { grid-area: name; }
  .field--company { grid-area: company; }
  .field--email { grid-area: email; }
  .field--message { grid-area: message; }

  .postcard__stamp-area {
    grid-area: stamp;
    align-self: end;
    gap: 10px;
    margin: 0;
  }

  .postcard__title { font-size: 24px; }
  .postcard__lede { margin-top: 10px; font-size: 13px; }
  .field { gap: 8px; padding-bottom: 6px; }
  .field__label { font-size: 13px; }
  .field__input { font-size: 15px; }
  .stamp-box { width: 100%; max-width: 104px; }
  .stamp-box__hint { font-size: 11px; white-space: nowrap; }

  .postcard__back {
    padding: 22px 20px 26px;
  }

  .postcard__clip { top: -18px; right: 6px; width: 28px; }
  .postcard__address { padding-bottom: 14px; }
  .postcard__address::before { bottom: 20px; }
  .postcard__address-label { font-size: 14px; }
  .postcard__address-name { font-size: 13px; }
  .postcard__note { margin: 28px 0; font-size: 24px; }
  .postcard__logo { width: 170px; }
  .postcard__contacts { gap: 14px; margin-top: 12px; font-size: 14px; }
}
