/* =========================================================
   Home on phones (640px and narrower): laid out for the hand, not shrunk
   from the desktop. Wider screens are untouched by this file.

   1. Hero: the facts are a still row of three figures (no ticker).
   2. Projects: one card at a time, swiped sideways, the next one peeking.
   3. How I untangle: the five habits are a row of chips to swipe and tap;
      the card for the chosen one sits right under them.
   4. Testimonials: the heading uses the full width, the arrows sit under
      the cards, the cards are wider.
   5. Closing: the two buttons share the row evenly.
   ========================================================= */
@media (max-width: 640px) {

  /* ---------- 1. Hero facts: three figures in a row ---------- */
  .fl-cx .fl-ticker { display: none !important; }
  .fl-cx .fl-counters { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 0; padding: 1.125rem 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
  .fl-cx .fl-counters li { display: flex !important; flex-direction: column; align-items: flex-start; gap: 0.25rem; padding: 0 0.75rem !important; }
  .fl-cx .fl-counters li:first-child { padding-left: 0 !important; }
  .fl-cx .fl-counters li + li { border-left: 1px solid var(--hairline) !important; }
  .fl-cx .fl-num { margin: 0 !important; font-size: 1.75rem !important; line-height: 1; }
  .fl-cx .fl-txt b { font-size: 0.875rem !important; }
  .fl-cx .fl-txt span { display: none !important; }
  .hc-down { display: none !important; }

  /* ---------- 2. Projects: a sideways swipe ---------- */
  .proj-tiles { display: flex !important; gap: 0.75rem !important; margin-inline: calc(var(--pad) * -1); padding: 0.25rem var(--pad) 0.5rem; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--pad); overscroll-behavior-x: contain; scrollbar-width: none; }
  .proj-tiles::-webkit-scrollbar { display: none; }
  .proj-tiles .pt { flex: 0 0 84%; scroll-snap-align: start; }
  .proj-tiles .pt-media { aspect-ratio: 4 / 3 !important; }
  .proj-tiles .pt-hook { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .proj-tiles .pt-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .proj-head p { font-size: 1rem; }

  /* ---------- 3. How I untangle: chips, then the card ---------- */
  .vx { display: flex !important; flex-direction: column; gap: 1rem !important; }
  .vx-list { display: flex; gap: 0.5rem; margin-inline: calc(var(--pad) * -1); padding: 0 var(--pad) 0.25rem; overflow-x: auto; border: 0 !important; scroll-snap-type: x proximity; scrollbar-width: none; }
  .vx-list::-webkit-scrollbar { display: none; }
  .vx-item { flex: none; border: 0 !important; scroll-snap-align: start; }
  .vx-trigger { padding: 0.5rem 0.875rem !important; border: 1px solid var(--hairline) !important; border-radius: 999px; font-size: 0.9375rem !important; white-space: nowrap; text-decoration: none !important; }
  .vx-item.is-active .vx-trigger { background: var(--fill); border-color: var(--fill) !important; color: var(--fill-ink) !important; }
  .vx-bar { display: none !important; }
  .vx-card { border-radius: 1rem !important; }

  /* ---------- 4. Testimonials ---------- */
  .testi-head { display: flex; flex-direction: column; align-items: stretch !important; }
  .testi-head-text { max-width: none !important; }
  .testi-head-text h2 { max-width: none !important; }
  .tq-arrows { order: 3; align-self: flex-end; margin-top: 0; }
  .testi .tq-arrows { position: relative; }

  /* ---------- 5. Closing ---------- */
  .next-actions { display: grid !important; grid-template-columns: 1fr 1fr; gap: 0.625rem; }
  .next-actions .btn { width: 100%; justify-content: center; }
}

/* ---------- 4b. Testimonials, rethought for the hand ----------
   One card at a time, nearly full width, the next one peeking; the video
   first (as on wide screens); cards as tall as their words (no fixed
   shape), the quote set larger; dots under the row show where you are
   (js/testi-strip.js) instead of the arrows. */
@media (max-width: 640px) {
  .tq-view { --tq-w: calc(100vw - 2 * var(--pad) - 2.75rem); --tq-gap: 0.75rem; margin-inline: calc(var(--pad) * -1); padding-inline: var(--pad); }
  .tq-track { align-items: stretch; }
  .tq-card { aspect-ratio: auto !important; min-height: 15rem; padding: 1.25rem 1.25rem 1.375rem; border-radius: 1rem !important; }
  .tq-card--video { order: -1; min-height: 0; aspect-ratio: auto !important; }
  .tq-quote { margin-top: 1.25rem !important; font-size: 1.0625rem !important; line-height: 1.5; }
  .tq-dp { width: 2.75rem; height: 2.75rem; font-size: 0.875rem; }
  .tq-name { margin-top: auto !important; padding-top: 1.25rem; } /* always at the foot of the card */
  .tq-name strong { font-size: 1rem; font-weight: 600; }
  .testi .tq-arrows { display: none !important; }
  .tq-dots { display: flex; justify-content: center; gap: 0.5rem; margin-top: 1rem; }
  .tq-dot { width: 0.5rem; height: 0.5rem; padding: 0; border: 0; border-radius: 999px; background: color-mix(in srgb, var(--ink) 18%, transparent); cursor: pointer; transition: width 0.3s ease, background-color 0.3s ease; }
  .tq-dot[aria-current="true"] { width: 1.5rem; background: var(--ink); }
  .tq-dot:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
}
@media (min-width: 641px) { .tq-dots { display: none; } }
@media (prefers-reduced-motion: reduce) { .tq-dot { transition: none; } }
/* The habit chips stay within the screen (they scroll inside their row);
   the card underneath keeps the page's margins. */
@media (max-width: 640px) {
  .vx { align-items: stretch !important; min-width: 0; }
  .vx-list { align-self: stretch; width: auto; max-width: none; min-width: 0; }
  .vx-card { width: 100%; box-sizing: border-box; }
  .value { overflow-x: clip; }
}
@media (max-width: 640px) {
  .vx-list { scroll-padding-inline: var(--pad); }
  .proj-tiles { scroll-padding-inline: var(--pad); }
}

/* ---------- 3b. The untangle card on phones ----------
   The result leads (a large figure with its line beside it), then what the
   habit is, then what you get and how long, side by side under a rule. */
@media (max-width: 640px) {
  .vx-card { padding: 1.25rem 1.25rem 1.375rem !important; }
  .vx-panel { display: flex !important; flex-direction: column; }
  .vx-panel .value-stat { order: -1; display: flex !important; flex-direction: row !important; align-items: center !important; gap: 0.75rem !important; margin: 0 0 1rem !important; padding: 0 0 1rem !important; border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); }
  .vx-panel .value-num { flex: none; font-size: 2.5rem !important; font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
  .vx-panel .value-cap { flex: 1; min-width: 0; max-width: 24ch; font-size: 0.875rem !important; line-height: 1.35; color: var(--ink-soft); }
  .vx-panel .value-text { margin: 0 !important; font-size: 1rem !important; line-height: 1.55; }
  .vx-panel .value-meta { display: grid !important; grid-template-columns: 1.4fr 1fr; gap: 1rem !important; margin: 1.125rem 0 0 !important; padding-top: 1rem !important; border-top: 1px solid color-mix(in srgb, var(--ink) 10%, transparent) !important; }
  .vx-panel .value-meta > div { display: flex; flex-direction: column; gap: 0.25rem; margin: 0 !important; }
  .vx-panel .value-meta dt { font-size: 0.75rem !important; color: var(--ink-soft); }
  .vx-panel .value-meta dd { margin: 0; font-size: 0.875rem !important; line-height: 1.4; font-weight: 500; }
}

/* ---------- 1b. The hero on phones, laid out again ----------
   Headline tighter; the ask box the full width; the three figures as a
   soft panel of three equal cells, each centred (number over its label). */
@media (max-width: 640px) {
  .hc-title.hc-big { line-height: 1.08 !important; letter-spacing: -0.04em !important; }
  .hc .hc-lede { margin-top: 1rem !important; }
  .hc > .hc-ask { justify-self: stretch !important; width: 100% !important; max-width: none !important; margin-top: 1.5rem !important; }
  .hc > .hc-resume { margin-top: 1.125rem !important; }
  .hc > .hc-foot { margin-top: 0 !important; }
  .fl-cx .fl-counters { padding: 1rem 0.5rem !important; border: 0 !important; border-radius: 1rem; background: var(--surface); }
  :root[data-theme="dark"] .fl-cx .fl-counters { background: var(--surface-2); }
  .fl-cx .fl-counters li { align-items: center !important; text-align: center; padding: 0 0.5rem !important; }
  .fl-cx .fl-counters li:first-child { padding-left: 0.5rem !important; }
  .fl-cx .fl-counters li + li { border-left: 1px solid color-mix(in srgb, var(--ink) 10%, transparent) !important; }
  .fl-cx .fl-num { justify-content: center; font-size: 1.875rem !important; }
  .fl-cx .fl-txt { align-items: center; text-align: center; }
  .fl-cx .fl-txt b { font-size: 0.8125rem !important; font-weight: 500; color: var(--ink-soft); }
  .fl, .fl * { text-align: center; }
}

/* ---------- 1c. Phones: the hero centred; the figures without a panel ---------- */
@media (max-width: 640px) {
  .hc { justify-items: center !important; text-align: center !important; }
  .hc > .hc-hi, .hc > .hc-title, .hc > .hc-lede, .hc > .hc-resume { justify-self: center !important; text-align: center !important; margin-inline: auto !important; }
  .hc-big .hc-line { margin-inline: auto !important; }
  .hc .hc-lede { text-wrap: balance; }
  .hc-ask .hc-q, .hc-ask .hc-q span { text-align: left; }
  .fl-cx .fl-counters, :root[data-theme="dark"] .fl-cx .fl-counters { background: none !important; border-radius: 0; padding: 0.25rem 0 !important; }
}
/* Phones: more room above the figures, and no dividers between them. */
@media (max-width: 640px) {
  .hc { grid-template-rows: auto auto auto auto auto auto 4rem auto !important; }
  .fl-cx .fl-counters li + li { border-left: 0 !important; }
  .fl-cx .fl-counters { border-top: 0 !important; border-bottom: 0 !important; }
}
/* Phones: more room under the nav and above the figures. */
@media (max-width: 640px) {
  .hc { padding-top: calc(var(--pad) + 8.5rem) !important; grid-template-rows: auto auto auto auto auto auto 5.25rem auto !important; }
}
@media (max-width: 640px) { .hc { grid-template-rows: auto auto auto auto auto auto 7rem auto !important; } }

/* ---------- 5b. The closing on phones: centred, like the hero ----------
   The badge sits straight and centred; heading and line balanced; the two
   actions stacked full width, the main one first. */
@media (max-width: 640px) {
  .next-ch { display: flex; flex-direction: column; align-items: center; text-align: center; }
  .next-ch .next-badge { rotate: 0deg !important; margin-bottom: 1rem !important; }
  .next-ch h2 { max-width: none !important; margin-inline: auto; font-size: 1.5rem !important; line-height: 1.3 !important; text-wrap: balance; }
  .next-ch p, .next-ch h2 + p { max-width: 32ch !important; margin-inline: auto; font-size: 1rem !important; text-wrap: balance; }
  .next-actions { display: flex !important; flex-direction: column; align-self: stretch; gap: 0.625rem !important; margin-top: 1.75rem !important; }
  .next-actions .btn { width: 100%; min-height: 3rem; justify-content: center; }
}

/* ---------- 1d. Phones: the hero fills the first screen ----------
   As on wide screens: the words up top, and the three figures with the
   arrow down to the work held at the bottom of the screen. The space
   between them flexes; on a short phone it shrinks to a minimum instead of
   letting things overlap. */
@media (max-width: 640px) {
  .hc { min-height: 100vh !important; min-height: 100svh !important; padding-bottom: 1rem !important; grid-template-rows: auto auto auto auto auto auto minmax(3rem, 1fr) auto !important; }
  .hc-down { display: inline-flex !important; align-self: center; margin-top: 0.75rem; }
  .hc-foot { gap: 0 !important; }
  .projects { margin-top: 4rem !important; }
}
/* The words sit a little above the middle of what is left, not stuck to the top. */
@media (max-width: 640px) {
  .hc { padding-top: calc(var(--pad) + 5.5rem) !important; grid-template-rows: minmax(0, 0.55fr) auto auto auto auto auto minmax(3rem, 1fr) auto !important; }
}
/* The green app sticker hangs beside "into", outside the line, so both
   lines of the headline centre on their words alone. */
@media (max-width: 640px) {
  .hc-big .hc-line { position: relative; }
  .hc-title .hs-app { position: absolute !important; left: -0.72em !important; top: 0.2em !important; margin: 0 !important; display: block; width: 0.56em !important; height: 0.46em !important; }
}
/* Phones: the ask box as wide as the headline above it (hero.js measures
   the headline's longest line as --hc-title-w), centred under it. */
@media (max-width: 640px) {
  .hc > .hc-ask { width: var(--hc-title-w, 100%) !important; max-width: 100% !important; justify-self: center !important; margin-inline: auto !important; }
}
/* Phones: the description as wide as the headline, so it can sit on two
   balanced lines wherever the screen allows. */
@media (max-width: 640px) {
  .hc .hc-lede { width: 100% !important; max-width: 25rem !important; text-wrap: balance !important; }
}
@media (max-width: 374px) { .hc .hc-lede { font-size: 0.9375rem !important; } }
