/* ============================================================================
   theme-surfaces.css — the last word on what colour a PANEL is.

   WHY THIS FILE EXISTS, AND WHY IT IS THE ONLY SHEET AFTER page_css.

   The theme picker shipped on 2026-11-28 with a limitation its own author
   wrote down: the dark palette could not reach the ~16,600 lines of per-page
   `<style>` that hardcode white panels. The coverage run that morning
   measured the consequence over 64 authenticated screens — 95 large
   near-white surfaces still painted under `body.theme-dark`, and 286 pieces
   of text below 3:1 — and found it split three ways:

     * the kit's light ink printed on a panel that stayed white (88),
     * a page's own near-black ink on a panel that DID darken (101),
     * `color: #fff` beside a semantic token the dark theme lightens (97).

   The third was one token fix, and the first two were mostly nine files —
   `layouts/eduqueue.html` (`p` and `h1..h6` are element selectors there, so
   two literals set the ink for the whole application), `index-page.css`,
   `responsive-visitor-table.css`, the users list, the duplicates screen, the
   pass-delivery log, the PowerSchool page, the student list and the
   scheduled-visits page. All of those were converted to tokens at source,
   which is the right fix: a panel and the words on it are ONE decision, and
   only the source has both in view.

   This file is not that fix. It is the floor under it. 86 templates still
   carry inline CSS and 2,019 raw colours remain in the tree, so the next
   page to hardcode `background: #fff !important` is a matter of when. A
   rule here cannot be outranked by a page: `{% block page_css %}` is the
   last block layouts/base.html renders, and this sheet is linked after it.

   WHAT MAY GO IN HERE — and it is deliberately narrow:

     a STRUCTURAL CONTAINER whose name is shared across the application and
     owned by no single template (Bootstrap's, DataTables', the kit's).

   Nothing else. A page-local class name does NOT belong here: put the token
   in the page, where the text colour is also visible. The reason is the
   failure this layer could otherwise cause — forcing a panel dark while its
   page keeps near-black text on it produces 1.2:1, which is worse than the
   white panel it replaced. Every selector below is a container rather than a
   text element, and sets its inherited ink along with its surface so a
   container-level literal cannot survive either.

   THE OPT-OUT is `.eq-keep-light`. One screen legitimately paints white
   under a dark theme: /settings/appearance/, whose cards are miniatures OF
   the three palettes and have to show the light one as light. It avoids this
   layer by not using these class names at all; the hook exists for the next
   case that cannot.

   The student scan screen needs no exception. `lib/theme.py` keeps the
   bulkmode blueprint out of every theme, so `body` carries no theme class
   there and not one selector in this file can match.

   WHICH THEMES NEED A FLOOR, AND WHY IT IS NOT ALL OF THEM. Only a theme
   whose `--eq-surface` is DARK does: the failure this layer exists to stop
   is a page hardcoding `background:#fff` on a panel the palette has made
   near-black. Light, Warm light and Compact all resolve a near-white
   surface, so a hardcoded white panel in those is already the right colour
   and forcing it would be a no-op with a repaint attached. `theme-dark` and
   `theme-midnight` are the two that qualify today, which is exactly the set
   `lib.theme.THEMES` marks `dark: True` — and tests/cssguard/
   test_theme_coverage.py fails if a new dark theme is added to that dict
   without being added here. High contrast still appears below for its own
   reason: its surface is white and it needs no re-pointing, only the borders
   its `--eq-shadow:none` leaves it without.

   PRINT is handled by the palette, not here: the kit's `@media print` block
   reverts every token to the light values for all three themes, so each
   `var()` below prints as white paper with dark ink without this file
   knowing anything about paper.
   ========================================================================== */

/* ---- Dialogs ---------------------------------------------------------------
   background-override.css forces `#ffffff !important` on `.modal-content`
   and, for the visitor-detail dialog, on `.modal-body` and
   `.modern-modal-body` too. That file is FUNCTIONAL — it owns modal opacity
   and stacking, and a dimmed visitor dialog (fc182b94) is what happens when
   someone edits it — so the colour is corrected here rather than there. The
   kit already handles plain `.modal-content`; these are the selectors it
   does not reach, and they are the ones that matter, because the
   visitor-detail modal is on the check-in path. */
body.theme-dark .modal-body:not(.eq-keep-light),
body.theme-midnight .modal-body:not(.eq-keep-light),
body.theme-dark .modal-header:not([class*="bg-"]):not(.eq-keep-light),
body.theme-midnight .modal-header:not([class*="bg-"]):not(.eq-keep-light),
body.theme-dark .modern-modal-content:not(.eq-keep-light),
body.theme-midnight .modern-modal-content:not(.eq-keep-light),
body.theme-dark .modern-modal-body:not(.eq-keep-light),
body.theme-midnight .modern-modal-body:not(.eq-keep-light),
body.theme-dark .visitor-detail-modal .modal-content:not(.eq-keep-light),
body.theme-midnight .visitor-detail-modal .modal-content:not(.eq-keep-light),
body.theme-dark .visitor-detail-modal .modal-body:not(.eq-keep-light),
body.theme-midnight .visitor-detail-modal .modal-body:not(.eq-keep-light) {
  background-color: var(--eq-surface) !important;
  color: var(--eq-text) !important;
}
body.theme-dark .modal-footer:not(.eq-keep-light),
body.theme-midnight .modal-footer:not(.eq-keep-light),
body.theme-dark .modern-modal-footer:not(.eq-keep-light),
body.theme-midnight .modern-modal-footer:not(.eq-keep-light) {
  background-color: var(--eq-surface-2) !important;
  color: var(--eq-text) !important;
}

/* ---- Shared panels --------------------------------------------------------
   `.card` and `.content-section` are the two names any page reaches for when
   it wants a panel, and `.breadcrumb` sat at the top of 34 of the 64 screens
   measured. `:not([class*="bg-"])` keeps Bootstrap's contextual headers
   (`.card-header.bg-danger` and friends) painted as the page meant them. */
body.theme-dark .card:not([class*="bg-"]):not(.eq-keep-light),
body.theme-midnight .card:not([class*="bg-"]):not(.eq-keep-light),
body.theme-dark .card-body:not([class*="bg-"]):not(.eq-keep-light),
body.theme-midnight .card-body:not([class*="bg-"]):not(.eq-keep-light),
body.theme-dark .card-header:not([class*="bg-"]):not(.eq-keep-light),
body.theme-midnight .card-header:not([class*="bg-"]):not(.eq-keep-light),
body.theme-dark .content-section:not(.eq-keep-light),
body.theme-midnight .content-section:not(.eq-keep-light),
body.theme-dark .breadcrumb:not(.eq-keep-light),
body.theme-midnight .breadcrumb:not(.eq-keep-light),
body.theme-dark .jumbotron:not(.eq-keep-light),
body.theme-midnight .jumbotron:not(.eq-keep-light),
body.theme-dark .toast:not(.eq-keep-light),
body.theme-midnight .toast:not(.eq-keep-light),
body.theme-dark .accordion > .card:not(.eq-keep-light),
body.theme-midnight .accordion > .card:not(.eq-keep-light) {
  background-color: var(--eq-surface) !important;
  color: var(--eq-text) !important;
}
body.theme-dark .card-footer:not([class*="bg-"]):not(.eq-keep-light),
body.theme-midnight .card-footer:not([class*="bg-"]):not(.eq-keep-light) {
  background-color: var(--eq-surface-2) !important;
  color: var(--eq-muted) !important;
}

/* ---- Fields ---------------------------------------------------------------
   A white field with a hardcoded dark label is the one case where forcing
   only the surface would be dangerous, so both go. Bootstrap's own
   `:disabled` fill is also a near-white that no token reaches. */
body.theme-dark .form-control:not(.eq-keep-light),
body.theme-midnight .form-control:not(.eq-keep-light),
body.theme-dark .custom-select:not(.eq-keep-light),
body.theme-midnight .custom-select:not(.eq-keep-light),
body.theme-dark .custom-file-label:not(.eq-keep-light),
body.theme-midnight .custom-file-label:not(.eq-keep-light),
body.theme-dark textarea.form-control:not(.eq-keep-light),
body.theme-midnight textarea.form-control:not(.eq-keep-light),
body.theme-dark select.form-control:not(.eq-keep-light),
body.theme-midnight select.form-control:not(.eq-keep-light) {
  background-color: var(--eq-field) !important;
  color: var(--eq-text) !important;
  border-color: var(--eq-field-line);
}
body.theme-dark .form-control:disabled,
body.theme-midnight .form-control:disabled,
body.theme-dark .form-control[readonly],
body.theme-midnight .form-control[readonly],
body.theme-dark .custom-select:disabled,
body.theme-midnight .custom-select:disabled {
  background-color: var(--eq-surface-2) !important;
  color: var(--eq-muted) !important;
}

/* ---- DataTables chrome ----------------------------------------------------
   Nine screens initialise DataTables and the plugin's own stylesheet paints
   its pager, its filter box and its length select from its own palette. No
   template owns these names, which is exactly what this layer is for. */
body.theme-dark .dataTables_wrapper .dataTables_length select,
body.theme-midnight .dataTables_wrapper .dataTables_length select,
body.theme-dark .dataTables_wrapper .dataTables_filter input,
body.theme-midnight .dataTables_wrapper .dataTables_filter input,
body.theme-dark .dataTables_wrapper .dataTables_paginate .paginate_button,
body.theme-midnight .dataTables_wrapper .dataTables_paginate .paginate_button,
body.theme-dark .dataTables_wrapper .dataTables_paginate .paginate_button:hover,
body.theme-midnight .dataTables_wrapper .dataTables_paginate .paginate_button:hover,
body.theme-dark table.dataTable tbody tr,
body.theme-midnight table.dataTable tbody tr,
body.theme-dark table.dataTable thead th,
body.theme-midnight table.dataTable thead th {
  background-color: var(--eq-surface) !important;
  color: var(--eq-text) !important;
  border-color: var(--eq-line);
}
body.theme-dark .dataTables_wrapper .dataTables_paginate .paginate_button.current,
body.theme-midnight .dataTables_wrapper .dataTables_paginate .paginate_button.current,
body.theme-dark .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover,
body.theme-midnight .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background-color: var(--eq-accent) !important;
  color: var(--eq-on-accent) !important;
  border-color: var(--eq-accent);
}
body.theme-dark .dataTables_wrapper .dataTables_info,
body.theme-midnight .dataTables_wrapper .dataTables_info,
body.theme-dark .dataTables_wrapper .dataTables_length,
body.theme-midnight .dataTables_wrapper .dataTables_length,
body.theme-dark .dataTables_wrapper .dataTables_filter,
body.theme-midnight .dataTables_wrapper .dataTables_filter {
  color: var(--eq-muted);
}

/* ---- High contrast --------------------------------------------------------
   This theme's surface IS white, so a hardcoded white panel is already the
   right colour and there is nothing to re-point. What it does need is the
   borders: a panel that leans on a soft shadow for its edge has no edge at
   all here, because the theme sets --eq-shadow to none. The kit does this
   for the parts it owns (.card, .dq-card, .dq-tile, .content-section); these
   are the shared names it does not, and the field rule is here because a
   1px hairline is the thing this theme exists to remove. */
body.theme-contrast .breadcrumb:not(.eq-keep-light),
body.theme-contrast .jumbotron:not(.eq-keep-light),
body.theme-contrast .toast:not(.eq-keep-light),
body.theme-contrast .card-header:not([class*="bg-"]),
body.theme-contrast .card-footer:not([class*="bg-"]) {
  border-color: var(--eq-line);
}
body.theme-contrast .dataTables_wrapper .dataTables_length select,
body.theme-contrast .dataTables_wrapper .dataTables_filter input,
body.theme-contrast .dataTables_wrapper .dataTables_paginate .paginate_button {
  border: 2px solid var(--eq-field-line);
  color: var(--eq-text);
}
body.theme-contrast .dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--eq-accent);
  color: var(--eq-on-accent);
  border-color: var(--eq-accent);
}
