/* How It Works — Pivot charter.
   Bordered-frame spec-sheet that pairs with sovereign-charter's
   engineering-paper vocabulary (L-brackets, tinted frame, white
   inner table, mono labels). Four rows, three columns:
     [Mechanism number + name]  |  [How it works body]  |  [Source]
   Row 4 ("Compliance is the gate") gets accent treatment so the
   row the procurement reader will check first is visually the
   loudest one on the page. */

.hiw-pivot {
  position: relative;
  padding-block: clamp(3rem, 6vw, 5rem);
}

.hiw-pivot > .container { position: relative; }

.hiw-pivot__intro {
  max-width: 56rem;
  margin: 0 0 clamp(1.75rem, 3vw, 2.5rem);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}

.hiw-pivot__heading {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.4vw, 2.5rem);
  font-weight: var(--font-weight-display);
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--color-foreground);
  max-width: 42rem;
  margin: 0;
  text-wrap: balance;
  text-transform: capitalize;
}

.hiw-pivot__deck {
  font-size: var(--fs-lg);
  line-height: 1.45;
  color: var(--color-muted-foreground);
  margin: 0;
  max-width: 60ch;
}

/* --- Frame --------------------------------------------------------
   Same vocabulary as sovereign-charter. Tinted teal background on
   the frame so the inner white table reads as a distinct "paper"
   layer. */
.hiw-pivot__frame {
  --hp-teal: var(--brand-teal);
  --hp-blue: var(--brand-blue);
  --hp-card: #ffffff;
  --hp-border: var(--color-border);
  --hp-accent: color-mix(in srgb, var(--hp-teal) 35%, transparent);

  position: relative;
  padding: clamp(1.25rem, 2.4vw, 1.75rem);
  background: color-mix(in srgb, var(--hp-teal) 2.5%, white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
}

/* --- Table -------------------------------------------------------- */

.hiw-pivot__table {
  background: var(--hp-card);
  border: 1px solid var(--hp-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.hiw-pivot__thead,
.hiw-pivot__row {
  display: grid;
  grid-template-columns: minmax(13rem, 1fr) minmax(0, 2fr) minmax(9rem, 0.75fr);
  gap: 0;
}

.hiw-pivot__thead {
  border-bottom: 1px solid var(--hp-border);
  background: color-mix(in srgb, var(--hp-teal) 3%, var(--hp-card));
}

.hiw-pivot__th {
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-muted-foreground);
}

.hiw-pivot__th--body,
.hiw-pivot__th--source {
  border-left: 1px solid var(--hp-border);
}

.hiw-pivot__th--source {
  color: color-mix(in srgb, var(--hp-teal) 70%, var(--color-foreground));
}

/* --- Rows --------------------------------------------------------- */

.hiw-pivot__row {
  border-bottom: 1px solid var(--hp-border);
  position: relative;
}

.hiw-pivot__row--last { border-bottom: 0; }

/* Accent row: teal rule on the leading edge, subtle teal background
   tint. The row that says "compliance is the gate" needs to be the
   single loudest line in the table. */
.hiw-pivot__row--accent {
  background: color-mix(in srgb, var(--hp-teal) 3.5%, var(--hp-card));
}
.hiw-pivot__row--accent::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(
    to bottom,
    var(--hp-teal) 0%,
    var(--hp-blue) 100%
  );
  pointer-events: none;
}

.hiw-pivot__cell {
  padding: 1.125rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
}

.hiw-pivot__cell--body,
.hiw-pivot__cell--source {
  border-left: 1px solid var(--hp-border);
}

/* --- Mechanism cell (leftmost): number + name ------------------- */

.hiw-pivot__n {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.14em;
  padding: 0.1875rem 0.4375rem;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--hp-teal) 10%, transparent);
  color: var(--hp-teal);
  border: 1px solid color-mix(in srgb, var(--hp-teal) 18%, transparent);
  align-self: flex-start;
  white-space: nowrap;
}

.hiw-pivot__name {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: var(--font-weight-display);
  line-height: 1.2;
  color: var(--color-foreground);
  letter-spacing: -0.01em;
  margin-top: 0.25rem;
}

/* --- Body cell ---------------------------------------------------- */

.hiw-pivot__cell-text {
  margin: 0;
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--color-foreground);
}

/* --- Source cell (rightmost) ------------------------------------- */

/* Cell-label is the per-row column label shown only when the thead
   is hidden (≤900px, see responsive block). At desktop the thead
   already labels the columns; showing the same word inside each cell
   just reads as a repeat. */
.hiw-pivot__cell-label {
  display: none;
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-muted-foreground);
}

.hiw-pivot__source {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: color-mix(in srgb, var(--hp-teal) 75%, var(--color-foreground));
  letter-spacing: -0.005em;
}

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

@media (max-width: 900px) {
  .hiw-pivot__thead { display: none; }
  .hiw-pivot__cell-label { display: inline; }
  .hiw-pivot__row {
    grid-template-columns: 1fr;
  }
  .hiw-pivot__cell--body,
  .hiw-pivot__cell--source {
    border-left: 0;
    border-top: 1px solid color-mix(in srgb, var(--hp-border) 70%, transparent);
  }
  .hiw-pivot__cell {
    padding: 0.875rem 1rem 1rem;
  }
  .hiw-pivot__row--accent::before {
    /* Thin accent stripe across the top of the row at narrow widths. */
    top: -1px;
    left: 0.75rem;
    right: 0.75rem;
    bottom: auto;
    width: auto;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: linear-gradient(
      to right,
      var(--hp-teal) 0%,
      var(--hp-blue) 100%
    );
  }
}

@media (max-width: 560px) {
  .hiw-pivot__name { font-size: var(--fs-base); }
}
