/* Hopeworks look: colour tokens, self-hosted fonts and components.
   Loaded after base.css, so it builds on the accessibility rules there.
   Nothing here loads from Google or any other outside site. */

/* ---- Fonts (self-hosted, Latin character set; licences are in static/fonts/) ---- */

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/SourceSans3-Bold.woff2") format("woff2");
}

@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/OpenSans-Regular.woff2") format("woff2");
}

@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/OpenSans-Bold.woff2") format("woff2");
}

/* ---- Colour tokens ---- */

:root {
  --hw-navy: #153463;
  --hw-teal-button: #07adb7;
  --hw-teal: #57c3bc;
  --hw-pale-teal: #d8f1ef;
  --hw-pale-teal-2: #eef9f8;
  --hw-orange: #f7972c;
  --hw-white: #ffffff;

  --hw-font-heading: "Source Sans Pro", "Source Sans 3", Arial, sans-serif;
  --hw-font-body: "Open Sans", Arial, sans-serif;

  --hw-line: rgba(21, 52, 99, 0.2);

  /* Menu, buttons and body text. The button values were measured on hopeworks.org. */
  --hw-menu-weight: 600;
  --hw-button-radius: 3px;
  --hw-button-padding: 10px 16px;
  --hw-button-border: 1px;
  --hw-button-weight: 700;
  --hw-body-colour: #404040;
  --hw-nav-size: 1rem;
}

/* ---- Base text ---- */

body {
  color: var(--hw-body-colour);
  background: var(--hw-white);
  font-family: var(--hw-font-body);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
}

/* ---- Headings ---- */

h1,
h2,
h3,
.hw-h1,
.hw-h2,
.hw-h3 {
  color: var(--hw-navy);
  font-family: var(--hw-font-heading);
  font-weight: 700;
  line-height: 1.2;
}

h1, .hw-h1 { font-size: 2.25rem; }
h2, .hw-h2 { font-size: 1.75rem; }
h3, .hw-h3 { font-size: 1.375rem; }

/* Short teal rule under h1 and h2. A pseudo-element, so screen readers do not read it. */
h1::after,
h2::after,
.hw-h1::after,
.hw-h2::after {
  content: "";
  display: block;
  width: 3rem;
  height: 4px;
  margin-top: 0.5rem;
  background: var(--hw-teal);
}

.hw-label {
  color: var(--hw-navy);
  font-family: var(--hw-font-body);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ---- Links: navy text, underlined; orange appears in the underline on hover only ---- */

a {
  color: var(--hw-navy);
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover,
a.is-hover {
  color: var(--hw-navy);
  text-decoration-color: var(--hw-orange);
  /* A thicker line as well, so the change does not rely on colour alone. */
  text-decoration-thickness: 3px;
}

/* ---- Focus: white inner ring and navy outer ring, visible on every colour ---- */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible,
.is-focus {
  outline: 3px solid var(--hw-navy);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--hw-white);
}

.skip-link:focus {
  color: var(--hw-navy);
  border-color: var(--hw-navy);
}

.message {
  border-color: var(--hw-navy);
}

/* ---- Buttons: work on <a>, <button> and <input type="submit"> ---- */

.hw-btn,
.hw-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 44px;
  min-height: 44px;
  padding: var(--hw-button-padding);
  border: var(--hw-button-border) solid var(--hw-navy);
  border-radius: var(--hw-button-radius);
  color: var(--hw-navy);
  font-family: var(--hw-font-body);
  font-size: 1rem;
  font-weight: var(--hw-button-weight);
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.hw-btn {
  background: var(--hw-teal-button);
  border-color: var(--hw-teal-button);
}

.hw-btn-secondary {
  background: transparent;
}

.hw-btn:hover,
.hw-btn.is-hover,
.hw-btn[aria-pressed="true"],
.hw-btn[aria-current="true"],
.hw-btn.is-selected,
.hw-btn-secondary:hover,
.hw-btn-secondary.is-hover,
.hw-btn-secondary[aria-pressed="true"],
.hw-btn-secondary[aria-current="true"],
.hw-btn-secondary.is-selected {
  background: var(--hw-orange);
  border-color: var(--hw-orange);
  color: var(--hw-navy);
  text-decoration: none;
}

/* ---- Panels ---- */

.hw-panel {
  padding: 1.25rem 1.5rem;
  border-radius: 4px;
  background: var(--hw-pale-teal);
  color: var(--hw-body-colour);
}

/* ---- Data tables ----
   Put the table inside <div class="hw-table-wrap" tabindex="0" role="region" aria-label="...">
   so it can scroll sideways on narrow screens and be reached by keyboard. */

.hw-table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.hw-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--hw-body-colour);
}

/* Table headers stay navy. */
.hw-table th {
  color: var(--hw-navy);
}

.hw-table caption {
  padding: 0 0 0.5rem;
  color: var(--hw-navy);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
}

.hw-table th,
.hw-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--hw-line);
  text-align: left;
  vertical-align: top;
}

.hw-table thead th {
  background: var(--hw-navy);
  border-bottom-color: var(--hw-navy);
  color: var(--hw-white);
  font-weight: 700;
}

.hw-table tbody th {
  font-weight: 700;
}

.hw-table tbody tr:nth-child(even) {
  background: var(--hw-pale-teal-2);
}

/* ---- Key figures ---- */

.hw-key-figure-grid {
  display: grid;
  /* As many tiles as fit across the page, sharing the row evenly; the whole grid stops growing at 100rem. */
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  max-width: 100rem;
  gap: 0.75rem;
}

/* Tiles with a lot of text (Report 12 measures) need room, so they use wider columns. */
.hw-key-figure-grid:has(.hw-measure-tile) {
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.hw-key-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 0;
  min-height: 9.5rem;
  padding: 0.75rem;
  text-align: center;
  overflow-wrap: anywhere;
}

.hw-key-figure p {
  margin: 0;
}

.hw-key-figure__figure {
  font-family: var(--hw-font-heading);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.1;
}

.hw-key-figure__label {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.hw-key-figure__note {
  margin-top: 0.25rem;
  font-size: 0.8rem;
}

.hw-key-figure--navy {
  background: var(--hw-navy);
  color: var(--hw-white);
}

.hw-key-figure--pale {
  background: var(--hw-pale-teal);
  color: var(--hw-navy);
}

.hw-key-figure--teal {
  background: var(--hw-teal);
  color: var(--hw-navy);
}

.hw-key-figure--orange {
  background: var(--hw-orange);
  color: var(--hw-navy);
}

/* ---- Tooltips: one look for every tooltip (static/js/tooltips.js) ----
   Navy with an orange edge, a bold heading and the details under it, and a small pointer to the item. */

.hw-tooltip {
  position: absolute;
  z-index: 1000;
  box-sizing: border-box;
  max-width: 18rem;
  padding: 0.5rem 0.75rem;
  border-left: 4px solid var(--hw-orange);
  border-radius: var(--hw-button-radius);
  background: var(--hw-navy);
  box-shadow: 0 2px 10px rgba(21, 52, 99, 0.35);
  color: var(--hw-white);
  font-family: var(--hw-font-body);
  font-size: 0.875rem;
  line-height: 1.4;
  pointer-events: none;
}

.hw-tooltip[hidden] {
  display: none;
}

.hw-tooltip__title {
  display: block;
  font-family: var(--hw-font-heading);
  font-size: 1rem;
  font-weight: 700;
}

.hw-tooltip__detail {
  display: block;
}

/* The pointer: under the tooltip, or above it when the tooltip has been placed below the item. */
.hw-tooltip::after {
  content: "";
  position: absolute;
  bottom: -0.4rem;
  left: var(--hw-tooltip-arrow, 50%);
  margin-left: -0.4rem;
  border: 0.4rem solid transparent;
  border-top-color: var(--hw-navy);
  border-bottom-width: 0;
}

.hw-tooltip--below::after {
  top: -0.4rem;
  bottom: auto;
  border-top-width: 0;
  border-top-color: transparent;
  border-bottom-width: 0.4rem;
  border-bottom-color: var(--hw-navy);
}

/* ---- Environment banner (dev and staging only) ---- */

.hw-env-banner {
  box-sizing: border-box;
  width: 100%;
  padding: 0.5rem 1rem;
  background-color: #ff8c00;
  color: var(--hw-navy);
  font-weight: bold;
  text-align: center;
}

/* ---- Forms ---- */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select {
  box-sizing: border-box;
  min-height: 44px;
  max-width: 100%;
  padding: var(--hw-button-padding);
  border: var(--hw-button-border) solid var(--hw-navy);
  border-radius: var(--hw-button-radius);
  background: var(--hw-white);
  color: var(--hw-navy);
  font-family: var(--hw-font-body);
  font-size: 1rem;
  font-weight: var(--hw-button-weight);
}

input[type="checkbox"] {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  accent-color: var(--hw-navy);
}

.hw-form {
  max-width: 32rem;
}

.hw-field {
  margin: 0 0 1.25rem;
}

.hw-field label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 700;
}

.hw-field input[type="text"],
.hw-field input[type="email"],
.hw-field input[type="password"],
.hw-field input[type="search"],
.hw-field select {
  width: 100%;
}

.hw-hint {
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
}

.hw-error {
  margin: 0 0 0.25rem;
  color: var(--hw-navy);
  font-weight: 700;
}

/* A thick left bar marks fields with a problem, so it does not rely on colour alone. */
.hw-field--error {
  padding-left: 0.75rem;
  border-left: 0.3125rem solid var(--hw-navy);
}

.hw-field--error input,
.hw-field--error select {
  border-width: 3px;
}

.hw-check {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hw-field .hw-check label {
  display: inline;
  margin: 0;
}

.hw-fieldset {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem 1rem;
  border: 2px solid var(--hw-navy);
  border-radius: 2px;
}

.hw-fieldset legend {
  padding: 0 0.5rem;
  font-weight: 700;
}

.hw-fieldset[hidden],
[data-site-field][hidden] {
  display: none;
}

.hw-fieldset ul,
.hw-fieldset div[id] > div {
  margin: 0;
}

.hw-fieldset div[id] > div {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}

.hw-error-summary {
  max-width: 40rem;
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem;
  border: 0.3125rem solid var(--hw-navy);
}

.hw-error-summary__title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.hw-error-summary__title::after {
  display: none;
}

.hw-error-summary ul {
  margin: 0;
  padding-left: 1.25rem;
}

.hw-filter__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0 1rem;
}

.hw-pager ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
  padding: 0;
  list-style: none;
}

/* ---- Administrator sign-in ---- */

.hw-qr {
  width: 12rem;
  max-width: 100%;
  margin: 0.5rem 0 1rem;
  padding: 0.5rem;
  background: var(--hw-white);
  border: 1px solid var(--hw-navy);
}

.hw-qr svg {
  display: block;
  width: 100%;
  height: auto;
}

.hw-secret,
.hw-backup-codes code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.hw-steps {
  max-width: 40rem;
  padding-left: 1.5rem;
}

.hw-backup-codes {
  columns: 2;
  margin: 0;
  padding-left: 1.25rem;
}

/* ---- Session timeout dialog ---- */

.session-timeout {
  max-width: 28rem;
  padding: 1.5rem;
  border: 3px solid var(--hw-navy);
  border-radius: 2px;
  background: var(--hw-white);
  color: var(--hw-navy);
}

.session-timeout::backdrop {
  background: rgba(21, 52, 99, 0.6);
}

.session-timeout__title {
  margin-top: 0;
}

.session-timeout__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}

.session-timeout__buttons form {
  margin: 0;
}

/* ---- Style guide page only ---- */

.hw-swatch {
  display: inline-block;
  width: 3rem;
  height: 1.5rem;
  border: 1px solid var(--hw-navy);
  vertical-align: middle;
}

.hw-demo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 0.75rem 0 1.5rem;
}


/* ---- Header and main menu ----
   One white bar with the logo on the left and the menu on the right, and a solid navy band under it. Without
   JavaScript the dropdowns are plain nested lists that are always visible; menu.js adds the "js" class that makes
   them collapse. Nothing depends on hover. */

.site-header-bar {
  padding: 0;
  background: var(--hw-white);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  box-sizing: border-box;
  padding: 0.75rem 1.5rem;
}

.site-header-band {
  width: 100%;
  height: 0.75rem;
  background: var(--hw-navy);
}

.site-brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  text-decoration: none;
}

.site-logo {
  display: block;
  width: auto;
  height: 3rem;
}

nav[aria-label="Main"] {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem 1.5rem;
}

.main-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.25rem 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.main-menu li {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.main-menu a,
.menu-button,
.menu-label,
.menu-link-button {
  color: var(--hw-navy);
  font-family: var(--hw-font-body);
  font-size: var(--hw-nav-size);
  font-weight: var(--hw-menu-weight);
  text-decoration: none;
}

.main-menu > li > a,
.menu-button,
.menu-label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  box-sizing: border-box;
  padding: 12px 20px;
  border-bottom: 3px solid transparent;
}

/* The current page: an orange underline (a shape, not only a colour) and aria-current in the markup. */
.main-menu a[aria-current="page"],
.has-current > .menu-button,
.has-current > .menu-label {
  border-bottom-color: var(--hw-orange);
}

.main-menu a:hover,
.menu-button:hover,
.menu-link-button:hover,
.main-menu a.is-hover,
.menu-button.is-hover {
  text-decoration: underline;
  text-decoration-color: var(--hw-orange);
  text-decoration-thickness: 3px;
  text-underline-offset: 0.25em;
}

.menu-button,
.menu-link-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.menu-button[hidden],
.menu-label[hidden] {
  display: none;
}

/* The chevron is drawn with CSS: a small square with two borders, turned to point down (up when open). */
.menu-chevron {
  display: inline-block;
  flex: none;
  box-sizing: border-box;
  width: 0.35em;
  height: 0.35em;
  margin-left: 0.25em;
  border-top: 0.1em solid currentColor;
  border-right: 0.1em solid currentColor;
  transform: rotate(135deg);
}

.menu-button[aria-expanded="true"] .menu-chevron {
  transform: translateY(0.15em) rotate(-45deg);
}

.dropdown {
  box-sizing: border-box;
  margin: 0;
  padding: 0.25rem 0.5rem 0.5rem;
}

.dropdown ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu-heading {
  margin: 0.5rem 0 0.125rem;
  color: var(--hw-navy);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.dropdown a {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  min-height: 44px;
  padding: 0.25rem 0.5rem;
  border-left: 3px solid transparent;
  font-weight: 400;
}

.dropdown a[aria-current="page"] {
  border-left-color: var(--hw-orange);
  font-weight: 700;
}

.site-user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
}

.site-user form,
.site-user p {
  margin: 0;
}

.site-user-info {
  color: var(--hw-navy);
  font-size: 0.9375rem;
}

.menu-link-button {
  min-height: 44px;
  padding: 0.25rem 0.25rem;
  text-decoration: underline;
}

/* With JavaScript a dropdown is closed until its button opens it (on small screens it opens in place). */
.js .dropdown {
  display: none;
}

.js .dropdown.is-open {
  display: block;
}

/* On wide screens a dropdown is a floating panel under its button. */
@media (min-width: 48rem) {
  .js .dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 50;
    min-width: 16rem;
    max-width: 24rem;
    border: 2px solid var(--hw-navy);
    border-radius: var(--hw-button-radius);
    background: var(--hw-white);
    box-shadow: 0 4px 12px rgba(21, 52, 99, 0.25);
  }

  .js .has-dropdown:last-child .dropdown {
    right: 0;
    left: auto;
  }

  /* A mouse can open a dropdown by hovering, but the button and keyboard do the same. */
  @media (hover: hover) {
    .js .has-dropdown:hover > .dropdown {
      display: block;
    }
  }

  /* Without JavaScript the lists are open inline under their label. */
  .main-menu {
    align-items: flex-start;
  }
}

/* Small screens: the items stack, and a dropdown opens in place under its button. */
@media (max-width: 47.99rem) {
  .site-header {
    padding: 0.5rem 1rem;
  }

  nav[aria-label="Main"] {
    display: block;
    flex: 1 0 100%;
  }

  .main-menu {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .main-menu > li > a,
  .menu-button,
  .menu-label {
    width: 100%;
  }

  .js .menu-button {
    justify-content: space-between;
  }

  .dropdown {
    padding-left: 1rem;
  }

  .site-user {
    margin-top: 0.5rem;
  }
}

/* The report and survey filters sit inside the page, not in the header. */
.hw-report-filters .hw-field select {
  width: 100%;
}

/* ---- Home page ---- */

.hw-home-welcome h2 {
  margin-top: 0;
}

.hw-home-note {
  margin: 0.5rem 0 0;
  font-weight: 700;
}

.hw-home-figure__link {
  margin: 0.5rem 0 0;
}

.hw-home-key {
  max-width: 48rem;
  padding-left: 1.25rem;
}

/* The style guide's sample menu: the open dropdown sits in the flow so the example is visible. */
.hw-sg-menu .sg-open {
  position: static;
  display: block;
  box-shadow: none;
  border: 2px solid var(--hw-navy);
  border-radius: var(--hw-button-radius);
}
