/* =====================================================================
   Directline — motion layer + verified fixes
   Loaded after styles.css. styles.css is the approved design baseline and
   is left untouched; everything here is either motion or a documented fix.

   Rules of this file
   - Hidden "from" states only exist under html.motion-ok (set by an inline
     head script when the visitor does NOT prefer reduced motion).
   - Animations use the individual `translate` / `rotate` / `scale`
     properties, so they compose with the `transform` values that hold the
     approved tilts in styles.css instead of overwriting them.
   ===================================================================== */

:root {
  --motion-fast: 160ms;
  --motion-ui: 240ms;
  --motion-panel: 360ms;
  --motion-reveal: 650ms;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-ui: cubic-bezier(.2, .65, .3, 1);
  --reveal-y: 16px;
}

/* ---------- Fix: scroll lock without horizontal jump ------------------
   keeps the scrollbar's space only while a dialog locks scrolling */
html:has(> body.modal-open) { scrollbar-gutter: stable; }

/* shared keyframes */
@keyframes dl-rise { from { opacity: 0; translate: 0 var(--rise, 16px); } }
@keyframes dl-fade { from { opacity: 0; } }

/* ---------- Header (entrance lives in hero.css) --------------------- */

.header nav a { transition: color var(--motion-fast) var(--ease-ui); }

/* hamburger → close icon */
.menu-button span { transition: translate var(--motion-ui) var(--ease-ui), rotate var(--motion-ui) var(--ease-ui); }
.menu-button[aria-expanded="true"] span:first-child { translate: 0 4.5px; rotate: 45deg; }
.menu-button[aria-expanded="true"] span:last-child { translate: 0 -4.5px; rotate: -45deg; }

@media (max-width: 800px) {
  .motion-ok .header nav {
    transition: opacity var(--motion-ui) var(--ease-out), translate var(--motion-ui) var(--ease-out);
  }
  @starting-style { .motion-ok .header nav.open { opacity: 0; translate: 0 -6px; } }
}

/* ---------- Section reveals (class added by JS only below the fold) ---- */
.motion-ok .reveal { opacity: 0; translate: 0 var(--reveal-y); }
.motion-ok .reveal.is-in {
  opacity: 1; translate: 0 0;
  transition: opacity var(--motion-reveal) var(--ease-out) var(--d, 0ms),
              translate var(--motion-reveal) var(--ease-out) var(--d, 0ms);
}

/* process: short line draw + dot, once */
.process.draw article { border-top-color: transparent; }
.process.draw article::after {
  content: ''; position: absolute; top: -1px; right: 0; left: 0; height: 1px;
  background: #ccc1d6; transform: scaleX(0); transform-origin: right;
}
.process.draw article::before { scale: 0; }
.process.draw.is-in article::after {
  transform: scaleX(1);
  transition: transform 600ms var(--ease-out) var(--d, 0ms);
}
.process.draw.is-in article::before {
  scale: 1;
  transition: scale 300ms var(--ease-out) calc(var(--d, 0ms) + 380ms);
}

/* closing artwork: slow, small entrance; text stays put */
.closing.art-pending .closing-orbit { opacity: 0; rotate: -7deg; scale: .95; }
.closing.art-pending .closing-arrow { opacity: 0; translate: 26px 26px; }
.closing .closing-orbit, .closing .closing-arrow {
  transition: opacity 1100ms var(--ease-out), rotate 1400ms var(--ease-out),
              scale 1400ms var(--ease-out), translate 1200ms var(--ease-out) 150ms;
}

/* ---------- Buttons & links ---------------------------------------- */
.button {
  transition: transform var(--motion-fast) var(--ease-ui),
              background-color var(--motion-fast) var(--ease-ui),
              box-shadow var(--motion-ui) var(--ease-ui);
}
.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(0); transition-duration: 80ms; }
.button > span, .text-link > span { transition: translate var(--motion-fast) var(--ease-ui); }
.text-link:hover span { transform: none; }
@media (hover: hover) {
  :is(.button, .text-link, .hero-bottom a):hover > [data-arrow="ul"] { translate: -3px -2px; }
  :is(.button, .text-link, .hero-bottom a):hover > [data-arrow="ur"] { translate: 3px -2px; }
  :is(.button, .text-link, .hero-bottom a):hover > [data-arrow="dl"] { translate: -3px 2px; }
  :is(.button, .text-link, .hero-bottom a):hover > [data-arrow="l"]  { translate: -4px 0; }
  :is(.button, .text-link, .hero-bottom a):hover > [data-arrow="d"]  { translate: 0 3px; }
}
.hero-bottom a > span { transition: translate var(--motion-fast) var(--ease-ui); }

/* ---------- Goal tabs ---------------------------------------------- */
.goal-tabs { position: relative; }
.goal-tabs button { transition: color var(--motion-fast) var(--ease-ui); }
.goal-tabs button:hover { color: var(--ink); }
.tab-arrow { transition: opacity var(--motion-ui) var(--ease-ui), translate var(--motion-ui) var(--ease-ui); translate: 4px 0; }
.goal-tabs button[aria-selected=true] .tab-arrow { translate: 0 0; }
.goal-tabs.has-ink button[aria-selected=true] { border-bottom-color: transparent; }
.tab-ink {
  position: absolute; left: 0; top: 0; height: 2px; background: var(--purple);
  width: var(--ink-w, 0); translate: var(--ink-x, 0) var(--ink-y, 0);
  pointer-events: none;
}
.tab-ink.animate { transition: translate 280ms var(--ease-ui), width 280ms var(--ease-ui); }

/* ---------- Work ---------------------------------------------------- */
.work-card { transition: transform 320ms var(--ease-out); }
.work-card:hover, .work-card:focus-visible { transform: translateY(-4px); }
.work-image > img { transition: transform 420ms var(--ease-out), opacity 450ms var(--ease-out); }
.work-card:hover .work-image > img, .work-card:focus-visible .work-image > img { transform: scale(1.03); }
.view-work { transition: opacity var(--motion-ui) var(--ease-ui), transform var(--motion-ui) var(--ease-ui); }
.motion-ok img.img-pending { opacity: 0; }

/* ---------- Accordions (height animated by JS) ---------------------- */
.plus, .faq-list summary span { transition: transform var(--motion-ui) var(--ease-ui), color var(--motion-ui) var(--ease-ui); }
.service-list summary, .faq-list summary { transition: color var(--motion-fast) var(--ease-ui); }
.service-list summary:hover h3, .faq-list summary:hover { color: var(--purple); }

/* ---------- Dialogs ------------------------------------------------- */
.motion-ok .request-dialog, .motion-ok .project-dialog {
  opacity: 0; scale: .98;
  transition: opacity 180ms var(--ease-ui), scale 180ms var(--ease-ui),
              overlay 180ms allow-discrete, display 180ms allow-discrete;
}
.motion-ok .request-dialog[open], .motion-ok .project-dialog[open] {
  opacity: 1; scale: 1;
  transition-duration: 260ms; transition-timing-function: var(--ease-out);
}
@starting-style {
  .motion-ok .request-dialog[open], .motion-ok .project-dialog[open] { opacity: 0; scale: .98; }
}
.motion-ok .request-dialog::backdrop, .motion-ok .project-dialog::backdrop {
  opacity: 0;
  transition: opacity 220ms var(--ease-ui), overlay 220ms allow-discrete, display 220ms allow-discrete;
}
.motion-ok .request-dialog[open]::backdrop, .motion-ok .project-dialog[open]::backdrop { opacity: 1; }
@starting-style {
  .motion-ok .request-dialog[open]::backdrop, .motion-ok .project-dialog[open]::backdrop { opacity: 0; }
}
dialog:not([open]) { pointer-events: none; }
.motion-ok dialog.no-exit, .motion-ok dialog.no-exit::backdrop { transition: none; }

.close-dialog { transition: background-color var(--motion-fast) var(--ease-ui), rotate var(--motion-ui) var(--ease-ui); }
.close-dialog:hover { background: #ded3e8; rotate: 90deg; }

/* wizard */
.wizard-progress span { transition: color var(--motion-ui) var(--ease-ui); }
.wizard-progress i { position: relative; overflow: hidden; }
.wizard-progress i::after {
  content: ''; position: absolute; inset: 0; background: var(--purple);
  transform: scaleX(0); transform-origin: right;
  transition: transform var(--motion-panel) var(--ease-out);
}
.wizard-progress i.done::after { transform: scaleX(1); }
.service-choices label > span { transition: background-color var(--motion-fast) var(--ease-ui), border-color var(--motion-fast) var(--ease-ui); }
.service-choices label:hover > span { border-color: #b9a6c9; }
.field input, .field select, .field textarea { transition: border-color var(--motion-fast) var(--ease-ui), box-shadow var(--motion-fast) var(--ease-ui); }

/* inline validation (fix: errors next to the field, input kept) */
.field-error { display: block; margin-top: 7px; font-size: 12px; font-weight: 500; color: #a0283f; line-height: 1.6; }
.motion-ok .field-error { animation: dl-rise 200ms var(--ease-out) both; --rise: -4px; }
[aria-invalid="true"] { border-color: #b3374f !important; box-shadow: 0 0 0 2px #b3374f1f !important; }
.service-choices[data-invalid] label > span { border-color: #c98a97; }

.copy-busy { opacity: .7; pointer-events: none; }
.toast { transition: opacity var(--motion-ui) var(--ease-ui), transform var(--motion-ui) var(--ease-out); }

/* ---------- Fix: contrast of small text (same hues, minimally darker) --
   measured against each section background; all now ≥ 4.5:1
   (≥ 3:1 for the 43px muted headline). */
.floating-note small { color: #736872; }
.principles > .container { color: #776d82; }
.section-head > p { color: #71667a; }
.goal-tabs button { color: #796d83; }
.goal-main > p { color: #72657d; }
.detail-top { color: #6e617a; }
#goal-items > div > span { color: #6d6177; }
#goal-items small { color: #6e6077; }
.work-section .muted { color: #8f8199; }
.work-caption small { color: #716579; }
.work-caption h3 span { color: #716678; }
.service-number { color: #766d7c; }
.service-en { color: #796c82; }
.service-body p { color: #796c81; }
.about-copy > p:nth-child(2) { color: #796c81; }
.service-tags span { color: #756184; }
.process article > span { color: #786c80; }
.process p { color: #786d7f; }
.faq-list p { color: #7b6c83; }
.footer-bottom { color: #8d7a9b; }
.wizard-sub { color: #7a6c83; }
.optional { color: #776d7e; }
.wizard-progress { color: #776e7d; }
.request-summary span { color: #736380; }
.summary-note { color: #7b6a86; }
.project-description p { color: #7a6c82; }

/* accordion: marker returns as soon as a panel starts closing */
.service-list details[open][data-closing] .plus { transform: none; color: inherit; }
.faq-list details[open][data-closing] summary span { transform: none; }

/* ---------- Fix: wizard footer wrapped into 3 lines at ≤360px ---------- */
@media (max-width: 400px) {
  .wizard-bottom { gap: 14px; }
  .wizard-bottom .button { gap: 14px; padding-inline: 16px; white-space: nowrap; }
  .wizard-bottom .text-link { white-space: nowrap; }
}
