/* The site's styles, phone first: the rules start from the phone screen and min-width queries add to them for
   wider screens (ADR 0017). Every value comes from tokens.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: var(--line-body);
  color: var(--colour-text);
  background: var(--colour-background);
  overflow-wrap: break-word;
}

img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* A phone: a page's own words never make the page wider than the screen (ADR 0042). A box the words give a set
   width narrows to fit, and a table's words wrap, breaking a long word only where they must. These rules weigh
   nothing (:where), so every other rule still wins; the tablet query below puts the wider layouts back. */
:where(.page__body, .post__body) * {
  max-width: 100%;
}

:where(.page__body, .post__body) :where(th, td) {
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  line-height: var(--line-heading);
}

h1 {
  font-size: var(--text-h1);
}

h2 {
  font-size: var(--text-h2);
}

a {
  color: var(--colour-link);
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* Skip link: hidden until it has focus. */
.skip-link {
  position: absolute;
  left: var(--space-2);
  top: calc(-1 * var(--space-6));
  padding: var(--space-2) var(--space-3);
  background: var(--colour-brand);
  color: var(--colour-brand-text);
  z-index: 10;
}

.skip-link:focus {
  top: var(--space-2);
}

/* Header and menu. On a phone the menu is a button that opens a list. */
.site-header {
  background: var(--colour-brand);
  color: var(--colour-brand-text);
}

.site-header__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  max-width: var(--width-page);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-target);
  color: var(--colour-brand-text);
  font-weight: var(--weight-bold);
  font-size: var(--text-large);
  text-decoration: none;
}

.main-menu {
  flex: 1 1 100%;
}

.main-menu__toggle > summary {
  list-style: none;
}

.main-menu__toggle > summary::-webkit-details-marker {
  display: none;
}

.main-menu__button {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-target);
  min-width: var(--tap-target);
  padding: 0 var(--space-3);
  border: 1px solid var(--colour-brand-text);
  border-radius: var(--radius);
  cursor: pointer;
}

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

.main-menu a {
  display: flex;
  align-items: center;
  min-height: var(--tap-target);
  color: var(--colour-brand-text);
  text-decoration: none;
}

.main-menu__groups {
  padding-bottom: var(--space-3);
}

.main-menu__top {
  font-weight: var(--weight-bold);
}

.main-menu__children {
  padding-left: var(--space-3);
}

/* Main content */
.site-main {
  display: block;
  max-width: var(--width-content);
  margin: 0 auto;
  padding: var(--space-3) var(--gutter) var(--space-6);
}

/* A post's picture at the top of its page (ADR 0096). */
.post__picture {
  margin: var(--space-3) 0;
}

.post__picture img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

.post__date {
  color: var(--colour-text-muted);
  font-size: var(--text-small);
}

.disclaimer {
  margin-top: var(--space-5);
  padding: var(--space-3);
  border-top: var(--border);
  background: var(--colour-surface);
  font-size: var(--text-small);
}

/* Listings */
.listing {
  margin: var(--space-4) 0;
  padding: 0;
  list-style: none;
}

.listing-item {
  padding: var(--space-2) 0;
  border-bottom: var(--border);
}

.listing-item a {
  display: flex;
  align-items: center;
  min-height: var(--tap-target);
}

/* A post's card picture (ADR 0096): beside its title, never wider than the list. */
.listing-item__picture {
  display: block;
  width: 100%;
  max-width: 20rem;
  height: auto;
  object-fit: cover;
}

.listing-item time {
  color: var(--colour-text-muted);
  font-size: var(--text-small);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.pager a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-target);
  min-width: var(--tap-target);
}

/* FAQ */
.faq summary {
  display: flex;
  align-items: center;
  min-height: var(--tap-target);
  cursor: pointer;
}

/* Forms */
.form-notice {
  padding: var(--space-3);
  background: var(--colour-notice);
  border-radius: var(--radius);
}

.contact-form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.form-field {
  margin-bottom: var(--space-3);
}

.form-field label {
  display: block;
  margin-bottom: var(--space-1);
}

.form-field input,
.form-field textarea {
  width: 100%;
  min-height: var(--tap-target);
  padding: var(--space-2);
  font: inherit;
  border: var(--border);
  border-radius: var(--radius);
}

.button {
  min-height: var(--tap-target);
  padding: 0 var(--space-4);
  font: inherit;
  font-weight: var(--weight-bold);
  color: var(--colour-action-text);
  background: var(--colour-action);
  border: 0;
  border-radius: var(--radius);
}

/* A link that looks like a button: the contact page's way to today's form (ADR 0102). White words on the
   action colour are about 3.1 to 1, under the 4.5 to 1 WCAG 2.2 AA needs, so it takes the brand colours,
   the pair today's blue buttons use (.btn-blue-round), about 11 to 1 (ADR 0119). */
a.button {
  display: inline-flex;
  align-items: center;
  color: var(--colour-brand-text);
  background: var(--colour-brand);
  text-decoration: none;
}

.contact-form__message {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

/* Pictures not yet received keep their size, so the page does not move as it loads. */
.image-placeholder {
  width: 100%;
  background: var(--colour-surface);
  border: var(--border);
}

/* Footer */
.site-footer {
  padding: var(--space-5) var(--gutter);
  background: var(--colour-surface);
  border-top: var(--border);
}

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

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-target);
}

.site-footer__heading {
  margin: var(--space-3) 0 0;
  font-size: var(--text-body);
}

.site-footer__name {
  color: var(--colour-text-muted);
  font-size: var(--text-small);
}

.site-footer__consent {
  margin: 0;
}

.site-footer__consent-button {
  min-height: var(--tap-target);
  padding: 0;
  border: 0;
  background: none;
  color: var(--colour-link);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* The cookie banner (ADR 0019): a new Phase 0 item, built to WCAG AA. Fixed to the foot of the screen, never
   covering more than most of it, and it scrolls inside itself on a small phone. Dark text on white and white
   text on the brand colour both pass AA; the two main buttons look the same. */
.consent {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--space-3) var(--gutter);
  background: var(--colour-background);
  color: var(--colour-text);
  border-top: 2px solid var(--colour-brand);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
}

.consent[hidden],
.consent__choices[hidden],
.site-footer__consent-button[hidden] {
  display: none;
}

.consent__inner {
  max-width: var(--width-page);
  margin: 0 auto;
}

.consent__heading {
  margin: 0 0 var(--space-2);
  font-size: var(--text-large);
}

.consent__text,
.consent__purpose-text {
  margin: 0 0 var(--space-3);
}

.consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.consent__button {
  min-height: var(--tap-target);
  padding: var(--space-2) var(--space-4);
  border: 2px solid var(--colour-brand);
  border-radius: var(--radius);
  background: var(--colour-brand);
  color: var(--colour-brand-text);
  font: inherit;
  font-weight: var(--weight-bold);
  cursor: pointer;
}

/* Side by side on a wide screen, one per row on a phone; the same width either way. */
.consent__actions .consent__button {
  flex: 1 1 14rem;
}

.consent__button--plain {
  background: var(--colour-background);
  color: var(--colour-brand);
}

/* The heading takes focus when the footer button reopens the banner. Everything else uses :focus-visible. */
.consent__heading:focus {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.consent__fieldset {
  margin: var(--space-3) 0;
  padding: 0;
  border: 0;
}

.consent__legend {
  margin-bottom: var(--space-2);
  font-weight: var(--weight-bold);
}

.consent__choice {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--space-2);
  align-items: center;
}

.consent__choice input {
  width: 24px;
  height: 24px;
  margin: 12px;
}

.consent__choice label {
  font-weight: var(--weight-bold);
}

.consent__purpose-text {
  grid-column: 2;
  color: var(--colour-text-muted);
}

/* A tablet and wider */
@media (min-width: 48em) {
  /* A tablet and a computer show a page's own words as they did before the phone rules (ADR 0042). */
  :where(.page__body, .post__body) * {
    max-width: none;
  }

  :where(.page__body, .post__body) :where(th, td) {
    overflow-wrap: inherit;
  }

  .site-header__bar,
  .site-main {
    padding-left: var(--gutter-wide);
    padding-right: var(--gutter-wide);
  }

  h1 {
    font-size: var(--text-h1-wide);
  }

  .site-footer__groups {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-4);
  }
}

/* A computer: the short script right after the menu opens it and adds is-wide before the first paint, and menu.js
   keeps both in step; the groups sit in a row and each opens on hover or focus. */
@media (min-width: 64em) {
  .main-menu {
    flex: 0 1 auto;
  }

  .is-wide .main-menu__button {
    display: none;
  }

  .is-wide .main-menu__groups {
    display: flex;
    gap: var(--space-4);
    padding-bottom: 0;
  }

  .is-wide .main-menu__group {
    position: relative;
  }

  .is-wide .main-menu__children {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 16rem;
    padding: var(--space-2) var(--space-3);
    background: var(--colour-brand);
    z-index: 5;
  }

  .is-wide .main-menu__group:hover .main-menu__children,
  .is-wide .main-menu__group:focus-within .main-menu__children {
    display: block;
  }

  /* Esc closes a group's links while the pointer or the focus is still on it (WCAG 1.4.13); menu.js marks it. */
  .is-wide .main-menu__group.is-closed .main-menu__children {
    display: none;
  }

  .site-footer__groups {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* The listed videos' play buttons (ADR 0068, 0075): a still panel with a play button each, which wistia.js turns
   into Wistia's player on a press. Hidden until the script runs. */
.wistia-videos {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  margin: var(--space-5) 0;
}

.wistia-videos[hidden] {
  display: none;
}

/* A video testimonial's play button in its listing item (ADR 0113): one video, under the name. */
.listing-item__video {
  grid-template-columns: 1fr;
  max-width: 32rem;
  margin: var(--space-2) 0;
}

.wistia-video__play,
.wistia-video__frame {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--radius);
}

.wistia-video__play {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--colour-brand);
  color: var(--colour-action);
  cursor: pointer;
}

.wistia-video__play:hover .wistia-video__icon,
.wistia-video__play:focus-visible .wistia-video__icon {
  transform: scale(1.1);
}

.wistia-video__triangle {
  fill: var(--colour-action-text);
}

/* The video's own picture under the play icon (ADR 0106). wistia.js takes out one that fails to load. */
.wistia-video__still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wistia-video__icon {
  position: relative;
  z-index: 1;
}

/* The About us line of links to the team's pages (ADR 0112): each name a full size target, with room
   between them, so a phone can tap one without touching the next. */
.team-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.team-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-target);
}

/* The "Wealth Within by the Numbers" banner (ADR 0079): the line of stars, three figures and the line under
   them, on the brand colour. */
.numbers-banner {
  margin: var(--space-5) 0;
  padding: var(--space-5) var(--space-3);
  border-radius: var(--radius);
  background: var(--colour-brand);
  color: var(--colour-brand-text);
  text-align: center;
}

.numbers-banner__stars {
  margin: 0 0 var(--space-4);
  font-weight: var(--weight-bold);
}

.numbers-banner__boxes {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

.numbers-banner__box {
  padding: var(--space-3);
  border: 1px solid var(--colour-brand-text);
  border-radius: var(--radius);
}

.numbers-banner__box p {
  margin: var(--space-2) 0 0;
}

.numbers-banner__figure {
  display: block;
  font-size: var(--text-h1);
  font-weight: var(--weight-bold);
  line-height: var(--line-heading);
}

.numbers-banner__note {
  margin: var(--space-4) 0 0;
  font-size: var(--text-small);
}

/* The same banner inside a page's own words (ADR 0083): the Frequently asked questions and Learning Centre pages
   keep today's banner in their words, less its block of style rules. The site marks that section
   (.numbers-banner__today, app/today_puts.py) and these rules of our own show it as today's page does: the
   heading and the line of stars above three boxes on a phone, beside them on a computer, on the brand colour.
   The widths and the note's size come from the page's own words. A browser that cannot read :has() shows the
   words plainly, as before. :has() matches every section around the mark, so a banner mark must never sit
   inside another section of the words (it would paint the outer one too). */
.page__body section:has(.numbers-banner__today) {
  margin: var(--space-5) 0;
  padding: var(--space-5) var(--space-3);
  border-radius: var(--radius);
  background: var(--colour-brand);
  color: var(--colour-brand-text);
}

.page__body section:has(.numbers-banner__today) > div {
  margin-left: auto;
  margin-right: auto;
}

.page__body section:has(.numbers-banner__today) > div:first-child {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

/* The heading and, under it, the line of stars */
.page__body section:has(.numbers-banner__today) > div:first-child > div:first-child {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.page__body section:has(.numbers-banner__today) > div:first-child > div:first-child > span:not(.numbers-banner__today):first-of-type {
  font-size: var(--text-h1);
  font-weight: var(--weight-bold);
  line-height: var(--line-heading);
}

.page__body section:has(.numbers-banner__today) a {
  color: inherit;
}

.page__body section:has(.numbers-banner__today) :focus-visible {
  outline-color: var(--colour-brand-text);
}

.page__body section:has(.numbers-banner__today) .numbers-banner__stars {
  margin: 0;
  font-size: var(--text-large);
}

/* The three boxes, side by side where they fit */
.page__body section:has(.numbers-banner__today) > div:first-child > div:last-child {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--space-3);
}

.page__body section:has(.numbers-banner__today) > div:first-child > div:last-child > div {
  flex: 1 1 6rem;
  padding: var(--space-2);
  border: 1px solid var(--colour-brand-text);
  border-radius: var(--radius);
  text-align: center;
  overflow-wrap: anywhere;
}

.page__body section:has(.numbers-banner__today) > div:first-child > div:last-child > div > div {
  margin-bottom: var(--space-3);
  font-size: var(--text-h2);
  font-weight: var(--weight-bold);
  line-height: var(--line-heading);
}

.page__body section:has(.numbers-banner__today) > div:first-child > div:last-child > div > p {
  margin: 0;
}

@media (min-width: 48em) {
  .page__body section:has(.numbers-banner__today) > div:first-child > div:last-child > div > div {
    font-size: var(--text-h1);
  }
}

@media (min-width: 64em) {
  .page__body section:has(.numbers-banner__today) > div:first-child {
    flex-direction: row;
    justify-content: space-between;
  }
}

/* The site's own small icon on a link (ADR 0083), where today's page shows one: two links of a chain, drawn here
   with no picture, the size and weight of today's and in the link's own colour. */
.link-icon {
  display: inline-block;
  position: relative;
  flex: none;
  width: var(--icon-size);
  height: var(--icon-size);
  margin-right: var(--space-2);
  vertical-align: text-bottom;
}

.link-icon::before,
.link-icon::after {
  content: "";
  position: absolute;
  width: 62.5%;
  height: 37.5%;
  border: var(--icon-stroke) solid currentColor;
  border-radius: var(--icon-size);
  transform: rotate(-45deg);
}

.link-icon::before {
  top: 12.5%;
  right: 0;
}

.link-icon::after {
  bottom: 12.5%;
  left: 0;
}

/* A link with the icon is a row of its own, in bold, as today. */
.page__body a:has(> .link-icon) {
  display: flex;
  align-items: center;
  min-height: var(--tap-target);
  font-weight: var(--weight-bold);
}

/* Today's questions and answers, opening and closing (ADR 0081) */
.page__body details {
  border-bottom: 1px solid var(--colour-border);
  padding: var(--space-2) 0;
}

.page__body details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--tap-target);
  cursor: pointer;
  list-style: none;
}

.page__body details > summary::-webkit-details-marker {
  display: none;
}

.page__body details > summary::after {
  content: "+";
  flex: none;
  font-size: var(--text-large);
  font-weight: var(--weight-bold);
}

.page__body details[open] > summary::after {
  content: "\2212";
}

.page__body details > summary > h3 {
  margin: 0;
}

/* The pop-up video behind Dale Gillham's picture (ADR 0081) */
.popup-video__picture {
  cursor: pointer;
}

.popup-video__open:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.popup-video__dialog {
  width: min(92vw, 52rem);
  padding: var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: var(--colour-background);
}

.popup-video__dialog::backdrop {
  background: var(--colour-shade);
}

.popup-video__frame {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}

.popup-video__close {
  display: block;
  margin: var(--space-3) 0 0 auto;
  min-height: var(--tap-target);
  padding: 0 var(--space-4);
  cursor: pointer;
}

/* EmbedSocial's reviews widget on /reviews, shown on a press (ADR 0114). */
.reviews-widget {
  margin: var(--space-4) 0;
}
