/* ============================================================
   Purple Kiwi AI — Portfolio page (/work/)
   Layered on top of styles.css. Inherits every brand token:
   Bricolage Grotesque display · Hanken Grotesk body ·
   aubergine ink · purple + kiwi-green accents · soft radii.
   ============================================================ */

:root {
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;

  /* Semantic scoring colors. Kiwi green = healthy, amber = watch,
     orange = at risk. These carry meaning, so they stay distinct
     from the brand accents. */
  --score-good: var(--accent);
  --score-warn: #F0B24A;
  --score-alert: #E8734A;

  /* On-dark text ramp for the panel visuals. */
  --on-dark: #f3edf9;
  --on-dark-soft: #cabbd9;
  --on-dark-muted: #a294b4;
  --on-dark-line: rgba(255, 255, 255, 0.12);
}

/* ---------- Shared bits ---------- */

/* Each project's own favicon, pulled from the live site, sits next to
   every place we name that site. Decorative — the adjacent text is the
   accessible label, so the images carry alt="". Most of these marks
   already ship with their own background, so no plate by default;
   .is-plate is for marks drawn in white line art (Service No-Show),
   which would otherwise vanish on the paper background. */
.pf-favicon {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  object-fit: contain;
}
.pf-favicon.is-plate {
  padding: 2px;
  background: var(--ink);
}
.pf-favicon.is-lg { width: 24px; height: 24px; border-radius: 6px; }

.pf-mono {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Everything that is metadata rather than prose is set in mono —
   the one typographic rule carried over wholesale from the design. */
.pf-meta,
.pf-status,
.pf-url,
.pf-num,
.pf-row-cat,
.pf-chips li,
.pf-label,
.pf-panel-eyebrow,
.pf-caption,
.pf-stat span,
.pf-ledger dt {
  font-family: var(--mono);
}

.pf-caption {
  margin-top: 10px;
  font-size: 0.68rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.pf-panel .pf-caption { color: var(--on-dark-muted); }

.pf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}
.pf-chips li {
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-soft);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

/* ---------- Hero ---------- */
.pf-hero { padding-top: calc(var(--pad) * 0.6); padding-bottom: calc(var(--pad) * 0.7); }
.pf-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.62fr);
  gap: 60px;
  align-items: end;
}
.pf-hero h1 { max-width: 14ch; }
.pf-hero-lede {
  margin-top: 26px;
  max-width: 58ch;
  font-size: 1.14rem;
  line-height: 1.6;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* Stat ledger — hairline rows, no card chrome. */
.pf-ledger {
  margin: 0;
  padding: 4px 0 0;
  border-top: 2px solid var(--ink);
}
.pf-ledger-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.pf-ledger-row:last-child { border-bottom: 0; }
.pf-ledger dt {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
}
.pf-ledger dd {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.7rem;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
}

/* ---------- Index table ---------- */
.pf-index { padding-block: calc(var(--pad) * 0.5); }
/* The index label is an h2 for heading order, but styled as an eyebrow —
   so it has to opt out of the display font the h1/h2/h3 rule applies. */
.pf-index h2.eyebrow { font-family: var(--body); }
.pf-index-table {
  margin-top: 22px;
  border-top: 1px solid var(--line);
}
.pf-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 2.1fr) minmax(0, 2.4fr) 150px;
  gap: 24px;
  align-items: baseline;
  padding: 20px 14px;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: background .18s ease;
}
.pf-row:hover { background: var(--panel-2); }
.pf-row:focus-visible {
  outline: 2px solid var(--purple-deep);
  outline-offset: 2px;
  background: var(--panel-2);
}
.pf-num {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--purple-deep);
}
.pf-row-title {
  font-family: var(--display);
  /* Kept inline (not flex) so the row's baseline alignment still keys
     off the title text rather than the favicon's bottom edge. */
  font-weight: 700;
  font-size: 1.28rem;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.pf-row-title .pf-favicon {
  display: inline-block;
  margin-right: 10px;
  vertical-align: -0.22em;
}
.pf-row-desc { font-size: 0.95rem; line-height: 1.45; color: var(--muted); }
.pf-row-cat {
  justify-self: end;
  text-align: right;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Case study shell ---------- */
.pf-case { border-top: 1px solid var(--line); scroll-margin-top: 92px; }
.pf-case-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 60px;
  align-items: start;
}
/* Visual-left cases are flipped with `order`, so the DOM keeps copy
   first and the single-column stack always reads copy → visual. */
.pf-case.is-flipped .pf-case-visual { order: -1; }

.pf-case-visual {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pf-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 16px;
}
.pf-status {
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
}
.pf-case h2 { font-size: clamp(2rem, 3.6vw, 3rem); }
.pf-url {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--purple-deep);
  font-weight: 600;
}
.pf-url span { transition: transform .18s ease; }
.pf-url:hover { color: var(--ink); }
.pf-url:hover span { transform: translateX(3px); }
.pf-case-lede {
  margin-top: 20px;
  font-size: 1.06rem;
  line-height: 1.6;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* The AI / value pair — the spine of every case study. */
.pf-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 32px;
  margin-top: 34px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.pf-label {
  margin: 0 0 10px;
  font-size: 0.66rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  font-weight: 500;
}
.pf-label.is-ai { color: var(--purple-deep); }
.pf-label.is-value { color: var(--accent-ink); }
.pf-pair p:not(.pf-label) { font-size: 0.95rem; line-height: 1.62; color: var(--ink-soft); }

/* Stat strip inside a case study. */
.pf-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  margin-top: 30px;
  padding: 1px;
  background: var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.pf-stat { padding: 16px 18px; background: var(--paper); }
.pf-stat strong {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.7rem;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.pf-stat strong i { font-style: normal; font-size: 1.05rem; }
.pf-stat.is-purple strong { color: var(--purple-deep); }
.pf-stat span {
  display: block;
  margin-top: 8px;
  font-size: 0.63rem;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Capability 2-up (Lakou). */
.pf-capabilities {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 24px;
  margin-top: 28px;
}
.pf-capabilities p:not(.pf-label) { font-size: 0.9rem; line-height: 1.55; color: var(--ink-soft); }

/* ---------- Visual: browser frame ---------- */
.pf-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.pf-frame-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.pf-frame-bar i { width: 9px; height: 9px; border-radius: 999px; background: var(--line-strong); }
.pf-frame-bar i:first-child { background: var(--purple); }
.pf-frame-bar i:nth-child(2) { background: var(--accent); }
.pf-frame-bar span {
  margin-left: 8px;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.pf-frame img { display: block; width: 100%; height: auto; }

/* ---------- Visual: dark panel ---------- */
.pf-panel {
  padding: 24px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--on-dark);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: var(--shadow-sm);
}
.pf-panel-eyebrow {
  margin: 0 0 4px;
  font-size: 0.63rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
}
.pf-panel-sub {
  margin: 0 0 18px;
  font-family: var(--mono);
  font-size: 0.66rem;
  line-height: 1.5;
  color: var(--on-dark-muted);
}

/* Score bars (AuditSpark). */
.pf-scores { display: grid; gap: 11px; margin-top: 16px; }
.pf-score {
  display: grid;
  grid-template-columns: 58px 1fr 40px;
  gap: 12px;
  align-items: center;
}
.pf-score dt {
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.06em;
  color: var(--on-dark-soft);
}
.pf-score-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.pf-score-fill { display: block; height: 100%; border-radius: 999px; background: var(--score-good); }
.pf-score-fill.is-warn { background: var(--score-warn); }
.pf-score-fill.is-alert { background: var(--score-alert); }
.pf-score dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  text-align: right;
  color: var(--on-dark);
}

/* Diagnostic stack (Citation Lab). Column-reverse so L1 sits at the
   bottom — the stack reads as a foundation. */
.pf-stack {
  display: flex;
  flex-direction: column-reverse;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}
.pf-stack li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 11px 0;
  border-top: 1px solid var(--on-dark-line);
}
.pf-stack b {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.63rem;
  letter-spacing: 0.06em;
  color: var(--purple);
}
.pf-stack span { font-size: 0.88rem; line-height: 1.4; color: var(--on-dark); }

/* Evidence strip (Citation Lab). */
.pf-evidence {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 26px;
  margin-top: 30px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.pf-evidence strong {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--purple-deep);
}
.pf-evidence p { margin-top: 10px; font-size: 0.86rem; line-height: 1.5; color: var(--muted); }

/* ---------- Visual: dealership dashboard (No-Show) ---------- */
.pf-dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--on-dark-line);
}
.pf-dash-head img { display: block; height: 22px; width: auto; }
.pf-dash-head span {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.pf-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 18px;
  padding: 1px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.pf-kpi { padding: 15px 14px; background: var(--ink); }
.pf-kpi dt {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--on-dark-muted);
}
.pf-kpi dd {
  margin: 8px 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.65rem;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--on-dark);
}
.pf-kpi dd.is-risk { color: var(--score-warn); }

.pf-heat { margin-top: 20px; }
.pf-heat-grid {
  display: grid;
  grid-template-columns: 34px repeat(5, 1fr);
  gap: 4px;
}
.pf-heat-grid b {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.58rem;
  color: var(--on-dark-muted);
  align-self: center;
}
.pf-heat-cell {
  height: 26px;
  border-radius: 5px;
  /* --v is the no-show rate, normalized 0–1. */
  background: color-mix(in srgb, var(--purple) calc(var(--v) * 100%), rgba(255, 255, 255, 0.05));
}
.pf-heat-grid u {
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.58rem;
  text-align: center;
  color: var(--on-dark-muted);
}
.pf-insight {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--on-dark-line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
}
.pf-insight p { margin-top: 8px; font-size: 0.85rem; line-height: 1.55; color: var(--on-dark-soft); }

/* ---------- Visual: Lakou bundle + membership paths ---------- */
.pf-logo-plate {
  display: inline-flex;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: #fff;
}
.pf-logo-plate img { display: block; height: 26px; width: auto; }
.pf-bundle-title {
  margin: 16px 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--on-dark);
}
.pf-bundle-desc { margin-top: 10px; font-size: 0.88rem; line-height: 1.55; color: var(--on-dark-soft); }
.pf-bundle-files { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 0; padding: 0; list-style: none; }
.pf-bundle-files li {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--on-dark-line);
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--on-dark-soft);
}
.pf-bundle-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 20px 0 0;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}
.pf-bundle-stats dt {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent);
}
.pf-bundle-stats dd {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 0.55rem;
  line-height: 1.35;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--on-dark-muted);
}

.pf-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.pf-card > .pf-panel-eyebrow { color: var(--accent-ink); }
.pf-paths { display: grid; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.pf-path {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}
.pf-path.is-selected {
  border-color: var(--accent-ink);
  background: var(--accent-soft);
}
.pf-path b {
  display: block;
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.pf-path.is-selected b { color: var(--accent-ink); }
.pf-path strong { display: block; margin-top: 6px; font-size: 0.98rem; font-weight: 700; color: var(--ink); }
.pf-path span { display: block; margin-top: 3px; font-size: 0.84rem; line-height: 1.45; color: var(--muted); }

/* ---------- Through-line (dark) ---------- */
.pf-through { padding-block: calc(var(--pad) * 0.8); }
.pf-through-inner {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 56px;
  align-items: start;
  padding: clamp(32px, 5vw, 62px);
  border-radius: var(--radius-lg);
  background: var(--ink);
  color: var(--on-dark);
  box-shadow: var(--shadow);
}
.pf-through .eyebrow { color: var(--accent); }
.pf-through h2 { color: var(--on-dark); }
.pf-through h2 em { color: var(--purple); font-style: italic; }
.pf-through-lede { margin-top: 20px; font-size: 1.02rem; line-height: 1.6; color: var(--on-dark-soft); }
.pf-steps {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  padding: 1px;
  background: var(--on-dark-line);
  border-radius: var(--radius);
  overflow: hidden;
}
.pf-step { padding: 24px; background: var(--ink); }
.pf-step b {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.63rem;
  letter-spacing: 0.1em;
  color: var(--purple);
}
.pf-step h3 { margin-top: 12px; color: var(--on-dark); }
.pf-step p { margin-top: 10px; font-size: 0.9rem; line-height: 1.55; color: var(--on-dark-soft); }

/* ---------- Closing CTA ---------- */
.pf-cta { border-top: 1px solid var(--line); }
.pf-cta-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.6fr);
  gap: 56px;
  align-items: end;
}
.pf-cta-copy p:not(.eyebrow) { margin-top: 18px; max-width: 50ch; font-size: 1.06rem; color: var(--ink-soft); }
.pf-links {
  display: grid;
  gap: 10px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.pf-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: var(--purple-deep);
}
.pf-links a:hover { color: var(--ink); }

/* ---------- Focus visibility (site-wide gap the design flagged) ---------- */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--purple-deep);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .pf-hero-grid,
  .pf-case-grid,
  .pf-through-inner,
  .pf-cta-grid { grid-template-columns: 1fr; gap: 40px; }

  /* Sticky and DOM-order flipping only make sense in two columns. */
  .pf-case-visual { position: static; }
  .pf-case.is-flipped .pf-case-visual { order: 0; }

  .pf-hero h1 { max-width: none; }
  .pf-ledger { max-width: 460px; }

  /* Index rows restack: number + title, then description. The category
     tag is redundant once the row wraps, so it drops out. */
  .pf-row { grid-template-columns: 40px minmax(0, 1fr); gap: 6px 14px; }
  .pf-row-desc { grid-column: 2; }
  .pf-row-cat { display: none; }
}

@media (max-width: 600px) {
  .pf-kpis { grid-template-columns: 1fr; }
  .pf-bundle-stats { grid-template-columns: repeat(2, 1fr); row-gap: 18px; }
  .pf-steps { grid-template-columns: 1fr; }
  .pf-heat-grid { grid-template-columns: 28px repeat(5, 1fr); }
  .pf-through-inner { border-radius: var(--radius); }
}
