/* /apply — the enquiry form. Shared tokens and primitives come from site.css. */

[hidden] { display: none !important; }

.nav-back { margin-left: auto; }
/* Plan view switch: the form is a sheet of the same set */
.apply-pv { margin-left: auto; }
.apply-pv:not([hidden]) + .nav-back { margin-left: 0; }
.nav-inner:has(.apply-pv:not([hidden])) { gap: 12px; }
@media (max-width: 640px) {
  /* phones: only someone who arrived in Plan view needs the way out of it */
  html:not(.plan-view) .apply-pv { display: none; }
  html:not(.plan-view) .apply-pv + .nav-back { margin-left: auto; }
  .apply-pv { padding: 0 9px; }
  .apply-pv > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 400px) { .plan-view .nav-inner .brand-name { display: none; } }
@media (max-width: 360px) { .nav-inner { gap: 12px; } .nav-back { padding: 0 12px; font-size: 0.875rem; } .nav-inner .brand-name { font-size: 1rem; } }

.apply-main { padding: clamp(28px, 4.5vw, 64px) 0 clamp(72px, 9vw, 120px); }

/* ─── Layout: intro + aside on the left, form on the right.
       On phones the form follows the intro straight away. ───── */
.apply-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "intro form" "aside form";
  column-gap: clamp(32px, 5vw, 80px);
  row-gap: 36px;
  align-items: start;
}
.apply-intro { grid-area: intro; display: grid; gap: 22px; }
.apply-form-wrap { grid-area: form; min-width: 0; }
.apply-aside { grid-area: aside; position: sticky; top: 92px; display: grid; gap: 20px; }
@media (max-width: 960px) {
  .apply-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "intro" "form" "aside"; row-gap: 28px; }
  .apply-aside { position: static; padding-top: 8px; border-top: 1px solid var(--line-2); padding-top: 28px; }
  .sheet-tb { display: none; }
}

.apply-title { font-size: clamp(1.75rem, 0.9rem + 2.6vw, 2.5rem); }
.apply-intro .lede { max-width: 26em; }

.apply-person { display: flex; align-items: center; gap: 16px; }
.apply-person img { width: 96px; height: 96px; border-radius: 50%; box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--line-2); }
.apply-person p { line-height: 1.35; }
.apply-person strong { display: block; font-weight: 650; }
.apply-person span { font-size: 0.9375rem; color: var(--ink-3); }
@media (max-width: 960px) { .apply-person img { width: 56px; height: 56px; } }

/* ─── The sheet's own title block: fills in as the form is filled ─── */
.sheet-tb { grid-template-columns: minmax(0, 1fr) minmax(104px, auto); width: 100%; max-width: 440px; border-width: var(--pen-2, 1.5px); }
.sheet-tb > div:nth-child(odd) { border-left: 0; }
.sheet-tb > div:nth-child(n+3) { border-top: 1px solid var(--ink); }
.sheet-tb dd {
  white-space: normal; overflow-wrap: anywhere; min-height: 1.25em;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.sheet-tb dd.is-blank, .sheetline .is-blank { color: var(--ink-3); font-weight: 500; }

/* Aside */
.plan-list { list-style: none; counter-reset: plan; border-top: 1px solid var(--line-2); }
.plan-list li {
  counter-increment: plan; display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: baseline;
  padding: 12px 0; border-bottom: 1px solid var(--line-2); color: var(--ink-2); font-size: 0.9375rem; line-height: 1.45;
}
.plan-list li::before { content: counter(plan, decimal-leading-zero); font-family: var(--mono); font-size: 0.75rem; font-weight: 500; color: var(--ink-3); }
.plan-list strong { color: var(--ink); font-weight: 650; }
.apply-trust { gap: 8px; font-size: 0.9375rem; }
.apply-alt a { color: var(--accent); font-weight: 600; }

/* ─── Progress ─────────────────────────────────────────────── */
.apply-dim { margin-bottom: 10px; }
.apply-progress {
  position: sticky; top: 68px; z-index: 5; height: 4px; margin-bottom: 14px;
  background: var(--line-2); border-radius: 2px; overflow: hidden;
}
.apply-progress-bar { height: 100%; width: 4%; background: var(--accent); border-radius: 2px; transition: width .35s var(--ease-out); }

/* ─── The sheet ────────────────────────────────────────────── */
/* clip, not hidden: hidden would make the form a scroll container and the phone line could not stick */
.apply-form { background: var(--sheet); border: 1px solid var(--line-2); border-radius: var(--r-lg); overflow: hidden; overflow: clip; }

/* ─── Carried in from the site: every prefilled number has a visible, removable source ─── */
.carry { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px clamp(22px, 3.2vw, 34px); border-bottom: 1px dashed var(--line-2); background: var(--paper); }
.carry-chip {
  display: inline-grid; grid-template-columns: minmax(0, auto) auto; align-items: center; column-gap: 6px;
  max-width: 100%; padding: 6px 4px 6px 12px; border: 1px solid var(--ink); border-radius: 6px; background: var(--sheet);
  font-size: 0.875rem; line-height: 1.3;
}
.carry-k { grid-column: 1; font: 500 0.6875rem/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.carry-v { grid-column: 1; font-weight: 600; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.carry-edit { margin-left: 8px; color: var(--accent); font-weight: 600; }
.carry-x {
  grid-column: 2; grid-row: 1 / span 2; display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 4px; background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background-color var(--t-ui, 180ms) ease, color var(--t-ui, 180ms) ease;
}
.carry-x:hover { background: var(--paper-2); color: var(--ink); }
.carry-x svg { width: 14px; height: 14px; }
@media (max-width: 640px) {
  .carry { padding: 12px 18px; }
  .carry-chip { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; }
  .carry-x { width: 44px; height: 44px; }
}

/* ─── Phones: one line of the sheet rides above Send ───────── */
.sheetline { display: none; }
@media (max-width: 960px) {
  .sheetline {
    position: sticky; bottom: 0; z-index: 4; display: flex; align-items: baseline; gap: 8px; margin: 0;
    padding: 9px 18px calc(9px + env(safe-area-inset-bottom, 0px));
    border-top: var(--pen-2, 1.5px) solid var(--ink); background: var(--sheet);
    font-size: 0.8125rem; line-height: 1.3; white-space: nowrap; overflow: hidden;
  }
  .sl-k { flex: none; font: 500 0.6875rem/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
  #slProject { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 650; color: var(--ink); }
  .sl-scope { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
  .sl-scope:not(:empty)::before { content: "· "; }
  .sl-fix { flex: none; margin-left: auto; display: inline-flex; gap: 10px; font: 500 0.75rem/1.3 var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
}

.apply-step { margin: 0; min-width: 0; padding: clamp(22px, 3.2vw, 34px); border: 0; border-top: 1px solid var(--line); }
.apply-form > .apply-step:first-child { border-top: 0; }
.apply-step > .sample-slot { margin-top: 20px; }
.apply-step > .hp-field { margin-top: 0; }
.apply-form .essentials { padding-bottom: 8px; }
.essentials { position: relative; }
.apply-step > legend.visually-hidden { float: none; display: block; width: 1px; height: 1px; margin: 0; padding: 0; left: 0; top: 0; }
.essentials > legend + * { margin-top: 0; }
.apply-step > legend + *, .apply-step > :first-child { margin-top: 0; }
.apply-step > .fld, .apply-step > .row, .apply-step > .q, .apply-step > .step-hint { margin-top: 20px; }
.apply-step > legend + * { margin-top: 0; }

.apply-step legend {
  display: flex; align-items: baseline; gap: 14px; float: left; width: 100%;
  padding: 0; margin: 0 0 20px; font-size: 1.25rem; font-weight: 680; letter-spacing: -0.012em; line-height: 1.2;
}
.apply-step legend ~ * { clear: both; }
.step-no { font-family: var(--mono); font-size: 0.8125rem; font-weight: 500; color: var(--ink-3); letter-spacing: 0.02em; }

.goal-blocks { border-top: 0; }
.goal-block { background: var(--paper); border-top: 1px dashed var(--line-2); }
.goal-block legend { font-size: 1.0625rem; }
.goal-block.just-opened { animation: open .45s var(--ease-out); }
@keyframes open { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .goal-block.just-opened { animation: none; } }
.step-hint { color: var(--ink-3); font-size: 0.9375rem; text-wrap: pretty; }

/* Fields */
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; }
@media (max-width: 640px) { .row { grid-template-columns: minmax(0, 1fr); } }
.fld, .other-field { min-width: 0; }
.fld-label { font-weight: 600; font-size: 0.9375rem; color: var(--ink); line-height: 1.35; }
.fld-label .opt, .q-label .opt { font-style: normal; font-weight: 450; color: var(--ink-3); }
.fld-label .req { font-style: normal; color: var(--ink-2); }
.fld-hint { font-size: 0.875rem; line-height: 1.4; color: var(--ink-3); text-wrap: pretty; }
.apply-form .field textarea { min-height: 132px; line-height: 1.5; }
/* the one-line answer grows with what is written instead of scrolling inside itself */
.apply-form .field textarea.msg-grow { field-sizing: content; max-height: 60vh; }
.apply-form .field select {
  appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%230f1828' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
.other-field { margin-top: 12px; }
.fld.invalid input, .fld.invalid textarea, .fld.invalid select { border-color: var(--warn); box-shadow: 0 0 0 3px var(--warn-wash); }
.fld-error { display: block; margin-top: 6px; color: var(--warn); font-size: 0.875rem; font-weight: 550; }

.q-label { font-weight: 600; font-size: 0.9375rem; margin-bottom: 10px; line-height: 1.35; }

/* File */
.apply-form .field input[type="file"] {
  width: 100%; padding: 10px; background: var(--paper); border: 1px dashed var(--line-2); border-radius: var(--r-md);
  font: inherit; font-size: 0.9375rem; color: var(--ink-2); cursor: pointer;
}
.apply-form .field input[type="file"]:hover { border-color: var(--ink-3); }
.apply-form .field input[type="file"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.apply-form input[type="file"]::file-selector-button {
  margin-right: 12px; min-height: 36px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--sheet); color: var(--ink); font: inherit; font-weight: 600; font-size: 0.9375rem; cursor: pointer;
}

/* ─── Chips: selectable pills ──────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; display: inline-flex; }
.chips input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chips label > span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 15px;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--sheet);
  color: var(--ink-2); font-size: 0.9375rem; font-weight: 520; line-height: 1.2;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.chips label > span::before {
  content: ""; flex: none; width: 0; height: 16px; margin-right: 0; opacity: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%232445e0' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-6.5'/%3E%3C/svg%3E") center / 16px no-repeat;
  transition: width .15s ease, margin .15s ease, opacity .15s ease;
}
.chips label:hover > span { border-color: var(--ink-3); color: var(--ink); }
.chips input:checked + span { border-color: var(--accent); background: var(--accent-wash); color: var(--ink); font-weight: 620; }
.chips input:checked + span::before { width: 16px; margin-right: 8px; opacity: 1; }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 640px) { .chips label > span { min-height: 44px; } }

/* ─── Submit, success, error ───────────────────────────────── */
.apply-submit { padding: clamp(22px, 3.2vw, 34px); border-top: 1px solid var(--line); background: var(--paper); display: grid; gap: 14px; }
.apply-send { width: 100%; white-space: normal; text-align: center; line-height: 1.25; padding-top: 10px; padding-bottom: 10px; }
.apply-send[aria-busy="true"] { opacity: .7; pointer-events: none; }
.apply-note { font-size: 0.9375rem; color: var(--ink-2); line-height: 1.45; text-wrap: pretty; }
.apply-submit--end { border-top: 1px solid var(--line); }
.apply-submit--main { border-top: 0; background: var(--sheet); padding-top: 14px; }

/* ─── "Add details": everything optional, closed by default ──── */
.more { border-top: 1px solid var(--line-2); background: var(--paper); }
.more > summary {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; cursor: pointer; list-style: none;
  padding: 18px clamp(22px, 3.2vw, 34px); min-height: 64px;
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary:hover .more-title { color: var(--accent); }
.more > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.more-head { display: grid; gap: 2px; flex: 1 1 200px; min-width: 0; }
.more-title { font-size: 1.0625rem; font-weight: 650; letter-spacing: -0.01em; color: var(--ink); }
.more-sub { font-size: 0.875rem; color: var(--ink-3); }
.more-badge {
  font-size: 0.8125rem; font-weight: 600; color: var(--accent); background: var(--accent-wash);
  border: 1px solid var(--accent); border-radius: 999px; padding: 4px 11px; line-height: 1.2;
}
.more-chev { flex: none; width: 20px; height: 20px; color: var(--accent); transition: transform .2s ease; }
.more[open] > summary .more-chev { transform: rotate(180deg); }
.more[open] > summary { border-bottom: 1px solid var(--line); }
.more.nudge > summary { animation: nudge 1.1s var(--ease-out); }
@keyframes nudge { 0%, 100% { background: transparent; } 25% { background: var(--accent-wash); } }
@media (prefers-reduced-motion: reduce) { .more.nudge > summary { animation: none; } .more-chev { transition: none; } }
.more-note { margin: 0; padding: 14px clamp(22px, 3.2vw, 34px) 0; font-size: 0.9375rem; color: var(--ink-2); }
.more-body > .apply-step { border-top: 1px solid var(--line); }
.more-body > .apply-step:first-of-type, .more-body > .more-note + .apply-step { border-top: 0; }
.more-body > .apply-step { background: var(--paper); }
.more-body > .goal-blocks { border-top: 0; }

/* Aside additions */
.apply-example { margin: -8px 0 0; }
.apply-example a { color: var(--accent); font-weight: 600; }
.apply-honest { font-size: 0.9375rem; color: var(--ink-2); line-height: 1.5; text-wrap: pretty; }
.form-consent { font-size: 0.875rem; color: var(--ink-3); line-height: 1.45; text-wrap: pretty; }
.form-consent a { color: var(--accent); }

.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.form-success { display: grid; gap: 8px; justify-items: start; padding: clamp(28px, 5vw, 52px); color: var(--ink-2); }
/* The approval stamp: lands once, when the sheet has really been received */
.rcv {
  display: inline-grid; gap: 3px; margin: 6px 0 16px 4px; padding: 10px 18px 9px;
  border: 3px solid var(--accent); border-radius: 8px; outline: 1px solid var(--accent); outline-offset: -7px;
  color: var(--accent); transform: rotate(-6deg); transform-origin: 30% 50%;
}
.rcv b { font: 800 1.5rem/1 var(--font); font-stretch: 112%; letter-spacing: -0.01em; text-transform: uppercase; }
.rcv i { font: 500 0.6875rem/1.2 var(--mono); font-style: normal; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.rcv i:empty { display: none; }
.rcv.is-landed { animation: rcv-land 560ms var(--ease-stamp, cubic-bezier(0.3, 1.45, 0.6, 1)) both; }
@keyframes rcv-land { from { opacity: 0; transform: rotate(-6deg) scale(1.7); } 12% { opacity: 1; } to { opacity: 1; transform: rotate(-6deg) scale(1); } }
@media (prefers-reduced-motion: reduce) { .rcv.is-landed { animation: none; } }
.form-success strong { font-size: var(--step-2); font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.form-error { margin: 0; display: grid; gap: 12px; justify-items: start; padding: 16px clamp(22px, 3.2vw, 34px); background: var(--warn-wash); color: var(--ink); border-top: 1px solid var(--line); font-size: 0.9375rem; }
.form-error a { color: var(--warn); font-weight: 600; }
.chips label > span [lang] { font-weight: 500; }

/* Phones: the Send button must come early */
@media (max-width: 960px) {
  .apply-intro { gap: 14px; }
  .apply-dim { margin-bottom: 6px; white-space: normal; text-align: center; }
}
@media (max-width: 640px) {
  .apply-person { display: none; }
  .apply-intro { gap: 12px; }
  .apply-main { padding-top: 20px; }
  .apply-step { padding: 18px 18px; }
  .apply-form .essentials { padding-top: 6px; padding-bottom: 4px; }
  .essentials > .fld, .essentials > .row, .essentials > .q, .essentials > .sample-slot { margin-top: 14px; }
  .essentials > .row { gap: 14px; }
  .essentials .q-label { margin-bottom: 8px; }
  .apply-form .essentials .field input { min-height: 46px; }
  .apply-note, .form-consent { font-size: 0.8125rem; }
  .apply-form .essentials .chips { gap: 6px; }
  .apply-form .essentials .chips label > span { min-height: 40px; padding: 0 12px; font-size: 0.875rem; }
  .apply-form .essentials .field textarea { min-height: 84px; }
  .apply-submit { padding: 16px 18px 18px; }
  .more > summary { padding: 16px 18px; }
}

/* ─── Plan view: the drawn-in icons and placeholders switch pens with the sheet ─── */
.plan-view .apply-form .field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23f5f8ff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
}
.plan-view .chips label > span::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a5e4ff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-6.5'/%3E%3C/svg%3E");
}
.plan-view .apply-form ::placeholder { color: var(--ink-3); }
.plan-view .apply-send { --b-fg: #0c2263; }
