/* =====================================================================
   2 · PROBLEM — "the duct-taped stack" vs Swarm OS
   Task: problem · prefix: prob- · background: --paper
   Builds on base.css; only styles prob-* classes and base classes used
   inside this section's own markup.
   ===================================================================== */

.prob {
  /* local tokens (scoped, never global) */
  --prob-line: rgba(0, 0, 0, .06);
  --prob-old-bg: #FAFBFC;
  --prob-new-bg: #FFFEFB;
  --prob-new-hover: #FFFAEB;
  --prob-head-old: #F5F7FA;
  --prob-head-new: #FFFCF2;
  --prob-mark: rgba(30, 58, 95, .34);
  --prob-pad-x: 28px;
  --prob-gx: 170px;            /* drafting-grid bleed around the card */
  --prob-gy: 88px;
  --prob-tape-bg:
    linear-gradient(180deg, rgba(255, 255, 255, .55) 0%, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0) 70%, rgba(15, 23, 42, .08) 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .22) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(0deg, rgba(15, 23, 42, .045) 0 1px, transparent 1px 4px),
    #CDD3DC;
}

/* ---------- Head ---------- */
.prob-head { text-align: center; }

.prob .prob-title {
  font-family: var(--f-display);
  font-weight: 400;                       /* Anton ships one weight */
  font-size: clamp(40px, 5vw, 64px);      /* two long lines: sized so each fits the 1200 container */
  line-height: 1.04;
  color: var(--ink);
  margin-bottom: 26px;
}
.prob-title__line { display: block; text-wrap: balance; }

/* "duct-taped": a strip of silver tape slapped behind the word */
.prob-tape {
  position: relative; display: inline-block; isolation: isolate; white-space: nowrap;
}
.prob-tape::before {
  content: ''; position: absolute; z-index: -1;
  left: -.15em; right: -.17em; top: .12em; bottom: -.04em;    /* ~.13em of tape above the caps and below the baseline */
  background: var(--prob-tape-bg);
  clip-path: polygon(
    .05em 0, calc(100% - .03em) .02em, 100% 18%, calc(100% - .06em) 32%, 100% 47%,
    calc(100% - .05em) 63%, 100% 78%, calc(100% - .04em) 92%, calc(100% - .02em) 100%,
    .03em calc(100% - .03em), 0 86%, .06em 71%, 0 56%, .05em 41%, 0 26%, .06em 12%
  );
  /* unrolls from the left edge; translateY keeps the 1deg tilt centred on the word */
  transform: translateY(.04em) rotate(-1deg);
  transform-origin: 0 50%;
}
.js .prob-title .prob-tape::before {
  transform: translateY(.04em) rotate(-1deg) scaleX(0);
  transition: transform .55s cubic-bezier(.25, .8, .25, 1) .6s;
}
.js .prob-title.is-in .prob-tape::before { transform: translateY(.04em) rotate(-1deg) scaleX(1); }

.prob .prob-body { max-width: 720px; text-wrap: pretty; }

/* ---------- Comparison frame (drafting sheet around the card) ---------- */
.prob-frame {
  position: relative; isolation: isolate;
  max-width: 820px; margin: 92px auto 0;
}
/* faint graph paper that fades out around the card */
.prob-frame::before {
  content: ''; position: absolute; z-index: -1; pointer-events: none;
  inset: calc(var(--prob-gy) * -1) calc(var(--prob-gx) * -1);
  background-image:
    linear-gradient(rgba(30, 58, 95, .075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 58, 95, .075) 1px, transparent 1px);
  background-size: 46px 46px;
  background-position: var(--prob-gx) var(--prob-gy);   /* a grid line lands on the card's left/top edge */
  -webkit-mask-image: radial-gradient(closest-side, #000 58%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 58%, transparent 100%);
}

/* figure caption, technical-drawing style */
.prob .prob-fig {
  position: absolute; right: -.24em; bottom: calc(100% + 26px);   /* cancels trailing tracking: text ends flush with the card */
  font-size: 10px; color: rgba(30, 58, 95, .55); white-space: nowrap;
}

/* registration / crop marks at the four corners */
.prob-marks {
  position: absolute; inset: -16px; pointer-events: none;
  background:
    linear-gradient(var(--prob-mark), var(--prob-mark)) left top / 10px 1px,
    linear-gradient(var(--prob-mark), var(--prob-mark)) left top / 1px 10px,
    linear-gradient(var(--prob-mark), var(--prob-mark)) right top / 10px 1px,
    linear-gradient(var(--prob-mark), var(--prob-mark)) right top / 1px 10px,
    linear-gradient(var(--prob-mark), var(--prob-mark)) left bottom / 10px 1px,
    linear-gradient(var(--prob-mark), var(--prob-mark)) left bottom / 1px 10px,
    linear-gradient(var(--prob-mark), var(--prob-mark)) right bottom / 10px 1px,
    linear-gradient(var(--prob-mark), var(--prob-mark)) right bottom / 1px 10px;
  background-repeat: no-repeat;
}

/* a torn strip of tape holding the old-stack corner together */
.prob-corner {
  position: absolute; z-index: 3; pointer-events: none;
  left: -30px; top: -4px; width: 76px; height: 24px;     /* centre sits 8px inside the card corner */
  transform: rotate(-45deg);
  filter: drop-shadow(0 1px 1.5px rgba(15, 23, 42, .16));
}
.prob-corner__tape {
  display: block; width: 100%; height: 100%;
  background: var(--prob-tape-bg);
  clip-path: polygon(
    2px 0, calc(100% - 1px) 1px, 100% 22%, calc(100% - 3px) 40%, 100% 60%,
    calc(100% - 2.5px) 80%, calc(100% - 1px) 100%, 1.5px calc(100% - 1px), 0 78%, 3px 58%, 0 38%, 2.5px 18%
  );
}

/* ---------- Card ---------- */
.prob-card {
  position: relative; isolation: isolate; overflow: hidden;
  background: var(--white);
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 18px;
  box-shadow: 0 30px 70px -42px rgba(15, 23, 42, .4);
}

/* header */
.prob-card__head {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border-bottom: 1px solid var(--prob-line);
}
.prob-card__th {
  display: flex; align-items: center; gap: 10px;
  padding: 18px var(--prob-pad-x);
  font: 700 16px/1.2 var(--f-label); letter-spacing: .06em; text-transform: uppercase;
}
.prob-card__th--old { background: var(--prob-head-old); color: var(--text-3); }
.prob-card__th--new {
  background: var(--prob-head-new); color: var(--ink);
  border-left: 1px solid var(--prob-line);
  box-shadow: inset 0 2px 0 var(--yellow);
}
.prob-card__th--combo { display: none; }

.prob-card__dot {
  flex: none; width: 8px; height: 8px; border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(247, 198, 0, .18);
  animation: dotPulse 2.4s ease-in-out infinite;
}

/* "vs" seal sitting on the column divider */
.prob-card__vs {
  position: absolute; left: 50%; top: 50%; z-index: 1;
  transform: translate(-50%, -50%);
  display: grid; place-items: center;
  width: 30px; height: 30px; padding-left: .08em;      /* optical centring for the tracking */
  border-radius: 50%;
  background: var(--white);
  border: 1px solid rgba(0, 0, 0, .08);
  box-shadow: 0 4px 10px -4px rgba(15, 23, 42, .18);
  font: 700 11px/1 var(--f-label); letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3);
}

/* rows */
.prob-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.prob-row + .prob-row { border-top: 1px solid var(--prob-line); }

.prob-cell {
  position: relative;
  display: flex; align-items: flex-start; gap: 14px;
  padding: 18px var(--prob-pad-x);
  font-size: 14.5px; line-height: 22px;
  transition: background-color .25s var(--ease-out);
}
.prob-cell--old { background: var(--prob-old-bg); color: var(--text-3); }
.prob-cell--new {
  background: var(--prob-new-bg); color: var(--text-2);
  border-left: 1px solid var(--prob-line);
}
.prob-cell--new strong { color: var(--ink); font-weight: 700; }
.prob-cell__text { min-width: 0; text-wrap: pretty; }

/* plan tag on mechanisms that start on Mosquito: small and neutral, like the season section's (no yellow) */
.prob-tier {
  display: inline-block; vertical-align: 1px;
  margin-left: 2px; padding: 3px 6px 2px;
  border: 1px solid rgba(0, 0, 0, .12);
  font: 600 11px/1 var(--f-label); letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); white-space: nowrap;
}

/* icon discs (inline SVG strokes, so they render identically everywhere) */
.prob-icon {
  flex: none; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  transition: transform .25s var(--ease-out);
}
.prob-icon svg { width: 12px; height: 12px; overflow: visible; }
.prob-icon--x { background: var(--red-soft); color: var(--red); }
.prob-icon--check { background: var(--green-soft); color: var(--green); }

/* ---------- Motion: rows reveal in a quick stagger, checks draw in ---------- */
.prob-row:nth-child(1) { --prob-d: .10s; }
.prob-row:nth-child(2) { --prob-d: .16s; }
.prob-row:nth-child(3) { --prob-d: .22s; }
.prob-row:nth-child(4) { --prob-d: .28s; }
.prob-row:nth-child(5) { --prob-d: .34s; }
.prob-row:nth-child(6) { --prob-d: .40s; }
.prob-row:nth-child(7) { --prob-d: .46s; }

.js .prob-row[data-reveal] {
  transform: translateY(12px);
  transition-duration: .55s;
  transition-delay: var(--prob-d, 0s);
}
.js .prob-row[data-reveal].is-in { transform: none; }

.js .prob-row .prob-icon--check path {
  stroke-dasharray: 11; stroke-dashoffset: 11;            /* path length ≈ 10.2 */
  transition: stroke-dashoffset .45s var(--ease-out);
  transition-delay: calc(var(--prob-d, 0s) + .3s);
}
.js .prob-row.is-in .prob-icon--check path { stroke-dashoffset: 0; }

@media (hover: hover) and (min-width: 901px) {
  .prob-row:hover .prob-cell--new { background: var(--prob-new-hover); }
  .prob-row:hover .prob-icon--check { transform: scale(1.08); }
}

/* ---------- Bridge to the Swarm OS section ---------- */
.prob-next { margin-top: 48px; text-align: center; }
.prob .prob-next__link {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--navy); border-bottom-color: rgba(30, 58, 95, .3);
}
.prob .prob-next__link svg { width: 12px; height: 12px; transition: transform .2s var(--ease-out); }
.prob .prob-next__link:hover { color: var(--ink); border-bottom-color: var(--yellow); }
.prob .prob-next__link:hover svg { transform: translateY(2px); }
.prob .prob-next__link:focus-visible { outline-color: var(--navy); }   /* yellow ring is too faint on paper */

/* ---------- ≤900px: one column, old struck above new, combined header ---------- */
@media (max-width: 900px) {
  .prob { --prob-pad-x: 22px; --prob-gx: 56px; --prob-gy: 56px; }

  .prob .prob-title { font-size: clamp(30px, 7.4vw, 56px); margin-bottom: 22px; }
  .prob-title__chunk { display: block; text-wrap: balance; }

  .prob-frame { margin-top: 80px; }

  /* the card can run edge to edge here, so the tape straddles the top edge instead of the corner */
  .prob-corner { left: 20px; top: -12px; width: 64px; height: 22px; transform: rotate(-5deg); }

  .prob-card__head { grid-template-columns: minmax(0, 1fr); }
  .prob-card__th--old, .prob-card__th--new, .prob-card__vs { display: none; }
  .prob-card__th--combo {
    display: flex; flex-wrap: wrap; gap: 10px;
    padding-top: 15px; padding-bottom: 15px;
    font-size: 15px;
    background: linear-gradient(90deg, var(--prob-head-old) 0%, var(--prob-head-old) 34%, var(--prob-head-new) 100%);
  }
  .prob-card__combo-old { color: var(--text-3); }
  .prob-card__combo-vs {
    display: inline-grid; place-items: center;
    width: 24px; height: 24px; padding-left: .08em; border-radius: 50%;
    background: var(--white); border: 1px solid rgba(0, 0, 0, .08);
    font-size: 10px; letter-spacing: .08em; color: var(--text-3);
  }
  .prob-card__combo-new { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }

  .prob-row { grid-template-columns: minmax(0, 1fr); }
  .prob-cell--old { padding-top: 16px; padding-bottom: 6px; }
  .prob-cell--new { padding-top: 10px; padding-bottom: 18px; border-left: 0; }

  .prob-cell--old .prob-cell__text {
    font-size: 13.5px;
    text-decoration: line-through;
    text-decoration-thickness: 1px;
    text-decoration-color: rgba(107, 114, 128, .65);
  }

  /* hairline joining each cross to its check: red half below the cross, green half above the check */
  .prob-cell--old::after,
  .prob-cell--new::before {
    content: ''; position: absolute; width: 1px;
    left: calc(var(--prob-pad-x) + 10.5px);
  }
  .prob-cell--old::after { top: calc(16px + 22px + 3px); bottom: 0; background: rgba(229, 62, 62, .28); }
  .prob-cell--new::before { top: 0; height: 7px; background: rgba(5, 150, 105, .32); }
}

/* ---------- ≤600px ---------- */
@media (max-width: 600px) {
  .prob { --prob-pad-x: 18px; --prob-gx: var(--gutter); --prob-gy: 40px; }

  .prob .prob-body { font-size: 16px; line-height: 1.75; }

  .prob-frame { margin-top: 64px; }
  .prob .prob-fig { bottom: calc(100% + 14px); }
  .prob-marks { display: none; }

  .prob-card { border-radius: 14px; }
  .prob-cell { gap: 12px; }

  .prob-next { margin-top: 40px; }
}

/* ---------- Reduced motion: everything settles immediately ---------- */
@media (prefers-reduced-motion: reduce) {
  .js .prob-row[data-reveal] { opacity: 1; transform: none; }
  .js .prob-title .prob-tape::before { transform: translateY(.04em) rotate(-1deg); }
  .js .prob-row .prob-icon--check path { stroke-dashoffset: 0; }
  .prob-row, .prob-tape::before, .prob-icon path { transition-delay: 0s !important; }
  .prob-card__dot { animation: none; }
}

/* ---------- Forced colours: keep the icon discs legible ---------- */
@media (forced-colors: active) {
  .prob-icon { border: 1px solid CanvasText; }
  .prob-card__dot { background: CanvasText; }
}
