/*
 * public/assets/css/site-compact.css — u213-832 run u832bp s10, Change 10 (phases 119-127, D-832-27): the optional site-wide compact look.
 * header.php links it right after app.css ONLY while it prints data-ed-density on the app-shell <html> (calm_ui_site_density() in
 * calm-ui-flags.php; switch off = no attribute, no link, the u213-831 page):
 *   "compact"  a signed-in app page (student / teacher / admin / account / billing / invite / quiz / student portal): the shell and the
 *              shared ui.php components get tighter spacing
 *   "spacing"  a signed-out header.php page (login / register / password; the Q3 sub-switch): the spacing part only
 * Rules (test-u832-s10-c10-site-compact-pure.php):
 *   - every selector starts with html[data-ed-density="compact"] or html[data-ed-density="spacing"]; every rule sits in an @media screen
 *     block, so print never sees it (PDFs and emails never load header.php; marketing pages use their own header)
 *   - spacing and sizes only: no colour, no !important, no font size at all (body text stays 14-15 px, meta 13 px), 44 px targets on
 *     coarse pointers (the density tokens switch back to 44 px there)
 *   - never inside the AI Chat root (.aic is also an .ed-page-shell): AI Chat keeps its own layout; the shell rules skip a page that shows
 *     the AI Chat rail (its compact layout hides the site shell there)
 *   - the global --ed-space-* tokens are NOT changed (AI Chat and the report designs read them); new --ed-density-* tokens instead
 */

/* -- Density tokens (phase 119) ------------------------------------------------------------------------------------------------- */
@media screen {
  html[data-ed-density="compact"] {
    --ed-density-topbar: 56px;
    --ed-density-sidebar: 256px;
    --ed-density-sidebar-collapsed: 72px;
    --ed-density-row: 36px;
    --ed-density-control: 36px;
    --ed-density-icon: 36px;
    --ed-density-page-y: 16px;
    --ed-density-page-x: 20px;
    --ed-density-card: 12px;
    --ed-density-card-md: 16px;
    --ed-density-cell-y: 8px;
    --ed-density-cell-x: 12px;
  }
  html[data-ed-density="spacing"] {
    --ed-density-topbar: 56px;
    --ed-density-auth-y: 32px;
    --ed-density-auth-card: 20px;
    --ed-density-auth-gap: 12px;
  }
}
@media screen and (pointer: coarse) {
  html[data-ed-density="compact"] {
    --ed-density-row: 44px;
    --ed-density-control: 44px;
    --ed-density-icon: 44px;
  }
}

/* -- App shell: top bar, sidebar, breadcrumbs, phone tab bar (phases 121 / 123) ------------------------------------------------ */
@media screen {
  html[data-ed-density="compact"] body:not(:has([data-aic-u831-rail])) [data-ed-topbar] { height: var(--ed-density-topbar); }
  html[data-ed-density="compact"] body:not(:has([data-aic-u831-rail])) #edulink-sidebar > .h-\[72px\] { height: var(--ed-density-topbar); }
  html[data-ed-density="compact"] body:not(:has([data-aic-u831-rail])) [data-ed-topbar] .ed-icon-btn { width: var(--ed-density-icon); height: var(--ed-density-icon); }
  html[data-ed-density="compact"] body:not(:has([data-aic-u831-rail])) .ed-nav-row { min-height: var(--ed-density-row); padding-top: 6px; padding-bottom: 6px; }
  html[data-ed-density="compact"] body:not(:has([data-aic-u831-rail])) .ed-nav-row[aria-current="page"]::before { top: 6px; bottom: 6px; }
  html[data-ed-density="compact"] body:not(:has([data-aic-u831-rail])) nav[aria-label="Breadcrumb"] { padding-top: 12px; }
  html[data-ed-density="compact"] body:not(:has([data-aic-u831-rail])) .ed-mobile-tabbar > .h-16 { height: 56px; }
}
@media screen and (max-width: 1023.98px) {
  html[data-ed-density="compact"] body:not(:has([data-aic-u831-rail])) main.pb-20 { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
}
@media screen and (min-width: 1024px) {
  html[data-ed-density="compact"] body:not(:has([data-aic-u831-rail])) #edulink-sidebar.lg\:w-\[290px\] { width: var(--ed-density-sidebar); }
  html[data-ed-density="compact"] body:not(:has([data-aic-u831-rail])) #edulink-sidebar.lg\:w-\[90px\] { width: var(--ed-density-sidebar-collapsed); }
}
@media screen and (prefers-reduced-motion: reduce) {
  html[data-ed-density="compact"] body:not(:has([data-aic-u831-rail])) #edulink-sidebar { transition: none; }
}

/* -- Shared components from ui.php / app.css, never inside the AI Chat root (phase 123) ----------------------------------------- */
@media screen {
  html[data-ed-density="compact"] .ed-page-shell:not(.aic) { padding-top: var(--ed-density-page-y); padding-bottom: 24px; }
  html[data-ed-density="compact"] .ed-card:not(.aic *) { padding: var(--ed-density-card); }
  html[data-ed-density="compact"] .ed-card-header:not(.aic *) { padding-bottom: 8px; margin-bottom: 12px; }
  html[data-ed-density="compact"] .ed-table-card-header:not(.aic *) { padding: var(--ed-density-cell-y) var(--ed-density-cell-x); }
  html[data-ed-density="compact"] :is(.ed-btn-primary, .ed-btn-secondary, .ed-btn-danger, .ed-btn-roadmap, .ed-btn-plan-analytics, .ed-btn-certificate):not(.aic *) {
    min-height: var(--ed-density-control); padding-left: 12px; padding-right: 12px;
  }
  html[data-ed-density="compact"] :is(.ed-input, .ed-select):not(.aic *) { min-height: var(--ed-density-control); }
  html[data-ed-density="compact"] textarea.ed-input:not(.aic *) { min-height: 80px; }
  html[data-ed-density="compact"] .ed-tab:not(.aic *) { min-height: var(--ed-density-control); }
  html[data-ed-density="compact"] .ed-table:not(.aic *) thead th,
  html[data-ed-density="compact"] .ed-table:not(.aic *) tbody td { padding: var(--ed-density-cell-y) var(--ed-density-cell-x); }
  html[data-ed-density="compact"] .ed-empty-state:not(.aic *) { padding: 24px 20px; }
  html[data-ed-density="compact"] .ed-calm-notice:not(.aic *) { padding: 8px 12px; }
  html[data-ed-density="compact"] .ed-calm-details:not(.aic *) > summary { min-height: var(--ed-density-control); }
  html[data-ed-density="compact"] .ed-calm-action-link:not(.aic *) { min-height: var(--ed-density-control); }
}
@media screen and (min-width: 640px) {
  html[data-ed-density="compact"] .ed-page-shell:not(.aic) { padding-left: var(--ed-density-page-x); padding-right: var(--ed-density-page-x); }
}
@media screen and (min-width: 768px) {
  html[data-ed-density="compact"] .ed-card:not(.aic *) { padding: var(--ed-density-card-md); }
}

/* -- Signed-out pages: spacing only, Q3 sub-switch (phase 124) ------------------------------------------------------------------ */
@media screen {
  html[data-ed-density="spacing"] [data-ed-topbar] { height: var(--ed-density-topbar); }
  html[data-ed-density="spacing"] main > .max-w-md.mx-auto.py-12 { padding-top: var(--ed-density-auth-y); padding-bottom: var(--ed-density-auth-y); }
  html[data-ed-density="spacing"] main > .max-w-md.mx-auto > .rounded-2xl.p-6 { padding: var(--ed-density-auth-card); }
  html[data-ed-density="spacing"] main > .max-w-md.mx-auto form.space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: var(--ed-density-auth-gap); }
}
