/* ==========================================================================
   Home 05 — "How I Work"
   Markup: resources/views/components/process/*.blade.php · Copy: config/process_section.php

   Phones: head → photo → CTA card (over the photo's edge) → accordion steps → strip.
   768+:   steps 2 × 2, all open. 1024+: copy left, photo right, then the four steps as
           one connected row that rises over the photo's lower edge.
   Motion: transform/opacity (plus the accordion's row height); reduced motion is
   handled in base.css. Each group enters differently — copy fades up, the photo
   settles, the connector draws, the cards stagger.
   ========================================================================== */

/* Same display serif as section 06 (declared there too — one file, one download);
   an 11 KB subset (A–Z a–z 0–9 & ' ’ - . , : +). */
@font-face {
  font-family: "Newsreader Display";
  src: url("../fonts/newsreader-display-600-subset.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

.hiw {
  --hiw-pad: calc(var(--hdr-inset) + var(--hdr-pad)); /* same content edge as the header */
  --hiw-serif: "Newsreader Display", Georgia, "Times New Roman", serif;
  --hiw-halo: 0 0 6px var(--warm-50), 0 0 14px var(--warm-50), 0 0 24px var(--warm-50);
  --hiw-card-shadow: 0 14px 30px -22px rgb(15 23 42 / 0.30), 0 1px 2px rgb(15 23 42 / 0.05);

  overflow-x: clip; /* the photo reaches into the page margin */
  background: var(--warm-50);
  border-top: 1px solid var(--color-border);
  padding-block: clamp(56px, 7vw, 104px) clamp(44px, 5vw, 72px);
  scroll-margin-top: var(--bar-h);
}

.hiw__wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "head" "media" "cta" "steps" "strip";
  max-width: var(--hdr-max);
  margin-inline: auto;
  padding-inline: var(--hiw-pad);
}
.hiw__head  { grid-area: head; }
.hiw-media  { grid-area: media; }
.hiw__cta   { grid-area: cta; }
.hiw__steps { grid-area: steps; }
.hiw-strip  { grid-area: strip; }

/* ---- Head ---------------------------------------------------------------- */

.hiw__title {
  margin: 16px 0 0;
  color: var(--ink-900);
  font-family: var(--hiw-serif);
  font-size: clamp(2.25rem, 1.35rem + 3vw, 3.75rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.hiw__mark {
  position: relative;
  display: inline-block;
  white-space: nowrap;
}
.hiw__underline {
  position: absolute;
  left: -2%;
  bottom: -0.2em;
  width: 104%;
  height: auto;
  overflow: visible;
  color: var(--color-primary);
  pointer-events: none;
}
.hiw__underline path {
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
}
/* Drawn once when the head scrolls in (reveal.js); otherwise simply there. */
.hiw__head.reveal .hiw__underline path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.hiw__head.reveal.is-in .hiw__underline path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 800ms var(--ease-out) 380ms;
}

.hiw__intro {
  max-width: 32rem;
  margin-top: 22px;
  color: var(--ink-900);
  font-size: clamp(1.125rem, 1.05rem + 0.3vw, 1.3125rem);
  line-height: 1.5;
}
.hiw__aside {
  max-width: 30rem;
  margin-top: 14px;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.6;
}

/* ---- Photo + handwritten notes ------------------------------------------- */

.hiw-media {
  position: relative;
  margin: 26px 0 0;
}
.hiw-media picture { display: block; }
.hiw-media__img {
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 4;
  object-fit: cover;
  object-position: 50% 28%;
  border-radius: var(--r-xl);
  -webkit-mask-image: linear-gradient(to bottom, #000 76%, transparent);
  mask-image: linear-gradient(to bottom, #000 76%, transparent);
}
.hiw-media.reveal { transform: scale(0.97); }
.hiw-media.reveal.is-in { transition: opacity 700ms var(--ease-out), transform 900ms var(--ease-out); }

.hiw-note {
  position: absolute;
  z-index: 1;
  display: grid;
  justify-items: start;
  margin: 0;
  color: var(--ink-900);
  font-family: var(--font-hand);
  font-size: clamp(1.0625rem, 0.9rem + 0.6vw, 1.375rem);
  line-height: 1.1;
  text-shadow: var(--hiw-halo); /* lifts the note off the photo like ink on a print */
  pointer-events: none;
}
.hiw-note__arrow {
  width: 34px;
  height: auto;
  margin-top: 4px;
  fill: none;
  stroke: var(--slate-600);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hiw-note--left  { top: 5%; left: -1%; transform: rotate(-8deg); }
.hiw-note--right { top: 4%; right: 4%; justify-items: end; transform: rotate(-5deg); }
.hiw-note--right .hiw-note__arrow { transform: scaleX(-1); }

/* ---- CTA ------------------------------------------------------------------ */
/* The site's one CTA style (.btn-call, header.css), sized for a section. */

.hiw__cta {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 12px;
  margin: -64px 12px 0;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  background: var(--paper);
  box-shadow: var(--shadow-panel);
}
.hiw__btn {
  width: 100%;
  height: 52px;
  padding-inline: 24px;
  font-size: 1rem;
}
.hiw__btn .btn-call__arrow { display: block; }
.hiw__cta-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--color-text-muted);
  font-size: 1rem; /* 16px floor on phones; a step smaller from 768px */
}

/* ---- Steps ---------------------------------------------------------------- */

.hiw__steps {
  position: relative;
  margin-top: 24px;
}
.hiw__line { display: none; }

.hiw-steps {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0; /* an <ol>: base.css only resets ul[role=list] */
}

.hiw-step {
  position: relative;
  display: flex;
  flex-direction: column;
}
.hiw-step__card {
  flex: 1;
  padding: 22px 22px 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  background: var(--paper);
  box-shadow: var(--hiw-card-shadow);
  transition: transform 280ms var(--ease-out), border-color 280ms var(--ease-out), box-shadow 280ms var(--ease-out);
}

.hiw-step__head {
  position: relative;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas: "num icon" "text text";
  justify-content: start;
  align-items: center;
  gap: 18px 20px;
}
.hiw-step__num {
  grid-area: num;
  min-width: 2ch;
  color: var(--ink-900);
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.hiw-step__icon {
  grid-area: icon;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 46% 54% 50% 50% / 52% 46% 54% 48%; /* a hand-washed blob, not a perfect circle */
  background: var(--tone-bg);
  color: var(--tone-mark);
  transition: transform 280ms var(--ease-out);
}
.hiw-step__text { grid-area: text; }
.hiw-step__title {
  margin: 0;
  color: var(--ink-900);
  font-family: var(--hiw-serif);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.1;
}
.hiw-step__lede {
  margin-top: 6px;
  color: var(--slate-700);
  font-size: 1rem;
  line-height: 1.45;
}
.hiw-step__toggle { display: none; }

/* Grid-row trick: the list's height animates between 0fr and 1fr. */
.hiw-step__panel {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 320ms var(--ease-out), opacity 260ms var(--ease-out);
}
.hiw-step__inner {
  min-height: 0;
  overflow: hidden;
}
.hiw-step__list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  color: var(--slate-700);
  font-size: 1rem;
  line-height: 1.4;
}
.hiw-step__list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.hiw-step__list .icon {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--color-primary);
}

.hiw-step__next { display: none; }

@media (hover: hover) {
  .hiw-step:hover .hiw-step__card {
    transform: translateY(-5px);
    border-color: color-mix(in srgb, var(--color-primary) 45%, var(--color-border));
    box-shadow: var(--shadow-panel);
  }
  .hiw-step:hover .hiw-step__icon { transform: scale(1.06); }
}

/* ---- Strip ---------------------------------------------------------------- */

.hiw-strip {
  display: grid;
  gap: 16px;
  margin-top: 24px;
  padding: 18px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  background: var(--paper);
}
.hiw-strip__item {
  display: flex;
  align-items: center;
  gap: 14px;
}
.hiw-strip__icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.hiw-strip__item p {
  display: grid;
  gap: 2px;
  margin: 0;
}
.hiw-strip__title { color: var(--ink-900); font-size: 1rem; font-weight: 700; }
.hiw-strip__text  { color: var(--color-text-muted); font-size: 1rem; line-height: 1.45; }

/* ---- Phones: compact accordion cards ---------------------------------------- */

@media (max-width: 767.98px) {
  .hiw__aside { display: none; }
  .hiw-note--wide { display: none; }

  .hiw-step__card { padding: 14px 16px; }
  .hiw-step__head {
    grid-template-columns: auto auto minmax(0, 1fr) 24px;
    grid-template-areas: "num icon text .";
    gap: 0 12px;
    min-height: 52px;
  }
  .hiw-step__num { font-size: 1.125rem; }
  .hiw-step__icon { width: 46px; height: 46px; }
  .hiw-step__icon .icon { width: 22px; height: 22px; }
  .hiw-step__title { font-size: 1.25rem; }
  .hiw-step__lede { margin-top: 2px; color: var(--slate-600); font-size: 1rem; line-height: 1.35; }
  .hiw-step__list { margin-top: 14px; padding-left: 2px; }

  /* The whole head row is the tap target; the chevron sits at its right edge. */
  html.js .hiw-step__toggle {
    position: absolute;
    inset: -14px -16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 16px;
    border: 0;
    border-radius: var(--r-lg);
    background: none;
    color: var(--slate-600);
    cursor: pointer;
  }
  .hiw-step__toggle:focus-visible { outline-offset: -3px; }
  .hiw-step__toggle .icon { transition: transform var(--t-base) var(--ease-out); }
  .hiw-step__toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }

  .hiw-step.is-collapsed .hiw-step__panel { grid-template-rows: 0fr; opacity: 0; }
}

/* ---- Tablet: 2 × 2, all open ---------------------------------------------- */

@media (min-width: 768px) {
  .hiw-media__img {
    aspect-ratio: 16 / 9;
    -webkit-mask-image: none;
    mask-image: none;
  }
  .hiw__cta {
    justify-items: start;
    margin: 28px 0 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }
  .hiw__btn { width: auto; }
  .hiw__cta-note,
  .hiw-strip__text { font-size: 0.9375rem; }
  .hiw-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .hiw-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; padding: 18px 4px; }
  .hiw-strip__item { padding-inline: 20px; }
  .hiw-strip__item + .hiw-strip__item { border-left: 1px solid var(--color-border); }
}

/* ---- Desktop: copy left, photo right, one connected row of steps ------------- */

@media (min-width: 1024px) {
  .hiw__wrap {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    grid-template-rows: auto 1fr auto auto;
    grid-template-areas:
      "head  media"
      "cta   media"
      "steps steps"
      "strip strip";
    column-gap: clamp(24px, 3vw, 48px);
  }

  /* The steps row rises over the photo; this bottom room keeps it clear of the CTA. */
  .hiw__cta { align-self: start; padding-bottom: 104px; }

  .hiw-media {
    align-self: end;
    margin: 0 calc(-1 * var(--hiw-pad)) 0 0;
  }
  .hiw-media__img {
    aspect-ratio: 3 / 2;
    border-radius: 0;
    -webkit-mask-image:
      linear-gradient(to right, transparent, #000 12%, #000 96%, transparent),
      linear-gradient(to bottom, transparent, #000 6%, #000 68%, transparent 97%);
    -webkit-mask-composite: source-in;
    mask-image:
      linear-gradient(to right, transparent, #000 12%, #000 96%, transparent),
      linear-gradient(to bottom, transparent, #000 6%, #000 68%, transparent 97%);
    mask-composite: intersect;
  }
  .hiw-note--left  { top: 7%; left: -2%; }
  .hiw-note--right { top: 5%; right: 21%; }

  .hiw__steps { margin-top: -96px; }
  .hiw-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 40px; }

  /* The connector: a thin line behind the row (seen in the gaps), drawn left to right. */
  .hiw__line {
    position: absolute;
    top: 54px;
    left: 10%;
    right: 10%;
    display: block;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg,
      color-mix(in srgb, var(--color-primary) 15%, transparent),
      color-mix(in srgb, var(--color-primary) 45%, transparent),
      color-mix(in srgb, var(--color-primary) 15%, transparent));
    transform-origin: left center;
  }
  .hiw__line.reveal { opacity: 1; transform: scaleX(0); }
  .hiw__line.reveal.is-in { transform: scaleX(1); transition: transform 1100ms var(--ease-out) 250ms; }

  .hiw-step__next {
    position: absolute;
    z-index: 2;
    top: 40px;
    right: -34px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--warm-50);
    color: var(--slate-500);
    transition: color 280ms var(--ease-out), border-color 280ms var(--ease-out), transform 280ms var(--ease-out);
  }
  .hiw-step:hover .hiw-step__next {
    border-color: color-mix(in srgb, var(--color-primary) 50%, var(--color-border));
    color: var(--color-primary);
    transform: translateX(3px);
  }
}
