/*
 * Beat support-host: Ledgerleaf, an invoicing app, with Pip in an anchored help panel
 * (web/landing/sections/support-host.html). Linked in the page head by lib/landing.ts
 * while the beat is enabled; the shells' sheets it builds on are linked by the page
 * itself, once each and before every section sheet. Every class here starts with the
 * beat id, and every rule is scoped by [data-beat]: the frame's variant
 * (support-host-ledgerleaf) is styled here and nowhere else.
 *
 * Layout: the copy as a header across the top (the title on the left, the body beside it),
 * the Ledgerleaf window full width below; in it the invoice screen and, on the right, the
 * help panel, anchored to the bottom while it is collapsed and growing upward when it opens.
 * Below 720 px of frame the panel is an inline card under the screen, full width, never a
 * floating overlay; below 520 px the invoice rows reflow into two lines each. The line's
 * status sits with its controls in the panel, so the frame has no foot.
 *
 * Product UI in the system sans; the answer is Pip's speech, so it is the sans too. The
 * serif is his greeting's alone.
 */

/* ── The copy, as a header ─────────────────────────────────────────────── */

.use-case[data-beat="support-host"] .use-case-copy {
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
  grid-template-areas:
    "eyebrow eyebrow"
    "title body";
  align-items: end;
  gap: 0 clamp(28px, 5vw, 72px);
  margin: 0 0 clamp(24px, 4vh, 36px);
}

.use-case[data-beat="support-host"] .use-case-eyebrow { grid-area: eyebrow; }
.use-case[data-beat="support-host"] .use-case-title { grid-area: title; margin: 0; }
.use-case[data-beat="support-host"] .use-case-body { grid-area: body; padding-bottom: 6px; }

@media (max-width: 860px) {
  .use-case[data-beat="support-host"] .use-case-copy {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "eyebrow" "title" "body";
  }

  .use-case[data-beat="support-host"] .use-case-title { margin: 0 0 16px; }
}

/* ── The window: the screen and the panel ──────────────────────────────── */

[data-beat="support-host"] .demo-frame-body {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "main" "aside";
}

@container demo-frame (min-width: 720px) {
  [data-beat="support-host"] .demo-frame-body {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
    grid-template-areas: "main aside";
  }
}

[data-beat="support-host"] .demo-frame-slot[data-slot="main"] { display: flex; }

[data-beat="support-host"] .demo-frame-slot[data-slot="aside"] {
  display: flex;
  flex-direction: column;
}

/* ── Ledgerleaf's screen ───────────────────────────────────────────────── */

[data-beat="support-host"] .support-host-app {
  flex: 1;
  min-width: 0;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.4;
  overflow: hidden;
}

[data-beat="support-host"] .support-host-appbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 46px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}

/* The mark: a leaf, two rounded corners of a square. */
[data-beat="support-host"] .support-host-mark {
  flex: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text);
  border-radius: 1px 11px;
}

[data-beat="support-host"] .support-host-nav {
  display: flex;
  gap: 18px;
  min-width: 0;
  color: var(--muted);
  white-space: nowrap;
}

[data-beat="support-host"] .support-host-nav-item[data-current] {
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 2px 0 var(--accent);
}

[data-beat="support-host"] .support-host-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
}

[data-beat="support-host"] .support-host-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 16px 16px 10px;
}

[data-beat="support-host"] .support-host-h {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

[data-beat="support-host"] .support-host-period {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

[data-beat="support-host"] .support-host-totals {
  display: flex;
  gap: 10px;
  padding: 0 16px 14px;
}

[data-beat="support-host"] .support-host-total {
  flex: 1;
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

[data-beat="support-host"] .support-host-total span { font-size: 12px; color: var(--muted); }

[data-beat="support-host"] .support-host-total b {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

[data-beat="support-host"] .support-host-invoices {
  width: 100%;
  border-collapse: collapse;
}

[data-beat="support-host"] .support-host-invoices th {
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 500;
  text-align: left;
  color: var(--muted);
}

[data-beat="support-host"] .support-host-invoices td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}

[data-beat="support-host"] .support-host-invoices tbody tr:last-child td { border-bottom: 0; }

[data-beat="support-host"] .support-host-invoices .support-host-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

[data-beat="support-host"] .support-host-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

[data-beat="support-host"] .support-host-due { color: var(--muted); }

[data-beat="support-host"] .support-host-state {
  display: inline-block;
  padding: 1px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11.5px;
}

[data-beat="support-host"] .support-host-state[data-state="paid"] { color: var(--muted); }
[data-beat="support-host"] .support-host-state[data-state="late"] { border-color: var(--muted); }

@container demo-frame (max-width: 519px) {
  [data-beat="support-host"] .support-host-appbar { gap: 14px; }
  [data-beat="support-host"] .support-host-nav { gap: 14px; }
  [data-beat="support-host"] .support-host-nav-item:nth-child(2) { display: none; }
  [data-beat="support-host"] .support-host-totals { gap: 8px; }
  [data-beat="support-host"] .support-host-total b { font-size: 15.5px; }

  /* Three invoices are enough of a screen here: Pip's panel follows close below. */
  [data-beat="support-host"] .support-host-invoices tbody tr:nth-child(n + 4) { display: none; }

  /* Two lines per invoice: the client and the amount, then the number and the state. */
  [data-beat="support-host"] .support-host-invoices thead { display: none; }

  [data-beat="support-host"] .support-host-invoices,
  [data-beat="support-host"] .support-host-invoices tbody { display: block; }

  [data-beat="support-host"] .support-host-invoices tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "client num" "id state";
    gap: 2px 12px;
    padding: 10px 14px;
    border-top: 1px solid var(--line);
  }

  [data-beat="support-host"] .support-host-invoices td { display: block; padding: 0; border: 0; }
  [data-beat="support-host"] .support-host-invoices .support-host-client { grid-area: client; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  [data-beat="support-host"] .support-host-invoices .support-host-num { grid-area: num; }
  [data-beat="support-host"] .support-host-invoices .support-host-id { grid-area: id; }
  [data-beat="support-host"] .support-host-invoices td:last-child { grid-area: state; text-align: right; }
  [data-beat="support-host"] .support-host-invoices .support-host-due { display: none; }
}

/* ── The help panel ────────────────────────────────────────────────────── */

[data-beat="support-host"] .support-host-help {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto; /* collapsed, it waits at the bottom of the column; open, it grows up */
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

[data-beat="support-host"] .support-host-pip {
  align-self: center;
  max-width: 296px;
}

/* Pip's greeting: the one line of the panel in the book voice. */
[data-beat="support-host"] .support-host-greeting {
  margin: 4px 0 0;
  text-align: center;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 19px;
  line-height: 1.3;
  text-wrap: balance;
}

[data-beat="support-host"] .support-host-examples {
  margin: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

[data-beat="support-host"] .support-host-ask > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  list-style: none;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .12s, color .12s, border-color .12s;
}

[data-beat="support-host"] .support-host-ask > summary::-webkit-details-marker { display: none; }

/* Open, the toggle steps back to a quiet header that closes the panel again. */
[data-beat="support-host"] .support-host-ask[open] > summary {
  justify-content: space-between;
  background: transparent;
  border-color: var(--line);
  color: var(--text);
  font-weight: 500;
}

[data-beat="support-host"] .support-host-ask > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .15s;
}

[data-beat="support-host"] .support-host-ask[open] > summary::after { transform: translateY(2px) rotate(-135deg); }

/* The questions, one per line; once one is chosen it is the reader's own line, right. */
[data-beat="support-host"] .support-host-flow { margin-top: 12px; }

[data-beat="support-host"] .support-host-flow .reader-flow-choices {
  flex-direction: column;
  align-items: stretch;
}

[data-beat="support-host"] .support-host-flow[data-chosen] .reader-flow-choices { align-items: flex-end; }
[data-beat="support-host"] .support-host-flow[data-chosen] .reader-flow-choice { border-radius: 16px 16px 4px 16px; }

/* Pip's answer: a bubble, his speech in the sans. */
[data-beat="support-host"] .support-host-flow .reader-flow-text {
  padding: 10px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px;
  font-size: 14.5px;
  line-height: 1.5;
}

/* With no script, each answer stands under its question. */
[data-beat="support-host"] .support-host-flow .reader-flow-label { margin: 6px 0 6px; }

[data-beat="support-host"] .support-host-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

[data-beat="support-host"] .support-host-tools[hidden] { display: none; }

[data-beat="support-host"] .support-host-tools button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: border-color .12s;
}

[data-beat="support-host"] .support-host-tools button:hover { border-color: var(--muted); }

/* The line's time beside its controls: the frame has no foot of its own here. */
[data-beat="support-host"] .support-host-status {
  align-self: center;
  margin-left: auto;
}
[data-beat="support-host"] .support-host-icon { width: 11px; height: 11px; flex: none; }
[data-beat="support-host"] .support-host-icon[hidden] { display: none; }

@container demo-frame (max-width: 719px) {
  [data-beat="support-host"] .support-host-help { margin-top: 0; }
  [data-beat="support-host"] .support-host-pip { max-width: 240px; }
}
