/* ==========================================================================
   One type scale and a few layout rules for every page (microplan, field
   team, registration, admin). Loaded after each page's own styles, from
   the shared top bar (microplan/includes/nav.php), the admin shell and the
   field page frame.

   Fonts: Source Sans 3 for text, Plus Jakarta Sans for headings (both
   already loaded from Google Fonts). Form controls and buttons inherit them
   (browsers otherwise use Arial or the system font).
   Sizes: 12 · 13 · 14 · 15 · 17 · 22. Body 15px; 16px on phones, which also
   stops phones zooming into inputs. Nothing smaller than 12px.
   ========================================================================== */

:root {
    --ty-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --ty-head: "Plus Jakarta Sans", "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
    --ty-xs: 12px;     /* labels, column headings, badges */
    --ty-sm: 13px;     /* notes, meta lines, small buttons */
    --ty-table: 14px;  /* table cells, lists */
    --ty-base: 15px;   /* body text, inputs, buttons */
    --ty-h2: 17px;     /* card and section headings */
    --ty-h1: 22px;     /* page title */
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body, body.app, body.app-shelled, body.fp, body.ds { font-family: var(--ty-body); font-size: var(--ty-base); line-height: 1.5; }

/* Controls take the page's font instead of Arial / system-ui. */
button, input, select, textarea, optgroup,
.btn, .form-control, .form-select, .vp-btn, .app-btn, .icon-btn { font-family: inherit; }
input, select, textarea, .form-control, .form-select { font-size: var(--ty-base); }
.form-control-sm, .form-select-sm, .btn-sm, .vp-btn.sm, .app-btn-sm { font-size: var(--ty-sm); }

/* Headings: one family, one size per level, weight 800. */
h1, .h1, .vp-title, .page-heading h1, .app-page-head h1 {
    font-family: var(--ty-head); font-size: var(--ty-h1); font-weight: 800; line-height: 1.25; letter-spacing: -.01em; margin-top: 0;
}
h2, .h2, .vp-work-head h2, .fp-card-head h2, .app-card-head h2, .card-header h5, .modal-title {
    font-family: var(--ty-head); font-size: var(--ty-h2); font-weight: 800; line-height: 1.3;
}
h3, .h3, h4, .h4, h5, .h5, .vp-list-head h2 { font-family: var(--ty-head); font-size: var(--ty-base); font-weight: 800; line-height: 1.35; }
h6, .h6 { font-family: var(--ty-head); font-size: var(--ty-sm); font-weight: 800; }
.page-heading .sub, .vp-lede, .app-page-head p { font-size: var(--ty-sm); line-height: 1.5; }

/* Labels, notes, badges: never below 12px. */
label, .form-label, .filter-field label, .fp-label, .filter-label { font-size: var(--ty-xs); }
small, .small, .vp-muted, .text-muted.small, .form-text { font-size: var(--ty-sm); }
.badge, .vp-badge, .vp-chip, .app-badge, .tab-count { font-size: var(--ty-xs); }

/* Tables: one size for cells, one for column headings. */
table td, .table td, .fp-table td, .data-table td, .app-table td { font-size: var(--ty-table); }
body th { font-size: var(--ty-xs) !important; }   /* column headings: one size on every page */

/* Numbers line up in columns and cards. */
.vp-big, .vp-pct, .tab-count, td.text-end, .fs-2, .display-6 { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Same-level boxes match: cards in one row are the same height, and grid
   columns share the width evenly.
   -------------------------------------------------------------------------- */
.row > [class*="col"] > .card:only-child,
.row > [class*="col"] > .vp-card:only-child,
.row > [class*="col"] > .fp-card:only-child,
.row > [class*="col"] > .app-card:only-child,
.row > [class*="col"] > .vp-kpi:only-child { height: 100%; }
.row > [class*="col"] > .card:only-child, .row > [class*="col"] > .fp-card:only-child { display: flex; flex-direction: column; }
.row > [class*="col"] > .card:only-child > .card-body { flex: 1 1 auto; }
.fp-kpis, .iu-checks, .app-kpis, .app-grid-2, .tv-grid { align-items: stretch; }
.fp-kpis > *, .iu-checks > *, .app-kpis > * { min-width: 0; height: 100%; }
.vp-kpi, .app-kpi { box-sizing: border-box; }

/* --------------------------------------------------------------------------
   Top bar: the sections fit or scroll; they never run under the page name
   or the user's name.
   -------------------------------------------------------------------------- */
.mp-bar { min-width: 0; }
.mp-sections { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.mp-sections::-webkit-scrollbar { display: none; }
.mp-page { display: none; }                    /* the page's own title says it */
.mp-user { flex: 0 1 auto; }
@media (max-width: 1440px) { .mp-user span { display: none; } }
/* Labels go when they do not fit (the bar adds .compact, nav.php); the
   names stay in each icon's tooltip and in the menu. Still too many for a
   phone: the icons scroll, with a fade at the cut edge. */
.mp-sections.compact a span { display: none; }
.mp-sections.compact a { padding: 0 11px; }
.mp-sections.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }

/* --------------------------------------------------------------------------
   Phones.
   -------------------------------------------------------------------------- */
@media (max-width: 700px) {
    :root { --ty-base: 16px; --ty-table: 14px; --ty-h1: 20px; --ty-h2: 16px; }
    .table-responsive, .fp-table-wrap { -webkit-overflow-scrolling: touch; }
}
/* Scrolling tables hold their screen-reader-only labels (position: absolute), which
   would otherwise sit outside the box and widen the page. */
.table-responsive, .fp-table-wrap, .app-table-wrap { position: relative; }

/* Admin portal top bar on small screens: the page section and the user's name give way
   (the name is in the tooltip and the side menu), so nothing runs off the screen. */
@media (max-width: 900px) { .app-shell-user span, .app-shell-where { display: none; } }
@media (max-width: 600px) { .app-shell-top { padding: .55rem .75rem; gap: .5rem; } .app-shell-top > div { gap: .4rem !important; min-width: 0; } }


/* Work pages on narrow screens: the side panel and the main column take the
   screen's width (a wide table scrolls inside its card instead of widening the page). */
@media (max-width: 1100px) {
    .vp-layout > .vp-main, .vp-layout > .vp-side, .vp-side > * { align-self: stretch; min-width: 0; max-width: 100%; }
}
