/*
 * Organisation hub chrome (documentation/organisation-hubs/plan.md §9, §12,
 * §13, H22). Loaded by layouts/scripts/hub.phtml AFTER style.css and
 * darkmode.css, so the hub's colours win the source-order ties those sheets
 * rely on. The colours themselves are custom properties the layout declares
 * on body.hub-page (light) and html.theme-dark body.hub-page (dark):
 *   --hub-primary, --hub-primary-rgb, --hub-primary-hover, --hub-on-primary
 * — all validated hex from Hansa_Hub_Color, never raw input.
 *
 * Only accents move to the hub colour: buttons, the hover state of links,
 * focus rings, the current-page marker and the promo accent. Body text and
 * surfaces stay ESL's (§6: "keep body text and surfaces readable").
 */

body.hub-page {
  --bs-primary: var(--hub-primary);
  --bs-primary-rgb: var(--hub-primary-rgb);
  --bs-link-hover-color: var(--hub-primary);
  --bs-link-hover-color-rgb: var(--hub-primary-rgb);
}

/* --- Header -------------------------------------------------------------- */

.hub-skip:focus {
  position: absolute;
  top: .5rem;
  left: .5rem;
  z-index: 1000;
  padding: .5rem 1rem;
  background: #fff;
  color: #16181b;
}

.hub-header {
  background: #ffffff;
  border-bottom: 1px solid #e3e5ea;
}
html.theme-dark .hub-header {
  background: #201e1d;
  border-color: #38352f;
}

.hub-bar,
.hub-nav-inner,
.hub-container {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.hub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1.5rem;
}

.hub-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
  color: inherit;
  text-decoration: none !important;
}
.hub-logo {
  display: block;
  width: auto;
  height: auto;
  max-height: 40px;
  margin-top: 8px;
  margin-bottom: 8px;
  max-width: min(360px, 55vw);
  object-fit: contain;
}
.hub-logo-missing {
  display: block;
  margin: 8px 0;
  font-style: italic;
  color: #6c727b;
}
html.theme-dark .hub-logo-missing { color: #b5b0ac; }

.hub-brand-name {
  display: block;
  margin: 8px 0;
  font-family: 'Archivo', sans-serif;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.2;
  color: #16181b;
  overflow-wrap: break-word;
  hyphens: auto;
}
html.theme-dark .hub-brand-name { color: #ffffff; }
.hub-logo-dark { display: none; }
html.theme-dark .hub-logo-light { display: none; }
html.theme-dark .hub-logo-dark { display: block; }


.hub-bar-end {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-shrink: 0;
}

.hub-powered {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  font-weight: 600;
  color: #4a4f57;
  text-decoration: none !important;
  white-space: nowrap;
}
/* esl_icon.png is 149×81: fix the height only, or the icon is squashed into
   a square and resampled blurry. */
.hub-powered img { width: auto; height: 22px; }
.hub-powered-by { font-weight: 400; }
.hub-powered:hover,
.hub-powered:focus { color: var(--hub-primary); }
html.theme-dark .hub-powered { color: #d9d6d4; }
html.theme-dark .hub-powered:hover,
html.theme-dark .hub-powered:focus { color: var(--hub-primary); }

.hub-divider {
  width: 1px;
  height: 28px;
  margin: 0 .5rem;
  background: #d3d6dc;
}
html.theme-dark .hub-divider { background: #4a4642; }

.hub-control {
  padding: .35rem .5rem;
  color: #3b3f45;
  font-size: 1.1rem;
  line-height: 1;
}
.hub-control:hover,
.hub-control:focus { color: var(--hub-primary); }
html.theme-dark .hub-control { color: #f2f0ef; }

/* --- Navigation --------------------------------------------------------- */

.hub-nav {
  padding: 0;
  background: #ffffff;
  border-top: 1px solid #eef0f3;
}
html.theme-dark .hub-nav {
  background: #1c1a19;
  border-color: #38352f;
}
.hub-nav-inner { width: 100%; padding: 0 1.5rem; }
/* The first link's text lines up with the logo above it. */
@media (min-width: 992px) {
  .hub-nav .nav-item:first-child .nav-link { padding-left: 0; }
}
/* Sized after ESL's own topnav: an icon before each label, a slightly
   larger font and roomier spacing between the entries. */
.hub-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .85rem 1.4rem;
  border-bottom: 3px solid transparent;
  color: #3b3f45;
  font-size: 1rem;
  font-weight: 600;
}
.hub-nav .nav-link i { font-size: 1.25rem; line-height: 1; }
.hub-nav .nav-link:hover,
.hub-nav .nav-link:focus { color: var(--hub-primary); }
.hub-nav .nav-link.active {
  color: #16181b;
  border-bottom-color: var(--hub-primary);
}
html.theme-dark .hub-nav .nav-link { color: #d9d6d4; }
html.theme-dark .hub-nav .nav-link:hover,
html.theme-dark .hub-nav .nav-link:focus { color: var(--hub-primary); }
html.theme-dark .hub-nav .nav-link.active { color: #ffffff; }
.hub-nav-toggler {
  padding: .6rem 0;
  border: 0;
  color: inherit;
  font-weight: 600;
}
.hub-nav-toggler:focus { box-shadow: 0 0 0 .2rem rgba(var(--hub-primary-rgb), .35); }
@media (max-width: 991.98px) {
  .hub-nav .nav-link { padding: .6rem 0; border-bottom: 0; border-left: 3px solid transparent; padding-left: .75rem; }
  .hub-nav .nav-link.active { border-left-color: var(--hub-primary); }
}

/* --- Page body ----------------------------------------------------------- */

/* The vendored template offsets .page-content for its FIXED header; the hub
   header scrolls with the page, so that offset would be a blank band. */
body.hub-page[data-layout=horizontal] .page-content {
  margin-top: 0;
  padding: 1.5rem 0 1rem;
}
/* Header, navigation, content and promo share one column: the template caps
   a horizontal-layout .container-fluid at 85% (and 98% inside .page-content),
   which would indent the content against the header. */
body.hub-page[data-layout=horizontal] .hub-container,
body.hub-page[data-layout=horizontal] .page-content .hub-container {
  width: 100%;
  max-width: 1400px;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}
/* A phone gives the brand its own row, so a long hub name wraps between
   words instead of being squeezed letter by letter beside the controls. */
@media (max-width: 575.98px) {
  .hub-bar { flex-wrap: wrap; row-gap: .5rem; }
  .hub-brand { flex: 1 1 100%; }
  .hub-bar-end { margin-left: auto; }
}
@media (max-width: 575.98px) {
  .hub-bar, .hub-nav-inner,
  body.hub-page[data-layout=horizontal] .hub-container,
  body.hub-page[data-layout=horizontal] .page-content .hub-container { padding-left: 1rem; padding-right: 1rem; }
}

/* --- Accents in the hub colour ------------------------------------------ */

body.hub-page .btn-primary {
  --bs-btn-color: var(--hub-on-primary);
  --bs-btn-bg: var(--hub-primary);
  --bs-btn-border-color: var(--hub-primary);
  --bs-btn-hover-color: var(--hub-on-primary);
  --bs-btn-hover-bg: var(--hub-primary-hover);
  --bs-btn-hover-border-color: var(--hub-primary-hover);
  --bs-btn-active-color: var(--hub-on-primary);
  --bs-btn-active-bg: var(--hub-primary-hover);
  --bs-btn-active-border-color: var(--hub-primary-hover);
  --bs-btn-disabled-bg: var(--hub-primary);
  --bs-btn-disabled-border-color: var(--hub-primary);
  background-color: var(--hub-primary);
  border-color: var(--hub-primary);
  color: var(--hub-on-primary);
}
/* !important for the same reason as style.css: the vendored sheet pins the
   hover/active colours with !important. */
body.hub-page .btn-primary:hover,
body.hub-page .btn-primary:focus,
body.hub-page .btn-primary:active,
body.hub-page .btn-primary.active {
  background-color: var(--hub-primary-hover) !important;
  border-color: var(--hub-primary-hover) !important;
  color: var(--hub-on-primary) !important;
}
body.hub-page .btn-primary:focus-visible {
  box-shadow: 0 0 0 .25rem rgba(var(--hub-primary-rgb), .35) !important;
}
body.hub-page .btn-outline-primary,
html.theme-dark body.hub-page .btn-outline-primary {
  --bs-btn-color: var(--hub-primary);
  --bs-btn-border-color: var(--hub-primary);
  --bs-btn-hover-color: var(--hub-on-primary);
  --bs-btn-hover-bg: var(--hub-primary);
  --bs-btn-hover-border-color: var(--hub-primary);
  --bs-btn-active-color: var(--hub-on-primary);
  --bs-btn-active-bg: var(--hub-primary-hover);
  --bs-btn-active-border-color: var(--hub-primary-hover);
  --bs-btn-focus-shadow-rgb: var(--hub-primary-rgb);
}

body.hub-page .page-content a:not(.btn):not(.badge):not(.nav-link):not(.dropdown-item):not(.page-link):not(.text-reset):not(.text-decoration-none):not(.stretched-link):hover,
html.theme-dark body.hub-page .page-content a:not(.btn):not(.badge):not(.nav-link):not(.dropdown-item):not(.page-link):not(.text-reset):not(.text-decoration-none):not(.stretched-link):hover,
body.hub-page .page-content button.link-action:hover,
html.theme-dark body.hub-page .page-content button.link-action:hover,
body.hub-page footer a:hover,
html.theme-dark body.hub-page footer a:hover {
  color: var(--hub-primary);
}

body.hub-page .form-control:focus,
body.hub-page .form-select:focus,
body.hub-page .form-check-input:focus {
  border-color: var(--hub-primary);
  box-shadow: 0 0 0 .15rem rgba(var(--hub-primary-rgb), .2);
}
body.hub-page .form-check-input:checked {
  background-color: var(--hub-primary);
  border-color: var(--hub-primary);
}
body.hub-page .pagination {
  --bs-pagination-hover-color: var(--hub-primary);
  --bs-pagination-focus-color: var(--hub-primary-hover);
  --bs-pagination-active-bg: var(--hub-primary);
  --bs-pagination-active-border-color: var(--hub-primary);
  --bs-pagination-active-color: var(--hub-on-primary);
}
body.hub-page .card-accent { border-bottom-color: var(--hub-primary); }
body.hub-page .progress,
body.hub-page .progress-stacked { --bs-progress-bar-bg: var(--hub-primary); }

/* --- Hub page components -------------------------------------------------- */

.hub-card-accent { border-top: 3px solid var(--hub-primary); }

/* The home page's introduction box: white in light mode (the card's own
   dark surface in dark mode), the organisation logo at the box's full width. */
.hub-intro-card { background: #ffffff; }
.hub-intro-card .hub-intro > p:last-child { margin-bottom: 0; }
.hub-intro-card .hub-intro + .btn { margin-top: 1rem; }
.hub-intro-card .card-body > :last-child { margin-bottom: 0; }
.hub-home-logo {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  margin-bottom: 1rem;
}

/* The hub search at the right end of the menu bar (inside the collapse, so
   on a phone it sits under the menu entries). */
.hub-nav .navbar-collapse { align-items: center; }
.hub-nav-search { padding: .5rem 0; }
.hub-nav-search .input-group { flex-wrap: nowrap; }
@media (min-width: 992px) {
  .hub-nav-search { width: 260px; flex-shrink: 0; }
}

.hub-count {
  font-family: 'Archivo', sans-serif;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.1;
}

.hub-partner-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  margin: 0 auto .5rem;
  object-fit: contain;
}
/* On the home page a partner is its logo alone — no caption below it, so
   no gap below it either; the row gutter (g-2) spaces the logos. */
.hub-area-partners .hub-partner-logo { margin-bottom: 0; }
/* The two resource boxes zero their own card margin (h-100 pairs), so the
   row keeps the gap to the partners box instead. */
.hub-area-recent { margin-bottom: 24px; }
.hub-partner-tile { min-height: 100%; }

.hub-host-badge {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 1rem;
  background: var(--hub-primary);
  color: var(--hub-on-primary);
  font-size: .75rem;
  font-weight: 600;
}

/* --- Footer promotion (§13) ----------------------------------------------- */

.hub-promo { margin-top: 1rem; padding: 0 0 2rem; }
.hub-promo-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem;
  background: #ffffff;
  border: 1px solid #e3e5ea;
  border-top: 4px solid var(--hub-primary);
  border-radius: .5rem;
}
html.theme-dark .hub-promo-box {
  background: #242220;
  border-color: #38352f;
  border-top-color: var(--hub-primary);
}

.hub-footer { margin-top: 0; }

/* --- Home page grid (§12) --------------------------------------------------
   One markup order, two arrangements. Below lg the areas stack in the order
   §12 asks for on a phone: title, introduction, projects, resources, then
   the supporting content (the search box is in the menu bar). From lg up: main | a right-hand rail holding
   the introduction above the numbers. The rail is a second rendering of
   those two blocks, last in the markup (see hub/index.phtml): the phone
   copies are d-lg-none and the rail d-none d-lg-block. */
.hub-home {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "title"
    "intro"
    "featured"
    "recent"
    "side"
    "partners"
    "visitors";
  column-gap: 1.5rem;
}
.hub-area-title    { grid-area: title; margin-top: 1rem; margin-bottom: 1.5rem; }
.hub-area-intro    { grid-area: intro; margin-bottom: 1.5rem; }
.hub-area-featured { grid-area: featured; }
.hub-area-recent   { grid-area: recent; }
.hub-area-side     { grid-area: side; }
.hub-area-partners { grid-area: partners; }
.hub-area-visitors { grid-area: visitors; }
.hub-rail-intro    { margin-bottom: 1rem; }
@media (min-width: 992px) {
  .hub-home {
    grid-template-columns: minmax(0, 9fr) minmax(0, 3fr);
    grid-template-areas:
      "title    rail"
      "featured rail"
      "recent   rail"
      "partners rail"
      "visitors rail";
    grid-template-rows: auto auto auto auto 1fr;
  }
  .hub-area-rail {
    grid-area: rail;
    align-self: start;
  }
}
