/* Contact "box": the page is one wall of a box seen from inside; opening the contact form turns the camera
   to the next wall. Layout-neutral until a visitor opens it (html.boxing), so the page scrolls as normal. */
html.boxing, html.boxing body { overflow: hidden; height: 100%; }
html.boxing #box-stage {
  position: fixed; inset: 0; z-index: 50; overflow: hidden; background: radial-gradient(120% 80% at 50% 50%, #1b1d20 0%, #121315 100%);
  perspective: 120vw;                      /* the camera sits just outside the open side of the box, so no wall ever passes
                                              behind it (mobile Safari stops drawing a wall that does: a black flash) */
}
html.boxing #box-stage .box {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transform-origin: 50% 50% 50vw;          /* centre of the box, half a wall in front of the page */
  transition: transform 1.1s cubic-bezier(0.65, 0, 0.35, 1);
}
html.boxing #box-stage .box.turned { transform: rotateY(90deg); }
html.boxing #box-stage .face-front {
  position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden;
}
.face-contact { display: none; }
html.boxing .face-contact {
  display: flex; position: absolute; top: 0; left: 100%; width: 100%; height: 100%;
  transform-origin: left center; transform: rotateY(-90deg); backface-visibility: hidden;
  background: radial-gradient(120% 90% at 20% 10%, #23262b 0%, #151618 55%, #0e0f11 100%);
  color: #FAFAFA; overflow-y: auto; align-items: flex-start; justify-content: center;
}
/* once the turn has finished the form wall is laid flat as a normal page: browsers don't reliably send clicks and
   typing to elements inside a turned 3D box, so the 3D only exists while it is moving */
html.boxing #box-stage .box.settled { transition: none; transform: none; }
html.boxing #box-stage .box.settled .face-front { visibility: hidden; }
html.boxing #box-stage .box.settled .face-contact { left: 0; transform: none; }
html.boxing #box-stage .box.settled .face-contact::after { opacity: 0; transition: none; }
/* shading as the walls turn, so the corner reads as a corner */
html.boxing #box-stage .face-front::after, html.boxing .face-contact::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; background: #000; opacity: 0;
  transition: opacity 1.1s cubic-bezier(0.65, 0, 0.35, 1);
}
html.boxing .box.turned .face-front::after { opacity: 0.55; }
html.boxing .box:not(.turned) .face-contact::after { opacity: 0.55; }

.contact-wrap { width: min(760px, 100%); padding: 6rem 1.5rem 4rem; box-sizing: border-box; position: relative; }
.contact-back {
  position: absolute; top: 2rem; left: 1.5rem; font: inherit; font-size: 0.9rem; color: #CBD5E1;
  background: none; border: 0; cursor: pointer; padding: 0.4rem 0;
}
.contact-back:hover { color: #FAFAFA; }
.contact-eyebrow { color: var(--contact-accent, #FF6B35); font-size: 0.8rem; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; }
.contact-wrap h2 { font-size: clamp(2.2rem, 6vw, 3.5rem); line-height: 1.05; margin: 0.6rem 0 1rem; font-weight: 800; letter-spacing: -1px; }
.contact-lead { color: #94A3B8; font-size: 1.05rem; line-height: 1.6; margin: 0 0 2.5rem; }
.contact-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem 1.5rem; }
.contact-form .full { grid-column: 1 / -1; }
.contact-form label { display: block; font-size: 0.8rem; letter-spacing: 1px; text-transform: uppercase; color: #94A3B8; margin-bottom: 0.45rem; }
.contact-form input, .contact-form select, .contact-form textarea {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 1rem; color: #FAFAFA;
  background: #1E2022; border: 1px solid rgba(255,255,255,0.12); border-radius: 6px; padding: 0.85rem 1rem;
}
.contact-form textarea { min-height: 160px; resize: vertical; }
.contact-form input:focus, .contact-form select:focus, .contact-form textarea:focus {
  outline: none; border-color: var(--contact-accent, #FF6B35); box-shadow: 0 0 0 3px rgba(255,107,53,0.2);
}
.contact-form .trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.contact-actions { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.contact-send {
  position: relative; font: inherit; font-weight: 700; font-size: 1rem; color: #1E2022;
  background: var(--contact-accent, #FF6B35); border: 0; border-radius: 4px; padding: 0.95rem 1.8rem; cursor: pointer;
}
.contact-send[disabled] { opacity: 0.6; cursor: progress; }
.contact-alt { color: #94A3B8; font-size: 0.9rem; }
.contact-alt a { color: #FAFAFA; }
.contact-status { min-height: 1.5rem; color: #FCA5A5; font-size: 0.95rem; }
.contact-status.ok { color: #86EFAC; }
.contact-plane {
  position: fixed; width: 44px; height: 44px; pointer-events: none; z-index: 5; color: var(--contact-accent, #FF6B35);
}
.contact-plane.fly { animation: plane-fly 1.4s cubic-bezier(0.45, 0, 0.2, 1) forwards; }
@keyframes plane-fly {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
  25%  { transform: translate(40px, 30px) rotate(10deg) scale(1.05); opacity: 1; }
  100% { transform: translate(70vw, -80vh) rotate(-25deg) scale(0.4); opacity: 0; }
}
@media (max-width: 700px) {
  .contact-form { grid-template-columns: 1fr; }
  .contact-wrap { padding-top: 5rem; }
}
/* reduce motion: a plain cross-fade instead of turning the box, and no flight */
@media (prefers-reduced-motion: reduce) {
  html.boxing #box-stage .box { transition: none; }
  html.boxing #box-stage .box.turned { transform: none; }
  html.boxing .face-contact { left: 0; transform: none; opacity: 0; transition: opacity 0.3s; }
  html.boxing .box.turned .face-contact { opacity: 1; }
  html.boxing .face-front::after, html.boxing .face-contact::after { display: none; }
  .contact-plane.fly { animation: none; opacity: 0; }
}

/* Turning between flintandslate.com and the studio: the leaving page turns away to reveal a wall naming the
   destination, the browser navigates, and the arriving page starts on the side wall and turns to face the visitor.
   l = turn left (to the studio), r = turn right (back to digital). */
.face-transit { display: none; }
html.boxing .box.transiting .face-transit {
  display: flex; position: absolute; top: 0; width: 100%; height: 100%; backface-visibility: hidden;
  align-items: center; justify-content: center; background: radial-gradient(120% 90% at 50% 45%, #23262b 0%, #151618 60%, #0e0f11 100%);
  color: #FAFAFA; font-weight: 800; letter-spacing: 4px; text-transform: uppercase; font-size: clamp(1.6rem, 6vw, 3.2rem);
}
.face-transit span { opacity: 0.55; font-weight: 400; margin-left: 0.6em; }
html.boxing .box.transiting .face-transit.on-right { left: 100%; transform-origin: left center; transform: rotateY(-90deg); }
html.boxing .box.transiting .face-transit.on-left { left: -100%; transform-origin: right center; transform: rotateY(90deg); }
html.boxing #box-stage .box.turn-l { transform: rotateY(90deg); }
html.boxing #box-stage .box.turn-r { transform: rotateY(-90deg); }
/* arriving: the page starts on the side wall (no transition), then the script lets it turn to the front */
html.arrive-l #box-stage .box { transition: none; transform: rotateY(-90deg); }
html.arrive-r #box-stage .box { transition: none; transform: rotateY(90deg); }
@media (prefers-reduced-motion: reduce) {
  html.arrive-l #box-stage .box, html.arrive-r #box-stage .box { transform: none; }
}
html.boxing #box-stage .box.transiting .face-contact { display: none; }
/* while arriving, the wall facing the visitor is the destination's name wall, never the form */
html.arrive-l .face-contact, html.arrive-r .face-contact { display: none; }
