/* Retouch section — our changes, loaded after css/home-edit-retouch.css + css/home-retouch.css + css/sep-b.css.
   Markup: retouch/section.html · scripts: js/retouch-section-data.js (data, shared), retouch/js/retouch-timeline.js
   (copy, the demo + timeline), retouch/js/retouch-title.js (the title). */

.rtx { --display: "SF Pro Display", "SF Pro", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; }

/* The sheet's top space, as the Stacking and Edit sheets'. */
.sb-slot > .cx.rtx { padding-top: clamp(48px, 5vw, 80px); }

/* ---------- Title: the Stacking / Editing title's twin, painted sharp by a brush ---------- */

.rtx-open { margin: 0 auto clamp(56px, 7vw, 104px); text-align: center; font-family: var(--display); }
.rtx-word {
  position: relative;
  width: fit-content;
  margin: 0 auto;
  font-size: clamp(60px, 12.4vw, 196px);    /* same size as the Stacking and Editing titles */
  font-weight: 700;
  letter-spacing: -0.04em;                  /* 2026-11-17: was -0.055em */
  line-height: 1;
  white-space: nowrap;
}
.rtx-word__text { display: block; padding: 0 0.04em 0.1em; color: transparent; }
/* The styles below are the end state (painted sharp, brush gone); the scroll motion after them starts soft. */
/* The flaw: the word out of focus. Its blur is drawn once; only its opacity moves. */
.rtx-word__soft {
  position: absolute; inset: 0; padding: 0 0.04em 0.1em;
  color: transparent; text-shadow: 0 0 0.07em rgba(241, 244, 242, 0.55);
  opacity: 0.4;
  will-change: opacity;
}
/* Painted back: sharp up to the brush, with a soft edge like the brush's feather (14 % of the word).
   The edge is a fixed gradient mask on a strip twice the word's width that slides right (__mask), while the sharp
   word inside slides back the same distance and stays put (__sharp): two transforms, no mask redrawn.
   __wipe keeps the strip from widening the page (a clip at the word's sides; 0.2em of room above and below for the
   glyphs). Edge at p (0 → 1): opaque to (116 p − 16) %, then the feather. */
.rtx-word__wipe { position: absolute; inset: -0.2em 0; overflow: hidden; pointer-events: none; }
.rtx-word__mask {
  position: absolute; top: 0; bottom: 0; left: 0; width: 200%;
  -webkit-mask-image: linear-gradient(90deg, #000 93%, transparent);
          mask-image: linear-gradient(90deg, #000 93%, transparent);
  transform: translateX(-43%);                          /* (58 p − 101) % */
  will-change: transform;
}
.rtx-word__sharp {
  position: absolute; top: 0.2em; bottom: 0.2em; left: 0; width: 50%;
  padding: 0 0.04em 0.1em;
  color: var(--text);
  transform: translateX(86%);                           /* (202 − 116 p) % */
  will-change: transform;
}
/* The brush ring (the app's brush cursor), riding the edge of what is painted: __track (the word's box) carries it
   across the word ((116 p − 9) % of its width), the ring bobs up and down on its own and fades in and out at the ends.
   __lane clips the track 0.5em round the word (the ring is gone before it gets further), so it never widens the page. */
.rtx-word__lane { position: absolute; inset: -0.5em; overflow: hidden; pointer-events: none; }
.rtx-word__track { position: absolute; inset: 0.5em; transform: translateX(107%); will-change: transform; }
/* 2026-11-17: the ring rides from −9 % to 107 % of the word, so with its radius and shadow it reaches ~1em past the
   word's sides while it fades in and out; 0.5em cut it with a straight edge. Desktop has the room: 1.2em at the sides. */
@media (min-width: 601px) {
  .rtx-word__lane { inset: -0.5em -1.2em; }
  .rtx-word__track { inset: 0.5em 1.2em; }
}
.rtx-word__brush {
  position: absolute; left: 0; top: 46%;
  width: 0.78em; height: 0.78em;
  border-radius: 50%;
  border: 0.018em solid rgba(255, 255, 255, 0.9);
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.02));
  box-shadow: 0 0 0.12em rgba(0, 0, 0, 0.45), inset 0 0 0.12em rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%);
  opacity: 0;
  will-change: transform, opacity;
}

/* Scroll motion (2026-11-16, phone perf pass): only transform and opacity move. The run starts once the whole word
   is on screen (its bottom at 90 % of the screen) and ends when its top reaches the top bar's lower edge: longer than
   the other titles', so the brush sweeps slower. Eased with cubic-bezier(1/3, 0, 2/3, 1) (= smoothstep); the bob and
   the ring's fades are sampled along that same curve (linear between stops). Scroll timelines where the browser has
   them (Safari 26, Chrome 115+); elsewhere retouch-title.js holds the animations paused and sets their time on scroll. */
@keyframes rtx-soft { from { opacity: 1; } to { opacity: 0.4; } }
@keyframes rtx-mask { from { transform: translateX(-101%); } to { transform: translateX(-43%); } }
@keyframes rtx-sharp { from { transform: translateX(202%); } to { transform: translateX(86%); } }
@keyframes rtx-track { from { transform: translateX(-9%); } to { transform: translateX(107%); } }
/* the ring: visible from p = 0.1 to 0.9, bobbing 0.1em × sin(3π p) */
@keyframes rtx-brush {
  0% { opacity: 0; } 19.58% { opacity: 1; } 80.42% { opacity: 1; } 100% { opacity: 0; }
  0% { transform: translate(-50%, -50%); }
  4.17% { transform: translate(-50%, calc(-50% + 0.0048em)); }
  8.33% { transform: translate(-50%, calc(-50% + 0.0184em)); }
  12.5% { transform: translate(-50%, calc(-50% + 0.0394em)); }
  16.67% { transform: translate(-50%, calc(-50% + 0.0643em)); }
  20.83% { transform: translate(-50%, calc(-50% + 0.0871em)); }
  25% { transform: translate(-50%, calc(-50% + 0.0995em)); }
  29.17% { transform: translate(-50%, calc(-50% + 0.0933em)); }
  33.33% { transform: translate(-50%, calc(-50% + 0.0643em)); }
  37.5% { transform: translate(-50%, calc(-50% + 0.0159em)); }
  41.67% { transform: translate(-50%, calc(-50% - 0.0393em)); }
  45.83% { transform: translate(-50%, calc(-50% - 0.0832em)); }
  50% { transform: translate(-50%, calc(-50% - 0.1000em)); }
  54.17% { transform: translate(-50%, calc(-50% - 0.0832em)); }
  58.33% { transform: translate(-50%, calc(-50% - 0.0393em)); }
  62.5% { transform: translate(-50%, calc(-50% + 0.0159em)); }
  66.67% { transform: translate(-50%, calc(-50% + 0.0643em)); }
  70.83% { transform: translate(-50%, calc(-50% + 0.0933em)); }
  75% { transform: translate(-50%, calc(-50% + 0.0995em)); }
  79.17% { transform: translate(-50%, calc(-50% + 0.0871em)); }
  83.33% { transform: translate(-50%, calc(-50% + 0.0643em)); }
  87.5% { transform: translate(-50%, calc(-50% + 0.0394em)); }
  91.67% { transform: translate(-50%, calc(-50% + 0.0184em)); }
  95.83% { transform: translate(-50%, calc(-50% + 0.0048em)); }
  100% { transform: translate(-50%, -50%); }
}
@media (prefers-reduced-motion: no-preference) {
  .rtx-word__soft { animation: rtx-soft 1s cubic-bezier(0.3333, 0, 0.6667, 1) both; }
  .rtx-word__mask { animation: rtx-mask 1s cubic-bezier(0.3333, 0, 0.6667, 1) both; }
  .rtx-word__sharp { animation: rtx-sharp 1s cubic-bezier(0.3333, 0, 0.6667, 1) both; }
  .rtx-word__track { animation: rtx-track 1s cubic-bezier(0.3333, 0, 0.6667, 1) both; }
  .rtx-word__brush { animation: rtx-brush 1s linear both; }
  @supports (animation-timeline: view()) {
    .rtx-word { view-timeline: --rtx-word block; }
    .rtx-word__soft, .rtx-word__mask, .rtx-word__sharp, .rtx-word__track, .rtx-word__brush {
      animation-duration: auto;
      animation-timeline: --rtx-word;
      animation-range-start: entry calc(100% + 10dvh);
      animation-range-end: cover calc(100dvh - var(--topbar-h, 76px));
    }
  }
}

.rtx-lede {
  margin-top: clamp(20px, 2.4vw, 36px);
  font-size: clamp(20px, 2vw, 30px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--muted);
}
.rtx-lede span { color: var(--text); }

/* ---------- Block: photo left, the timeline right, starting on the photo's top edge ---------- */

.rtx .rde__block { grid-template-areas: "visual side"; grid-template-rows: auto; }
.rtx .rde__side { max-width: 420px; font-family: var(--display); }

/* The timeline, bigger and shorter: the step titles carry it. */
.rtx .rde__steps { --node: 36px; margin: 0; }
.rtx .rde__steps li { padding: 2px 0 clamp(36px, 4vw, 56px) calc(var(--node) + 20px); }
.rtx .rde__steps li:last-child { padding-bottom: 0; }
.rtx .rde__node { font-size: 15px; }
.rtx .rde__steps b { font-size: clamp(22px, 2.1vw, 30px); font-weight: 700; letter-spacing: -0.03em; line-height: 32px; }
.rtx .rde__steps p { margin-top: 6px; font-size: clamp(16px, 1.35vw, 19px); font-weight: 500; letter-spacing: -0.01em; line-height: 1.35; }

/* Side by side: the timeline runs the photo card's full height; the steps share it evenly and the last rail
   ends on the card's bottom edge. */
@media (min-width: 1060px) {
  /* Mirrored (2026-11-13): the timeline on the left, the photo on the right, so it doesn't repeat Stacking and
     Editing (both photo left). */
  .rtx .rde__block { grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr); grid-template-areas: "side visual"; }
  .rtx .rde__side { align-self: stretch; display: flex; flex-direction: column; }
  .rtx .rde__steps { flex: 1; display: flex; flex-direction: column; }
  .rtx .rde__steps li { flex: 1; }
  .rtx .rde__steps li:last-child::before, .rtx .rde__steps li:last-child::after { bottom: 0; }
}

@media (max-width: 1059px) {
  .rtx .rde__block { grid-template-areas: "visual" "side"; }
  .rtx .rde__side { max-width: 600px; }
}
@media (max-width: 640px) {
  .rtx-word { font-size: clamp(44px, 15vw, 60px); }     /* phones: the other titles' 60px, smaller only where the longest word would not fit */
  .rtx .rde__steps { --node: 30px; }
  .rtx .rde__steps li { padding-left: calc(var(--node) + 14px); padding-bottom: 28px; }
  .rtx .rde__steps b { line-height: 28px; }
}
