/* The page grammar (ADR-0069): how a Samvesta page is COMPOSED — the type scale, the cards, the
 * list card, the segmented control, the workbench split, the agent card, the trust note, the
 * designed empty state and the big numbers. Ported from the canvas's aurora.css (brand/sme-os/)
 * and drawn only from packages/ui/tokens.css: this file names no colour, font or gradient of its
 * own (scripts/check_brand.py). One namespace, `sv-`, beside brand.css (the AI's paint). The React
 * pieces over these classes are packages/product-ui/components/brand/page.tsx.
 *
 * Every SME page has five beats: kicker → hero (h1 + one warm word + lede ‖ agent card) →
 * control row (seg + count) → workbench (list card 7 ‖ ringed artifact + trust note 5) →
 * designed empty / big numbers. Keep this file under 800 lines: split by area (page-*.css). */

/* ---------- the page: 1120 wide, 18 px rhythm (dense, founder 2026-10-31) ---------- */
.sv-page {
  max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px;
  container-type: inline-size; container-name: sv-page;
}
/* A page drawn as a part of another (Smart replies › Answers / Teach) fills it: its auto margins
   in a flex column would cancel the stretch, and inline-size containment then shrinks it to a word a line. */
.sv-page .sv-page { max-width: none; margin: 0; width: 100%; }
/* The 18 px section rhythm as a token, for a grid inside the page to keep the same beat (P11). */
.sv-page { --sv-rhythm: 18px; }

/* ---------- type: big steps, read at a glance (P6) ---------- */
.sv-kicker {
  font: var(--weight-semibold) 12px var(--font-sans); letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3); margin: 0;
}
.sv-h1 {
  font-family: var(--font-display); font-size: 36px; line-height: 1.08; font-weight: 640;
  font-stretch: 112%; letter-spacing: -.025em; color: var(--ink); margin: 0;
}
/* The padding keeps the gradient (background-clip: text) from cutting the italic overhang; the
   negative margin gives the layout back, so "money," never reads as "money ," (wrap partial 6). */
.sv-h1 .sv-serif { font-size: 1.08em; padding-right: 6px; margin-right: -5px; }
.sv-h2 {
  font-family: var(--font-display); font-size: 21px; font-weight: var(--weight-display);
  font-stretch: 106%; letter-spacing: -.01em; color: var(--ink); margin: 0;
}
.sv-h3 {
  font-family: var(--font-display); font-size: 16.5px; font-weight: var(--weight-display);
  font-stretch: 104%; color: var(--ink); margin: 0;
}
.sv-lede { font-size: 15.5px; line-height: 1.45; color: var(--ink-2); max-width: 640px; margin: 0; }
.sv-body { font-size: 15.5px; line-height: 1.5; color: var(--ink-soft); }
.sv-small { font-size: 13.5px; color: var(--ink-3); }
.sv-tiny { font-size: 12.5px; color: var(--ink-3); }

/* ---------- money is the hero on money pages (P12): Anek's tabular figures carry ₹ ---------- */
.sv-num-xl, .sv-num-lg {
  font-family: var(--font-display); font-weight: var(--weight-semibold); line-height: 1;
  font-stretch: 108%; font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--ink);
}
.sv-num-xl { font-size: 40px; }
.sv-num-lg { font-size: 26px; }
.sv-num-label { font-size: 13.5px; color: var(--ink-3); }
.sv-big { display: flex; flex-direction: column; gap: 6px; }
.sv-num-xl .sv-money, .sv-num-lg .sv-money { font: inherit; letter-spacing: inherit; }

/* ---------- beat 2: the hero row ---------- */
.sv-hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.sv-hero-main { flex: 1 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.sv-hero-aside { flex: none; }

/* ---------- cards: 22 px, the long soft shadow (P11) ---------- */
.sv-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow); padding: 16px 18px; min-width: 0;
}
.sv-card-tight { padding: 12px; border-radius: var(--radius-card-tight); }
.sv-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 6px; flex-wrap: wrap; }
/* A quiet line under a card's rows (where the setting applies, what it costs). */
.sv-card-foot { margin: 0; padding-top: 12px; }

/* ---------- the agent: a persona orb, a name and an honest state (P3, RW4) ---------- */
.sv-agent-card { display: flex; align-items: center; gap: 12px; }
.sv-agent-who { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
/* The shell's aside on the card (the ladder chip): its own row under the name, never above the h1 (P7). */
.sv-agent-card:has(> .sv-agent-aside) { flex-wrap: wrap; }
.sv-agent-aside { flex-basis: 100%; min-width: 0; }
.sv-agent-aside > * { margin: 0; max-width: 100%; }
.sv-agent-name { font-weight: var(--weight-semibold); color: var(--ink); }
.sv-agent-state { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-3); }
.sv-agent-state[data-state="ready"] { color: var(--ai); }
.sv-persona {
  width: 44px; height: 44px; border-radius: 50%; flex: none; display: flex; align-items: center;
  justify-content: center; color: var(--on-accent); box-shadow: var(--persona-shadow);
  font: italic var(--weight-regular) 22px var(--font-serif);
}
.sv-persona-sm { width: 32px; height: 32px; font-size: 16px; }
.sv-persona-lg { width: 64px; height: 64px; font-size: 32px; }
.sv-persona[data-persona="writer"] { background-image: var(--persona-writer); }
.sv-persona[data-persona="replies"] { background-image: var(--persona-replies); }
.sv-persona[data-persona="marketing"] { background-image: var(--persona-marketing); }
.sv-persona[data-persona="accounts"] { background-image: var(--persona-accounts); }
.sv-persona[data-persona="learner"] { background-image: var(--persona-learner); }
.sv-persona[data-persona="followup"] { background-image: var(--persona-followup); }
.sv-persona[data-persona="social"] { background-image: var(--persona-social); }
.sv-persona[data-persona="website"] { background-image: var(--persona-website); }
.sv-persona[data-persona="pm"] { background-image: var(--persona-pm); }
.sv-persona[data-persona="eng"] { background-image: var(--persona-eng); }

/* ---------- beat 3: the control row and the pill segmented control ---------- */
.sv-control { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.sv-count { font-size: 13.5px; color: var(--ink-3); }
.sv-count b { color: var(--ink); font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }
/* The tab row WRAPS when its tabs don't fit (prompt 07 D18, overriding Q25's one scrolling row: at
 * 360 a scrolled row clipped a tab, G1). A tab never breaks inside (`white-space: nowrap` below); the
 * row breaks between tabs. The radius is the card's 22px: on one row (4 + 34 + 4 + 2 = 44px tall) that
 * is the same pill, on two rows a rounded panel instead of a lumpy stadium. Seg still sets
 * data-more-* if a single tab is wider than the row (the fade then shows it), else they stay unset. */
.sv-seg {
  position: relative; display: inline-flex; flex-wrap: wrap; overflow-x: auto; scrollbar-width: none;
  padding: 4px; gap: 2px; border-radius: var(--radius-card);
  background: var(--panel-2); border: 1px solid var(--line); max-width: 100%; min-width: 0;
}
.sv-seg::-webkit-scrollbar { display: none; }
.sv-seg[data-more-end] { -webkit-mask-image: linear-gradient(to left, transparent, black 40px); mask-image: linear-gradient(to left, transparent, black 40px); }
.sv-seg[data-more-start] { -webkit-mask-image: linear-gradient(to right, transparent, black 40px); mask-image: linear-gradient(to right, transparent, black 40px); }
.sv-seg[data-more-start][data-more-end] {
  -webkit-mask-image: linear-gradient(to right, transparent, black 40px, black calc(100% - 40px), transparent);
  mask-image: linear-gradient(to right, transparent, black 40px, black calc(100% - 40px), transparent);
}
.sv-seg button {
  flex: none; min-height: 34px; padding: 0 14px; border-radius: var(--radius-pill); border: 0; background: transparent;
  color: var(--ink-3); font: var(--weight-medium) 14px var(--font-sans); cursor: pointer; white-space: nowrap;
}
.sv-seg button:hover { color: var(--ink); }
.sv-seg button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.sv-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- beat 4: the workbench — quiet list (7) ‖ the AI's artifact (5) ---------- */
.sv-workbench { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; align-items: start; }
.sv-workbench > .sv-wb-list { grid-column: span 7; }
.sv-workbench > .sv-wb-art { grid-column: span 5; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* One card, hairline-divided rows; the selected row is a quiet tint (P5). */
.sv-list { display: flex; flex-direction: column; list-style: none; margin: 0; padding: 0; }
.sv-li { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.sv-li:first-child { border-top: 0; }
.sv-li-btn {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; min-height: 40px; padding: 8px 10px;
  border: 0; border-radius: var(--radius-lg); background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.sv-li-btn:hover { background: var(--hover); }
.sv-li-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sv-li[data-on] > .sv-li-btn { background: var(--panel-2); }
.sv-li-main { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.sv-li-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sv-li-extra { padding: 0 10px 8px; }

/* The artifact: what the AI made, ringed and glowing (brand.css sv-ring), with its header. */
.sv-artifact { display: flex; flex-direction: column; gap: 10px; }
.sv-artifact-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; font-size: 13.5px; color: var(--ink-3); }
/* Each label keeps its line: at 360 the head wraps whole labels, never a word a line. */
.sv-artifact-by, .sv-artifact-src { white-space: nowrap; }
.sv-artifact-by { display: inline-flex; align-items: center; gap: 8px; font-weight: var(--weight-medium); color: var(--ai); }
.sv-artifact-src { color: var(--ok-ink); }
.sv-artifact-text { font-size: 15px; line-height: 1.5; white-space: pre-line; color: var(--ink-soft); margin: 0; overflow-wrap: anywhere; }
.sv-artifact-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.sv-chips { display: flex; flex-wrap: wrap; gap: 8px; }
/* The refine chips under a draft (canvas `.chip`; 44 px tall, the target floor, not the canvas 36). */
.sv-refine {
  min-height: 34px; padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--ink-2); font: var(--weight-regular) 14px var(--font-sans);
  cursor: pointer; display: inline-flex; align-items: center; white-space: nowrap;
}
.sv-refine:hover { border-color: var(--accent); color: var(--ink); }
.sv-refine:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sv-refine:disabled { opacity: .5; cursor: default; }
.sv-artifact-more { display: flex; flex-wrap: wrap; gap: 8px; }
/* The draft stays editable in place: a borderless field that reads as the artifact's text. */
.sv-artifact-edit {
  display: block; width: calc(100% + 20px); box-sizing: border-box; min-height: 96px; padding: 8px 10px; margin: 0 -10px;
  border: 1px solid transparent; border-radius: 12px; background: transparent; resize: vertical;
  font: var(--weight-regular) 16px/1.6 var(--font-sans); color: var(--ink-soft);
}
.sv-artifact-edit:hover { border-color: var(--line); }
.sv-artifact-edit:focus { outline: 0; border-color: var(--accent); background: var(--panel); }
.sv-wb-pane { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sv-li-acts { display: flex; flex-wrap: wrap; gap: 8px; flex: none; }
.sv-pre { white-space: pre-wrap; }

/* Trust sits beside the action (P9). */
.sv-trust { display: flex; flex-direction: column; gap: 8px; }

/* Empty is designed (P10): AI-tinted and dashed, it says what will appear. */
.sv-dash {
  display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: var(--radius-card);
  border: 1.5px dashed var(--ai-dash); background: var(--ai-soft);
}
.sv-dash-act { padding-top: 6px; }

/* The canvas pill on a converted page (Q12): st-btn keeps its role, wears 44 px and the pill. */
.sv-page .st-btn { min-height: 36px; border-radius: var(--radius-pill); padding: 0 16px; }
/* Only a primary that can be pressed glows: a disabled Save kept it (Bills, desktop 1440; wrap partial
 * 16 item 9), since `.st-bl-save:disabled` ties this rule and load order picked the winner. */
.sv-page .st-btn--primary:not(:disabled) { box-shadow: var(--accent-glow); }
/* The app's older cards and tiles take the grammar's geometry inside a page (P11, wrap partial 13). */
.sv-page .st-card { border-radius: var(--radius-card); }
.sv-page .st-stage { border-radius: var(--radius-card-tight); }

/* ---------- motion: results rise (P13) ---------- */
.sv-page .sv-rise { animation: sv-in var(--motion-rise) var(--ease-rise) both; }
@media (prefers-reduced-motion: reduce) { .sv-page .sv-rise { animation: none; } }

/* ---------- ≤ 1000 px: h1 40, the split stacks with the ARTIFACT FIRST ----------
   Only an artifact column that holds an AI result (a ring or an AiArtifact) leads: an empty state
   never goes above the list it is empty beside (wow run 03, F3). Else DOM order. */
@media (max-width: 1000px) {
  .sv-h1 { font-size: 30px; }
  .sv-workbench > .sv-wb-list, .sv-workbench > .sv-wb-art { grid-column: span 12; }
  .sv-workbench > .sv-wb-art:has(.sv-ring, .sv-artifact) { order: -1; }
}
/* A narrow page beside a wide rail stacks too: the split needs ~720 px to breathe. */
@container sv-page (max-width: 720px) {
  .sv-h1 { font-size: 30px; }
  .sv-workbench > .sv-wb-list, .sv-workbench > .sv-wb-art { grid-column: span 12; }
  .sv-workbench > .sv-wb-art:has(.sv-ring, .sv-artifact) { order: -1; }
}
@media (max-width: 640px) {
  .sv-card { padding: 14px; }
  .sv-hero-aside { flex: 1 1 100%; }
  /* A row's actions go under its text on a phone: beside it they squeeze it to a word a line. */
  .sv-li-btn:has(> .sv-li-acts) { flex-wrap: wrap; }
  .sv-li-btn > .sv-li-acts { flex: 1 1 100%; }
}

/* ---------- touch: a finger still gets 44 px (the dense sizes above are for a mouse) ---------- */
@media (pointer: coarse) {
  .sv-seg button, .sv-refine, .sv-li-btn, .sv-page .st-btn { min-height: 44px; }
}
