/* ============================================================
   Contact / "Case Request" — Figma 1690-7380 (form), 1715-8015
   (filed), 1715-7949 + 1715-8075 (mobile).

   A black page with a single white sheet of paper on it. The form
   is set as a fill-in-the-blanks paragraph, and on submit the
   sheet folds in half and posts itself off-screen
   (js/contact/contact.js).

   Self-contained: tokens.css + this file only. It deliberately
   does NOT pull hero.css (38 KB of home-page choreography).
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

/* The filed state and the attribution line ship hidden; both are display:flex
   further down, which would otherwise win over the [hidden] attribute. */
[hidden] { display: none !important; }

.ct-body {
  margin: 0;
  background: #000;
  color: #fff;
  font-family: var(--dn-font-sans);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

/* One shared vertical line. The lede, the sheet's left edge, the filed block and
   the "last thing" line all start here — that alignment is the spine of the
   layout, so it lives in a single variable rather than four grid guesses. */
:root {
  --ct-rail: 22.3%;
  --ct-paper-top: calc(var(--dn-gutter) + 112px);   /* ~45px under the nav block */
}

/* Fixed-height stage: nav across the top, the sheet filling the rest of the
   right side down to the bottom gutter, mail + attribution pinned bottom-left. */
.ct {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--dn-gutter);
}

.ct-sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Nav ----------------------------------------------------------- */
/* 12-col grid so the right rail lands on the same column as the home page. */
.ct-nav {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  align-items: start;
  font-size: 14px;
  line-height: 0.92;
  text-transform: uppercase;
}
.ct-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.ct-nav a,
.ct-nav button {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s;
}
.ct-nav a:hover,
.ct-nav button:hover { opacity: 0.6; }

.ct-menu { grid-column: 1 / span 4; }
.ct-menu-toggle {
  display: none;                 /* desktop: the columns are always shown */
  list-style: none;
  cursor: pointer;
}
.ct-menu-toggle::-webkit-details-marker { display: none; }

.ct-nav-cols {
  display: flex;
  gap: 1rem;
}
.ct-annot { user-select: none; }
.ct-sf { display: inline-block; height: 0.8em; width: auto; vertical-align: -0.08em; }
.ct-dim { opacity: 0.5; }

/* The standing brief — pulled out of the grid onto the shared rail. */
.ct-lede {
  position: absolute;
  left: var(--ct-rail);
  top: var(--dn-gutter);
  margin: 0;
  width: 162px;
}

.ct-nav-right {
  grid-column: 11 / -1;
  display: flex;
  gap: 1.25rem;
}
.ct-marks { min-width: 38px; }

/* The copy widget must read as nav type, not a button. */
.ct-nav .nh-copy-email {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  text-transform: inherit;
  line-height: inherit;
  cursor: pointer;
}

/* ---- The paper ----------------------------------------------------- */
/* Starts on the rail, runs to the right gutter, and stretches all the way to
   the bottom of the screen (Figma). */
.ct-paper {
  --paper-pad: clamp(16px, 1.7vw, 24px);
  position: absolute;
  z-index: 1;
  left: var(--ct-rail);
  right: var(--dn-gutter);
  top: var(--ct-paper-top);
  bottom: var(--dn-gutter);
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: var(--paper-pad);
  background: #fff;
  color: #000;
}

.ct-paper-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  font-size: clamp(14px, 1.25vw, 18px);
  line-height: 0.9;
}
.ct-paper-head > :last-child { text-align: right; }

/* ---- The fill-in-the-blanks paragraph ------------------------------ */
.ct-body-copy {
  margin-top: clamp(28px, 5vw, 76px);
  font-family: var(--dn-font-sans);
  font-weight: 400;                    /* Regesto Regular, per Figma */
  font-size: clamp(20px, 2.42vw, 35px);
  line-height: 1.06;
  letter-spacing: -0.02em;
}
.ct-line { margin: 0; }

/* Inline auto-growing input. The sizer and the input share one grid cell, so
   the wrapper is always exactly as wide as the text it holds. */
.ct-field {
  display: inline-grid;
  vertical-align: baseline;
  max-width: 100%;
}
.ct-field > * {
  grid-area: 1 / 1;
  font: inherit;
  letter-spacing: inherit;
}
.ct-sizer {
  visibility: hidden;
  white-space: pre;
  padding-inline: 0.12em;
  min-width: 2ch;
}
.ct-field input {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding-inline: 0.12em;
  border: 0;
  border-bottom: 1px solid #000;
  border-radius: 0;
  background: none;
  color: #000;
  appearance: none;
  -webkit-appearance: none;
}
.ct-field input::placeholder { color: #9f9f9f; opacity: 1; }
.ct-field input:focus {
  outline: none;
  border-bottom-color: var(--dn-red);
}
.ct-field input:focus::placeholder { color: #c9c9c9; }

/* ---- Chips --------------------------------------------------------- */
.ct-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 8px;
  margin: 0;
  padding: 0;
  border: 0;
}
.ct-chips-when { margin-top: 0.1em; }
.ct-when-label { margin-right: 4px; }

.ct-chip {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0 0.1em;
  border: 0;
  border-radius: 2px;
  background: none;
  color: #000;
  font: inherit;
  letter-spacing: inherit;
  line-height: 1.06;
  cursor: pointer;
  transition: background-color 0.18s, color 0.18s;
}
.ct-chip:hover { color: var(--dn-red); }
/* Chosen reads as a red pen stroke scribbled across the option, the way you'd
   strike one on a paper form. Stretched with preserveAspectRatio="none" so one
   wobbling path fits any chip width. */
.ct-chip[aria-pressed="true"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 24' preserveAspectRatio='none'%3E%3Cpath d='M2 15C18 8 34 17 50 11 66 5 82 15 98 9' fill='none' stroke='%23e72b25' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.ct-chip:focus-visible { outline: 2px solid var(--dn-red); outline-offset: 2px; }

.ct-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #000;
  flex: none;
}

/* ---- "The case, in my words" --------------------------------------- */
/* Label, the growing blank and the counter all sit on one line (Figma); the
   textarea takes whatever width is left and gains rules as it wraps. */
.ct-words {
  display: flex;
  align-items: baseline;
  margin: 0.1em 0 0;
}
.ct-words-label { flex: none; white-space: nowrap; }
.ct-words textarea {
  flex: 1 1 auto;
  min-width: 0;
}
.ct-words textarea {
  --rule: 1.45em;               /* one ruled line; JS snaps the height to it */
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #000;
  font: inherit;
  letter-spacing: inherit;
  line-height: 1.45;
  resize: none;
  overflow: hidden;
  /* Ruled writing lines, drawn on the line-height grid. */
  background-image: linear-gradient(to bottom, transparent calc(var(--rule) - 1px), #000 calc(var(--rule) - 1px), #000 var(--rule));
  background-size: 100% var(--rule);
}
.ct-words textarea:focus { outline: none; }
/* Superscript, in the body colour — not a grey utility label (Figma). */
.ct-count {
  flex: none;
  align-self: flex-start;
  margin-left: 0.15em;
  font-size: 0.62em;
  line-height: 1;
  color: inherit;
  pointer-events: none;
}

/* ---- Submit -------------------------------------------------------- */
.ct-file {
  align-self: flex-end;
  margin-top: auto;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: none;
  color: #000;
  font-family: var(--dn-font-sans);
  font-weight: 400;
  font-size: clamp(20px, 2.42vw, 35px);
  letter-spacing: -0.02em;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.2s;
}
.ct-file:hover { opacity: 0.55; }
.ct-file[disabled] { opacity: 0.35; cursor: default; }

.ct-error {
  margin: 0.6em 0 0;
  color: var(--dn-red);
  font-size: 14px;
  text-transform: uppercase;
  line-height: 1.2;
}

/* ---- Filed ---------------------------------------------------------- */
/* Sits where the paper was, at the same left edge as the standing brief. */
.ct-success {
  position: absolute;
  left: var(--ct-rail);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 162px;
  font-size: 14px;
  line-height: 0.92;
  text-transform: uppercase;
}
.ct-success p { margin: 0; }
.ct-check { font-size: 16px; }

/* Filed: the close control grows into the page's headline. Scaling the rail's
   font-size (rather than hiding one CLOSE and revealing a bigger one) keeps it
   as one continuous move; the rows beneath it just fade under it. */
.ct-nav-right { transition: font-size 0.55s var(--dn-ease-out), gap 0.55s var(--dn-ease-out); }
.ct-fade { transition: opacity 0.3s ease; }
.ct-body.is-filed .ct-nav-right {
  font-size: clamp(24px, 3vw, 43px);
  gap: 0.5rem;
}
.ct-body.is-filed .ct-marks { min-width: 0; }
.ct-body.is-filed .ct-fade { opacity: 0; pointer-events: none; }

/* ---- Footer --------------------------------------------------------- */
/* The mail address keeps the far-left gutter; the attribution line starts on
   the shared rail, under the sheet's left edge. */
/* Both children are positioned against .ct itself, so --ct-rail resolves
   against the same box the sheet and the lede use. */
.ct-foot {
  font-size: 14px;
  text-transform: uppercase;
  line-height: 0.92;
}
.ct-mail {
  position: absolute;
  left: var(--dn-gutter);
  bottom: var(--dn-gutter);
  color: inherit;
  text-decoration: none;
}
.ct-mail:hover { opacity: 0.6; }

.ct-howd {
  position: absolute;
  left: var(--ct-rail);
  bottom: var(--dn-gutter);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.ct-howd .ct-field input {
  border-bottom-color: #fff;
  color: #fff;
}
.ct-howd .ct-field-wide .ct-sizer { min-width: 34ch; }
.ct-howd button {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.ct-howd button:hover { opacity: 0.6; }

/* ---- Fold-and-post -------------------------------------------------- */
/* Built by contact.js: two halves of a cloned sheet, the lower one hinged at
   its top edge so it folds up over the upper one, then the packet flies off. */
.ct-fold-stage {
  position: fixed;
  z-index: 80;
  perspective: 1800px;
  pointer-events: none;
  will-change: transform, opacity;
}
.ct-fold-half {
  position: absolute;
  left: 0;
  width: 100%;
  transform-style: preserve-3d;
}
.ct-fold-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  background: #fff;
}
.ct-fold-back { transform: rotateX(180deg); }
/* The crease: a soft shade that deepens as the flap comes over. */
.ct-fold-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.28), rgba(0,0,0,0));
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .ct-fold-stage { display: none !important; }
}

/* ===================================================================
   MOBILE (Figma 1715-7949 / 1715-8075) — [Menu] · [Close], the brief
   under the nav, then the sheet. NB: this export scales the root font
   size with the viewport, so mobile uses px, not rem.
   =================================================================== */
@media (max-width: 767px) {
  /* No shared rail on a phone — everything returns to normal flow at 16px. */
  .ct {
    display: flex;
    flex-direction: column;
    padding: 16px;
  }
  .ct-lede,
  .ct-paper,
  .ct-success,
  .ct-mail,
  .ct-howd { position: static; left: auto; right: auto; top: auto; bottom: auto; transform: none; }
  .ct-lede { width: auto; }
  .ct-foot { margin-top: auto; padding-top: 20px; }

  .ct-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
  }
  /* Beat `.ct-nav ul { display:flex }` — a bare .ct-marks loses on specificity. */
  .ct-nav .ct-marks { display: none; }
  .ct-menu { order: 1; }
  .ct-menu-toggle { display: block; }
  .ct-menu[open] .ct-nav-cols { padding-top: 12px; }
  .ct-nav-right { order: 2; gap: 0; }
  .ct-nav-right ul:last-child { flex-direction: row; }
  .ct-nav-right ul:last-child li:not(:first-child):not(:last-child) { display: none; }
  .ct-nav-right ul:last-child li + li { margin-left: 14px; }
  .ct-lede {
    order: 3;
    flex: 1 0 100%;
    max-width: 280px;
  }

  .ct-paper {
    flex: 1;                 /* still runs to the bottom of the screen */
    width: 100%;
    margin-top: 14px;
    --paper-pad: 14px;
  }
  .ct-body-copy {
    margin-top: 18px;
    font-size: 21px;
    line-height: 1.14;
  }
  /* Too narrow to keep the label, the blank and the counter on one line — the
     blank drops under the label and the count parks at the top right. */
  .ct-words { position: relative; display: block; }
  .ct-words textarea { display: block; width: 100%; }
  .ct-count { position: absolute; right: 0; top: 0; margin: 0; }
  .ct-paper-head { grid-template-columns: 1fr auto; font-size: 14px; }
  .ct-paper-head-mid { display: none; }
  .ct-paper-head > :last-child { grid-column: 2; }

  .ct-file { margin-top: 40px; font-size: 26px; }

  .ct-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .ct-howd { flex-wrap: wrap; }
  .ct-howd .ct-field-wide .ct-sizer { min-width: 18ch; }

  .ct-success {
    position: static;
    transform: none;
    width: auto;
    max-width: 280px;
    margin: 40px 0 auto;
  }
}
