/* The focused pages: contact, the sent page and client login.
   One task per screen, a quiet ink panel beside it, and motion that shows where things went. */

:root {
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --alert: #B4412F;
  --field: 0.75rem;
}

/* Moving between these pages, the ink panel stays where it is and the rest changes around it. */
@view-transition { navigation: auto; }
::view-transition-group(flow-panel) { animation-duration: 0.7s; animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.35s; }

.flow { background: var(--paper); }
.flow-shell { display: grid; grid-template-columns: minmax(20rem, 38%) minmax(0, 1fr); min-height: 100vh; min-height: 100svh; }

/* The ink panel */
.flow-panel {
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden;
  display: flex; flex-direction: column; padding: 1.5rem clamp(1.5rem, 3vw, 3rem);
  background: var(--ink); color: var(--paper); view-transition-name: flow-panel;
}
.flow-logo { position: relative; z-index: 1; align-self: flex-start; }
.flow-logo img { height: 1.75rem; width: auto; }
.flow-panel .hero-copy { position: relative; z-index: 1; margin-top: clamp(3rem, 15vh, 8.5rem); transition: opacity 0.3s ease, transform 0.6s var(--spring); }
.flow-panel .hero-copy.swap { opacity: 0; transform: translate3d(0, 0.5rem, 0); }
.flow-panel h1 { font-size: clamp(2.25rem, 3.5vw, 3.75rem); line-height: 1; letter-spacing: -0.045em; font-weight: 600; max-width: 9em; }
.flow-panel .hero-copy p { margin-top: 1rem; max-width: 22em; color: var(--fog); font-size: 1.0625rem; line-height: 1.5; }

/* The working side */
.flow-main { position: relative; display: flex; flex-direction: column; min-height: 100vh; min-height: 100svh; padding: 1.5rem clamp(1.25rem, 6vw, 6.5rem) 2.5rem; }
.flow-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 2.5rem; font-size: 0.875rem; }
.flow-top a { color: var(--granite); text-decoration: none; font-weight: 500; transition: color 0.2s ease; }
.flow-top a:hover { color: var(--ink); }
.flow-back {
  display: inline-flex; align-items: center; gap: 0.375rem; margin-left: -0.5rem; padding: 0.5rem 0.75rem 0.5rem 0.5rem;
  background: none; border: 0; border-radius: 0.5rem; color: var(--granite); font-weight: 500; font-size: 0.875rem; cursor: pointer;
  transition: color 0.2s ease, opacity 0.3s ease, transform 0.5s var(--spring);
}
.flow-back:hover { color: var(--ink); }
.flow-back svg { width: 1rem; height: 1rem; transform: rotate(180deg); }
.flow-back[hidden] { display: inline-flex; opacity: 0; pointer-events: none; transform: translate3d(0.5rem, 0, 0); }
.flow-progress { height: 2px; margin-top: 0.75rem; background: var(--mist); border-radius: 1px; overflow: hidden; }
.flow-progress span { display: block; height: 100%; background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform 0.9s var(--spring); }
.flow-count { min-height: 1.25rem; margin-top: 0.625rem; color: var(--granite); font-size: 0.8125rem; }

.steps { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: clamp(1.5rem, 5vh, 3.5rem) 0; }
.step { width: 100%; max-width: 35rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.js .step[hidden] { display: none; }
html:not(.js) .step { margin-bottom: 3rem; }
.step h2 { font-size: clamp(1.75rem, 2.5vw, 2.5rem); line-height: 1.08; letter-spacing: -0.04em; font-weight: 600; outline: none; }
.step .hint { margin-top: 0.625rem; max-width: 30em; color: var(--granite); }
.step h3 { margin: 1.75rem 0 0.625rem; font-size: 0.9375rem; font-weight: 600; }
.step-body { margin-top: 1.75rem; }

/* One step leaves, the next arrives from the side you are heading towards. */
.step.leave { animation: step-out 0.2s ease both; }
.step.enter { animation: step-in 0.65s var(--spring) both; }
.step.enter.back { animation-name: step-in-back; }
.step.enter .choices > *, .step.enter .chips > *, .step.enter .field, .step.enter .row2, .step.enter .actions-row {
  animation: rise 0.65s var(--spring) both; animation-delay: calc(var(--n, 0) * 45ms + 90ms);
}
.choices > :nth-child(2), .chips > :nth-child(2) { --n: 1; }
.choices > :nth-child(3), .chips > :nth-child(3) { --n: 2; }
.choices > :nth-child(4), .chips > :nth-child(4) { --n: 3; }
.choices > :nth-child(5), .chips > :nth-child(5) { --n: 4; }
.choices > :nth-child(6), .chips > :nth-child(6) { --n: 5; }
.choices > :nth-child(n + 7), .chips > :nth-child(n + 7) { --n: 6; }
.step .actions-row { --n: 6; }
@keyframes step-out { to { opacity: 0; transform: translate3d(-0.75rem, 0, 0); } }
@keyframes step-in { from { opacity: 0; transform: translate3d(1.75rem, 0, 0); } }
@keyframes step-in-back { from { opacity: 0; transform: translate3d(-1.75rem, 0, 0); } }
@keyframes rise { from { opacity: 0; transform: translate3d(0, 0.75rem, 0); } }

/* Choices: one tap answers the question */
.choices { display: grid; gap: 0.625rem; }
.choices.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choices.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice .card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.125rem 1rem; height: 100%;
  padding: 0.9375rem 1.125rem; background: var(--white); border: 1px solid var(--mist); border-radius: 0.875rem;
  transition: border-color 0.2s ease, box-shadow 0.3s ease, transform 0.4s var(--spring);
}
.choice .card b { font-weight: 600; letter-spacing: -0.01em; }
.choice .card small { grid-column: 1; color: var(--granite); font-size: 0.875rem; line-height: 1.4; }
.choice .tick { grid-column: 2; grid-row: 1 / span 2; display: grid; place-items: center; width: 1.375rem; height: 1.375rem; border: 1px solid var(--mist); border-radius: 50%; transition: border-color 0.2s ease; }
.choice .tick::after { content: ""; width: 0.625rem; height: 0.625rem; border-radius: 50%; background: var(--ink); transform: scale(0); transition: transform 0.45s var(--spring); }
.choice:hover .card { border-color: var(--fog); box-shadow: 0 0.625rem 1.5rem -1.125rem rgba(15, 28, 34, 0.45); transform: translate3d(0, -1px, 0); }
.choice:active .card { transform: scale(0.985); }
.choice input:checked + .card { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.choice input:checked + .card .tick { border-color: var(--ink); }
.choice input:checked + .card .tick::after { transform: scale(1); }
.choice input:focus-visible + .card { outline: 3px solid var(--lichen); outline-offset: 2px; }

.choice.big .card { grid-template-columns: minmax(0, 1fr); align-content: space-between; gap: 2.5rem; min-height: 12.5rem; padding: 1.375rem; border-radius: 1.125rem; }
.choice.big .card b { display: block; font-size: 1.375rem; line-height: 1.15; letter-spacing: -0.03em; }
.choice.big .card small { display: block; margin-top: 0.5rem; font-size: 0.9375rem; }
.choice.big .go-mark { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--ink); color: var(--paper); transition: background-color 0.25s ease, transform 0.5s var(--spring); }
.choice.big .go-mark svg { width: 1rem; height: 1rem; }
.choice.big:hover .go-mark { background: var(--sea); transform: translate3d(0.25rem, 0, 0); }
.choice.compact .card { padding: 0.75rem 0.875rem; text-align: center; grid-template-columns: minmax(0, 1fr); }
.choice.compact .tick { display: none; }
.choice.quiet .card { background: transparent; }
.aside-label { margin: 1.25rem 0 0.625rem; color: var(--granite); font-size: 0.8125rem; font-weight: 600; }

/* Chips: choose several */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 1.125rem; background: var(--white); border: 1px solid var(--mist); border-radius: 999px; font-weight: 500; font-size: 0.9375rem; transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.4s var(--spring); }
.chip:hover span { border-color: var(--fog); }
.chip:active span { transform: scale(0.96); }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip input:focus-visible + span { outline: 3px solid var(--lichen); outline-offset: 2px; }

/* Fields: the label starts inside and moves up out of the way */
.field { position: relative; display: block; margin-top: 0.75rem; }
.field input, .field textarea {
  width: 100%; padding: 1.5rem 1rem 0.5rem; background: var(--white); border: 1px solid var(--mist); border-radius: var(--field);
  font-size: 1rem; line-height: 1.4; outline: none; -webkit-appearance: none; appearance: none;
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
}
.field textarea { display: block; min-height: 8.5rem; padding-top: 1.625rem; resize: vertical; }
.field label { position: absolute; left: 1rem; top: 1rem; color: var(--granite); pointer-events: none; transform-origin: left top; transition: transform 0.4s var(--spring); }
.field input:focus, .field textarea:focus { border-color: var(--sea); box-shadow: 0 0 0 0.25rem rgba(44, 107, 120, 0.16); }
.field input:focus + label, .field input:not(:placeholder-shown) + label, .field input:-webkit-autofill + label,
.field textarea:focus + label, .field textarea:not(:placeholder-shown) + label { transform: translate3d(0, -0.5625rem, 0) scale(0.78); }
.field.bad input, .field.bad textarea { border-color: var(--alert); }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.row2 .field { margin-top: 0; }
.row2 { margin-top: 0.75rem; }
.field[hidden] { display: none; }
.chips.tight { margin-top: 0.75rem; }

.reveal { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 0.65s var(--spring), opacity 0.4s ease; }
.reveal > div { min-height: 0; overflow: hidden; padding: 0 0.25rem; margin: 0 -0.25rem; }
.reveal.open { grid-template-rows: 1fr; opacity: 1; }
.reveal.open > div { padding-bottom: 0.25rem; overflow: visible; }
html:not(.js) .reveal { grid-template-rows: 1fr; opacity: 1; }

.error { min-height: 1.4em; margin-top: 0.875rem; color: var(--alert); font-size: 0.9375rem; font-weight: 500; }
.hp { position: absolute; left: -200vw; width: 1px; height: 1px; overflow: hidden; }

/* The one button that moves things on */
.go {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.625rem;
  min-height: 3.25rem; padding: 0 1.625rem; background: var(--ink); color: var(--paper); border: 0; border-radius: var(--field);
  font-weight: 600; font-size: 1rem; text-decoration: none; cursor: pointer;
  transition: background-color 0.25s ease, transform 0.4s var(--spring);
}
.go:hover { background: var(--sea); }
.go:active { transform: scale(0.98); }
.go svg { width: 1rem; height: 1rem; transition: transform 0.45s var(--spring); }
.go:hover svg { transform: translate3d(0.25rem, 0, 0); }
.go.wide { width: 100%; }
.go.light { background: var(--paper); color: var(--ink); }
.go.light:hover { background: var(--white); }
.go[aria-busy="true"] { pointer-events: none; }
.go[aria-busy="true"] > * { visibility: hidden; }
.go[aria-busy="true"]::after { content: ""; position: absolute; width: 1.125rem; height: 1.125rem; border: 2px solid rgba(244, 242, 237, 0.3); border-top-color: var(--paper); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; margin-top: 1.5rem; }
.quiet-link { background: none; border: 0; padding: 0; color: var(--granite); font-weight: 500; font-size: 0.9375rem; text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; transition: color 0.2s ease; }
.quiet-link:hover { color: var(--ink); }
.below { margin-top: 1.75rem; color: var(--granite); font-size: 0.9375rem; }
.below a { color: var(--ink); font-weight: 500; text-underline-offset: 0.2em; }

.recap { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem 0.75rem; margin-bottom: 1.25rem; padding: 0.75rem 1rem; background: #EBE8E0; border-radius: var(--field); color: var(--slate); font-size: 0.875rem; }
.recap span { flex: 1; min-width: 12rem; }
.notice { margin-top: 1rem; padding: 0.875rem 1rem; background: #EBE8E0; border-radius: var(--field); color: var(--slate); font-size: 0.9375rem; }
.notice[hidden] { display: none; }

/* Client login */
.login { max-width: 24rem; }
.login .field:first-of-type { margin-top: 0; }
.login .email input { padding-right: 3.75rem; }
.login .peek { position: absolute; right: 0.5rem; top: 0.5rem; height: 2.375rem; padding: 0 0.75rem; background: none; border: 0; border-radius: 0.5rem; color: var(--granite); font-size: 0.8125rem; font-weight: 600; cursor: pointer; }
.login .peek:hover { color: var(--ink); }
.login .keep { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.875rem; font-size: 0.9375rem; }
.login .keep label { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.login .keep input { width: 1.0625rem; height: 1.0625rem; accent-color: var(--ink); }
.login .keep a { color: var(--granite); text-underline-offset: 0.2em; }
.login .keep a:hover { color: var(--ink); }
.login .go { margin-top: 1.25rem; }
.caps { margin-top: 0.5rem; color: var(--granite); font-size: 0.8125rem; }
.caps[hidden] { display: none; }

/* The sent page: the ink panel opens out to fill the screen */
.sent { position: relative; min-height: 100vh; min-height: 100svh; overflow: hidden; display: flex; flex-direction: column; padding: 1.5rem 0 0; background: var(--ink); color: var(--paper); view-transition-name: flow-panel; }
.js .sent:not(.ready) .hero-copy { visibility: hidden; }
.sent .wrap { position: relative; z-index: 1; width: 100%; }
.sent .wrap { padding-bottom: clamp(12rem, 30vh, 20rem); }
.sent .hero-copy { margin-top: clamp(2rem, 8vh, 5rem); max-width: 46rem; }
.sent h1 { font-size: clamp(2.5rem, min(5.2vw, 10vh), 5rem); line-height: 0.98; letter-spacing: -0.05em; font-weight: 600; margin-top: 1.75rem; }
.sent .lede { margin-top: 1.25rem; max-width: 30em; color: var(--fog); font-size: clamp(1.0625rem, 1.25vw, 1.25rem); line-height: 1.5; }
.sent .lede b { color: var(--paper); font-weight: 500; }
.sent [data-kind] { display: none; }
.sent[data-kind="message"] [data-kind="message"], .sent[data-kind="call"] [data-kind="call"] { display: revert; }
.next { margin-top: 2.25rem; border-top: 1px solid var(--line-dark); counter-reset: next; max-width: 30rem; }
.next li { counter-increment: next; display: grid; grid-template-columns: 2rem minmax(0, 1fr); padding: 0.75rem 0; border-bottom: 1px solid var(--line-dark); font-size: 0.9375rem; }
.next li::before { content: counter(next); color: var(--lichen); font-weight: 600; }
.sent .actions-row { margin-top: 2rem; }
.sent .quiet-link { color: var(--fog); }
.sent .quiet-link:hover { color: var(--paper); }

.done-mark { width: 4rem; height: 4rem; overflow: visible; }
.done-mark circle, .done-mark path { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.done-mark circle { stroke: var(--lichen); transform: rotate(-90deg); transform-origin: center; }
.done-mark path { stroke: var(--paper); }
.sent.ready .done-mark { animation: settle 0.7s var(--spring) 0.95s both; }
.sent.ready .done-mark circle { animation: draw 0.9s var(--spring) 0.15s forwards; }
.sent.ready .done-mark path { animation: draw 0.5s var(--spring) 0.75s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes settle { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }

@media (max-width: 899px) {
  .flow-shell { grid-template-columns: minmax(0, 1fr); }
  .flow-panel { position: relative; height: auto; padding: 1.125rem 1.25rem 9.5rem; }
  .flow-logo img { height: 1.5rem; }
  .flow-panel .hero-copy { margin-top: 2rem; }
  .flow-panel h1 { font-size: 2rem; }
  .flow-panel .hero-copy p { font-size: 1rem; }
  .flow-main { min-height: 0; padding-top: 1rem; }
  .steps { justify-content: flex-start; padding-top: 1.75rem; }
  .choices.two { grid-template-columns: minmax(0, 1fr); }
  .choice.big .card { min-height: 0; gap: 1.25rem; }
  .row2 { grid-template-columns: minmax(0, 1fr); }
  .go { width: 100%; }
  .sent .wrap { padding-bottom: 11rem; }
}

@media (prefers-reduced-motion: reduce) {
  .step.enter, .step.leave, .step.enter *, .sent.ready .done-mark { animation: none !important; }
  .done-mark circle, .done-mark path { stroke-dashoffset: 0; animation: none !important; }
}
