/* Rediall marketing site: modules, hairline art, frames and hatched bands.
   After mothershiplabs.io's Modules: a numbered list beside one framed
   drawing. On wide screens (modules.js) the drawings move into one sticky
   frame and the row nearest the middle of the viewport picks the drawing;
   hover picks it too. Narrow screens and no JS: every row shows its own
   drawing, stacked. Nothing to click.
   The drawings are inline SVG on a true 30deg isometric grid in 1px strokes:
   ink from currentColor, detail in --muted, connectors in --accent, the one
   "Paid" stamp in status green. Shared by How it works (.row-art) and the
   hero diagram (hero.css).
   One scale for every drawing: K = 1.3 on the iso grid, rendered at
   --art-k px per unit on wide screens (the Modules frame: 400px for a 336
   unit viewBox). Labels carry no font-size of their own; --art-fs sets it in
   user units, so 9.25 units render at 11px wherever the scale is --art-k.
   Loads after workflow.css, before hues.css, sky.css and motion.css. */

:root {
  --bracket: color-mix(in srgb, var(--ink) 40%, transparent);
  --reg: color-mix(in srgb, var(--ink) 24%, transparent);
  --dots: color-mix(in srgb, var(--ink) 13%, transparent);
  --paid: #1a7f45;
}

:root[data-theme="dark"] {
  --dots: color-mix(in srgb, var(--ink) 11%, transparent);
  --paid: #4ade80;
}

/* ---------- frame: corner brackets drawn on ::before, nothing else ----------
   --bk-s is the arm length, --bk-i the inset from the edge. */

.frame {
  --bk-s: 12px;
  --bk-i: 12px;
  position: relative;
}

.frame::before {
  content: "";
  position: absolute;
  inset: var(--bk-i);
  pointer-events: none;
  --g: linear-gradient(var(--bracket), var(--bracket));
  background:
    var(--g) left top / var(--bk-s) 1px,
    var(--g) left top / 1px var(--bk-s),
    var(--g) right top / var(--bk-s) 1px,
    var(--g) right top / 1px var(--bk-s),
    var(--g) left bottom / var(--bk-s) 1px,
    var(--g) left bottom / 1px var(--bk-s),
    var(--g) right bottom / var(--bk-s) 1px,
    var(--g) right bottom / 1px var(--bk-s);
  background-repeat: no-repeat;
}

/* registration marks: a small "+" in from each corner */
.frame-reg::after {
  content: "";
  position: absolute;
  inset: 36px;
  pointer-events: none;
  --g: linear-gradient(var(--reg), var(--reg));
  background:
    var(--g) left 0 top 4px / 9px 1px,
    var(--g) left 4px top 0 / 1px 9px,
    var(--g) right 0 top 4px / 9px 1px,
    var(--g) right 4px top 0 / 1px 9px,
    var(--g) left 0 bottom 4px / 9px 1px,
    var(--g) left 4px bottom 0 / 1px 9px,
    var(--g) right 0 bottom 4px / 9px 1px,
    var(--g) right 4px bottom 0 / 1px 9px;
  background-repeat: no-repeat;
}

/* the art panel: a hairline border over a faint dot grid */
.art-panel {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background-color: var(--bg);
  background-image: radial-gradient(circle at 1px 1px, var(--dots) 1px, transparent 1.5px);
  background-size: 16px 16px;
  background-position: 7px 7px;
}

/* ---------- hairline art ---------- */

.art {
  --art-k: 1.19;
  --art-fs: 9.25px;
  color: var(--ink);
}

.art svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.art :is(.s, .m, .f, .a, .g) {
  fill: none;
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.art .s {
  stroke: currentColor;
}

.art .m {
  stroke: var(--muted);
}

.art .f {
  stroke: var(--line-strong);
}

.art .a {
  stroke: var(--accent);
  stroke-width: 1.25px;
}

.art .g {
  stroke: var(--paid);
  stroke-width: 1.25px;
}

.art .dash {
  stroke-dasharray: 3 3;
}

.art .t {
  fill: var(--bg);
}

.art .d {
  fill: var(--surface);
}

.art .ak {
  fill: var(--accent);
}

.art text {
  font-family: var(--mono);
  font-size: var(--art-fs);
  font-weight: 500;
  letter-spacing: 0.04em;
  fill: var(--muted);
}

.art .tk {
  fill: var(--ink);
}

.art .tg {
  fill: var(--paid);
}

.art .dv {
  font-family: var(--sans);
  letter-spacing: 0;
}

/* the mono trace under each drawing: steps joined by hairlines */
.trace {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  margin: 0;
  font-family: var(--mono);
  font-size: var(--fs-micro);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.trace span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.trace span::before {
  content: "";
  width: 7px;
  height: 7px;
  box-shadow: inset 0 0 0 1px currentColor;
}

.trace span + span::after {
  order: -1;
  content: "";
  width: 14px;
  height: 1px;
  margin-right: 3px;
  background: var(--line-strong);
}

.trace span:last-child {
  color: var(--ink);
}

.trace span:last-child::before {
  background: var(--accent);
  box-shadow: none;
}

/* ---------- modules ---------- */

.module-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--line-strong);
}

.module {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  column-gap: 24px;
  align-items: center;
  padding: 28px 20px;
  border-top: 1px solid var(--line-strong);
}

.module-num {
  --bk-s: 7px;
  --bk-i: 0px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: var(--fs-micro);
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
}

.module h3 {
  font-size: var(--fs-h3);
}

.module p {
  max-width: 46ch;
  margin-top: 6px;
  font-size: var(--fs-sm);
  line-height: 1.43;
  color: var(--muted);
}

.module-art {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 18px;
  padding: clamp(28px, 4vw, 40px) clamp(16px, 3vw, 32px);
}

.module-art svg {
  max-width: 400px;
}

/* stacked (narrow screens, no JS): each drawing under its own row */
.modules:not(.is-story) .module-art {
  grid-column: 1 / -1;
  margin-top: 24px;
}

@media (min-width: 861px) {
  .modules:not(.is-story) .module {
    grid-template-columns: 32px minmax(0, 1fr) minmax(0, 480px);
    column-gap: 24px;
  }

  .modules:not(.is-story) .module-art {
    grid-column: 3;
    margin: 0 0 0 24px;
  }
}

/* story (wide, JS): list at left, one sticky frame in the 480px column */
.modules.is-story {
  --stage-h: min(clamp(420px, 36vw, 500px), calc(100vh - var(--header-h) - 48px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 480px);
  column-gap: 48px;
  align-items: start;
}

.modules.is-story .module {
  min-height: clamp(128px, 17vh, 160px);
  transition: background-color 300ms var(--ease);
}

/* the active row: an ink bar on the left edge, a surface fill, a filled number */
.modules.is-story .module::before {
  content: "";
  position: absolute;
  left: 0;
  top: -1px;
  bottom: 0;
  width: 2px;
  background: var(--ink);
  transform: scaleY(0);
  transition: transform 300ms var(--ease-out);
}

.modules.is-story .module.is-active {
  background-color: var(--surface);
}

.modules.is-story .module.is-active::before {
  transform: none;
}

.module-num {
  transition:
    background-color 150ms var(--ease),
    color 150ms var(--ease);
}

.modules.is-story .module.is-active .module-num {
  background-color: var(--ink);
  color: var(--bg);
}

.modules-stage {
  position: sticky;
  top: calc(50vh - var(--stage-h) / 2 + var(--header-h) / 2);
  grid-column: 2;
  grid-row: 1;
  height: var(--stage-h);
  overflow: hidden;
}

/* inside the stage the drawings shed their own frame and crossfade */
.modules-stage .module-art {
  position: absolute;
  inset: 0;
  padding: 40px 36px;
  border: 0;
  background: none;
  opacity: 0;
  filter: blur(4px);
  transition:
    opacity 300ms var(--ease),
    filter 300ms var(--ease);
}

.modules-stage .module-art::before {
  display: none;
}

.modules-stage .module-art.is-active {
  opacity: 1;
  filter: none;
}

/* ---------- How it works: title and copy left, the drawing in the right column ---------- */

#how .row {
  grid-template-rows: auto 1fr;
  align-items: start;
  padding-bottom: 40px;
}

#how .row p {
  grid-column: 2;
  grid-row: 2;
}

.row-art {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
}

/* the Modules scale for all three: each viewBox is cropped to its drawing
   (same height, same ground line), --vbw is its width in units */
.row-art svg {
  width: calc(var(--vbw) * var(--art-k) * 1px);
  max-width: 100%;
}

/* ---------- hatched band: hairlines across the page, stripes in the container ---------- */

.hatch {
  height: 32px;
  border-block: 1px solid var(--line);
}

.hatch::before {
  content: "";
  display: block;
  width: var(--container);
  height: 100%;
  margin: 0 auto;
  background: repeating-linear-gradient(-45deg, var(--line-strong) 0 1px, transparent 1px 8px);
}

@media (max-width: 760px) {
  .module {
    padding: 24px 0 32px;
    column-gap: 16px;
  }

  /* the drawing takes the panel's width so labels stay above 9px */
  .modules:not(.is-story) .module-art {
    padding-inline: 8px;
  }

  #how .row {
    grid-template-rows: none;
  }

  #how .row p,
  .row-art {
    grid-column: auto;
    grid-row: auto;
  }

  .row-art {
    margin-top: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modules.is-story .module,
  .modules.is-story .module::before,
  .module-num,
  .modules-stage .module-art {
    transition: none;
  }

  .modules-stage .module-art {
    filter: none;
  }
}

@media print {
  .modules.is-story {
    display: block;
  }

  .modules-stage {
    position: static;
    height: auto;
    overflow: visible;
  }

  .modules-stage .module-art {
    position: static;
    opacity: 1;
    filter: none;
    break-inside: avoid;
  }

  .hatch {
    display: none;
  }
}

@media (forced-colors: active) {
  .art-panel {
    background-image: none;
  }

  .hatch::before {
    background: none;
  }
}
