/*
  Home's folders (HY-265): the page's body as a stack of file folders, How it
  works, Services and About, one open at a time. Load after pages.css, on the
  home page only. Alma's stack (tabs in fixed places, a strip of back flap, the
  front flap's edge), Lorenzo's paper and motion; RB's picks on the card. The
  source of the paper and the promise: design/components/Folders.

  - The paper is a risograph print in the pressboard's colours: manila, kraft
    and dusty rose, its dark grain softened to 40% so no fleck reads as type
    (RB, HY-296). js/folders.js paints each folder's tab and body as one
    sheet into an SVG inside the folder, so the paper moves with it. Without
    the script the same paper fills the tab and the body as backgrounds.
  - In dark mode the folders are the same print on night stock (HY-296, RB's
    picks): bottle green, slate and maroon, the key line, the halftone and the
    print's specks in a pale ink, the words in the dark theme's own ink. The
    pen's blue marks words there and never fills a sentence.
  - With the script, the open folder sets the stack's height and the others
    lie behind it, each showing a sliver of its edge. Without it, every folder
    stands open, one after another.
*/

/* On a phone a tab's name can take two lines, so the tab stands taller and its
   foot, where the open folder shades it, stays clear of the words. */
.fs {
  --tab-w: 6.5rem;
  --tab-h: 3.25rem;
  --tab-gap: 2px;
  --strip: 14px;
}

.fs-stack {
  position: relative;
  padding-top: var(--tab-h);
}

/* The hairlines print in the key ink: the light theme's rule, made for white
   paper, is paler than the folders' paper. --fs-key and --fs-dots are the key
   line's ink and the halftone's, which js/folders.js reads when it paints;
   --fs-edge is the front flap's edge as drawn without the script.
   The stack is the container the sections' layouts measure (steps, the
   copier's rows, About's split), so they switch at the width they always
   did; measured inside a folder's padding they would wait until about 1060px. */
.fs-folders {
  --rule: rgba(42, 38, 34, 0.22);
  --fs-key: #2A2622;
  --fs-dots: #2A2622;
  --fs-edge: rgba(42, 38, 34, 0.7);
  /* The colour the step at work's number and title light in while the bench
     plays (js/folders.js): the pen's blue on the light papers, the ink on the
     night ones, where the blue is 2.54:1 and a word needs 3:1 (HY-325). */
  --fs-lit: var(--signature);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  isolation: isolate;
  color: var(--ink);
  container: steps / inline-size;
}

.fs :is(.l-split, .runs-on, .steps) {
  container-type: normal;
}

.fs-folder {
  position: relative;
  display: flex;
  flex-direction: column;
  grid-area: 1 / 1;
}

/* Each tab keeps its place in the row, whichever folder is open (RB). --paper
   is the paper's own colour, so a drawing's paper-white parts take the
   folder's paper. */
.fs-folder--1 { --slot: 0; --paper: #EDDDC3; --sheet: url("../img/folders/paper-manila.webp"); }
.fs-folder--2 { --slot: 1; --paper: #E2CAAE; --sheet: url("../img/folders/paper-kraft.webp"); }
.fs-folder--3 { --slot: 2; --paper: #DFC4BA; --sheet: url("../img/folders/paper-rose.webp"); }

/* At night the folders are the same risograph on night stock (HY-296, RB's
   picks of 2026-10-23): bottle green, slate and maroon, its key line, halftone
   and specks printed in a pale ink. The tiles are the Paper print run in
   another ink (design/review/2026-10-23-dark-folders-round-3), chosen for
   colour rather than darkness so none reads as black. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fs-folders { --rule: rgba(232, 233, 236, 0.22); --fs-key: #D8CFC2; --fs-dots: #D8CFC2; --fs-edge: rgba(216, 207, 194, 0.7); --fs-lit: var(--ink); }
  :root:not([data-theme="light"]) .fs-folder--1 { --paper: #183F2B; --sheet: url("../img/folders/night-green.webp"); }
  :root:not([data-theme="light"]) .fs-folder--2 { --paper: #30363D; --sheet: url("../img/folders/night-slate.webp"); }
  :root:not([data-theme="light"]) .fs-folder--3 { --paper: #4C2E34; --sheet: url("../img/folders/night-maroon.webp"); }
}

[data-theme="dark"] .fs-folders { --rule: rgba(232, 233, 236, 0.22); --fs-key: #D8CFC2; --fs-dots: #D8CFC2; --fs-edge: rgba(216, 207, 194, 0.7); --fs-lit: var(--ink); }
[data-theme="dark"] .fs-folder--1 { --paper: #183F2B; --sheet: url("../img/folders/night-green.webp"); }
[data-theme="dark"] .fs-folder--2 { --paper: #30363D; --sheet: url("../img/folders/night-slate.webp"); }
[data-theme="dark"] .fs-folder--3 { --paper: #4C2E34; --sheet: url("../img/folders/night-maroon.webp"); }

/* The tab: cut from the back flap with shoulders that lean a little (Alma; RB
   found a steeper cut "piramidy"). Its paper comes from js/folders.js; this is
   its shape and its words. The shoulders are files of their own, as the
   site's security rules (vercel.json) refuse a picture written into the
   stylesheet; js/folders.js paints the same lean (tabPath). */
.fs-tab {
  position: absolute;
  bottom: calc(100% - 1px);
  left: 0;
  /* With larger text the three tabs share the folder's width rather than run
     past a phone's edge, and their sides give way as far as the shoulders'
     12px. Each tab moves along by its own width (100% in a transform). */
  width: min(var(--tab-w), calc((100% - 2 * var(--tab-gap)) / 3));
  height: var(--tab-h);
  min-height: var(--tap);
  padding: var(--space-2) clamp(12px, var(--space-5) - var(--tab-w) + (100% - 2 * var(--tab-gap)) / 3, var(--space-5)) 0;
  background: var(--sheet) 0 0 / 414px 600px, var(--paper);
  color: var(--ink);
  /* The name grows with the reader's text only as far as a third of the stack
     holds its longest word, "Servicios" at 4.4em, inside the shoulders' 12px:
     at 150% text on a 360 phone it ran past its tab and the tab's cut hid its
     last letters (HY-324). From a 320 phone up the cap stays above the default
     15px, so at the default text nothing moves. */
  font: var(--weight-medium) min(var(--size-small), 7.5cqi - 5.75px) / 1.2 var(--font-sans);
  transform: translateX(calc(var(--slot) * (100% + var(--tab-gap))));
  -webkit-mask:
    url("../img/folders/tab-shoulder-left.svg") left top / 12px 100% no-repeat,
    linear-gradient(#000 0 0) center top / calc(100% - 24px) 100% no-repeat,
    url("../img/folders/tab-shoulder-right.svg") right top / 12px 100% no-repeat;
  mask:
    url("../img/folders/tab-shoulder-left.svg") left top / 12px 100% no-repeat,
    linear-gradient(#000 0 0) center top / calc(100% - 24px) 100% no-repeat,
    url("../img/folders/tab-shoulder-right.svg") right top / 12px 100% no-repeat;
}

/* The tab's focus is the accessibility floor's 2px ink ring, drawn round the
   tab's cut edge in the folder's paint (js/folders.js), because the tab's mask
   would clip an outline (Alma, HY-265). Without the script a tab is plain
   text and takes no focus. */
.fs-tab:focus-visible {
  outline: none;
}

.fs-paint .paint-focus {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  opacity: 0;
}

.fs-folder:has(> .fs-tab:focus-visible) .paint-focus {
  opacity: 1;
}

/* The folder's face: the strip of back flap above the front flap's edge, then
   the words. The stack and each face are one column no wider than the page
   on a phone: an automatic column grows to its longest word, and with large
   text the folders ran past the screen (HY-324). */
.fs-body {
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--space-8);
  padding: calc(var(--strip) + var(--space-8)) var(--space-5) var(--space-12);
  border-radius: 0 3px 4px 4px;
  background: linear-gradient(transparent var(--strip), var(--fs-edge) var(--strip) calc(var(--strip) + 1px), transparent calc(var(--strip) + 1px)), var(--sheet) 0 0 / 414px 600px, var(--paper);
}

/* ---------- Without the script: every folder open, one after another ---------- */

.fs:not(.is-live) .fs-folder {
  grid-area: auto;
}

.fs:not(.is-live) .fs-folder + .fs-folder {
  margin-top: calc(var(--tab-h) + var(--space-12));
}

/* ---------- With the script: one stack ---------- */

.fs.is-live .fs-folder {
  will-change: transform;
}

.fs.is-live .fs-tab {
  cursor: pointer;
}

/* The paper is painted into each folder (js/folders.js), under its words. */
.fs.is-live :is(.fs-tab, .fs-body) {
  background: none;
}

.fs-paint {
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
  overflow: visible;
  pointer-events: none;
}

/* The folder shown lies in the stack's flow and sets its height; the others
   lie behind it at its size, a taller one cut to it, their words out of sight.
   The open folder keeps its height while it is pulled away. */
.fs.is-live .fs-folder:not(.is-sizing) {
  position: absolute;
  inset: 0;
}

.fs.is-live .fs-folder:not([data-depth="0"]):not(.is-next) .fs-body {
  max-height: 100%;
  overflow: clip;
}

.fs.is-live .fs-folder:not([data-depth="0"]):not(.is-next) .fs-body > * {
  visibility: hidden;
}

/* Depth: the open folder in front; the two behind show a sliver of their edge
   below and to the right. The folder about to be uncovered moves up right
   behind the open one; a folder dropping into the back keeps its body on its
   tab, one object, until it is behind the open folder. */
.fs.is-live .fs-folder[data-depth="0"] { z-index: 2; }
.fs.is-live .fs-folder[data-depth="1"] { z-index: 1; }
.fs.is-live .fs-folder[data-depth="2"] { z-index: 0; }

.fs.is-live .fs-body,
.fs-paint .paint-body {
  transition: transform 360ms var(--ease-out);
}

.fs-folder[data-depth="1"] :is(.fs-body, .paint-body) { transform: translate(4px, 7px); }
.fs-folder[data-depth="2"] :is(.fs-body, .paint-body) { transform: translate(8px, 14px); }
.fs-folder.is-next :is(.fs-body, .paint-body) { transform: none; }
.fs-folder.is-landing :is(.fs-body, .paint-body) { transform: none; transition: none; }

.fs.is-live .fs-folder.is-next .fs-body > * {
  visibility: visible;
}

/* The halftone shade at the foot of a tab, only while its folder stands behind
   the open one. */
.fs-paint .paint-shade {
  opacity: 0;
  transition: opacity 300ms var(--ease-out);
}

.fs-folder:not([data-depth="0"]) .fs-paint .paint-shade {
  opacity: 1;
}

/* ---------- How it works: the promise, the bench and the four steps ----------
   On a phone the folder reads in its markup's order: the promise, the bench
   whose stations bring its lines up, the steps, then the two ways on. On a
   computer the bench stands beside the promise with the two ways on at its
   foot, and the steps run across under both; no link sits between them, so
   the keyboard meets the two ways on in the same place either way (Alma,
   HY-265: they used to come first in the markup and last on a phone). */

.fs-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-8);
}

.fs-actions > p {
  margin: 0;
}

/* The bench's frame (its viewBox) keeps empty paper beside its drawing, 118
   of its 1200 units on the left and 124 on the right, room for its parts when
   it comes apart. Its drawing, not its frame, is what sits on the folder
   (Alma, HY-285); if Lorenzo redraws the bench, these numbers follow its
   drawing. On a phone and a tablet the frame spans the screen, as the bench
   did before the folders: the drawing then reaches to 15px of the paper's
   edges, 288px wide at 360 where it was 224, and only empty frame hangs past
   the paper. */
.fs .machine--bench {
  --bench-bleed: calc(var(--space-5) + var(--gutter));
  width: calc(100% + 2 * var(--bench-bleed));
  margin-inline: calc(-1 * var(--bench-bleed));
}

/* The promise: four lines, one per step, in the type of the steps' titles
   (RB, HY-265: the handwriting was "overcooked"; "the animation and color is
   enough flair"). One column no wider than the folder's words: an automatic
   column grew to "Diagnosticamos" with large text and pushed the page
   sideways (HY-324). */
.promise {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
  margin: 0;
  max-width: 30rem;
  font-size: var(--size-heading);
  line-height: var(--leading-heading);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
}

.promise__line {
  display: block;
}

/* A line of two sentences breaks between them, never inside one: at 320 to
   360 the first line read "You talk. We / ask questions." (HY-285). */
.promise__sentence {
  display: inline-block;
  max-width: 100%;
}

/* Before the bench plays, a line waits unseen until its step comes, and the
   pen's marks wait until the bench is still (js/folders.js). */
.promise.is-waiting .promise__line {
  opacity: 0;
}

/* Until then the steps show only their numbers and titles, standing back at
   the strength the script dims them to, and their words and the two ways on
   wait unseen, each to come in on its step's turn (RB, HY-323). The strength
   is measured on the folder's own paper, not the page's: 56% clears 3:1 for
   these bold titles on the manila's darker fibers (3.53) and on the night
   green's lighter ones (3.85); 42% read 2.46 and 2.85 there (HY-384). */
.steps.is-waiting :is(.step__number, .step__title) {
  color: color-mix(in srgb, var(--ink) 56%, transparent);
}

.steps.is-waiting .step > :not(.step__number, .step__title),
.fs-actions.is-waiting {
  opacity: 0;
}

.fs-folder.is-unmarked .mark__ink {
  visibility: hidden;
}

/* ---------- Services: three groups, each a small ledger ---------- */

.fs .runs-on__group + .runs-on__group {
  margin-top: var(--space-8);
}

.fs .runs-on__group-title {
  margin: 0 0 var(--space-3);
  font-size: var(--size-ui);
  line-height: var(--leading-ui);
  font-weight: var(--weight-bold);
  letter-spacing: 0;
}

/* Each line behind a pen arrow, drawn as it comes in (js/folders.js). */
.fs.is-live .runs-on__list > li {
  display: grid;
  grid-template-columns: 1.4em minmax(0, 1fr);
  column-gap: var(--space-3);
}

.runs-on__arrow {
  width: 1.4em;
  height: auto;
  margin-top: 0.45em;
  overflow: visible;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The fountain pen's arrow is a filled shape (js/folders.js, HY-451). */
.runs-on__arrow path {
  fill: var(--ink);
  stroke: none;
}

.runs-on__arrow circle {
  fill: var(--ink);
  stroke: none;
}

/* What each line is, set heavier, so the list reads at a glance. */
.fs .runs-on__list strong {
  font-weight: var(--weight-medium);
}

/* The line after the list is its punchline, set as large as a heading: we
   build whatever is not on the list (RB, HY-265: "a highlight, not a
   footnote"). */
.fs .runs-on__closer {
  margin-top: var(--space-12);
  font-size: var(--size-title);
  line-height: var(--leading-title);
  font-weight: var(--weight-bold);
  letter-spacing: -0.015em;
}

/* The answer keeps together, so a break falls between the two sentences. */
.fs .runs-on__closer > span {
  display: inline-block;
  text-wrap: balance;
}

/* ---------- About: larger words, marked by the pen ---------- */

.about-words {
  font-size: var(--size-lede);
  line-height: var(--leading-lede);
}

.about-words__alone {
  position: relative;
}

/* The underlined opening phrase never breaks, and on the narrowest phones the
   Spanish one, "Escríbenos cuando quieras," with its comma, is 254px at the
   lede's 20px: 14px past its 240px column at 320 (Lorenzo, HY-460; fixed on
   HY-453). Under an 18.5rem folder (up to a 336px screen) the words take the
   body's 18px, where the phrase is 228px and fits from 320 up; from 340 the
   lede's size fits again, with 6px to spare. */
@container steps (max-width: 18.5rem) {
  .about-words {
    font-size: var(--size-body);
  }
}

/* The pen's line under the opening phrase is drawn for one line, and with
   large text on a phone the phrase is longer than a line ("Escríbenos cuando
   quieras" was 219px longer than its line on a 360 screen at twice the text,
   and pushed the page sideways, HY-324). There the phrase wraps and each line
   takes a pen-blue underline of the pen's width instead, and the words step
   down from the lede to the body's size, which the reader's setting has
   already made large, so the pen's loop round "Nunca un bot." fits a 320
   phone. 15em of the stack's own text is never reached at the default size
   from 320 up. */
@container steps (max-width: 15em) {
  .about-words {
    font-size: var(--size-body);
  }

  .about-words .mark--underline {
    white-space: normal;
    text-decoration: underline var(--pen-width) var(--signature);
    text-decoration-skip-ink: none;
    text-underline-offset: 0.18em;
  }

  .about-words .mark--underline .mark__ink {
    display: none;
  }
}

/* The arrow points from the lamp's column at the human who never works alone;
   on a phone there is no column beside the words, so it goes. */
.about-words__arrow {
  display: none;
}

@container (min-width: 54rem) {
  .about-words__arrow {
    display: block;
    top: 0.05em;
    right: calc(100% + var(--space-3));
    left: auto;
    width: 3em;
    height: auto;
  }
}

/* ---------- Tablet widths ----------
   From 640px there is room for every tab's name on one line: at 768 the phone's
   6.5rem tab broke "How it / works" while "Services" and "About" sat on one
   line beside it (HY-384). 9.5rem holds "Cómo funciona" too. */

@media (min-width: 40rem) {
  .fs {
    --tab-w: 9.5rem;
  }
}

/* ---------- Computer widths ---------- */

@media (min-width: 60rem) {
  .fs {
    --tab-w: 11rem;
    --tab-h: 2.75rem;
    --strip: 18px;
  }

  .fs-body {
    padding: calc(var(--strip) + var(--space-12)) var(--space-12) var(--space-16);
  }

  .fs-folder--1 .fs-body {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    column-gap: var(--space-12);
    row-gap: var(--space-12);
  }

  .fs-folder--1 .fs-bench {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
  }

  /* The drawing's left end stands on the steps' rule below it, and its frame
     reaches across the gap to the promise's column, never into it: the
     drawing is 580px wide at 1280 where it was 484, wider than on a tablet
     again. The frame's empty left part hangs past the paper. */
  .fs-folder--1 .machine--bench {
    width: calc((100% + var(--space-12)) * 1200 / 1082);
    margin-inline: calc((100% + var(--space-12)) * -118 / 1082) 0;
  }

  .fs-folder--1 .fs-intro {
    grid-column: 2;
    grid-row: 1;
  }

  .fs-folder--1 .fs-actions {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
  }

  .fs-folder--1 .steps {
    grid-column: 1 / -1;
    grid-row: 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fs.is-live .fs-body,
  .fs-paint .paint-body,
  .fs-paint .paint-shade {
    transition: none;
  }
}
