/* hub.css — styling for the static hub-links block that
 * scripts/inject-hub-links.mjs writes into the homepage, the 12 city hubs, the
 * 81 suburb hubs and the 22 chain hubs.
 *
 * The block exists so those links are real HTML rather than something only
 * JavaScript can reach. The first version of it shipped with no stylesheet at
 * all, so it rendered as a bare <ul> — on the Johannesburg page, 88 links in a
 * single vertical column. This file exists so that cannot happen again.
 *
 * Structure comes from Bulma 0.9.4, which every one of these pages already
 * loads. Only the handful of properties Bulma cannot reach live here, to match
 * the .suburb-card idiom in cities.css:
 *
 *   property      .suburb-card        Bulma .card
 *   border-radius 10px                .25rem (4px)
 *   padding       1rem 1.25rem       1.5rem (card-content)
 *   border        1px #e8e8e8         0 0 0 1px rgba(10,10,10,.02)
 *   hover         (see below)        none at all
 *
 * On hover: the site had four different treatments. .card's translateY(-5px)
 * lift is used on 103 pages via gauteng.js, suburb-directory.js and
 * company-directory.js, so it is the house idiom and the one used here. The
 * border-and-shadow-only treatments on .suburb-card and .box.h-100 are not
 * replicated; a directional lift reads as "pickable", which is what a tile of
 * links needs.
 *
 * The count chip uses .tag.has-background-success-light rather than a colour
 * modifier, because .tag has no is-* colour modifiers in 0.9.4.
 * has-background-success resolves to #48c78e, the same green the rest of the
 * site uses.
 */

/* ---------------------------------------------------------------- block */

.hub-index {
  background: #fafafa;
  border-top: 1px solid #f0f0f0;
  padding: 2.5rem 0 3rem;
}

.hub-index .container {
  width: 100%;
}

/* Each section is its own landmark. The first version wrapped three unrelated
 * sections in a single <nav>, which told assistive tech they were one list. */
.hub-section + .hub-section {
  margin-top: 2.5rem;
}

.hub-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #363636;
  margin: 0 0 0.75rem;
}

.hub-section-note {
  font-size: 0.9rem;
  color: #7a7a7a;
  margin: -0.5rem 0 1rem;
}

/* ---------------------------------------------------------------- grid */

/* The Bulma equivalent of cities.css's #locButtons
 * (repeat(auto-fit, minmax(180px, 1fr))): a wrapping column set that reflows
 * on narrow screens. is-4 is the target density, is-6 the fallback. */
.hub-grid {
  display: flex;
  flex-wrap: wrap;
  margin: -0.5rem;
}

.hub-grid > .hub-cell {
  display: flex;
  flex: 0 0 25%;
  max-width: 25%;
  padding: 0.5rem;
}

@media screen and (max-width: 1023px) {
  .hub-grid > .hub-cell {
    flex: 0 0 33.3333%;
    max-width: 33.3333%;
  }
}

@media screen and (max-width: 768px) {
  .hub-grid > .hub-cell {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

@media screen and (max-width: 480px) {
  .hub-grid > .hub-cell {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* ---------------------------------------------------------------- tile */

/* Structure is Bulma's .card; these are the four properties that close the gap
 * to .suburb-card. The anchor is the whole tile so the entire surface is the
 * hit area and the keyboard focus ring follows it. */
a.hub-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  box-shadow: 0 0.5em 1em -0.125em rgba(10, 10, 10, 0.06);
  color: #363636;
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Matches .card:hover in home.css. One idiom for every card on the site. */
a.hub-card:hover {
  transform: translateY(-5px);
  border-color: #b5b5b5;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  color: #363636;
}

/* Keyboard focus must be at least as visible as hover. */
a.hub-card:focus-visible {
  outline: 2px solid #48c78e;
  outline-offset: 2px;
}

a.hub-card:focus {
  outline: 2px solid #48c78e;
  outline-offset: 2px;
}

.hub-card-body {
  padding: 1rem 1.25rem;
}

.hub-card-label {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: #363636;
  margin: 0 0 4px;
  /* Long branch names wrap to two lines rather than stretching the row. */
  overflow-wrap: anywhere;
}

.hub-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0;
}

.hub-card-count {
  font-size: 12px;
  color: #888;
  margin: 0;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- chip */

/* .tag has no is-* colour modifiers in Bulma 0.9.4, so the green comes from
 * has-background-success-light / has-text-success-dark, both verified present.
 * #48c78e is what has-background-success resolves to. */
.hub-card-count .tag {
  font-size: 11px;
  height: auto;
  padding: 0 6px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------- hidden */

/* Sections the page's own JavaScript already renders as cards stay in the HTML
 * for crawlers and screen readers, and are hidden from the page. Hiding the
 * whole block instead would have cost 809 unique cross-links. */
.hub-sr-only {
  border: 0 !important;
  clip: rect(0, 0, 0, 0) !important;
  height: 1px !important;
  overflow: hidden !important;
  padding: 0 !important;
  position: absolute !important;
  white-space: nowrap !important;
  width: 1px !important;
}

.hub-sr-only:focus-within {
  clip: auto !important;
  height: auto !important;
  overflow: visible !important;
  position: static !important;
  white-space: normal !important;
  width: auto !important;
}

/* ---------------------------------------------------------------- motion */

/* The other hover transitions on the site do not honour this; the new tiles do. */
@media (prefers-reduced-motion: reduce) {
  a.hub-card {
    transition: none;
  }
  a.hub-card:hover {
    transform: none;
    box-shadow: 0 0.5em 1em -0.125em rgba(10, 10, 10, 0.06);
  }
}
