/* ==========================================================================
   KF Crafts — "How you pay" (#pay, in the How we build view). Round 7, 28.09.2026.
   Ivan's four stages as one calm timeline: a proportion bar (35 / 40 / 20 / 5) drawn in champagne hairlines,
   then the stages — a vertical thread on phones, four columns hanging from one line on desktop — then the
   four facts. Ink ground, champagne only as a line or a number (site.css tokens). No new colours.
   ========================================================================== */

.pay { background: var(--ink); }

.pay__head {
  display: grid;
  gap: 1.25rem;
  align-content: start;
  max-width: 44rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.pay__lead { max-width: 36rem; }

/* ---------- the proportion bar ---------- */

.pay__bar {
  display: flex;
  gap: 3px;
  margin-top: clamp(2.5rem, 5vw, 4rem);
}
.pay__seg {
  position: relative;
  flex: var(--w) 1 0;
  min-width: 0;
  padding-top: 2.1rem;
  border-bottom: 2px solid var(--gold);
  transform-origin: left center;
}
.pay__seg:nth-child(2) { border-bottom-color: var(--champagne); }
.pay__seg:nth-child(3) { border-bottom-color: var(--gold-hi); }
.pay__seg:nth-child(4) { border-bottom-color: var(--paper); }
.pay__seg b,
.pay__seg i {
  position: absolute;
  left: 0;
  white-space: nowrap;
  font-style: normal;
}
.pay__seg b {
  top: 0;
  color: var(--text-strong);
  font-size: 1.0625rem;
  font-weight: 300;
  line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
}
.pay__seg i {
  bottom: -1.6rem;
  color: var(--text-dim);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
/* The last sliver is too narrow for its words: they hang from its right edge. */
.pay__seg:last-child b,
.pay__seg:last-child i { left: auto; right: 0; }
/* Phones: the two short labels would touch; the bar keeps the numbers, the stages below carry the words. */
@media (max-width: 519.98px) {
  .pay__seg:nth-child(3) i,
  .pay__seg:nth-child(4) i { display: none; }
}

/* Drawn in once, left to right (main.js adds .draw / .is-drawn; nothing hides under reduced motion or without JS). */
.draw.pay__bar .pay__seg { transform: scaleX(0); }
.draw.pay__bar .pay__seg b,
.draw.pay__bar .pay__seg i { opacity: 0; }
.draw.pay__bar.is-drawn .pay__seg {
  transform: none;
  transition: transform 0.9s var(--ease-in-out);
  transition-delay: calc(var(--i, 0) * 0.16s);
}
.draw.pay__bar.is-drawn .pay__seg b,
.draw.pay__bar.is-drawn .pay__seg i {
  opacity: 1;
  transition: opacity 0.6s var(--ease-out);
  transition-delay: calc(0.35s + var(--i, 0) * 0.16s);
}
.pay__seg:nth-child(2) { --i: 1; }
.pay__seg:nth-child(3) { --i: 2; }
.pay__seg:nth-child(4) { --i: 3; }

/* ---------- the stages ---------- */

.pay__example {
  margin-top: clamp(2.75rem, 5vw, 3.75rem);
  max-width: 40rem;
  color: var(--text-dim);
  font-size: 0.9375rem;
}
.pay__example .link { display: inline; }

.pay__stages {
  display: grid;
  margin-top: clamp(1.75rem, 3.5vw, 2.75rem);
}
/* Phones: the number and its amount on the left, the words on the right, one hairline threading the four. */
.pay__stage {
  position: relative;
  display: grid;
  grid-template-columns: 4.25rem minmax(0, 1fr);
  column-gap: 1rem;
  align-content: start;
  padding-bottom: 1.75rem;
}
.pay__stage::before {
  content: "";
  position: absolute;
  left: 1.1rem;
  top: 4.6rem;
  bottom: 0.9rem;
  width: 1px;
  background: var(--line);
}
.pay__stage:last-child { padding-bottom: 0; }
.pay__stage:last-child::before { display: none; }
.pay__pct {
  grid-column: 1;
  grid-row: 1;
  color: var(--champagne);
  font-size: 2.25rem;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: lining-nums;
}
.pay__eg {
  grid-column: 1;
  grid-row: 2 / span 3;
  align-self: start;
  margin-top: 0.5rem;
  color: var(--text-dim);
  font-size: 0.8125rem;
  font-weight: 300;
  font-variant-numeric: lining-nums tabular-nums;
}
.pay__eg-k { display: none; }
.pay__title { grid-column: 2; grid-row: 1; }
.pay__when { grid-column: 2; grid-row: 2; }
.pay__text { grid-column: 2; grid-row: 3; }
.pay__note { grid-column: 2; grid-row: 4; }
.pay__title {
  color: var(--text-strong);
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1.3;
  text-wrap: balance;
}
.pay__when {
  margin-top: 0.4rem;
  color: var(--champagne);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  line-height: 1.5;
  text-transform: uppercase;
}
.pay__text { margin-top: 0.6rem; color: var(--text-dim); font-size: 0.9375rem; line-height: 1.6; }
.pay__note {
  margin-top: 0.75rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ---------- the four facts ---------- */

.pay__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(1.25rem, 3vw, 3rem);
  margin-top: clamp(2.25rem, 5vw, 3.5rem);
}
.pay__fact {
  display: grid;
  align-content: start;
  gap: 0.4rem;
  padding: 1.1rem 0 1.4rem;
  border-top: 1px solid var(--rule);
}
.pay__fact-title {
  color: var(--text-strong);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.35;
}
.pay__fact p { color: var(--text-dim); font-size: 0.875rem; line-height: 1.55; }
@media (max-width: 359.98px) {
  .pay__facts { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 640px) {
  .pay__fact-title { font-size: 1.0625rem; }
  .pay__fact p { font-size: 0.9375rem; }
}

/* ---------- desktop: four columns hanging from one line; the rows line up across them ---------- */

@media (min-width: 1024px) {
  .pay__stages {
    position: relative;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(6, auto);
    column-gap: var(--col-gap);
  }
  .pay__stages::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--line-strong);
  }
  .pay__stage {
    grid-row: span 6;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: subgrid;
    padding: 2.25rem 0 0;
  }
  .pay__stage::before {
    left: 0;
    top: -6px;
    bottom: auto;
    height: 13px;
    background: var(--champagne);
  }
  .pay__stage:last-child::before { display: block; }
  .pay__pct { grid-row: 1; font-size: clamp(3.25rem, 1.6rem + 2.6vw, 5rem); margin-bottom: 1rem; }
  .pay__title { grid-column: 1; grid-row: 2; }
  .pay__when { grid-column: 1; grid-row: 3; }
  .pay__text { grid-column: 1; grid-row: 4; max-width: 19rem; }
  .pay__note { grid-column: 1; grid-row: 5; align-self: start; }
  .pay__eg {
    grid-column: 1;
    grid-row: 6;
    align-self: end;
    margin-top: 1.25rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--rule);
    color: var(--text-strong);
    font-size: 1rem;
  }
  .pay__eg-k {
    display: inline;
    margin-right: 0.35rem;
    color: var(--muted);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }
  .pay__facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .draw.pay__bar .pay__seg { transform: none; }
  .draw.pay__bar .pay__seg b,
  .draw.pay__bar .pay__seg i { opacity: 1; }
}
