/* ==========================================================================
   Harbour <-> Blazor integration layer.
   Loaded last, after theme.css / admin.css / effects.css.

   Everything here exists because of Blazor, not because of the design. The
   three Harbour stylesheets stay faithful copies of html/ so they can be
   diffed against the reference; anything Blazor needs goes in this file.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. FocusOnNavigate
   Routes.razor focuses the page's <h1> after every navigation, for screen
   reader and keyboard users. Two consequences to absorb:

   a) The heading would get a focus ring. FocusOnNavigate gives it
      tabindex="-1", so only script ever focuses it and Tab never reaches it:
      a ring there tells a keyboard user nothing, while screen readers still
      move to it. :focus:not(:focus-visible) was not enough: after keyboard
      input (Enter in the address bar, F5, Enter on a link) browsers treat the
      script focus as :focus-visible and theme.css drew its ring. Real
      controls keep their ring on Tab.
   b) Focusing scrolls the heading to the very top of the viewport, which is
      directly underneath Harbour's sticky .site-head. scroll-margin-top keeps
      it clear. 4.25rem is the header's own min-height, plus breathing room.
   -------------------------------------------------------------------------- */
:is(h1, h2, h3, h4, h5, h6)[tabindex="-1"]:focus {
  outline: none;
}

:is(h1, h2, h3, h4, h5, h6) {
  scroll-margin-top: 6rem;
}

/* The admin shell has its own sticky topbar rather than .site-head. */
.adm-shell :is(h1, h2, h3, h4, h5, h6) {
  scroll-margin-top: 5rem;
}

/* A settings page links to its cards (html/admin-settings.html, the account area's #s-profile): they
   stop clear of the topbar and the sticky page header (5), level with the sticky settings nav. */
.adm-shell .card[id] {
  scroll-margin-top: calc(var(--adm-topbar) + var(--adm-page-header, 0px) + 1.25rem);
}

/* --------------------------------------------------------------------------
   2. Error UI
   Blazor's #blazor-error-ui is plain markup in every layout; give it the
   Harbour surface tokens so it is not an unstyled yellow bar.
   -------------------------------------------------------------------------- */
#blazor-error-ui {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 1080;
  display: none;
  padding: .75rem 1.25rem;
  background: var(--hb-invert);
  color: var(--hb-on-invert);
  box-shadow: var(--bs-box-shadow-lg);
  font-size: .8125rem;
}

#blazor-error-ui .reload {
  color: var(--bs-primary);
  text-decoration: underline;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  float: right;
  padding: 0 .5rem;
}


/* --------------------------------------------------------------------------
   3. BootstrapBlazor <Tab> as Harbour tabs
   Components/Admin/Content/TranslationTabs wraps the library's Tab in .hb-tabs
   and switches off its border card, sliding active bar and scroll arrows. What
   is left is restyled as Harbour tabs: one bordered panel, a tinted tab bar,
   a gold underline on the active tab. The library's markup is
   fixed, so this targets its class names (.tabs-header, .tabs-item, ...), all
   scoped under .hb-tabs so no other Tab is affected. The section editor's item
   tabs (SectionFieldEditor) render that same structure by hand, so their Add
   button can sit in the bar as one more tab.
   -------------------------------------------------------------------------- */
.hb-tabs .tabs {
  background: var(--hb-surface);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg);
  box-shadow: none;
  overflow: hidden;
}

.hb-tabs .tabs-header {
  margin: 0;
  height: auto; /* the library fixes it at 40px, shorter than a Harbour tab */
  background: var(--hb-surface-2);
  border-bottom: 1px solid var(--bs-border-color);
}

.hb-tabs .tabs-header::after,
.hb-tabs .tabs-item-fix {
  display: none;
}

.hb-tabs .tabs-nav-wrap,
.hb-tabs .tabs-nav-scroll {
  margin: 0;
  padding: 0;
  overflow: visible;
  height: auto;
}

.hb-tabs .tabs-nav {
  display: flex;
  height: auto;
  flex-wrap: wrap;
  float: none;
  transform: none;
}

.hb-tabs .tabs-item {
  display: block;
  height: auto;
  margin: 0;
  padding: .6875rem 1rem;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--hb-muted);
  font-size: .875rem;
  line-height: var(--bs-body-line-height);
  text-decoration: none;
  cursor: pointer;
}

.hb-tabs .tabs-item:hover {
  color: var(--hb-ink);
}

.hb-tabs .tabs-item:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: -2px;
}

.hb-tabs .tabs-item-wrap.active .tabs-item {
  background: var(--hb-surface);
  border-bottom-color: var(--bs-primary);
  color: var(--hb-ink);
  font-weight: 600;
}

.hb-tabs .tabs-item-body {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: 0;
}

.hb-tabs .tabs-item-text {
  padding: 0;
}

.hb-tabs .tabs-body {
  padding: 1.125rem;
  background: transparent;
}

.hb-tabs .tabs-body-content {
  background: transparent;
}


/* --------------------------------------------------------------------------
   4. ImageField's drop card (docs/decisions/0020)
   image-editor.js puts .hb-drop-over on the field while a file is held over it.
   -------------------------------------------------------------------------- */
.hb-image-field.hb-drop-over .card {
  border-color: var(--bs-primary);
  background: var(--bs-primary-bg-subtle);
}

/* --------------------------------------------------------------------------
   5. The admin's page header stays in view
   Every admin and tenant screen opens with .page-header (title, breadcrumb, and
   the Save / Add buttons). It is Cms's own markup, not html/'s, so it lives here.
   On a long editor it stays pinned under the sticky topbar, so Save is always at
   hand. It spans the body's padding and wears the topbar's glass, so content
   scrolls under it cleanly; the negative top margin keeps it where it was at rest.
   Not on phones, where it wraps to several lines and would take the screen.
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  .adm-shell .page-header {
    position: sticky;
    top: var(--adm-topbar);
    z-index: 1015; /* above the content, under the topbar (1020) and modals */
    margin-inline: -1.5rem;
    margin-top: -.75rem;
    padding: .75rem 1.5rem;
    border-bottom: 1px solid var(--hb-line-soft);
    background: var(--hb-glass);
    backdrop-filter: blur(14px) saturate(160%);
  }

  /* What sticks in the content (a settings nav, .filter-rail at 5.5rem in theme.css) sticks under the header, whose
     height admin.js measures into --adm-page-header. */
  .adm-shell .filter-rail {
    top: calc(var(--adm-topbar) + var(--adm-page-header, 0px) + 1.25rem);
  }
}

/* --------------------------------------------------------------------------
   6. BootstrapBlazor's inputs on Harbour's surface
   theme.css puts inputs on the theme's input background (Harbour: --hb-surface,
   white in light; moss: --hb-input-bg), but a few BootstrapBlazor rules are
   more specific and paint --bs-body-bg, Bootstrap's grey-lilac tint: the
   Select's read-only box, and the date pickers. Match theme.css in both
   themes; a disabled one stays grey. The date picker's calendar icon sits over
   the text's first 2.4rem: BootstrapBlazor pads past it through a variable that
   the theme's .form-control padding overrides, so the padding is set here.
   -------------------------------------------------------------------------- */
:is(.select .form-select, .datetime-picker .form-control[readonly], .datetime-range-control .datetime-range-input):not(:disabled) {
  background-color: var(--hb-input-bg, var(--hb-surface));
}

[data-bs-theme="dark"] :is(.select .form-select, .datetime-picker .form-control[readonly], .datetime-range-control .datetime-range-input):not(:disabled) {
  background-color: var(--hb-input-bg, var(--hb-surface-2));
}

.datetime-picker .form-control.has-icon {
  padding-left: 2.5rem;
}

/* BootstrapBlazor sets the icon's line-height to its own control height; the theme's inputs are taller, so it sat high.
   The icon lies over the input, which is the calendar's toggle: a click on it reached the icon only, and nothing opened
   (the user, 2026-11-07). It lets the click through to the input. */
.datetime-picker .datetime-picker-bar {
  top: 50%;
  line-height: 1;
  transform: translateY(-50%);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   7. BootstrapBlazor's dropdown menus as Harbour's
   The Select and its kin open a .dropdown-menu.popover-region placed by Popper.
   a) Its background: BootstrapBlazor sets --bs-dropdown-bg to --bs-body-bg (the
      grey-lilac tint) on the menu itself; Harbour's menus are --hb-menu-bg.
   b) Its pointer: a small triangle (.dropdown-menu-arrow) at the menu's top-left.
      Harbour's menus have none.
   c) Its place: effects.css animates every open menu with menu-in, which ends on
      transform: none and holds it, overriding the transform Popper places it by;
      the menu then covered its own field. These fade in instead.
   -------------------------------------------------------------------------- */
.popover-region.dropdown-menu {
  --bs-dropdown-bg: var(--hb-menu-bg);
}

/* !important: BootstrapBlazor shows it with selectors up to 0,4,0 (placement, .show + ...), one per variant. */
.dropdown-menu-arrow {
  display: none !important;
}

.popover-region.dropdown-menu.show {
  animation-name: hb-menu-fade;
}

@keyframes hb-menu-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --------------------------------------------------------------------------
   8. The Table head's icons in Harbour's colours
   BootstrapBlazor paints the filter, sort and column icons #ddd (#6c757d in
   dark), set on the table itself, and a filtered column blue: on Harbour's
   near-white head that is 1.3:1, all but invisible. They take the head's own
   text colour (--hb-muted: 3.4:1 light, 5.2:1 dark), the body text on hover,
   and the brand's text colour when a filter is on. The tokens follow the theme.
   -------------------------------------------------------------------------- */
.adm-shell .table-container .table {
  --bb-table-header-icon-color: var(--hb-muted);
  --bb-table-header-icon-hover-color: var(--bs-body-color);
  --bb-table-header-icon-hover-bg: var(--bs-tertiary-bg);
  --bb-table-header-icon-active-color: var(--bs-primary-text-emphasis);
}

/* A column filtered or sorted shows it at a glance (the user, 2026-10-22: "the filter icon is not highlighted"): the
   funnel of an active filter (BootstrapBlazor adds .active) and the arrow of the active sort (bi-sort-up/-down, from
   BootstrapIconTheme) take the brand's colour on a tinted pill; a column that can be sorted but is not shows its arrows
   in a light brand tint instead of grey (the user: "give them a color"). */
.adm-shell .table-container .table > thead > tr > th .bi.bi-funnel.active,
.adm-shell .table-container .table > thead > tr > th .bi.bi-sort-up,
.adm-shell .table-container .table > thead > tr > th .bi.bi-sort-down {
  color: var(--bs-primary);
  background-color: var(--bs-primary-bg-subtle);
  border-radius: var(--bs-border-radius-sm);
  padding: .0625rem .1875rem;
  font-weight: 700;
}
.adm-shell .table-container .table > thead > tr > th .bi.bi-arrow-down-up {
  color: color-mix(in srgb, var(--bs-primary) 55%, transparent);
}
.adm-shell .table-container .table > thead > tr > th .bi.bi-arrow-down-up:hover {
  color: var(--bs-primary);
}

/* A column with TextWrap breaks between words; BootstrapBlazor's break-all split "payments" into "payme / nts" (the
   user's Roles list, 2026-10-13). A word longer than the column still breaks. */
.adm-shell .table-container .table-cell.is-wrap {
  word-break: normal;
  overflow-wrap: anywhere;
}
/* --------------------------------------------------------------------------
   9. Plain tables and small icon buttons in the work areas
   Bootstrap paints every cell with --bs-table-bg, which is the page's
   --bs-body-bg (#f7f6fc): on a white card each row showed as a grey band.
   The cells take the card's surface instead (a row's own .table-light still
   wins). Harbour's cell padding (.8125rem) and 2.25rem .btn-icon, made for
   html/'s few summary tables, made long lists tall: a plain table is tighter,
   a .table-sm tighter still, and .btn-icon.btn-sm is a real small size.
   BootstrapBlazor's <Table>s (inside .table-container) keep their own spacing.
   -------------------------------------------------------------------------- */
.adm-shell .table {
  --bs-table-bg: transparent;
}

.adm-shell .table:not(.table-container .table) > thead th {
  padding: .5rem .875rem;
}

.adm-shell .table:not(.table-container .table) > tbody td {
  padding: .5rem .875rem;
}

.adm-shell .table-sm:not(.table-container .table) > thead th,
.adm-shell .table-sm:not(.table-container .table) > tbody td {
  padding: .3125rem .625rem;
}

.adm-shell .btn-icon.btn-sm {
  width: 1.75rem;
  height: 1.75rem;
  font-size: .875rem;
}

.adm-shell .table .btn-icon.btn-sm {
  width: 1.5rem;
  height: 1.5rem;
  font-size: .8125rem;
}

/* --------------------------------------------------------------------------
   10. A screen's messages in its header
   A save's answer (saved, the errors, a notice) sits in the sticky .page-header,
   between the title and the buttons, so it is seen wherever the page is
   scrolled (the user's wish): .page-header-alerts is the header's middle child.
   The alerts are compact to keep the header low. Logical properties only, so
   right to left needs nothing in rtl.css.
   -------------------------------------------------------------------------- */
.page-header-alerts {
  display: grid;
  flex: 1 1 16rem;
  gap: .5rem;
  align-self: center;
  min-width: 0;
  max-width: 40rem;
  margin-inline: auto;
}

.page-header-alerts .alert {
  margin-bottom: 0;
  padding-block: .5rem;
  padding-inline-start: .875rem;
  font-size: .8125rem;
}

.page-header-alerts .alert:not(.alert-dismissible) {
  padding-inline-end: .875rem;
}

.page-header-alerts .alert-dismissible .btn-close {
  padding: .75rem .875rem;
}

/* --------------------------------------------------------------------------
   11. Required fields and the invalid ones
   A field carries the HTML required attribute when its service always needs it
   (the service stays the judge). Its label then shows a red "*": the label
   followed by the field itself, or by a wrapper holding it (an input group, a
   BootstrapBlazor input), and a check or switch's own label.
   An empty required field turns red when a submit tried it (:user-invalid, on
   the plain forms the browser checks), or while its form shows an error: the
   screen's header holds a danger alert, or the field's panel or dialog body has one
   as a direct child. A required check or switch
   then shows its .invalid-feedback line under it. A select bound to an id counts as empty
   while its "Choose …" option (value 0) is chosen. Bootstrap's own .was-validated
   is not used: it would also paint every valid field green.
   -------------------------------------------------------------------------- */
.form-label:is(:has(+ [required]), :has(+ * [required]))::after,
.form-check-input[required] ~ .form-check-label::after {
  content: " *";
  color: var(--bs-danger-text-emphasis);
}

:is(.form-control, .form-select, .form-check-input):user-invalid,
.adm-shell:has(.page-header-alerts .alert-danger) :is(.form-control, .form-select, .form-check-input):invalid,
:has(> .alert-danger) :is(.form-control, .form-select, .form-check-input):invalid,
.adm-shell:has(.page-header-alerts .alert-danger) .form-select[required]:has(> option[value="0"]:checked),
:has(> .alert-danger) .form-select[required]:has(> option[value="0"]:checked) {
  border-color: var(--bs-form-invalid-border-color);
}

:is(.form-control, .form-select):user-invalid:focus,
.adm-shell:has(.page-header-alerts .alert-danger) :is(.form-control, .form-select):invalid:focus,
:has(> .alert-danger) :is(.form-control, .form-select):invalid:focus,
.adm-shell:has(.page-header-alerts .alert-danger) .form-select[required]:has(> option[value="0"]:checked):focus,
:has(> .alert-danger) .form-select[required]:has(> option[value="0"]:checked):focus {
  border-color: var(--bs-form-invalid-border-color);
  box-shadow: none;
}

/* No glow on a focused field (the user, 2026-11-17): the border alone shows the focus, red while the field is wrong.
   Bootstrap's own validation states, which BootstrapBlazor's validated inputs carry, too. */
:is(.form-control, .form-select).is-invalid:focus,
:is(.form-control, .form-select).is-valid:focus {
  box-shadow: none;
}

.form-check-input:user-invalid ~ .invalid-feedback,
.adm-shell:has(.page-header-alerts .alert-danger) .form-check-input:invalid ~ .invalid-feedback,
:has(> .alert-danger) .form-check-input:invalid ~ .invalid-feedback {
  display: block;
}

/* --------------------------------------------------------------------------
   12. Modals on the surface, and a wider one
   Bootstrap paints a modal with --bs-modal-bg, which is the page's
   --bs-body-bg (#f7f6fc): every dialog read grey. It takes the card's
   surface instead, in both themes (the user). .modal-wide on a .modal-dialog
   is a form dialog wider than .modal-lg (50rem), narrowed by the viewport.
   -------------------------------------------------------------------------- */
.modal {
  --bs-modal-bg: var(--hb-surface);
}

/* In dark mode the surface is barely lighter than the backdrop over the dark page, so a dialog's edge was lost: a thin
   line marks it (the user, 2026-10-13). Harbour's theme.css leaves the border transparent in both themes. */
[data-bs-theme="dark"] .modal {
  --bs-modal-border-color: rgba(255, 255, 255, .14);
}

.modal-dialog.modal-wide {
  --bs-modal-width: 62rem;
}

/* --------------------------------------------------------------------------
   13. BootstrapBlazor's toasts on the surface
   Harbour paints a toast dark (--hb-invert, theme.css 8), and Bootstrap's
   grey .toast-header sat on it with its own border. The work areas' toasts
   (ToastService, top right) read as a light card instead, in both themes
   (the user): the surface, the card's border, one piece with no header rule.
   -------------------------------------------------------------------------- */
.toast-container .toast {
  --bs-toast-bg: var(--hb-surface);
  --bs-toast-color: var(--bs-body-color);
  --bs-toast-border-color: var(--bs-border-color);
  --bs-toast-header-bg: transparent;
  --bs-toast-header-color: var(--bs-emphasis-color);
  --bs-toast-header-border-color: transparent;
}

/* A success reads light green and an error light red (the user, 2026-10-13); BootstrapBlazor marks the kind only on
   the icon's .toast-bar (text-success, text-danger). Warnings and information stay on the surface. */
:root {
  --hb-toast-success-bg: #e6f6ee;
  --hb-toast-success-border: #bfe5d3;
  --hb-toast-error-bg: #fdecee;
  --hb-toast-error-border: #f5c6cc;
}

[data-bs-theme="dark"] {
  --hb-toast-success-bg: #122a23;
  --hb-toast-success-border: #1e4739;
  --hb-toast-error-bg: #2e171b;
  --hb-toast-error-border: #57262e;
}

.toast-container .toast:has(.toast-bar.text-success) {
  --bs-toast-bg: var(--hb-toast-success-bg);
  --bs-toast-border-color: var(--hb-toast-success-border);
}

.toast-container .toast:has(.toast-bar.text-danger) {
  --bs-toast-bg: var(--hb-toast-error-bg);
  --bs-toast-border-color: var(--hb-toast-error-border);
}

.toast-container .toast .toast-header {
  font-weight: 600;
  padding-bottom: 0;
}

.toast-container .toast .btn-close {
  filter: none;
}

[data-bs-theme="dark"] .toast-container .toast .btn-close {
  filter: invert(1) grayscale(1);
}

/* --------------------------------------------------------------------------
   14. BootstrapBlazor's drawers on the surface
   A drawer (the unit types' form, on the right) painted itself with the
   page's --bs-body-bg and padded its body, so it read grey and its own header
   and footer rules stopped short of its edges. It takes the modal's surface,
   and its content lays out its own padding (p-3 header, body and footer).
   -------------------------------------------------------------------------- */
.drawer {
  --bb-drawer-bg: var(--hb-surface);
  --bb-drawer-body-padding: 0;
}

/* --------------------------------------------------------------------------
   15. The cookie banner (docs/requirements/tracking.md)
   A card at the bottom of a public page, above the content, until the visitor
   chooses; consent.js shows it. Logical insets, so it needs no rtl.css mirror.
   -------------------------------------------------------------------------- */
.hb-consent {
  position: fixed;
  inset-block-end: 1rem;
  inset-inline: 1rem;
  z-index: 1080;
  max-width: 40rem;
  margin-inline: auto;
  background: var(--hb-surface);
  box-shadow: 0 .75rem 2rem rgba(0, 0, 0, .18);
}

.hb-consent[hidden] {
  display: none;
}

/* ---------------------------------------------------------------------------
   The sidebar's collapsible groups (AdminSidebar): the group's title is its button, a chevron shows open or closed,
   and the links of a closed group are hidden. Harbour's .adm-nav-title look is kept.
   --------------------------------------------------------------------------- */
.adm-nav-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  border: 0;
  background: none;
  text-align: start;
  cursor: pointer;
}
.adm-nav-toggle:hover { color: var(--bs-body-color); }
.adm-nav-toggle:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: -2px; border-radius: var(--bs-border-radius); }
.adm-nav-toggle .bi { margin-inline-start: auto; font-size: .75rem; transition: transform .16s var(--hb-ease); }
.adm-nav-toggle[aria-expanded="false"] .bi { transform: rotate(-90deg); }
[dir="rtl"] .adm-nav-toggle[aria-expanded="false"] .bi { transform: rotate(90deg); }
.adm-nav-group[hidden] { display: none; }

/* --------------------------------------------------------------------------
   16. Stored rich text on public pages (RichContent)
   The editor floats an image left or right (style="float: right", class
   note-float-right); with little text beside it, the image hung out of the
   text's box, over whatever came next. flow-root makes the box hold its
   floats. An image never runs wider than the column.
   -------------------------------------------------------------------------- */
.rich-content { display: flow-root; }
.rich-content img { max-width: 100%; height: auto; }
.rich-content > :last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   17. An open dropdown inside a scroll-revealed element
   effects.js tags cards and articles for AOS, whose animation leaves a
   transform on them: a stacking context of its own, so a dropdown opened in
   one (a post's Share menu) was painted under a later positioned block such
   as the footer. While its menu is open, the element is lifted above them.
   -------------------------------------------------------------------------- */
[data-aos]:has(.dropdown-menu.show) { position: relative; z-index: 1020; }
