/* Type: Alegreya Sans for everything read; Bree Serif only for titles and the wordmark.
   All four files are preloaded in base.njk and use font-display: block, so text renders once in the
   final face instead of flashing a fallback and swapping. */
@font-face {
  font-family: "Alegreya Sans";
  src: url("/assets/fonts/alegreya-sans-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: "Alegreya Sans";
  src: url("/assets/fonts/alegreya-sans-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: block;
}
@font-face {
  font-family: "Alegreya Sans";
  src: url("/assets/fonts/alegreya-sans-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: "Bree Serif";
  src: url("/assets/fonts/bree-serif-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

/* Colour comes from the portrait: feathers, collar, horns, eyes. Each colour has one job: page and text carry
   the reading, quiet is for dates and captions, link is for what you can click, focus is the keyboard
   ring. Keep the theme-color tags in base.njk in step with --page. */
:root {
  --page: #f2f4f6; /* pale feather */
  --text: #2c1c2c; /* collar plum */
  --quiet: #535263; /* dark feather: secondary text */
  --link: #843d4e; /* horns */
  --focus: #3b7a12; /* eyes, deepened to keep 3:1 against the page */

  --sans: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --serif: "Bree Serif", Georgia, serif;

  --body: 1.25rem; /* 20px: Alegreya runs small; scripts and prose share it */
  --small: 1.0625rem;
  --h2: 1.75rem;
  --h1: clamp(2.25rem, 1.75rem + 2.5vw, 3.25rem);
  --leading: 1.6;

  /* One spacing scale in multiples of 8px; the larger steps ease down on narrow screens. */
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 1rem;
  --s4: 1.5rem;
  --s5: clamp(1.5rem, 1rem + 2vw, 2.5rem);
  --s6: clamp(2.5rem, 1.5rem + 4vw, 4rem);
  --s7: clamp(4rem, 2.5rem + 6vw, 6rem);

  --measure: 34rem;
  --label-col: 6rem; /* date / label column shared by every list */
  --gutter: clamp(1.25rem, 5vw, 2rem);
  color-scheme: light dark;
}

/* Dark: the deep navy of the videos. Light type reads thinner, so it gets a little more leading. */
@media (prefers-color-scheme: dark) {
  :root {
    --page: #161827;
    --text: #ece8f1;
    --quiet: #a9abc0;
    --link: #ec9ab0;
    --focus: #68df27;
    --leading: 1.65;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable; /* the column doesn't shift between short and long pages */
}

body {
  margin: 0;
  padding: clamp(var(--s4), 6vh, var(--s6)) var(--gutter) var(--s5);
  background: var(--page);
  color: var(--text);
  font: 400 var(--body) / var(--leading) var(--sans);
  font-kerning: normal;
  font-variant-numeric: lining-nums; /* Alegreya defaults to old-style figures, which look wrong beside capitals */
  overflow-wrap: break-word;
}

body > header,
main,
footer {
  max-width: var(--measure);
  margin-inline: auto;
}

p,
ul,
ol {
  margin: 0 0 1em;
}

p {
  text-wrap: pretty;
}

ul {
  padding-left: 1.2em;
}

li + li {
  margin-top: var(--s1);
}

strong {
  font-weight: 700;
}

h1,
h2 {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.15;
  text-wrap: balance;
}

h1 {
  font-size: var(--h1);
  line-height: 1.1;
  margin: 0 0 var(--s2);
}

h2 {
  font-size: var(--h2);
  margin: var(--s6) 0 var(--s3);
}

/* Links keep a thin underline, softened so a page of them isn't a page of heavy pink lines; hover and
   focus bring it to full strength. Without color-mix the underline simply stays at full strength. */
a,
.pager .title {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: currentColor;
  text-underline-offset: 0.2em;
}

@supports (color: color-mix(in srgb, red, blue)) {
  a,
  .pager .title {
    text-decoration-color: color-mix(in srgb, currentColor 65%, transparent);
  }

  ::selection {
    background: color-mix(in srgb, var(--link) 35%, transparent);
  }
}

a:hover {
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

time {
  font-variant-numeric: lining-nums tabular-nums;
}

.skip {
  position: absolute;
  left: var(--s3);
  top: -4rem;
  padding: var(--s2) var(--s3);
  background: var(--page);
}

.skip:focus {
  top: var(--s3);
}

/* Kept for screen readers and the page outline, not shown. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Masthead: the site name goes home, one quiet link goes to the course. Not shown on the home page. */
.masthead {
  margin-bottom: var(--s5); /* same gap as .intro: every page head is followed by the same space */
  font-size: var(--small);
}

.masthead nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

.masthead a {
  padding-block: var(--s2); /* 44px-tall touch targets without a taller bar */
  color: var(--quiet);
  text-decoration-color: transparent;
}

.masthead a:hover {
  color: var(--link);
  text-decoration-color: currentColor;
}

.masthead a[aria-current] {
  color: var(--text);
}

.masthead .home {
  color: var(--text);
  font: 400 1.25rem / 1 var(--serif);
  text-decoration: none;
}

.masthead .home:hover {
  color: var(--link);
}

footer {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s4);
  margin-top: var(--s7);
  font-size: var(--small);
}

footer a {
  padding-block: var(--s2);
  color: var(--quiet);
}

footer a:hover {
  color: var(--link);
}

/* Page heads: title, then one line of context. */
.intro {
  margin-bottom: var(--s5);
}

.byline,
.aside {
  color: var(--quiet);
  font-size: var(--small);
}

.byline {
  margin: 0;
}

/* The home page opens with the portrait beside the name; the tagline is the one line that says who this is. */
.intro.home {
  display: flex;
  align-items: center;
  gap: var(--s4);
  margin-bottom: var(--s6);
  padding-top: clamp(0rem, 6vh, var(--s6));
}

.portrait {
  flex: none;
  border-radius: 50%;
}

.home .byline {
  color: var(--text);
  font-size: var(--body);
}

@media (max-width: 30rem) {
  .portrait {
    width: 80px;
    height: 80px;
  }
}

/* Label and value pairs: the home page, and the weekly plan on the course page. */
.pairs {
  margin: 0 0 1em; /* same as paragraphs */
}

.pairs div {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  gap: var(--s3);
  align-items: baseline;
}

/* Rows of one-line items sit close (--s1); rows with a description under each get a full line (--s3). */
.pairs div + div {
  margin-top: var(--s1);
}

.pairs.plan div + div {
  margin-top: var(--s3);
}

.pairs dt {
  color: var(--quiet);
  font-size: var(--small);
}

.pairs dd {
  margin: 0;
}

.pairs time {
  color: var(--quiet);
}

.pairs .aside {
  display: block;
  line-height: 1.5;
}

/* List links get a taller hit area through padding that margin gives back, so rows keep their spacing.
   Schedule titles can wrap, and an inline-block would align the date with the title's last line, so
   those are blocks that shrink to their text. */
.pairs a,
.schedule a {
  padding-block: var(--s2);
  margin-block: calc(var(--s2) * -1);
}

.pairs a {
  display: inline-block;
}

.schedule a {
  display: block;
  width: fit-content;
}

.schedule {
  list-style: none;
  padding: 0;
}

.schedule li {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  gap: var(--s3);
  align-items: baseline;
}

.schedule li + li {
  margin-top: var(--s1);
}

.schedule time {
  color: var(--quiet);
  font-size: var(--small);
}

.schedule .aside {
  display: block;
}

/* Lesson page. */
.video {
  margin: 0 0 var(--s3);
}

.video > p {
  margin: var(--s2) 0 0;
  font-size: var(--small);
}

.embed-fallback {
  margin: 0 0 var(--s6);
}

.embed-fallback a {
  display: inline-block;
  padding: var(--s2) var(--s3);
  border: 1px solid currentColor;
}

/* The embed document declares no color-scheme; matching it keeps the iframe transparent.
   lib/bluesky.js picks the card's light or dark theme. */
.video iframe {
  color-scheme: light;
}

/* "Play from: Dropbox  this site  Bluesky": buttons that look like the site's links; the current one is plain text. */
.video [hidden] {
  display: none;
}

.video .host {
  margin: var(--s2) 0 0;
  font-size: var(--small);
}

.host button {
  margin-left: var(--s2);
  padding: var(--s2) 0;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  text-decoration: underline 1px;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.host button:hover {
  text-decoration-thickness: 2px;
}

.host button[aria-pressed="true"] {
  color: var(--text);
  text-decoration: none;
  cursor: default;
}

.video video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: #000;
}

/* What shows before embed.js runs, or without it: the post text, plainly. */
blockquote.bluesky-embed {
  margin: 0 0 var(--s3);
  white-space: pre-line;
}

blockquote.bluesky-embed p:last-child {
  margin: 0;
  color: var(--quiet);
  font-size: var(--small);
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s4);
  margin-top: var(--s6);
}

.pager a {
  display: block;
  padding-block: var(--s2);
  color: var(--text);
  text-decoration: none;
}

.pager .label {
  display: block;
  color: var(--quiet);
  font-size: var(--small);
}

.pager .title {
  color: var(--link);
}

.pager a:hover .title {
  text-decoration-thickness: 2px;
}

.pager .next {
  grid-column: 2;
  text-align: end;
}

@media (max-width: 30rem) {
  .pager {
    grid-template-columns: 1fr;
  }

  .pager .next {
    grid-column: 1;
    text-align: start;
  }
}

@media print {
  :root {
    --page: #fff;
    --text: #000;
    --quiet: #444;
    --link: #000;
  }

  .masthead,
  footer,
  .video,
  .pager {
    display: none;
  }
}
