/* v3 page frame and cards (core §5, §6, §7): one column of cards on --page,
   page title (h1) with an optional lead line, cards with a 1px border and no
   shadow. Also the few layout rows used by the local component preview page
   (lg-preview-*), which only exists in development (plan §11 #66). */

/* Ledger 2 width (decision 304): fluid up to --page-max, centred beyond (v3: 80rem, pinned left). */
.lg-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  inline-size: 100%;
  max-inline-size: var(--page-max);
  margin-inline: auto;
}
/* A group of parts that belong together inside a page (e.g. a grid's filters
   and the grid): closer than the page's own sections. */
.lg-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-inline-size: 0;
}
/* Page header (macro core/components/_lg_page.html). Desktop: breadcrumb,
   then [stub] title + pills / fact line on the left, actions on the right of
   the same row. Phone: "‹ Parent" instead of the breadcrumb, secondary
   actions move into ⋯ (Primer, Material 3). */
.lg-phead { display: flex; flex-direction: column; gap: var(--space-2); }
.lg-phead__crumbs ol {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--size-caption);
  line-height: var(--leading-caption);
  color: var(--text-muted);
}
.lg-phead__crumbs li + li::before { content: "/"; padding-inline: var(--space-2); }
.lg-phead__crumbs a { color: var(--text-muted); text-decoration: none; }
.lg-phead__crumbs a:hover { color: var(--primary); text-decoration: underline; }
.lg-phead__up { display: none; }
.lg-phead__bar { display: flex; align-items: center; gap: var(--space-4); }
.lg-phead__lead { display: flex; flex: 1; align-items: center; gap: var(--space-4); min-inline-size: 0; }
.lg-phead__main { display: flex; flex: 1; flex-direction: column; gap: var(--space-1); min-inline-size: 0; }
.lg-phead__titleline { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.lg-phead__title {
  margin: 0;
  font-size: var(--size-page-title);
  line-height: var(--leading-page-title);
  font-weight: var(--weight-page-title);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.lg-phead__meta { margin: 0; color: var(--text-muted); }
/* Event switcher (decision 316): the title + ▾ is one button; the ▾ is an SVG
   chevron in a soft box, centred on the title line. */
.lg-phead__switch {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: start;
  cursor: pointer;
  touch-action: manipulation;
}
.lg-phead__chev {
  display: inline-grid;
  place-items: center;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  margin-inline-start: var(--space-2);
  border-radius: var(--radius-control);
  background: var(--neutral-tint);
  color: var(--text-muted);
  vertical-align: 0.15em;
  transition: background-color var(--dur-fast) var(--ease);
}
.lg-phead__switch:focus-visible { outline: var(--focus-ring) solid var(--focus); outline-offset: 2px; border-radius: var(--radius-control); }
.lg-phead__switchmark { position: relative; flex: none; margin: 0; padding: 0; border: 0; background: none; cursor: pointer; }
/* Phones: the small mark keeps a 44px tap area (same ::before as .lg-btn). */
@media (max-width: 39.99em) {
  .lg-phead__switchmark::before {
    content: "";
    position: absolute;
    inset: calc((var(--touch-target) - 100%) / -2) 0;
    min-block-size: var(--touch-target);
  }
}
@media (hover: hover) and (pointer: fine) {
  .lg-phead__switch:hover .lg-phead__chev,
  .lg-phead__switchmark:hover + .lg-phead__main .lg-phead__chev { background: var(--secondary-fill); color: var(--text); }
}
/* What the page is for, one sentence (decision 257). */
.lg-phead__intro { margin: 0; max-inline-size: 70ch; color: var(--text-muted); font-size: var(--size-body); line-height: var(--leading-body); }
.lg-phead__actions { display: flex; flex: none; align-items: center; gap: var(--space-2); }
.lg-phead__sec, .lg-phead__primary, .lg-phead__more { display: contents; }

/* Ledger 2 header band (decision 305): the page's own header is a --surface band
   joined to the top bar, 1px --border at its bottom, tabs at its bottom (308).
   The band cancels .lg-main's top padding; its fill (::before) bleeds sideways to
   the main area's edges, which .lg-main clips (overflow-x: clip, shell.css). */
.lg-phead--band { position: relative; isolation: isolate; padding-block: var(--space-6) var(--space-5); }
/* Joined to the top bar only when nothing comes before the page in #content
   (anything above it would be covered). */
.lg-main > .lg-page:first-child > .lg-phead--band:first-child { margin-block-start: calc(-1 * var(--space-8)); }
.lg-phead--band::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset-block: 0;
  inset-inline: -100vmax;
  background: var(--surface);
  border-block-end: 1px solid var(--border);
}
.lg-phead__tabs { margin-block-start: var(--space-3); min-inline-size: 0; }
.lg-phead--band:has(> .lg-phead__tabs) { padding-block-end: var(--space-4); }

@media (min-width: 40em) {
  .lg-phead__more--phone { display: none; }
}

/* Condensed header (decision 305; motion 319 (5)): one 48px row pinned under the
   top bar once the band has scrolled away (js/v3/phead.js sets html.lg-pinned).
   Fade + 6px slide, 200ms in / 140ms out; reduced motion: instant swap.
   Desktop and tablet only; phones never pin (the top bar shows the title). */
.lg-phead__pin {
  position: fixed;
  z-index: var(--layer-bar);
  inset-block-start: var(--bar-height);
  inset-inline: var(--sidebar-width) 0;
  block-size: 3rem;
  border-block-end: 1px solid var(--border);
  background: var(--surface);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.375rem);
  transition: opacity var(--dur-exit) var(--ease), transform var(--dur-exit) var(--ease),
              visibility 0s linear var(--dur-exit);
}
html[data-lg-rail] .lg-phead__pin { inset-inline-start: var(--rail-width); }
html.lg-pinned .lg-phead__pin {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity var(--dur-enter) var(--ease), transform var(--dur-enter) var(--ease), visibility 0s;
}
.lg-phead__pin-inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  block-size: 100%;
  max-inline-size: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--space-8);
}
.lg-phead__pin-title {
  min-inline-size: 0;
  margin: 0;
  overflow: hidden;
  font-size: var(--size-card-title);
  line-height: var(--leading-card-title);
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lg-phead__pin-primary { display: inline-flex; margin-inline-start: auto; }
.lg-phead__pin .lg-btn { min-height: var(--control-height-sm); }
/* Focus is never hidden under the pinned row (WCAG 2.4.11). */
html.lg-pinned:has(.lg-body) { scroll-padding-top: calc(var(--bar-height) + 3rem + var(--space-2)); }
@media (max-width: 39.99em) {
  .lg-phead__pin { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .lg-phead__pin, html.lg-pinned .lg-phead__pin { transform: none; transition: none; }
}

@media (max-width: 39.99em) {
  /* Compact phone band (305): not pinned, about 150px with tabs. */
  .lg-phead--band { padding-block: var(--space-3); }
  .lg-main > .lg-page:first-child > .lg-phead--band:first-child { margin-block-start: calc(-1 * var(--space-4)); }
  .lg-phead__tabs { margin-block-start: var(--space-2); }
  .lg-phead__crumbs ol { display: none; }
  .lg-phead__up {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: var(--touch-target);
    margin-inline-start: calc(-1 * var(--space-1));
    color: var(--primary);
    text-decoration: none;
  }
  .lg-phead--fold .lg-phead__sec,
  .lg-phead__primary--fold { display: none; }
  /* Title row holds the primary and ⋯ (305, amends 295's own action row); the
     intro line is left out of the phone band. */
  .lg-phead__bar { align-items: flex-start; gap: var(--space-2); }
  .lg-phead__lead { align-items: flex-start; gap: var(--space-3); }
  .lg-phead--band .lg-phead__intro { display: none; }
  /* Status and the fact line share one line under the title, cut with "…" (305). */
  .lg-phead--band .lg-phead__main { flex-flow: row wrap; align-items: center; column-gap: var(--space-2); }
  .lg-phead--band .lg-phead__titleline { display: contents; }
  .lg-phead--band .lg-phead__main .lg-phead__title { flex: 1 0 100%; }   /* not the greeting h1: its parent is a column, 100% = its own height */
  .lg-phead--band .lg-phead__meta { flex: 1 1 0; min-inline-size: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  /* "‹ Parent": 44px to the finger, less to the eye. */
  .lg-phead--band .lg-phead__up { margin-block: calc(-1 * var(--space-3)) calc(-1 * var(--space-2)); }
  /* Compact phone header (owner, 2026-10-08, decision 284): smaller fact line and
     stub (buttons: button.css). The title's phone size is the token (1.25rem,
     Ledger 2 decision 307; it was section size here). */
  .lg-phead__meta { font-size: var(--size-label); line-height: var(--leading-label); }
  .lg-phead .lg-stub:not(.lg-stub--range) { inline-size: 2.5rem; block-size: 2.5rem; }
  .lg-phead .lg-evmark { block-size: 2.5rem; }   /* banner mark, same height (decision 300) */
  .lg-phead .lg-stub .lg-stub__day { font-size: var(--size-card-title); }
}

.lg-card {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.lg-card__title {
  margin: 0;
  font-size: var(--size-card-title);
  line-height: var(--leading-card-title);
  font-weight: 600;
}
.lg-card__lead { margin: var(--space-1) 0 0; color: var(--text-muted); }

@media (max-width: 39.99em) {
  .lg-card { padding: var(--space-4); }
}

/* Home greeting (decisions 318, 343; preview §8d; page_header(greeting=…)).
   Full on the Command Center band: date, "Good afternoon, <name>" (the h1),
   one live sentence whose facts are links, a "Next up" row. Slim on the TA
   event dashboard: one line at the top of the band. Facts are underlined
   text in --text (amber when something needs the user, said in words too). */
.lg-phead--greet .lg-phead__lead { align-items: stretch; }
.lg-greet { display: flex; flex: 1; flex-direction: column; gap: var(--space-1); min-inline-size: 0; }
.lg-greet__date { margin: 0; color: var(--text-muted); font-size: var(--size-label); line-height: var(--leading-label); }
.lg-greet__line { margin: 0; max-inline-size: var(--measure); color: var(--text-muted); font-size: var(--size-body); line-height: var(--leading-body); }
.lg-greet__fact { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 0.2em; }
.lg-greet__plain { color: var(--text); }
.lg-greet__fact--warning { color: var(--warning); text-decoration-color: currentColor; }
.lg-greet__fact--danger { color: var(--danger); text-decoration-color: currentColor; }
a.lg-greet__fact:focus-visible { outline: var(--focus-ring) solid var(--focus); outline-offset: 2px; border-radius: var(--radius-pill); }
.lg-greet__next {
  display: flex; align-items: center; gap: var(--space-3);
  max-inline-size: 40rem; min-block-size: var(--touch-target); margin-block-start: var(--space-3); padding: var(--space-3);
  border-radius: var(--radius-card); background: var(--page); color: var(--text); text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease);
}
a.lg-greet__next:focus-visible { outline: var(--focus-ring) solid var(--focus); outline-offset: 2px; }
.lg-greet__next-text { display: flex; flex: 1; flex-direction: column; min-inline-size: 0; }
.lg-greet__next-text strong { font-weight: 600; overflow-wrap: anywhere; }
.lg-greet__next-text span { color: var(--text-muted); font-size: var(--size-label); line-height: var(--leading-label); }
.lg-greet__open { display: inline-flex; flex: none; align-items: center; gap: var(--space-1); color: var(--primary); font-size: var(--size-label); }
@media (hover: hover) and (pointer: fine) {
  a.lg-greet__fact:hover { text-decoration-color: currentColor; }
  a.lg-greet__next:hover { background: var(--neutral-tint); }
}
.lg-greet--slim { display: block; margin: 0 0 var(--space-3); color: var(--text-muted); font-size: var(--size-label); line-height: var(--leading-label); }
.lg-greet--slim .lg-greet__hello { color: var(--text); font-weight: 600; }
/* Rises once per visit (318, core §8): opacity + 4px, 200ms, 40ms stagger;
   html[data-lg-greeted] (js/v3/greet.js) = at rest. Reduced motion: 100ms fade. */
@keyframes lg-greet-rise { from { opacity: 0; transform: translateY(0.25rem); } }
@keyframes lg-greet-fade { from { opacity: 0; } }
:root:not([data-lg-greeted]) .lg-greet:not(.lg-greet--slim) > *,
:root:not([data-lg-greeted]) .lg-greet--slim { animation: lg-greet-rise var(--dur-enter) var(--ease) both; }
:root:not([data-lg-greeted]) .lg-greet > :nth-child(2) { animation-delay: 40ms; }
:root:not([data-lg-greeted]) .lg-greet > :nth-child(3) { animation-delay: 80ms; }
:root:not([data-lg-greeted]) .lg-greet > :nth-child(4) { animation-delay: 120ms; }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-lg-greeted]) .lg-greet:not(.lg-greet--slim) > *,
  :root:not([data-lg-greeted]) .lg-greet--slim { animation: lg-greet-fade 100ms linear both; animation-delay: 0s; }
}

/* Preview page layout only. A frame shows a header sample on the page colour. */
.lg-preview-stack { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-4); }
.lg-preview-frame { padding: var(--space-5); border-radius: var(--radius-control); background: var(--page); }
.lg-preview-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-4); }
.lg-preview-gap { margin-block-start: var(--space-4); }
.lg-preview-row--line { padding-block: var(--space-3); border-block-end: 1px solid var(--border); }
.lg-preview-list { display: flex; flex-direction: column; gap: var(--space-4); margin: var(--space-5) 0 0; padding: 0; list-style: none; }
.lg-preview-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); }
.lg-preview-row__text { display: flex; flex: 1 1 12rem; flex-direction: column; min-inline-size: 0; overflow-wrap: anywhere; }
.lg-preview-row__meta { color: var(--text-muted); font-size: var(--size-caption); line-height: var(--leading-caption); }
/* A sample shown at page level, not inside a card (event page tabs + footer). */
.lg-preview-section { display: flex; flex-direction: column; gap: var(--space-3); }
.lg-preview-section__title { margin: 0; font-size: var(--size-section); line-height: var(--leading-section); font-weight: 600; }
/* Ledger 2 foundation sample (decision 307 type scale, 313 / 310 tokens). */
.lg-l2type { flex: 1 1 16rem; min-inline-size: 0; }
.lg-l2type--title { font-size: var(--size-page-title); line-height: var(--leading-page-title); font-weight: var(--weight-page-title); letter-spacing: -0.02em; }
.lg-l2type--section { font-size: var(--size-section); line-height: var(--leading-section); font-weight: 600; letter-spacing: -0.01em; }
.lg-l2type--card { font-size: var(--size-card-title); line-height: var(--leading-card-title); font-weight: 600; }
.lg-l2type--body { font-size: var(--size-body); line-height: var(--leading-body); }
.lg-l2type--label { font-size: var(--size-label); line-height: var(--leading-label); font-weight: 500; }
.lg-l2type--caption { font-size: var(--size-caption); line-height: var(--leading-caption); color: var(--text-muted); }
@media (max-width: 39.99em) { .lg-l2type--body { font-size: 1rem; line-height: 1.5rem; } }
.lg-l2swatch { flex: none; inline-size: 3rem; block-size: 2rem; border-radius: var(--radius-control); }
.lg-l2swatch--secondary { background: var(--secondary-fill); }
.lg-l2swatch--secondary-hover { background: var(--secondary-fill-hover); }
.lg-l2swatch--shade { background: linear-gradient(to left, var(--scroll-shade), transparent); box-shadow: inset 0 0 0 1px var(--border); }
