/* =====================================================================
   Royds Hall — roydshall.uk
   One stylesheet. Colours, shadows, type sizes, line heights, spacing
   and layout widths are variables in :root, so the look can be adjusted
   in one place.
   ===================================================================== */

/* ---------- Fonts ---------- */

@font-face {
  font-family: "Stowe Titling";
  src: url("../fonts/stowe-titling.woff2") format("woff2");
  font-display: swap;
}

/* Georgia, resized to take the same space as Stowe Titling, so the text
   does not jump when the web font arrives. Numbers from tools/build-assets.py. */
@font-face {
  font-family: "Stowe Titling Fallback";
  src: local("Georgia");
  size-adjust: 98%;
  ascent-override: 46.1%;
  descent-override: 9.6%;
  line-gap-override: 0%;
}

/* ---------- Theme ---------- */

:root {
  /* Colours */
  --page-bg: #20272a;          /* behind the photo, and below it */
  --panel: #f2f2f2;            /* the light content panel */
  --frame: #fff;               /* frame round the video */
  --video-bg: #000;            /* inside the video frame before the cover picture loads */
  --text: #404040;
  --accent-display: #f35600;   /* page title, always 24px or more: 3.05:1 on the panel */
  --accent-text: #c14500;      /* headings and highlighted words: 4.55:1 on the panel */
  --rule: #d9d9d9;             /* engraved line between sections: grey, white, grey */
  --rule-light: #fff;
  --dots: #3a3a3a;             /* dotted line under section headings */

  /* Shadows and lines */
  --title-shadow: 2px 2px #fff;
  --panel-shadow:
    0 0 6px rgb(0 0 0 / 0.55),
    0 22px 26px -14px rgb(160 197 207 / 0.45);
  --video-frame: 3px;
  --rule-height: 3px;
  --focus-ring: 2px solid var(--accent-text);
  --focus-offset: 2px;

  /* Type */
  --font-brand: "Stowe Titling", "Stowe Titling Fallback", Georgia, "Times New Roman", serif;
  --text-body: 1rem;                                    /* 16px */
  --leading-body: 1.4375;                               /* 23px */
  --text-lead: 1.125rem;                                /* 18px */
  --leading-lead: 1.2222;                               /* 22px */
  --text-lead-name: 1.375rem;                           /* 22px */
  --text-intro: 1.25rem;                                /* 20px */
  --text-h2: 1.375rem;                                  /* 22px */
  --leading-h2: 2;                                      /* 44px */
  --text-h3: 1.125rem;                                  /* 18px */
  --leading-h3: 1.2778;                                 /* 23px, one line of body text */
  --text-kicker: clamp(1.5rem, 1rem + 1.6vw, 2rem);     /* 24px -> 32px; never under 24px, so it counts as large text */
  --leading-kicker: 1;
  --text-title: clamp(2.25rem, 1.25rem + 4.4vw, 3.5625rem); /* 36px -> 57px */
  --leading-title: 1.2;

  /* Spacing: steps of 5px (--space-N is N x 5px) */
  --space-1: 5px;
  --space-2: 10px;
  --space-3: 15px;
  --space-4: 20px;
  --space-8: 40px;
  --space-9: 45px;
  --paragraph-gap: 1.4375rem;  /* one blank line of body text (23px), as on the original site */
  --lead-gap: 1.375rem;        /* one blank line of the introduction (22px), as on the original site */

  /* Layout */
  --panel-max: 980px;          /* 940px of content + 20px padding each side */
  --panel-gutter: var(--space-3);
  --panel-outer: var(--space-2);
  --image-max: 48%;
  --image-max-wide: 56%;
  --image-gap: var(--space-3); /* between a photo and the text beside it */
}

@media (min-width: 700px) {
  :root {
    --panel-gutter: var(--space-4);
    --panel-outer: var(--space-4);
  }
}

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

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

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

body {
  margin: 0;
  padding-block: var(--panel-outer);
  background-color: var(--page-bg);
  background-image: url("../img/page-background-960.webp");
  background-image: image-set(
    url("../img/page-background-960.avif") type("image/avif"),
    url("../img/page-background-960.webp") type("image/webp")
  );
  background-position: top center;
  background-repeat: no-repeat;
  background-size: max(960px, 100%) auto;
  color: var(--text);
  font-family: var(--font-brand);
  font-size: var(--text-body);
  line-height: var(--leading-body);
}

@media (min-width: 961px) {
  body {
    background-image: url("../img/page-background-1920.webp");
    background-image: image-set(
      url("../img/page-background-1920.avif") type("image/avif"),
      url("../img/page-background-1920.webp") type("image/webp")
    );
    background-size: max(1920px, 100%) auto;
  }
}

/* The photo stays still while the panel scrolls, as before — only on
   desktops, where it is smooth. Phones scroll it with the page. */
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  body {
    background-attachment: fixed;
  }
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

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

/* ---------- The panel ---------- */

.page {
  width: min(100% - 2 * var(--panel-outer), var(--panel-max));
  margin-inline: auto;
  padding: var(--space-9) var(--panel-gutter) var(--space-8);
  background: var(--panel);
  box-shadow: var(--panel-shadow);
}

/* ---------- Title ---------- */

.masthead {
  padding-block-end: var(--space-4);
  text-align: center;
}

.masthead h1 {
  color: var(--accent-display);
  font-weight: normal;
  text-transform: uppercase;
  text-shadow: var(--title-shadow);
  text-wrap: balance;
}

.masthead__kicker {
  display: block;
  font-size: var(--text-kicker);
  line-height: var(--leading-kicker);
}

.masthead__title {
  display: block;
  font-size: var(--text-title);
  line-height: var(--leading-title);
}

/* ---------- Introduction and video ---------- */

.video {
  padding: var(--video-frame);
  background: var(--frame);
}

.video video {
  width: 100%;
  aspect-ratio: 854 / 480;
  background: var(--video-bg);
}

.lead {
  padding-block-start: var(--space-4);
  font-size: var(--text-lead);
  line-height: var(--leading-lead);
}

.lead p + p {
  margin-block-start: var(--lead-gap);
}

.lead__name {
  color: var(--accent-text);
  font-size: var(--text-lead-name);
}

/* ---------- Sections ---------- */

.section {
  padding-block-start: var(--space-4);
}

/* Engraved line (grey, white, grey) closing the introduction and every
   section but the last. It clears the photos, so it lands 20px below
   whichever ends lower: the last line of text or the photo. */
.intro::after,
.section:not(:last-child)::after {
  content: "";
  display: block;
  clear: both;
  height: calc(var(--space-3) + var(--rule-height));
  margin-block-start: var(--space-1);
  padding-block-start: var(--space-3);
  background:
    linear-gradient(var(--rule) 0 1px, var(--rule-light) 1px 2px, var(--rule) 2px 3px)
    content-box;
}

.section h2 {
  /* dotted line underneath: 1px dots, 4px apart */
  background: repeating-linear-gradient(to right, var(--dots) 0 1px, transparent 1px 4px) left bottom / 100% 1px no-repeat;
  color: var(--accent-text);
  font-size: var(--text-h2);
  font-weight: normal;
  line-height: var(--leading-h2);
  text-transform: uppercase;
}

.section__intro {
  margin-block: var(--space-3);
  font-size: var(--text-intro);
  line-height: var(--leading-lead);
}

.section__body {
  padding-block-start: var(--space-3);
}

.section__body p {
  text-wrap: pretty;
}

.section__body p + p {
  margin-block-start: var(--paragraph-gap);
}

.section__body h3 {
  color: var(--accent-text);
  font-size: var(--text-h3);
  font-weight: normal;
  line-height: var(--leading-h3);
  text-transform: uppercase;
}

.section__body p + h3 {
  margin-block-start: var(--paragraph-gap);
}

.subsection {
  display: flow-root;
}

.subsection + .subsection {
  padding-block-start: var(--space-3);
}

/* Photos sit beside the text and the text wraps round them */
.section__img {
  max-width: var(--image-max);
  margin-block-end: var(--space-1);
}

.section__img--wide {
  max-width: var(--image-max-wide);
}

.section__img--left {
  float: left;
  margin-inline-end: var(--image-gap);
}

.section__img--right {
  float: right;
  margin-inline-start: var(--image-gap);
}

/* ---------- Phones ---------- */

@media (max-width: 599px) {
  .section__img,
  .section__img--wide {
    float: none;
    max-width: 100%;
    margin-inline: auto;
    margin-block-end: var(--space-3);
  }

  .section__intro {
    font-size: var(--text-lead);
  }
}

/* ---------- Justified text, as on the original site ----------
   Only where the column is wide enough: justified text in a narrow
   column leaves large gaps between words. */

@media (min-width: 600px) {
  .lead {
    text-align: justify;
  }
}

@media (min-width: 1000px) {
  .section__body p {
    text-align: justify;
  }
}

/* ---------- Print ---------- */

@media print {
  body {
    padding: 0;
    background: none;
  }

  .page {
    width: auto;
    padding: 0;
    box-shadow: none;
    background: none;
  }

  .video {
    display: none;
  }

  .section__img {
    break-inside: avoid;
  }
}
