/* Spanfold v4 demo chrome: top bar, spend ticker, footnotes, brand greens, phone rails. */
:root {
  --v4d-paper: #F6F1E6; --v4d-sage: #E3ECE5; --v4d-sage2: #EEF3EF; --v4d-sand: #EFE8D9;
  --v4d-forest: #245A41; --v4d-ink: #24221F; --v4d-muted: #5E5B54; --v4d-line: #D8D0BF;
  --v4d-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --v4d-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- top bar (every screen) ---------- */
.v4d-sticky { position: sticky; top: 0; z-index: 60; }
.v4d-bar { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 16px; background: var(--v4d-paper); border-bottom: 1px solid var(--v4d-line); font-family: var(--v4d-sans); }
.v4d-home { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--v4d-ink); text-decoration: none; font-weight: 600; font-size: 1.125rem; letter-spacing: -0.01em; }
.v4d-home svg { width: 30px; height: 20px; flex: none; }
.v4d-back { margin-left: auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--v4d-forest); font-size: 0.875rem; font-weight: 600; text-decoration: none; }
.v4d-back::before { content: "←"; margin-right: 4px; }
.v4d-back:hover, .v4d-home:hover .v4d-word { text-decoration: underline; }
header.v4d-sticky:not(.v4d-bar) { background: var(--v4d-paper); }
.v4d-chip-slot { display: none; }

/* ---------- ticker ---------- */
.v4d-tick { position: sticky; top: var(--v4d-hh, 52px); z-index: 59; }
.v4d-tick-bar { display: flex; align-items: center; gap: 12px; width: 100%; height: 26px; margin: 0; padding: 0 16px; border: 0; border-bottom: 1px solid var(--v4d-line); background: var(--v4d-sage); color: var(--v4d-ink); font: 600 0.75rem/1 var(--v4d-mono); cursor: pointer; overflow: hidden; text-align: left; }
.v4d-tick-bar:focus-visible { outline: 2px solid var(--v4d-forest); outline-offset: -2px; }
.v4d-tick-track { flex: 1 1 auto; min-width: 0; display: flex; white-space: pre; overflow: hidden; }
.v4d-tick-text { flex: none; animation: v4d-marquee 40s linear infinite; }
.v4d-tick-bar:hover .v4d-tick-text, .v4d-tick-bar:focus-visible .v4d-tick-text { animation-play-state: paused; }
@keyframes v4d-marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }
.v4d-tick-info { flex: none; font-family: var(--v4d-sans); color: var(--v4d-forest); }
.v4d-tick-info::before { content: "ⓘ "; }
.v4d-tick-bar:hover .v4d-tick-info { text-decoration: underline; }
.v4d-tick-pill, .v4d-tick-chip { display: none; }
@media (prefers-reduced-motion: reduce) {
  .v4d-tick-text { animation: none; overflow: hidden; text-overflow: ellipsis; }
  .v4d-tick-text + .v4d-tick-text { display: none; }
}
@media (max-width: 640px) {
  .v4d-tick-bar { height: 22px; font-size: 0.6875rem; gap: 8px; padding: 0 12px; }
  .v4d-tick-info { font-size: 0; }
  .v4d-tick-info::before { font-size: 0.8125rem; }
  html[data-mticker="B"] .v4d-tick-bar, html[data-mticker="C"] .v4d-tick-bar { display: none; }
  html[data-mticker="B"] .v4d-tick-pill { display: inline-flex; position: fixed; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 58; align-items: center; min-height: 32px; padding: 0 12px; border: 1px solid var(--v4d-ink); border-radius: 999px; background: var(--v4d-sage); color: var(--v4d-ink); font: 600 0.75rem/1 var(--v4d-mono); box-shadow: 0 6px 18px rgba(36,34,31,.18); }
  html[data-mticker="B"] .v4d-tick-pill::before { content: "●"; color: var(--v4d-forest); margin-right: 6px; font-size: 0.5rem; }
  html[data-mticker="C"] .v4d-chip-slot { display: inline-flex; margin-left: 8px; }
  html[data-mticker="C"] .v4d-tick-chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; border: 1px solid #8A8577; border-radius: 999px; background: var(--v4d-sage); color: var(--v4d-ink); font: 600 0.6875rem/1 var(--v4d-mono); white-space: nowrap; }
  html[data-mticker="C"] .v4d-bar .v4d-back { margin-left: auto; }
  html[data-mticker="C"] header.v4d-sticky:not(.v4d-bar) .v4d-chip-slot { margin-left: auto; }
}

/* pop-up with the full status strip */
.v4d-dlg { width: min(460px, calc(100vw - 32px)); max-height: min(82vh, 680px); padding: 0; border: 1px solid var(--v4d-ink); border-radius: 10px; background: #FFFDF8; color: var(--v4d-ink); font-family: var(--v4d-sans); box-shadow: 0 12px 40px rgba(36,34,31,.25); }
.v4d-dlg::backdrop { background: rgba(36,34,31,.35); }
.v4d-dlg.is-sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
.v4d-dlg-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; background: var(--v4d-sage); border-bottom: 1px solid var(--v4d-line); }
.v4d-dlg-head h2 { margin: 0; font-size: 1rem; }
.v4d-dlg-x { width: 44px; height: 44px; border: 0; background: transparent; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--v4d-ink); }
.v4d-dlg-body { padding: 12px 16px 16px; font-size: 0.875rem; }
.v4d-dlg-body [data-sf-status] { margin: 0; }
.v4d-dlg-note { margin: 12px 0 0; font-size: 0.75rem; color: var(--v4d-muted); }

/* ---------- footnotes ---------- */
.v4d-star { margin-left: 2px; color: var(--v4d-forest); text-decoration: none; font-weight: 600; font-size: 0.6em; vertical-align: super; }
.v4d-star:hover { text-decoration: underline; }
.v4d-notes { max-width: 1100px; margin: 32px auto 0; padding: 14px 16px 22px; border-top: 1px solid var(--v4d-line); font: 0.75rem/1.5 var(--v4d-sans); color: var(--v4d-muted); }
.v4d-note { display: flex; gap: 6px; align-items: baseline; }
.v4d-note + .v4d-note { margin-top: 4px; }
.v4d-note-star { color: var(--v4d-forest); font-weight: 600; }
.v4d-notes .v4d-moved, .v4d-notes .v4d-moved * { margin: 0 !important; padding: 0 !important; border: 0 !important; background: none !important; box-shadow: none !important; font-size: 0.75rem !important; line-height: 1.5 !important; color: var(--v4d-muted) !important; font-weight: 400 !important; }
.v4d-notes .v4d-moved a { color: var(--v4d-forest) !important; text-decoration: underline; }
.v4d-notes .v4d-moved:empty { display: none; }

/* ---------- brand greens: alternating sections ---------- */
html.v4d body { background: var(--v4d-paper); }
html.v4d .hero { background: var(--v4d-sage); }
html.v4d .band, html.v4d .band2 { background: var(--v4d-paper); }
html.v4d .band.alt, html.v4d .band2.alt, html.v4d section.incident { background: var(--v4d-sage2); }
html.v4d .band.next { background: var(--v4d-sage); }
/* single-column apps (Document Desk, Lead Scout): the head sits on a green panel, cards alternate */
html.v4d .v4d-headpanel { background: var(--v4d-sage); border-radius: 10px; padding: 16px 18px; margin: 12px 0 16px; }
html.v4d .wrap > .card:nth-of-type(even), html.v4d .wrap > section:nth-of-type(even) > .card { background: var(--v4d-sage2); }

/* ---------- phone rails and the swipe deck ---------- */
.v4d-rail-hint { display: none; }
@media (max-width: 640px) {
  .v4d-rail { display: flex !important; flex-wrap: nowrap !important; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; padding: 2px 2px 10px !important; margin-left: 0; margin-right: 0; list-style: none; grid-template-columns: none !important; }
  .v4d-rail > * { flex: 0 0 82%; max-width: 82%; scroll-snap-align: start; margin: 0 !important; box-sizing: border-box; }
  ul.v4d-rail > li { background: rgba(255,255,255,.55); border: 1px solid var(--v4d-line); border-radius: 8px; padding: 10px 12px; }
  .v4d-rail-hint { display: block; margin: 4px 0 6px; font: 600 0.6875rem/1.2 var(--v4d-mono); color: var(--v4d-forest); text-transform: uppercase; letter-spacing: .04em; }
  .v4d-rail-hint::after { content: " →"; }
  .v4d-deck { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 0 12px 12px; background: var(--v4d-sage); }
  .v4d-deck > section { flex: 0 0 90%; max-width: 90%; max-height: 74vh; overflow-y: auto; scroll-snap-align: center; box-sizing: border-box; border-radius: 10px; border: 1px solid var(--v4d-line); padding: 16px 14px !important; margin: 0 !important; }
  .v4d-deck > section:nth-child(odd) { background: #FFFDF8; }
  .v4d-deck > section:nth-child(even) { background: var(--v4d-sage2); }
  .v4d-deck-head { padding: 18px 16px 8px; background: var(--v4d-sage); }
  .v4d-deck-head h2 { margin: 0 0 4px; font: 600 1.125rem/1.25 var(--v4d-sans); color: var(--v4d-ink); }
  .v4d-deck-head p { margin: 0; font: 0.8125rem/1.4 var(--v4d-sans); color: var(--v4d-muted); }
  .v4d-deck-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; }
  .v4d-deck-tabs button { flex: none; min-height: 36px; padding: 0 12px; border: 1px solid #8A8577; border-radius: 999px; background: #FFFDF8; font: 600 0.75rem/1 var(--v4d-sans); color: var(--v4d-ink); cursor: pointer; }
  .v4d-deck-tabs button[aria-current="true"] { background: var(--v4d-forest); border-color: var(--v4d-forest); color: #fff; }
  /* compact headers that came with the apps */
  header.v4d-sticky:not(.v4d-bar) { padding-top: 6px !important; padding-bottom: 6px !important; }
  header.v4d-sticky:not(.v4d-bar) nav { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 14px; font-size: 0.8125rem; }
  header.v4d-sticky:not(.v4d-bar) nav a { white-space: nowrap; }
}
@media (min-width: 641px) {
  .v4d-deck, .v4d-deck-wrap { display: contents; }
  .v4d-deck-head { display: none; }
}

/* Lead Scout: its header doubles as the Spanfold bar */
header.v4d-sticky .v4d-back { margin-left: auto; }
header.v4d-sticky .top-in { display: flex; align-items: center; gap: 12px; }
html.v4d .wrap > .hero, html.v4d .wrap .hero:not(section.hero:first-child) { border-radius: 10px; padding: 16px 18px; margin-top: 12px; }
html.v4d body > footer, html.v4d footer.foot { font-size: 0.75rem; line-height: 1.5; }
html.v4d body > footer p, html.v4d footer.foot p { font-size: inherit; }
.v4d-rail { align-items: flex-start; }
.v4d-note:has(> .v4d-moved:empty), .v4d-note:has(> .v4d-moved[hidden]) { display: none; }
