/* Case study: Concrete delivery data via WhatsApp
   Extends case-studies.css — shares its tokens (:root) and layout. */

/* ---------- Truck-to-register pipeline (signature) ---------- */

.pipeline {
  display: grid;
  grid-template-columns: 1fr 24px 1fr 24px 1fr;
  gap: 10px;
  align-items: stretch;
  margin-top: 22px;
}

.pipeline-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.pipeline-panel:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(66, 63, 238, 0.1);
  border-color: rgba(66, 63, 238, 0.2);
}

.pipeline-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

.pipeline-panel-head .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.pipeline-panel-body {
  padding: 14px;
  flex: 1;
}

.pipeline-connector {
  align-self: center;
  color: #c4c9da;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pipeline-step-label {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Panel 1 — WhatsApp group chat */
.panel-chat .pipeline-panel-head {
  background: #f0f7f4;
  color: #0d7a5f;
}

.panel-chat .dot {
  background: #25d366;
}

.panel-chat .pipeline-panel-body {
  background: #efeae2;
  display: grid;
  gap: 10px;
  align-content: start;
}

.chat-bubble {
  justify-self: end;
  max-width: 88%;
  background: #dcf8c6;
  border-radius: 10px 2px 10px 10px;
  padding: 6px;
  box-shadow: 0 1px 1px rgba(20, 18, 31, 0.12);
}

.chat-photo {
  border-radius: 7px;
  border: 1px solid rgba(20, 18, 31, 0.08);
  background: linear-gradient(160deg, #fdfcf8 0%, #eef0ea 100%);
  padding: 10px 12px;
}

.chat-photo .doc-head {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8b8f7f;
}

.chat-photo .doc-line {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: #4a4d42;
  line-height: 1.4;
}

.chat-photo .doc-line strong {
  color: #2e3129;
}

.chat-photo.slump-photo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slump-cone {
  flex: 0 0 auto;
  width: 34px;
  height: 30px;
  background: linear-gradient(180deg, #b9bdb2 0%, #8f9488 100%);
  clip-path: polygon(32% 0, 68% 0, 100% 100%, 0 100%);
}

.chat-meta {
  display: block;
  margin-top: 4px;
  text-align: right;
  font-size: 0.66rem;
  color: #6f8171;
}

/* Panel 2 — agent extraction */
.panel-agent .pipeline-panel-head {
  background: linear-gradient(135deg, rgba(94, 80, 160, 0.06), rgba(236, 72, 153, 0.06));
  color: var(--accent);
}

.panel-agent .dot {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.field-list {
  display: grid;
  gap: 6px;
  align-content: start;
}

.field-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbff;
}

.field-key {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #73809f;
}

.field-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

.field-row.is-highlight .field-value {
  color: var(--accent);
}

/* Panel 3 — register in SharePoint */
.panel-register .pipeline-panel-head {
  background: #f3f9f5;
  color: #1e7145;
}

.panel-register .dot {
  background: #1e7145;
}

.mini-sheet {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.72rem;
}

.mini-sheet-row {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr 1fr;
  border-top: 1px solid var(--line);
}

.mini-sheet-row:first-child {
  border-top: 0;
  background: #f4f3fa;
  font-weight: 600;
  color: #58617a;
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mini-sheet-row > span {
  padding: 6px 7px;
  border-left: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-sheet-row > span:first-child {
  border-left: 0;
}

.mini-sheet-row.is-new {
  background: rgba(94, 80, 160, 0.06);
  font-weight: 600;
}

.register-note {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.register-note strong {
  color: var(--text);
}

/* ---------- Workflow steps ---------- */

.step-card {
  margin-top: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.step-eyebrow {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.step-num {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.step-card h3 {
  margin: 10px 0 8px;
  font-size: clamp(1.15rem, 2.6vw, 1.5rem);
}

.step-card > p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.step-card ul {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

/* Cube-test chase timeline */
.chase-track {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.chase-node {
  position: relative;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fbff;
}

.chase-node::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -9px;
  width: 10px;
  border-top: 2px dashed #c4c9da;
}

.chase-node:last-child::after {
  content: none;
}

.chase-when {
  margin: 0;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #73809f;
}

.chase-what {
  margin: 4px 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.chase-node.is-agent {
  background: rgba(94, 80, 160, 0.05);
  border-color: rgba(94, 80, 160, 0.2);
}

.chase-node.is-agent .chase-when {
  color: var(--accent);
}

/* ---------- Golden record register table ---------- */

.register-wrap {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}

.register-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #f4f3fa;
  font-size: 0.78rem;
  font-weight: 600;
  color: #58617a;
}

.register-toolbar .sheet-icon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: #1e7145;
  flex: 0 0 auto;
}

.register-toolbar .path {
  font-weight: 400;
  color: #73809f;
}

.register-scroll {
  overflow-x: auto;
}

.register-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.register-table th {
  padding: 9px 10px;
  text-align: left;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #73809f;
  border-bottom: 1px solid var(--line);
  background: #fbfbfe;
  white-space: nowrap;
}

.register-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  white-space: nowrap;
}

.register-table tr:last-child td {
  border-bottom: 0;
}

.register-table .cell-pass {
  color: #1e7145;
  font-weight: 600;
}

.register-table .cell-pending {
  color: #b45309;
  font-weight: 600;
}

.register-table .source-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(94, 80, 160, 0.08);
  color: var(--accent);
}

.register-caption {
  padding: 10px 16px;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* ---------- Teams grid ---------- */

.team-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.team-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.team-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(66, 63, 238, 0.1);
  border-color: rgba(66, 63, 238, 0.2);
}

.team-card h3 {
  margin: 8px 0 6px;
  font-size: 1.1rem;
}

.team-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.team-uses {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.rebar-callout {
  margin-top: 16px;
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px dashed rgba(94, 80, 160, 0.35);
  background: rgba(94, 80, 160, 0.04);
  color: var(--muted);
  line-height: 1.6;
}

.rebar-callout strong {
  color: var(--text);
}

/* ---------- Why WhatsApp ---------- */

.why-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.why-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}

.why-card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.why-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .pipeline {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .pipeline-connector {
    transform: rotate(90deg);
    padding: 2px 0;
  }
}

@media (max-width: 900px) {
  .team-grid,
  .why-grid {
    grid-template-columns: 1fr;
  }

  .chase-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chase-node:nth-child(2)::after {
    content: none;
  }
}

@media (max-width: 640px) {
  .chase-track {
    grid-template-columns: 1fr;
  }

  .chase-node::after {
    content: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pipeline-panel,
  .team-card {
    transition: none;
  }
}

/* ---------- One dataset, every team: before/after flow ---------- */

.dataflow {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
}

.flow-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.flow-panel--after {
  border-color: rgba(94, 80, 160, 0.25);
  background: linear-gradient(180deg, rgba(94, 80, 160, 0.05), var(--surface) 55%);
}

.flow-head {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.flow-panel--before .flow-head {
  color: #b45309;
}

.flow-panel--after .flow-head {
  color: var(--accent);
}

.flow-sub {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.flow-svg {
  width: 100%;
  height: auto;
  display: block;
}

.flow-caption {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.flow-arrow {
  align-self: center;
  color: #c4c9da;
  font-size: 1.5rem;
  line-height: 1;
}

/* SVG nodes */
.flow-svg .node {
  fill: #fff;
  stroke: var(--line);
  stroke-width: 1.5;
}

.flow-svg .node--source {
  fill: #f7f7fa;
}

.flow-svg .node--team {
  fill: #f9fbff;
  stroke: rgba(94, 80, 160, 0.25);
}

.flow-svg .node--capture {
  fill: #f0f7f4;
  stroke: #25d366;
}

.flow-svg .node--record {
  fill: rgba(94, 80, 160, 0.07);
  stroke: var(--accent);
  stroke-width: 2;
}

.flow-svg .node-label {
  fill: var(--text);
  font-weight: 600;
  font-size: 15px;
}

.flow-svg .node-label--sm {
  fill: var(--muted);
  font-weight: 500;
  font-size: 11px;
}

.flow-svg .node-title {
  fill: var(--accent);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
}

/* SVG connector lines */
.flow-svg .flow-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 540;
  stroke-dashoffset: 540;
  transition: stroke-dashoffset 0.7s ease;
}

.flow-svg .flow-line--messy {
  stroke: #b45309;
  opacity: 0.5;
}

.flow-svg .flow-line--clean {
  stroke: var(--accent);
}

/* Entrance: nodes + labels fade in, lines draw on when in view */
.flow-svg .node,
.flow-svg text {
  opacity: 0;
  transition: opacity 0.5s ease;
}

.dataflow.in-view .flow-svg .node,
.dataflow.in-view .flow-svg text {
  opacity: 1;
}

.dataflow.in-view .flow-line {
  stroke-dashoffset: 0;
}

@media (max-width: 760px) {
  .dataflow {
    grid-template-columns: 1fr;
  }

  .flow-arrow {
    transform: rotate(90deg);
    align-self: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flow-svg .node,
  .flow-svg text {
    opacity: 1;
    transition: none;
  }

  .flow-svg .flow-line {
    stroke-dashoffset: 0;
    transition: none;
  }
}
