/* Page shell, header and section chrome. Figma canvas: 1390 px wide, 32 px gutters. */

.page {
  display: flex; flex-direction: column; gap: 24px;
  max-width: 1600px; margin: 0 auto; padding: 0 32px 60px;
}
/* The header's band bleeds to the viewport edges; without this the bleed could scroll. */
html, body { overflow-x: clip; }

/* --- header ------------------------------------------------------------- */
/* One toolbar row in a full-width light band, directly under whatever the host application shows
   above the page (its own header carries the account menu): the logo, a hairline, the title with
   the description in an info tip; then the snapshot picker, Export, the theme toggle and, on the
   index, a divider and the view switch. */
.header {
  position: relative; isolation: isolate;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 12px 0;
}
.header::before {
  content: ""; position: absolute; inset: 0 calc(50% - 50vw); z-index: -1;
  background: var(--band); border-bottom: 1px solid var(--border-strong);
}
.header__filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
/* The controls share the row's 36 px height. */
.header__filters .theme-toggle { width: 36px; height: 36px; border-radius: var(--radius-input); flex: none; }
.header__filters .view-switch { height: 36px; align-items: stretch; border-radius: var(--radius-input); }
.header__divider { width: 1px; height: 24px; margin: 0 4px; background: var(--border-strong); flex: none; }
.brand { display: flex; align-items: center; gap: 18px; min-width: 0; flex: 1; }
/* The lockup image, cropped as the login page crops it, at two thirds of its width. */
.brand__logo { position: relative; flex: none; width: 148px; aspect-ratio: 222 / 52; overflow: hidden; }
.brand__img { position: absolute; left: 0; top: -0.14%; width: 104.92%; height: 118.06%; max-width: none; }
/* Two renditions of the lockup: navy ink for light, light ink for dark. The marks are identical. */
:root[data-theme="dark"] .brand__img--light { display: none; }
:root:not([data-theme="dark"]) .brand__img--dark { display: none; }
.brand__text { display: flex; align-items: center; gap: 4px; min-width: 0; padding-left: 18px; border-left: 1px solid var(--border-strong); }
.brand__title { font: 600 18.5px/1.2 var(--font-display); color: var(--text); }
.brand__wordmark {
  font: 500 16px/1.4 var(--font-display);
  background: linear-gradient(178.5deg, var(--wordmark-from) 27%, var(--wordmark-to) 154%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand__title .brand__wordmark { font: inherit; }

/* --- sections ----------------------------------------------------------- */
/* Sections sit directly on the page: heading + content, no panel chrome. */
.section { display: flex; flex-direction: column; gap: 16px; }
.section + .section { margin-top: 40px; }
.section__bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section__heading { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.section__title { font: 600 18.5px/normal var(--font-body); color: var(--text); }
.section__subtitle { font-size: 12.5px; color: var(--text-2); }

/* --- Overview cards: the workstream grid ---------------------------------- */
/* Reads across (four library populations) and down (three workstreams). Five columns: the rail,
   then one per population; rows: 1 the governance header, 2 the population header cards, 3 to 5
   the workstreams (inventory, contributions, delivered), 6 the reading guide. The scaffolding
   (the governance header, one faint lane per row, the rail) comes first in the markup so it
   paints under the cards; each card takes its column from data-col and its row from what it is.
   Cards inside a lane keep 14 px from its top and bottom and 12 px from its sides. */
.overview-grid { display: grid; grid-template-columns: 212px repeat(4, minmax(0, 1fr)); column-gap: 16px; row-gap: 0; }
.overview-grid__group {
  grid-column: 4 / 6; grid-row: 1; margin: 0 0 10px 12px; padding: 9px 14px; text-align: center;
  font: 700 12px/1.2 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--text);
  background: var(--border); border-radius: var(--radius-card);
}
.overview-grid__lane { grid-column: 2 / 6; margin: 4px 0; border: 1px solid var(--border); border-radius: var(--radius-card); }
.overview-grid__lane[data-row="heads"] { grid-row: 2; }
.overview-grid__lane[data-row="inventory"] { grid-row: 3; }
.overview-grid__lane[data-row="contributions"] { grid-row: 4; }
.overview-grid__lane[data-row="delivered"] { grid-row: 5; }
.overview-grid > [data-col="1"] { grid-column: 2; }
.overview-grid > [data-col="2"] { grid-column: 3; }
.overview-grid > [data-col="3"] { grid-column: 4; }
.overview-grid > [data-col="4"] { grid-column: 5; }
.overview-grid > .population-head { grid-row: 2; }
.overview-grid > .library-card { grid-row: 3; }
.overview-grid > .impact-measure[data-measure="contributions"] { grid-row: 4; }
.overview-grid > .impact-measure[data-measure="delivered"] { grid-row: 5; }
.overview-grid > .population-head, .overview-grid > .library-card, .overview-grid > .impact-measure { margin: 14px 12px; }
/* The alternation is on the cards: every card of the second and fourth populations takes the
   rail's band tint, the first and third stay on the plain surface. */
.overview-grid > [data-col="2"], .overview-grid > [data-col="4"] { background: var(--band); }
.overview-grid > .read-guide { grid-column: 1 / -1; grid-row: 6; margin-top: 12px; }

/* --- KPI band ----------------------------------------------------------- */
/* A row of KPI cards (the KPI detail page); auto-flow columns share the width however many
   there are. */
.kpi-band {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  padding: 16px 0; background: var(--surface-muted); border: 1px solid var(--border-strong);
}
.kpi-band > .kpi-card { border-right: 1px solid var(--border-strong); }
.kpi-band > .kpi-card:last-child { border-right: 0; }

/* --- detail pages ------------------------------------------------------- */
.back-link { font-size: 12.5px; color: var(--text-2); text-decoration: none; }
.back-link:hover { color: var(--text); text-decoration: underline; }
.lede { max-width: 640px; font-size: 13px; color: var(--text-2); }
.placeholder { padding: 32px; text-align: center; font-size: 12.5px; color: var(--text-3); border: 1px dashed var(--border-strong); border-radius: var(--radius-card); }

/* --- auth --------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth__card {
  width: min(420px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 32px;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-overlay);
}
/* The login page's full-size lockup: the logo over the right-aligned wordmark. */
.brand__lockup { display: flex; flex-direction: column; align-items: flex-end; width: 222px; align-self: flex-start; }
.brand__lockup > .brand__logo { width: 222px; height: 52px; aspect-ratio: auto; margin-bottom: -7px; }
.brand__lockup > .brand__wordmark { width: 208px; text-align: right; }
.auth__title { font: 600 18.5px/normal var(--font-body); color: var(--text); }
.auth__subtitle { font-size: 12.5px; color: var(--text-2); }
.auth__theme { position: fixed; top: 20px; right: 24px; }

/* --- responsive --------------------------------------------------------- */
@media (max-width: 1100px) {
  /* One column: each population's header card then its three cards in turn; the scaffolding goes. */
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
  .overview-grid__group, .overview-grid__lane { display: none; }
  .overview-grid > .population-head, .overview-grid > .library-card, .overview-grid > .impact-measure { grid-row: auto; grid-column: auto; margin: 0 0 10px; }
  /* The measures' row rules above name data-measure, so this override has to as well. */
  .overview-grid > .impact-measure[data-measure] { grid-row: auto; }
  .overview-grid > .population-head { margin-top: 16px; }
  .overview-grid > [data-col="1"] { order: 10; } .overview-grid > [data-col="2"] { order: 20; }
  .overview-grid > [data-col="3"] { order: 30; } .overview-grid > [data-col="4"] { order: 40; }
  .overview-grid > .read-guide { grid-row: auto; order: 50; margin: 8px 0 6px; }
}
/* The KPI cards' and trend panels' own breakpoints live with their blocks in components.css,
   which loads after this file and would otherwise win the cascade. */
@media (max-width: 900px) {
  .page { padding: 0 16px 40px; }
  /* Stacked header: the brand row, then the controls across the full width, wrapping. */
  .header { flex-direction: column; align-items: stretch; gap: 14px; padding: 16px 0; }
  .brand__logo { width: 124px; }
  .header__filters { justify-content: flex-start; }
  .header__divider { display: none; }
  .header__filters .select-field { flex: 1 1 260px; min-width: 0; }
  .header__filters .select-field__control { flex: 1 1 200px; width: auto; }
}
@media (max-width: 640px) {
  /* Cards stack: without switching the flow to rows the single template column would take the
     first card and the rest would still line up beside it in implicit columns. */
  .kpi-band { grid-auto-flow: row; grid-template-columns: minmax(0, 1fr); }
  .kpi-band > .kpi-card { border-right: 0; border-bottom: 1px solid var(--border-strong); }
  .kpi-band > .kpi-card:last-child { border-bottom: 0; }
}
