/* Base stylesheet: the colours, type and layout every page on the site shares.
   Loaded first, on every page, before anything more specific.

   The colour values here are not chosen by eye. Each one is checked by
   scripts/check-contrast.mjs against the background it sits on, so text
   clears the 4.5 to 1 ratio WCAG asks for and the edge of every control
   clears 3 to 1. If you change a colour, change it there too and run
   "npm run check:contrast", or the site quietly stops being readable for
   people who need the contrast. */

/* ---------------------------------------------------------------- *
 * The display face
 *
 * Barlow Condensed, served from this site rather than a font service, so
 * it costs no third-party request and needs nothing added to the content
 * security policy (font-src 'self' already covers it). Two weights, Latin
 * only, about 22 KB each. The licence travels with the files, in
 * /assets/fonts/OFL.txt, as the SIL Open Font License requires.
 *
 * font-display: optional, because a headline that changes face after it has
 * painted moves everything under it. The pages preload the heavy weight, so
 * on any reasonable connection it is there in time; on a poor one the
 * fallback stays put for that page and the font is cached for the next.
 * ---------------------------------------------------------------- */

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 700;
  font-display: optional;
  src: url("/assets/fonts/barlow-condensed-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 800;
  font-display: optional;
  src: url("/assets/fonts/barlow-condensed-800-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------------------------------------------------------------- *
 * Colour, in two themes
 *
 * The site follows whatever the visitor's device is set to. There is no
 * theme switch, because a switch needs somewhere to remember the choice
 * and this site deliberately stores nothing it does not have to.
 *
 * "Night" is a third set that does not follow the theme: the header, the
 * home page's opening band, the page heads and the footer are always dark,
 * the colour of site lighting at a five o'clock start. It is what makes
 * every page read as the same product, and accent reads best against it.
 *
 * Every value here is the same as on the JSA Live and Take 5 Live
 * websites except the accent, which is turf green rather than their amber:
 * Pavilion Hosting is a different business, for sports clubs.
 * ---------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  /* Surfaces, lightest first */
  --page: #ffffff;
  --panel: #f4f5f7;
  --raised: #ffffff;

  /* Text */
  --ink: #1b1f24;
  --muted: #565f6b;
  --link: #0b5cab;

  /* The brand accent, the green of the pavilion icon. It is too light to be
     text on white, so text that wants to be accent uses
     --accent-text, a darker cut of it that clears 4.5 to 1. */
  --accent: #3dd68c;
  --accent-ink: #052a14;
  --accent-text: #1d7a46;
  --accent-soft: #e2f6ea;

  /* Night, the same in both themes apart from a shade deeper in dark. */
  --night: #0f1318;
  --night-2: #171c23;
  --night-3: #212833;
  --night-ink: #eef1f4;
  --night-muted: #aab4c0;
  --night-hair: #2b333e;
  --night-edge: #6f7a87;

  /* Meaning. Used for inspection results and for form feedback. */
  --ok: #0f6b3a;
  --ok-bg: #e3f3ea;
  --warn: #6b4c00;
  --warn-bg: #fbf0d6;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;

  /* Lines. Three of them, and the difference matters.
     "hair" is decoration: the rule between two sections. Nothing is lost
     if you cannot see it. "edge" is the outline of something you click or
     type into, which has to be visible to everyone. "line" sits between the
     two: chart gridlines and the muted "total" portion of a bar, which need
     more presence than a hairline but are not an interactive control. */
  --hair: #e2e5ea;
  --line: #c9ced6;
  --edge: #767e8a;
  --focus: #0b5cab;

  --shadow: 0 1px 2px rgba(20, 24, 30, .06), 0 6px 20px rgba(20, 24, 30, .05);
  --shadow-lift: 0 2px 6px rgba(20, 24, 30, .08), 0 26px 56px rgba(20, 24, 30, .16);
  --radius: 12px;
  --measure: 68ch;      /* comfortable reading width for long text */
  --wide: 1080px;       /* page width for the long text pages */
  --site: 1180px;       /* page width for the public pages */

  /* Type. The display face is for headlines only, set in capitals the way a
     site sign is. Everything that is read stays in the system face. */
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* One easing for everything that moves, so the site moves as one thing. */
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #14181d;
    --panel: #1c2128;
    --raised: #1c2128;
    --ink: #e8ebef;
    --muted: #a3adba;
    --link: #7cb8f7;
    --accent-text: #5fe09c;
    --accent-soft: #12291c;
    --night: #0a0d10;
    --night-2: #11161b;
    --night-3: #1b2129;
    --night-hair: #252c35;
    --ok: #4ecb84;
    --ok-bg: #102b1c;
    --warn: #e5b13d;
    --warn-bg: #2c2410;
    --bad: #ff8a80;
    --bad-bg: #331716;
    --hair: #2b323b;
    --line: #3c4552;
    --edge: #767e8a;
    --focus: #3dd68c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .28);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .45), 0 26px 56px rgba(0, 0, 0, .45);
  }
}

/* ---------------------------------------------------------------- *
 * Reset, kept to the few rules that actually earn their place
 * ---------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  /* Long words and URLs must not push the page sideways on a phone. */
  overflow-wrap: break-word;
}

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

[hidden] { display: none !important; }

/* ---------------------------------------------------------------- *
 * Focus
 *
 * Every interactive thing gets a visible ring when reached by keyboard.
 * :focus-visible rather than :focus so a mouse click does not leave a ring
 * behind, but tabbing always shows one.
 * ---------------------------------------------------------------- */

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Anything that hides the ring is a bug. This makes it loud rather than
   silent, so it gets noticed in review instead of in an audit. */
:focus:not(:focus-visible) { outline: none; }

/* Blue disappears against night, so anything on the dark bands rings in
   accent instead. */
.siteHeader, .siteFooter, .onNight { --focus: #3dd68c; }

/* The first thing in the tab order on every page: a link that jumps past
   the navigation, for someone using a keyboard or a screen reader who does
   not want to tab through the menu on every page. */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 12px 18px;
  font-weight: 700;
  z-index: 100;
  text-decoration: none;
}
.skip:focus { left: 0; }

/* ---------------------------------------------------------------- *
 * Type
 * ---------------------------------------------------------------- */

h1, h2, h3, h4 {
  line-height: 1.25;
  margin: 0 0 .5em;
  font-weight: 700;
  letter-spacing: -.01em;
}
h1 { font-size: clamp(1.9rem, 1.4rem + 2.2vw, 2.9rem); }
h2 { font-size: clamp(1.35rem, 1.15rem + 1vw, 1.75rem); margin-top: 2em; }
h3 { font-size: 1.1rem; margin-top: 1.8em; }
h1 + p, h2 + p, h3 + p { margin-top: 0; }

/* Headlines on the public pages: condensed capitals, like a site sign.
   text-wrap: balance stops a two-line headline leaving one word alone. */
.display {
  font-family: var(--display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .004em;
  line-height: .95;
  text-wrap: balance;
}

p, ul, ol, dl, table { margin: 0 0 1.1em; }
ul, ol { padding-left: 1.4em; }
li { margin-bottom: .4em; }

a { color: var(--link); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }

strong, b { font-weight: 700; }

small, .fine { font-size: .85rem; color: var(--muted); }

code, kbd, samp {
  font-family: ui-monospace, "Cascadia Code", Consolas, "Liberation Mono", monospace;
  font-size: .9em;
  background: var(--panel);
  padding: .12em .38em;
  border-radius: 4px;
}

hr { border: 0; border-top: 1px solid var(--hair); margin: 2.5em 0; }

/* Only ever used for text that must reach a screen reader but not the
   screen: the label on an icon-only button, a heading that structures a
   region visually shown another way. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- *
 * Layout
 * ---------------------------------------------------------------- */

.wrap { width: 100%; max-width: var(--wide); margin: 0 auto; padding: 0 20px; }

/* A page whose content sits straight inside <main> needs air above the
   heading. Pages built from .section blocks manage their own spacing, so
   this only applies to the long text pages such as the privacy policy. */
main > .wrap { padding-top: 44px; padding-bottom: 24px; }
.prose { max-width: var(--measure); }
.prose h2 { margin-top: 2.2em; }

main { display: block; }
section { margin: 0; }

.section { padding: 56px 0; }
.section--tint { background: var(--panel); border-block: 1px solid var(--hair); }

.grid { display: grid; gap: 20px; }
@media (min-width: 620px) { .grid--2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 860px) { .grid--3 { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--raised);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- *
 * Header and footer
 *
 * Both are night on every page, signed in or not. The header stays at the
 * top while scrolling on anything wider than a phone; see below for why a
 * phone is different.
 * ---------------------------------------------------------------- */

.siteHeader {
  background: var(--night);
  color: var(--night-ink);
  border-bottom: 1px solid var(--night-hair);
  position: sticky;
  top: 0;
  z-index: 40;
}

/* On a phone the navigation wraps onto a second line, which makes a sticky
   header about 110px tall and permanently costs an eighth of the screen. The
   pages here are read, not navigated constantly, so the header scrolls away
   and gives the content the whole viewport back. A hamburger menu would keep
   it short but needs JavaScript to open, on pages that otherwise ship none. */
@media (max-width: 600px) {
  /* Relative rather than static, so the reading line still sits under it. */
  .siteHeader { position: relative; }
}
.siteHeader .wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
  padding: 6px 2px;
  /* It is a link to the home page and it is on every screen, so it gets the
     same 44px target as everything else rather than the 39px the text and
     icon happened to add up to. */
  min-height: 44px;
}
.siteHeader .brand, .siteFooter .brand { color: var(--night-ink); }
.brand svg { width: 26px; height: 26px; flex: 0 0 auto; transition: transform .35s var(--ease); }
.brand:hover svg { transform: rotate(-8deg) scale(1.06); }

.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
/* :not(.btn) throughout, because an anchor styled as a button is a button.
   .nav a is a class and an element, so it would outrank a button's own
   class and hand an anchor-button a different size from its neighbours.
   Excluding buttons here is the fix rather than piling on specificity, which
   would only move the fight somewhere else. */
.nav a:not(.btn) {
  color: var(--night-muted);
  text-decoration: none;
  font-size: .93rem;
  font-weight: 600;
  padding: 9px 11px;
  border-radius: 8px;
  transition: color .2s, background-color .2s;
}
.nav a:not(.btn):hover { color: var(--night-ink); background: var(--night-3); }

/* aria-current="page" is what tells a screen reader which page you are on.
   Styling the same attribute means the visual state can never drift from
   the announced one. */
.nav a:not(.btn)[aria-current="page"] {
  color: var(--night-ink);
  box-shadow: inset 0 -2px 0 var(--accent);
  border-radius: 8px 8px 0 0;
}
.nav .btn { margin-left: 6px; }
/* A button label never breaks in two; the row wraps instead. */
.siteHeader .btn { white-space: nowrap; }

/* Ghost buttons in the header and on night bands: the light-theme ghost is
   dark ink on a dark ground. */
.siteHeader .btn--ghost, .onNight .btn--ghost {
  color: var(--night-ink);
  border-color: var(--night-edge);
}
.siteHeader .btn--ghost:hover, .onNight .btn--ghost:hover { background: var(--night-3); }

/* How far down the page you are, as a thin accent line under the header.
   Scroll-driven, so it needs no script; a browser without scroll timelines
   simply does not draw it. */
.readProgress {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
  pointer-events: none;
}

.siteFooter {
  border-top: 1px solid var(--night-hair);
  background: var(--night-2);
  color: var(--night-muted);
  padding: 52px 0 56px;
  margin-top: 60px;
  font-size: .92rem;
}
/* A page that ends on the night band runs straight into the night footer.
   The band is the last thing inside main and the footer comes after main, so
   ".cta + .siteFooter" never matched and left a strip of page colour between
   the two. */
main:has(> .cta:last-child) + .siteFooter { margin-top: 0; }
.siteFooter h2 {
  font-family: var(--display);
  font-size: .95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--night-ink);
  margin: 0 0 .8em;
}
.siteFooter .fine { color: var(--night-muted); }
.siteFooter .brand { margin-bottom: 6px; }
.siteFooter ul { list-style: none; padding: 0; margin: 0; }
.siteFooter li { margin-bottom: .55em; }
.siteFooter a { color: var(--night-ink); text-decoration: none; }
.siteFooter a:hover { text-decoration: underline; }
.footCols { display: grid; gap: 28px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .footCols { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.footBase {
  margin-top: 34px; padding-top: 22px;
  border-top: 1px solid var(--night-hair);
  color: var(--night-muted); font-size: .85rem;
}
.footBase p { margin: 0 0 .4em; }
.footBase .legal { max-width: 82ch; }
.footBase .legal a { color: inherit; text-decoration: underline; }

/* ---------------------------------------------------------------- *
 * Buttons and links that look like buttons
 * ---------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  /* 44px is the touch target size a thumb in a glove can actually hit. */
  min-height: 44px;
  transition: transform .18s ease, box-shadow .25s ease, background-color .2s, border-color .2s;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(61, 214, 140, .32); }
.btn--primary:focus-visible { outline-color: var(--accent-ink); }
.siteHeader .btn--primary:focus-visible, .onNight .btn--primary:focus-visible { outline-color: var(--night-ink); }

.btn--ghost { background: transparent; color: var(--ink); border-color: var(--edge); }
.btn--ghost:hover { background: var(--panel); }

/* An arrow inside a button nudges forward on hover, which is the whole of
   its job: saying the button goes somewhere. */
.btn .arrow { transition: transform .2s ease; }
.btn:hover .arrow { transform: translateX(3px); }

.btnRow { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* An action belonging to the whole section above it rather than to the last
   card in it. Without the space and the centring it sits flush against the
   grid and reads as part of the final card. */
.btnRow--section { justify-content: center; margin-top: 36px; }

/* No form styles: the site has no forms, because there is nothing yet for
   one to submit to (see check-html.mjs). Take 5 Live's base.css has them. */

/* ---------------------------------------------------------------- *
 * Notices
 * ---------------------------------------------------------------- */

.note {
  border: 1px solid var(--hair);
  border-left: 4px solid var(--muted);
  background: var(--panel);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 0 0 1.2em;
}
.note > :first-child { margin-top: 0; }
.note > :last-child { margin-bottom: 0; }
.note--ok { border-left-color: var(--ok); background: var(--ok-bg); }
.note--warn { border-left-color: var(--warn); background: var(--warn-bg); }
.note--bad { border-left-color: var(--bad); background: var(--bad-bg); }

/* ---------------------------------------------------------------- *
 * Tables
 *
 * A table on a phone is the classic cause of a page that scrolls sideways.
 * Wrapping it in .tableWrap keeps the scroll inside the table.
 *
 * position: relative so that a positioned descendant, such as the .sr-only
 * label in a header cell, is clipped by the wrapper too. Without it that
 * label is placed against the page, sits past the right edge of a phone
 * screen, and the whole page scrolls sideways.
 * ---------------------------------------------------------------- */

.tableWrap { overflow-x: auto; margin-bottom: 1.2em; position: relative; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
caption { text-align: left; font-weight: 700; padding-bottom: .6em; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--hair); }
th { font-weight: 700; }
thead th { border-bottom: 2px solid var(--edge); }

/* ---------------------------------------------------------------- *
 * Motion
 *
 * Three kinds, all of them optional.
 *
 * Page changes cross-fade where the browser supports view transitions. CSS
 * only: nothing loads for it and a browser without it navigates normally.
 *
 * Sections rise into place as they scroll into view. site.js adds .rv-on to
 * the page only when it can watch for that, and marks anything already on
 * screen as shown first, so nothing visible ever flickers out and back.
 * Without the script, or with motion reduced, everything is simply there.
 *
 * The reading line under the header follows the scroll position.
 * ---------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }

  .rv-on .rv:not(.in) { opacity: 0; transform: translateY(26px); }
  .rv-on .rv { transition: opacity .7s var(--ease), transform .7s var(--ease); }
  .rv-on .rv.d2 { transition-delay: .08s; }
  .rv-on .rv.d3 { transition-delay: .16s; }

  @supports (animation-timeline: scroll()) {
    .readProgress { animation: readGrow linear both; animation-timeline: scroll(root); }
  }
}
@keyframes readGrow { to { transform: scaleX(1); } }

/* ---------------------------------------------------------------- *
 * Printing
 *
 * The legal pages get printed and filed. Make that produce something
 * readable rather than a screenshot of a website.
 * ---------------------------------------------------------------- */

@media print {
  .siteHeader, .siteFooter, .skip, .noPrint { display: none !important; }
  body { font-size: 11pt; color: #000; background: #fff; }
  a { color: #000; text-decoration: underline; }
  /* Printed pages lose the ability to click, so put the destination in
     the text where it can still be read. */
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; }
  h2, h3 { break-after: avoid; }
  .card, .note { break-inside: avoid; }
  /* Anything waiting to scroll into view is printed as it is. */
  .rv { opacity: 1 !important; transform: none !important; }
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
