/* Joer — case study pages. Builds on site.css; same three colors, same rules. */

ol, ul, dl, dd { margin: 0; }
h3 { margin: 0; }

/* ---------- Back link ---------- */
.j-case-back { padding-top: clamp(24px, 3vw, var(--space-40)); }

/* ---------- Case hero ---------- */
.j-case-hero .j-hero__grid { padding-bottom: clamp(48px, 6vw, var(--space-88)); }
.j-case-hero__title { grid-column: 1 / -1; max-width: 1280px; }

.j-case-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: var(--space-24) clamp(var(--space-24), 3vw, var(--space-40));
  padding-top: var(--space-20);
  border-top: var(--rule-strong) solid var(--border-strong);
}
.j-case-meta dt { margin-bottom: var(--space-6); }
.j-case-meta dd { font-weight: 700; font-size: 17px; line-height: 1.35; }

/* ---------- Context panel ---------- */
.j-case-context { padding-top: clamp(56px, 7vw, var(--space-112)); padding-bottom: clamp(80px, 10vw, var(--space-140)); }
.j-facts {
  background: var(--surface-panel);
  color: var(--text-on-panel);
  border-radius: 0;
  padding: clamp(24px, 4vw, var(--space-56));
  display: grid;
  gap: clamp(var(--space-40), 5vw, var(--space-64));
}
.j-facts .j-section-header { align-items: center; gap: var(--space-20); }
.j-facts__logo { display: block; width: auto; height: clamp(72px, 9vw, 120px); }
.j-facts__body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: clamp(var(--space-32), 4vw, var(--space-56));
  align-items: start;
}
.j-facts__text { display: grid; gap: var(--space-20); max-width: 760px; }
.j-facts__text p { font-size: clamp(18px, 1.6vw, 22px); line-height: 1.5; }
.j-facts__text p:first-child { font-weight: 700; }
/* Product shot sits inside the panel: drop its own frame */
.j-facts .j-case-shot { margin-top: 0; }
.j-facts .j-case-shot__frame { padding: 0; background: none; }
.j-facts .j-stripes--field { height: clamp(56px, 7vw, 96px); }

/* ---------- Product shot ---------- */
.j-case-shot { margin-top: clamp(var(--space-40), 5vw, var(--space-72)); display: grid; gap: var(--space-14); }
.j-case-shot__frame {
  position: relative;
  display: block;
  padding: clamp(var(--space-16), 4vw, var(--space-56));
  border-radius: 0;
  background: var(--surface-panel);
  transition: background .35s ease;
}
.j-case-shot__media { display: block; overflow: hidden; border-radius: 0; }
.j-case-shot__media img {
  width: 100%;
  height: auto;
  transition: scale .7s cubic-bezier(.2, .8, .3, 1), filter .4s ease;
}
/* "Ver projeto no ar" pill rises from the bottom of the frame */
.j-case-shot__cta {
  position: absolute;
  left: 50%;
  top: 50%;
  display: inline-flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-18) var(--space-32);
  border-radius: 0;
  background: var(--accent);
  color: var(--ink);
  font-weight: 800;
  font-size: clamp(16px, 1.4vw, 20px);
  white-space: nowrap;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
  opacity: 0;
  translate: -50% calc(-50% + 16px);
  transition: opacity .3s ease, translate .45s cubic-bezier(.2, .8, .3, 1.3);
}
.j-case-shot__cta > span { display: inline-block; transition: translate .3s ease; }

.j-case-shot__frame:is(:hover, :focus-visible) { background: var(--ink-deep); }
.j-case-shot__frame:is(:hover, :focus-visible) img { scale: 1.035; filter: brightness(.7); }
.j-case-shot__frame:is(:hover, :focus-visible) .j-case-shot__cta { opacity: 1; translate: -50% -50%; }
.j-case-shot__frame:is(:hover, :focus-visible) .j-case-shot__cta > span { translate: 3px -3px; }
.j-case-shot__frame:active img { scale: 1.01; transition-duration: .1s; }
.j-case-shot__frame:focus-visible { outline-offset: 4px; }

/* Touch screens have no hover: keep the pill visible so the link reads as a link */
@media (hover: none) {
  .j-case-shot__cta { opacity: 1; translate: -50% -50%; padding: var(--space-12) var(--space-18); font-size: 14px; }
}
.j-case-shot__caption { display: flex; justify-content: space-between; gap: var(--space-6) var(--space-24); flex-wrap: wrap; }

/* ---------- Chapters ---------- */
.j-chapters { padding-bottom: clamp(80px, 10vw, var(--space-140)); }
.j-chapter {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--space-24) clamp(var(--space-32), 5vw, var(--space-88));
  padding: clamp(40px, 5vw, var(--space-72)) 0;
  border-top: var(--rule-strong) solid var(--border-strong);
}
.j-chapter__head {
  display: grid;
  gap: var(--space-14);
  align-content: start;
  position: sticky;
  top: var(--header-offset);
  align-self: start;
}
.j-chapter__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(44px, 5.4vw, 88px);
  line-height: .95;
  letter-spacing: -.005em;
  text-transform: uppercase;
  text-wrap: balance;
}
.j-chapter__body { display: grid; gap: clamp(var(--space-32), 4vw, var(--space-56)); min-width: 0; }

.j-prose { display: grid; gap: var(--space-22); max-width: 700px; }
.j-prose p {
  font-size: clamp(18px, 1.35vw, 20px);
  line-height: 1.6;
  font-weight: 500;
  text-wrap: pretty;
}
.j-prose strong { font-weight: 800; }
.j-prose .j-prose__open {
  font-size: clamp(22px, 2vw, 28px);
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -.3px;
}

.j-pull {
  padding-left: var(--space-24);
  border-left: var(--rule-strong) solid var(--ink);
  max-width: 760px;
}

/* ---------- Flow diagram (write path vs read path) ----------
   A "U": the vote path runs down into the vote store, the scoreboard
   path runs back up from it. Both lanes share row tracks (subgrid) so
   the steps line up; connectors live in the row gaps. */
@property --j-sweep { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

.j-flow {
  --edge: var(--space-40);
  background: var(--surface-panel);
  color: var(--text-on-panel);
  border-radius: 0;
  padding: clamp(20px, 3vw, var(--space-40));
  display: grid;
  gap: clamp(var(--space-28), 3vw, var(--space-40));
}

.j-flow__head { display: grid; gap: var(--space-14); }
.j-flow__kicker { display: flex; justify-content: space-between; gap: var(--space-12); }
.j-flow__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(32px, 3.4vw, 52px);
  line-height: .95;
  text-transform: uppercase;
  color: var(--text-display);
}
.j-flow__title span { color: var(--accent); }
.j-flow__legend {
  list-style: none;
  padding: var(--space-14) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6) var(--space-24);
  border-top: var(--rule-hair) solid var(--border-on-panel);
}
.j-flow__legend li { display: inline-flex; align-items: center; gap: var(--space-12); }
.j-flow__swatch { display: inline-block; flex: none; }
.j-flow__swatch--key { width: 14px; height: 14px; border-radius: 0; background: var(--accent); }
.j-flow__swatch--edge { position: relative; width: 24px; height: 2px; background: var(--accent); }
.j-flow__swatch--edge::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -4px;
  border-left: 7px solid var(--accent);
  border-block: 5px solid transparent;
}

/* Map */
.j-flow__map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto repeat(3, auto) auto;
  gap: var(--edge) clamp(var(--space-16), 2.4vw, var(--space-32));
}
.j-flow__lane { grid-row: 1 / span 4; display: grid; grid-template-rows: subgrid; }
.j-flow__lane--read { grid-column: 2; }
.j-flow__label {
  display: grid;
  gap: var(--space-4);
  align-self: end;
  margin-bottom: calc(var(--space-16) - var(--edge));
  padding-bottom: var(--space-12);
  border-bottom: var(--rule-hair) solid var(--border-on-panel);
}
.j-flow__label strong { color: var(--text-display); font-weight: 400; }
.j-flow__steps { grid-row: 2 / span 3; display: grid; grid-template-rows: subgrid; list-style: none; padding: 0; }
/* Read lane flows upward: data leaves the store and climbs to the visitor */
.j-flow__lane--read .j-flow__step:nth-child(1) { grid-row: 3; }
.j-flow__lane--read .j-flow__step:nth-child(2) { grid-row: 2; }
.j-flow__lane--read .j-flow__step:nth-child(3) { grid-row: 1; }

.j-flow__step,
.j-flow__hub {
  position: relative;
  display: grid;
  gap: var(--space-6);
  align-content: start;
  padding: var(--space-16) var(--space-18) var(--space-18);
  border: var(--rule-strong) solid var(--border-on-panel);
  border-radius: 0;
}
.j-flow__meta {
  display: flex;
  gap: var(--space-12);
  margin-bottom: var(--space-6);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  text-transform: uppercase;
}
.j-flow__meta em { font-style: normal; color: var(--text-display); }
.j-flow__step b,
.j-flow__hub b { font-weight: 800; font-size: 17px; line-height: 1.2; letter-spacing: -.2px; color: var(--text-display); }
.j-flow__desc { font-size: 14px; line-height: 1.45; font-weight: 500; text-wrap: pretty; }

.j-flow__step--key { background: var(--accent); color: var(--ink); }
.j-flow__step--key :is(b, .j-flow__meta em) { color: var(--ink); }

/* The store both paths meet at */
.j-flow__hub {
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--space-24);
  padding: var(--space-20) var(--space-24);
  background: var(--paper);
  border-color: var(--paper);
  color: var(--ink);
}
.j-flow__hub > :not(.j-flow__clock) { grid-column: 1; }
.j-flow__hub .j-flow__meta em,
.j-flow__hub b { color: var(--ink); }
.j-flow__hub b { font-family: var(--font-display); font-weight: 400; font-size: clamp(28px, 2.6vw, 40px); line-height: 1; text-transform: uppercase; letter-spacing: 0; }
.j-flow__hub .j-flow__desc { max-width: 520px; }
/* 5-minute cycle, sped up: the sweep is the cache aging until the next snapshot */
.j-flow__clock {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  width: clamp(48px, 5vw, 64px);
  aspect-ratio: 1;
  border-radius: 0;
  border: var(--rule-strong) solid var(--ink);
  background: conic-gradient(var(--ink) var(--j-sweep), transparent 0);
  animation: j-flow-sweep 6s linear infinite;
}

/* Connectors: a line, an arrowhead and a travelling pulse, all backgrounds
   on one pseudo-element. Drawn pointing down; flipped for the read lane. */
.j-flow__step::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% + var(--rule-strong));
  width: 12px;
  height: calc(var(--edge) - 2 * var(--rule-strong));
  translate: -50% 0;
  background:
    radial-gradient(circle, var(--paper) 2.5px, transparent 3.5px) center -12px / 12px 12px no-repeat,
    linear-gradient(var(--accent), var(--accent)) center top / 2px calc(100% - 7px) no-repeat,
    linear-gradient(to top right, transparent 50%, var(--accent) 0) left bottom / 6px 7px no-repeat,
    linear-gradient(to bottom right, var(--accent) 50%, transparent 0) right bottom / 6px 7px no-repeat;
  animation: j-flow-pulse 2.8s cubic-bezier(.5, 0, .5, 1) infinite;
  animation-delay: var(--d, 0s);
}
.j-flow__lane--read .j-flow__step::after { scale: 1 -1; }
.j-flow__lane--write .j-flow__step:nth-child(2) { --d: .35s; }
.j-flow__lane--write .j-flow__step:nth-child(3) { --d: .7s; }
.j-flow__lane--read .j-flow__step:nth-child(1) { --d: 1.4s; }
.j-flow__lane--read .j-flow__step:nth-child(2) { --d: 1.75s; }
.j-flow__lane--read .j-flow__step:nth-child(3) { --d: 2.1s; }

@keyframes j-flow-pulse {
  0%, 15% { background-position: center -12px, center top, left bottom, right bottom; }
  60%, 100% { background-position: center calc(100% + 12px), center top, left bottom, right bottom; }
}
@keyframes j-flow-sweep { to { --j-sweep: 360deg; } }
@media (prefers-reduced-motion: reduce) {
  .j-flow__step::after,
  .j-flow__clock { animation: none; }
  .j-flow__clock { --j-sweep: 300deg; }
}

/* Numbers */
.j-flow__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: var(--space-24);
  padding-top: var(--space-24);
  border-top: var(--rule-hair) solid var(--border-on-panel);
}
.j-flow__stats > div { display: grid; gap: var(--space-6); align-content: start; }
.j-flow__stats dd { font-size: 14px; line-height: 1.4; font-weight: 500; }
.j-flow__stats strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(44px, 4.4vw, 64px);
  line-height: .95;
  color: var(--text-display);
}
.j-flow__note { font-size: 15px; line-height: 1.5; font-weight: 500; color: var(--paper); max-width: 720px; }

/* ---------- Final tally ---------- */
.j-tally-section { padding-bottom: clamp(80px, 10vw, var(--space-140)); }
.j-tally {
  background: var(--surface-panel);
  color: var(--text-on-panel);
  border-radius: 0;
  padding: clamp(24px, 4vw, var(--space-56));
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(var(--space-40), 5vw, var(--space-88));
}
.j-tally__head { display: grid; gap: var(--space-20); align-content: space-between; }
.j-tally__total {
  font-family: var(--font-display);
  font-size: clamp(88px, 11vw, 180px);
  line-height: .84;
  letter-spacing: -.01em;
  color: var(--text-display);
}
.j-tally__caption { padding-top: var(--space-24); font-family: var(--font-mono); font-weight: 400; font-size: 16px; line-height: 1.4; }
.j-tally__note { font-size: 14px; line-height: 1.5; font-weight: 500; color: var(--paper); max-width: 420px; }

.j-tally__list { list-style: none; padding: 0; display: grid; gap: var(--space-18); align-content: center; }
.j-tally__row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: var(--space-6) var(--space-14);
  align-items: baseline;
}
.j-tally__pos { font-family: var(--font-mono); font-size: 12px; }
.j-tally__name { font-weight: 800; font-size: clamp(16px, 1.4vw, 20px); letter-spacing: -.2px; }
.j-tally__value { font-family: var(--font-mono); font-size: 12px; text-align: right; white-space: nowrap; }
.j-tally__value b { font-weight: 400; color: var(--text-display); }
.j-tally__bar {
  grid-column: 2 / -1;
  height: 12px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 0;
  overflow: hidden;
}
.j-tally__bar > span {
  display: block;
  height: 100%;
  width: var(--w);
  min-width: 4px;
  background: var(--accent);
  border-radius: 0;
}
.j-tally__row:first-child .j-tally__bar > span { background: var(--paper); }

/* ---------- Stack ---------- */
.j-stack { list-style: none; padding: 0; border-top: var(--rule-strong) solid var(--border-strong); }
.j-stack li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: var(--space-6) var(--space-24);
  padding: var(--space-18) 0;
  border-bottom: var(--rule-hair) solid var(--border-strong);
}
.j-stack b { font-weight: 800; font-size: 18px; }
.j-stack span { font-size: 16px; line-height: 1.45; font-weight: 500; }

/* ---------- Live link + next ---------- */
.j-case-next { padding-bottom: clamp(96px, 12vw, var(--space-160)); }
.j-case-next__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  border-top: var(--rule-strong) solid var(--border-strong);
}
.j-case-next__link {
  display: grid;
  gap: var(--space-16);
  align-content: space-between;
  padding: var(--space-28) clamp(0px, 1.4vw, var(--space-20)) var(--space-40);
  border-bottom: var(--rule-strong) solid var(--border-strong);
  transition: background .25s ease, color .25s ease;
}
.j-case-next__link + .j-case-next__link { border-left: var(--rule-strong) solid var(--border-strong); }
.j-case-next__title {
  font-family: var(--font-display);
  font-size: clamp(48px, 6vw, 96px);
  line-height: .95;
  text-transform: uppercase;
  color: var(--text-display);
  transition: color .25s ease;
}
.j-case-next__link:is(:hover, :focus-visible) { background: var(--ink); color: var(--accent); }
.j-case-next__link:is(:hover, :focus-visible) .j-case-next__title { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .j-chapter,
  .j-tally { grid-template-columns: minmax(0, 1fr); }
  .j-chapter__head { position: static; }
  .j-case-next__link + .j-case-next__link { border-left: 0; }
}
@media (max-width: 560px) {
  /* One column: vote path, store, then scoreboard path, all reading downward */
  .j-flow__map { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; row-gap: 0; }
  .j-flow__lane,
  .j-flow__steps { grid-row: auto; grid-template-rows: none; row-gap: var(--edge); }
  .j-flow__lane { grid-column: 1; row-gap: var(--space-16); }
  .j-flow__lane--read { order: 2; padding-top: var(--edge); }
  .j-flow__hub { order: 1; margin-top: var(--edge); }
  .j-flow__label { margin-bottom: 0; }
  .j-flow__lane--read .j-flow__step:nth-child(n) { grid-row: auto; }
  .j-flow__lane--read .j-flow__step::after { scale: 1 1; top: auto; bottom: calc(100% + var(--rule-strong)); }
  .j-flow__lane--read .j-flow__step:first-child::after { content: none; }
  .j-flow__hub::after {
    content: "";
    position: absolute;
    left: 50%;
    top: calc(100% + var(--rule-strong));
    translate: -50% 0;
    width: 2px;
    height: calc(var(--edge) - 7px);
    background: var(--accent);
  }
  .j-flow__hub { grid-template-columns: minmax(0, 1fr); }
  .j-flow__clock { display: none; }
  .j-stack li { grid-template-columns: minmax(0, 1fr); }
}
