/* RESET */

* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}


/* OVERALL */

:root {
  --font-serif: utopia-std, Palatino, serif;
  --font-sans: cronos-pro-caption, Optima, sans-serif;
  --font-mono: Menlo, Courier, "Courier New", monospace;
  --font-inline-mono: Menlo, Courier, "Courier New", monospace;

  --weight-normal: 400;
  --weight-serif-bold: 600;

  font-family: var(--font-serif);
  font-size: 20px;
  text-size-adjust: none;
  -webkit-text-size-adjust: none;

  --spacing: 16px;
  --spacing-third: calc(var(--spacing) / 3);
  --spacing-half: calc(var(--spacing) / 2);
  --spacing-1_5x: calc(var(--spacing) * 1.5);
  --spacing-2x: calc(var(--spacing) * 2);
  --spacing-3x: calc(var(--spacing) * 3);
  --spacing-5x: calc(var(--spacing) * 5);

  --button-border-radius: 3px;

  --spacing-page-border: min(5vw, var(--spacing-3x));
  --spacing-button: var(--spacing-half);

  --iphone-landscape-width: 667px;
  --min-width-with-padding: calc(100vw - 1rem);

  --color-white: #fff;
  --color-black: #000;
  --color-almost-white: #fcfcfc;
  --color-almost-black: #111;
  --color-darkest-grey: #2a2a2a;
  --color-dark-grey: #4c4c4e;
  --color-medium-dark-grey: #888888;
  --color-medium-grey: #a9a9a9;
  --color-medium-light-grey: #dbdbdb;
  --color-light-grey: #ededed;

  --color-main: #41a9cc;    /* blue */
  --color-main-lightest: #d1e6ee;
  --color-main-light: #8ec1d6;
  --color-main-medium-dark: #168fb7;
  --color-main-dark: #00668f;
  --color-main-darkest: #002839;

  --color-accent: #9eb75b;  /* green */
}

/* Semantic colors (light mode) */
:root {
  --color-page-background: var(--color-almost-white);
  --color-page-foreground: var(--color-almost-black);
  --color-page-foreground-muted: var(--color-dark-grey);  /* use for larger areas of foreground color */

  --color-button-background: var(--color-main);
  --color-button-foreground: var(--color-almost-white);
  --color-button-background-hover: var(--color-main-dark);
  --color-button-foreground-hover: var(--color-light-grey);

  --color-input-background: var(--color-white);
  --color-input-foreground: var(--color-almost-black);
  --color-input-border: var(--color-darkest-grey);
  --input-selected-shadow: 0px 0px 7px 0px var(--color-main-medium-dark);

  --color-link: var(--color-main-dark);
  --color-link-underline: var(--color-main-dark);
  --color-link-underline-dashed: var(--color-main-dark);
  --color-link-hover: var(--color-main);

  --color-hero-background: #010101;   /* matches background color of image */
  --color-hero-foreground: var(--color-light-grey);

  --color-summary-box: var(--color-medium-grey);

  --color-breadcrumbs-background: var(--color-dark-grey);
  --color-breadcrumbs-foreground: var(--color-almost-white);
  --color-breadcrumbs-link-underline: var(--color-medium-grey);
  --color-breadcrumbs-link-hover: var(--color-main-light);

  --color-sitenotice-background: var(--color-main-lightest);
  --color-sitenotice-foreground: var(--color-almost-black);

  --color-calendar-month-background: var(--color-main-dark);
  --color-calendar-month-foreground: var(--color-almost-white);
  --color-calendar-day-background: white;
  --color-calendar-day-foreground: var(--color-page-foreground);
  --color-calendar-year-background: var(--color-main-lightest);
  --color-calendar-year-foreground: var(--color-dark-grey);
  --calendar-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.4);
  --calendar-border: none;

  --color-highlighter: #FFFF99;

  --color-footer-background: var(--color-light-grey);

  --color-inline-code: var(--color-main-darkest);

  /* syntax highlighting is based on WebStorm color scheme */
  --color-syntax-default: var(--color-page-foreground);
  --color-syntax-comment: var(--color-medium-dark-grey);
  --color-syntax-punctuation: var(--color-page-foreground);
  --color-syntax-number: #0600FF;
  --color-syntax-string: #008000;
  --color-syntax-operator: var(--color-page-foreground);
  --color-syntax-keyword: #010080;
  --color-syntax-function: var(--color-page-foreground);
  --color-syntax-annotation: purple;
  --color-syntax-variable: #008000;

  --image-shadow-light: 0px 0px 7px 0px rgba(0, 0, 0, 0.3);
  --image-shadow-heavy: 0px 0px 7px 2px rgba(0, 0, 0, 0.3);
}

.dark-mode {
  display: none !important;
}

/* Dark mode */
@media screen and (prefers-color-scheme: dark) {
  :root {
    --color-page-background: var(--color-darkest-grey);
    --color-page-foreground: var(--color-medium-light-grey);
    --color-page-foreground-muted: var(--color-light-grey);

    --color-button-background: var(--color-main-dark);
    --color-button-foreground: var(--color-light-grey);
    --color-button-background-hover: var(--color-main-medium-dark);

    --color-input-background: var(--color-almost-black);
    --color-input-foreground: var(--color-medium-light-grey);
    --color-input-border: var(--color-medium-grey);
    --input-selected-shadow: 0px 0px 7px 0px var(--color-main-light);

    --color-link: var(--color-main-light);
    --color-link-underline: var(--color-main-light);
    --color-link-underline-dashed: var(--color-main-light);
    --color-link-hover: var(--color-main);

    --color-hero-background: #010101;
    --color-hero-foreground: var(--color-medium-light-grey);

    --color-summary-box: var(--color-dark-grey);

    --color-breadcrumbs-background: var(--color-almost-black);
    --color-breadcrumbs-foreground: var(--color-medium-light-grey);
    --color-breadcrumbs-link-underline: var(--color-medium-grey);
    --color-breadcrumbs-link-hover: var(--color-main-light);

    --color-sitenotice-background: var(--color-main-darkest);
    --color-sitenotice-foreground: var(--color-medium-light-grey);

    --color-calendar-month-background: var(--color-main-light);
    --color-calendar-month-foreground: var(--color-page-background);
    --color-calendar-day-background: var(--color-almost-black);
    --color-calendar-day-foreground: var(--color-light-grey);
    --color-calendar-year-background: var(--color-main-darkest);
    --color-calendar-year-foreground: var(--color-light-grey);
    --calendar-shadow: 0px 0px 4px 0px rgba(255, 255, 255, 0.2);
    --calendar-border: none;

    --color-highlighter: #4F4E00;

    --color-footer-background: var(--color-dark-grey);

    --color-inline-code: var(--color-main-lightest);

    /* syntax highlighting is based on VSCode color scheme */
    --color-syntax-default: #6BB7EE;
    --color-syntax-comment: #74985D;
    --color-syntax-punctuation: var(--color-page-foreground);
    --color-syntax-number: #BACDAB;
    --color-syntax-string: #C5947C;
    --color-syntax-operator: var(--color-page-foreground);
    --color-syntax-keyword: #BC89BD;
    --color-syntax-function: #D8D8AC;
    --color-syntax-annotation: #71C6B1;
    --color-syntax-variable: #C5947C;

    --image-shadow-light: 0px 0px 7px 0px rgba(255, 255, 255, 0.3);
    --image-shadow-heavy: 0px 0px 7px 2px rgba(255, 255, 255, 0.3);
  }
  .light-mode {
    display: none !important;
  }
  .dark-mode {
    display: inherit !important;
  }
}

/* Print */
@media print {
  :root {
    --color-page-background: white;
    --color-page-foreground: black;
    --color-page-foreground-muted: var(--color-dark-grey); /* use for larger areas of foreground color */

    --color-button-background: white;
    --color-button-foreground: black;
    --color-button-background-hover: var(--color-main);
    --color-button-foreground-hover: white;

    --color-input-background: white;
    --color-input-foreground: black;
    --color-input-border: var(--color-medium-grey);

    --color-link: black;
    --color-link-underline: var(--color-medium-grey);
    --color-link-underline-dashed: var(--color-dark-grey);
    --color-link-hover: var(--color-main-dark);

    --color-hero-background: white;
    --color-hero-foreground: black;

    --color-summary-box: var(--color-medium-grey);

    --color-breadcrumbs-background: white;
    --color-breadcrumbs-foreground: black;
    --color-breadcrumbs-link-underline: black;
    --color-breadcrumbs-link-hover: var(--color-main-dark);

    --color-sitenotice-background: var(--color-main-lightest);
    --color-sitenotice-foreground: var(--color-almost-black);

    --color-calendar-month-background: var(--color-main-dark);
    --color-calendar-month-foreground: white;
    --color-calendar-day-background: white;
    --color-calendar-day-foreground: black;
    --color-calendar-year-background: var(--color-main-lightest);
    --color-calendar-year-foreground: var(--color-dark-grey);
    --calendar-shadow: 0;
    --calendar-border: solid 1px var(--color-dark-grey);

    --color-highlighter: #FFFF99;

    --color-footer-background: var(--color-light-grey);

    /* syntax highlighting is based on WebStorm color scheme */
    --color-syntax-default: var(--color-page-foreground);
    --color-syntax-comment: var(--color-medium-dark-grey);
    --color-syntax-punctuation: var(--color-page-foreground);
    --color-syntax-number: #0600FF;
    --color-syntax-string: #008000;
    --color-syntax-operator: var(--color-page-foreground);
    --color-syntax-keyword: #010080;
    --color-syntax-function: var(--color-page-foreground);
    --color-syntax-annotation: purple;
    --color-syntax-variable: red;

    --image-shadow-light: 0px 0px 7px 0px rgba(0, 0, 0, 0.3);
    --image-shadow-heavy: 0px 0px 7px 2px rgba(0, 0, 0, 0.3);
  }
}


html {
  background-color: var(--color-page-background);
  color: var(--color-page-foreground);
}

p {
  line-height: 1.4em;
}

a {
  text-decoration: none;
  color: unset;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-serif-bold);
}

img {
  height: 100%;
}

img.text, svg.text {
  height: 0.7em;
}


/*** FORMS ***/

input {
  font-family: inherit;
  font-size: inherit;
  appearance: none;
}

input:focus-visible {
  outline: none;
  box-shadow: var(--input-selected-shadow);

}

input[type="submit"] {
  border: inherit;
}

input[type="email"], input[type="text"] {
  background-color: var(--color-input-background);
  color: var(--color-input-foreground);
  border: solid var(--color-input-border) 1px;
  padding: calc(var(--spacing-button) - 1px);
}


/*** BUTTONS ***/

.button {
  padding: var(--spacing-button) 1.5ch var(--spacing-button) 1.5ch;

  display: inline-block;

  font-family: var(--font-sans);
  text-align: center;
  background-color: var(--color-button-background);
  color: var(--color-button-foreground);

  border-radius: var(--button-border-radius);
}

.button:hover {
  background-color: var(--color-button-background-hover);
  color: var(--color-button-foreground-hover);
  cursor: pointer;
}

.story a.button {
  color: var(--color-button-foreground);
  text-decoration: none;
}

.story a.button:hover {
  color: var(--color-button-foreground-hover);
}

.button--full {
  display: block;
}

.button--footer {
  margin-top: calc(var(--p-spacing) * 2);
}


/*** BANNER ***/

/* Okay, so we got some weirdness going on here with the title. We want it to:
 * 1. Be flush to the left when the nav links are on the same row.
 * 2. But be CENTERED when the nav links have wrapped to the next row (which happens when window is narrow).
 * I didn't think this would be possible, but it is! Here's what's going on.
 *
 * On this element, we've set the 'flex-basis' to 0 (using a shortcut property on 'flex'). We've also set
 * flex-basis to zero in the sibling element, .banner__nav. This means the flex layout will ignore their sizes
 * wrapping or allocating space. But we've set flex-grow on .banner__nav to 100, which means that, practically
 * speaking, .banner_nav will get all the available space and .banner__title won't grow at all. (So why do we
 * bother allowing .banner_title to grow? Keep reading!)
 *
 * So that's taken care of making sure the title stays on the left when the nav links are on the same row.
 * Now for the real magic: making it center when the nav links wrap.
 *
 * First, we make sure it wraps at the right time. We use 'min-width' in '.banner__nav' and 'width' in
 * '.banner__title img' to make sure the nav wraps when we want it to. AND THEN, WHEN IT WRAPS, now .banner__nav
 * is no longer competing for available space! So .banner_title is free to grow for the first time. So it does.
 *
 * Now it's just a simple matter of making .banner__title use its newfound growth to center properly. We do
 * that by making it be a flex box itself and setting 'justify-content: center'. That ensures that the contents
 * are centered. It wouldn't work if the titles weren't contained in a single element, but they are, so it does.
 *
 * And that's how it works!
 */

.banner {
  display: flex;
  flex-flow: row wrap;
  justify-content: normal;
  align-items: flex-end;
}

.banner > * {
  margin: var(--spacing);
  margin-left: var(--spacing-page-border);
  margin-right: var(--spacing-page-border);
}

.banner__title {
  flex: 1 0 0;

  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
}

.banner__title img {
  display: block;
  width: 250px;
}

.banner__subtitle {
  margin-top: -35px;
  text-align: center;
  font-size: 24px;
  font-style: italic;
  font-weight: var(--weight-serif-bold);
}

.banner__subtitle sup {
  font-size: 35%;
}

.banner__nav {
  flex: 100 1 0;
  min-width: min(25ch, calc(100vw - (var(--spacing-page-border) * 2)));
  margin-top: var(--spacing-half);   /* override .banner and adjust for padding */

  display: flex;
  align-items: flex-end;
  justify-content: flex-end;

  font-family: var(--font-sans);
  font-size: 0.92rem;
  text-transform: uppercase;
}

.banner__nav li {
  display: inline-block;
  margin-top: var(--spacing);
}

.banner__nav a {
  padding: var(--spacing-half);
}

/* adjust for padding */
.banner__nav > *:first-child {
  margin-left: calc(var(--spacing-half) * -1);
}
.banner__nav > *:last-child {
  margin-right: calc(var(--spacing) * -1);
}

.banner__nav a:hover {
  border-radius: var(--button-border-radius);
  background-color: var(--color-button-background);
  color: var(--color-button-foreground);
}

/* group icons */
li.banner__nav__icons {
  padding: 0;
  margin: 0;
}
li.banner__nav__icons:hover {
  background-color: unset;
  color: unset;
  border-radius: unset;
}


/*** HERO CONTENT (home page) ***/

.hero {
  display: flex;
  flex-flow: row wrap;
  justify-content: space-between;

  background-color: var(--color-hero-background);
  color: var(--color-hero-foreground);
}

.hero > * {
  /* copy and image are same size, then wrap once min-width is achieved, which is hand-tuned based on width copy */
  flex: 1 1 0;
}

.hero__copy {
  min-width: min(40ch, 100vw);
  max-width: max(60ch, var(--iphone-landscape-width));

  padding: var(--spacing-page-border);
}

.hero__copy h2 {
  font-size: 1.8rem;
  font-weight: var(--weight-serif-bold);
}

.hero__copy p {
  margin-top: 1em;
  font-size: 1.2rem;
  font-weight: var(--weight-normal);
}

/* Lots of complicated stuff going on here. When we start to run out of space, we need to do several things with image:
 * 1. Scale it down.
 * 2. But if it starts to get TOO small, crop it instead.
 * 3. And if the image is so small the text is taller, align the image to the bottom.
 * Scaling it down is handled by 100% width on the img tag. We cap the maximum size with the 'max-width' property.
 * Cropping is handled by the width: max() function on the img tag and the 'overflow: hidden' property on .hero-image.
 * min-width on .hero-image prevents it from being cropped too far.
 * Aligning to the bottom is handled by 'align-self' property.
 * All in all, it works very well!
 */
.hero__image {
  --image-max-width: 730px;               /* the largest size the image can become */
  --image-min-width-before-crop: 550px;   /* the smallest size the image can become before being cropped */
  --image-min-width-after-crop: 310px;    /* the smallest size the image can become before wrapping */

  align-self: flex-end;
  min-width: var(--image-min-width-after-crop);
  max-width: var(--image-max-width);
  overflow: hidden;

  /* remove left margin */
  margin-left: calc(var(--spacing-page-border) * -1);
}

/* overlay the image with a gradient so there's no hard edge between the picture and the copy */
.hero__image::before {
  position: relative;

  background: linear-gradient(to right, var(--color-hero-background), transparent 30%);
  padding-bottom: 200%;   /* the gradient stops covering bottom of image if this is 100%. Don't know why. */
  padding-right: 100%;
  content: "";
}

.hero__image img {
  display: block;
  width: max(100%, var(--image-min-width-before-crop));
}


/*** COLUMNS ***/

.columns {
  display: flex;
  flex-flow: row wrap;
  justify-content: space-evenly;
  margin-top: var(--spacing);
}

.columns > * {
  flex: 1 1 0;      /* force all columns to be the same width */
  min-width: min(36ch, var(--min-width-with-padding));

  margin: var(--spacing-page-border);
}

.columns h1 {
  font-style: italic;
  font-weight: var(--weight-serif-bold);
}


/*** SUMMARY TESTIMONIAL ***/

.summary-testimonial {
  font-style: italic;
  font-size: 1.15rem;
  margin-top: var(--spacing-2x);
}

.summary-testimonial > p:first-child::before {
  content: "“";
  font-size: 1.5em;
  position: relative;
  top: 0.33rem;
  line-height: 0;
  color: var(--color-page-foreground-muted);
}

.summary-testimonial > p:nth-last-child(2)::after {
  content: "”";
}

.summary-testimonial__sig::before {
  content: "—";
}

.summary-testimonial__sig {
  text-align: right;
  font-size: 1rem;
  margin-top: var(--spacing-third);
}


/*** SUMMARY BOX ***/

.summary-box {
  padding: var(--spacing);
  border: 1px solid var(--color-summary-box);
  border-radius: 1px;
  margin-top: var(--spacing-2x);
}

.summary-box h1 {
  font-size: 1.35rem;
}

.summary-box p {
  margin-top: 1em;
  line-height: 1.6em;
}

.summary-box__poster {
  float: right;
  width: 33%;
  margin-left: var(--spacing-half);
  box-shadow: var(--image-shadow-light);
}

.summary-box__banner {
  margin-bottom: var(--spacing);
  box-shadow: var(--image-shadow-heavy);
}

.summary-box__banner img, .summary-box__poster img {
  width: 100%;
  display: block;
}

/* Prevent floated image from escaping box */
.summary-box > *:last-child::after {
  content: "";
  display: block;
  clear: both;
}

.summary-box__link a {
  font-family: var(--font-sans);
  border-bottom: dashed 1px var(--color-link-underline-dashed);
  /* use border because dashed underline looks funny on Chrome as of 15 Aug 2020 */

  /*text-decoration: underline dashed var(--color-link-underline-dashed);*/
  /*text-decoration-thickness: 1px;*/
  /*-webkit-text-decoration: underline dashed var(--color-link-underline-dashed);*/
  /* color requires prefix on Safari as of 6 Aug 2020 */
}

.summary-box__link a::after {
  content: " »";
}

.summary-box__link a:hover {
  color: var(--color-link-hover);

  border-bottom-color: var(--color-link-hover);

  /*text-decoration-color: var(--color-link-hover);*/
}


/*** BREADCRUMBS & RESTRICTED PAGES ***/

.breadcrumbs, .restricted {
  display: flex;
  flex-flow: row wrap;
  justify-content: space-between;
  align-items: center;
  column-gap: 2ch;
  row-gap: var(--spacing-half);

  font-family: var(--font-sans);
  font-size: 0.9rem;

  padding: var(--spacing) var(--spacing-page-border) var(--spacing) var(--spacing-page-border);

  background-color: var(--color-breadcrumbs-background);
  color: var(--color-breadcrumbs-foreground);
}

.restricted {
  background-color: var(--color-sitenotice-background);
  color: var(--color-sitenotice-foreground);
}

.breadcrumbs__text, .restricted__text {
  margin-top: var(--spacing-button);
  margin-bottom: var(--spacing-button);
}

.breadcrumbs li {
  display: inline-block;
}

.breadcrumbs li::after {
  content: "»";
  padding-left: 1ch;
  padding-right: 1ch;
}

.breadcrumbs li:last-child::after {
  display: none;
}

.breadcrumbs > *, .restricted > * {
  flex: 0 1 auto;
}

.breadcrumbs a {
  text-decoration: underline var(--color-breadcrumbs-link-underline);
  text-decoration-thickness: 1px;
  -webkit-text-decoration: underline var(--color-breadcrumbs-link-underline);   /* see previous -webkit- note */
}

.breadcrumbs a:hover {
  color: var(--color-breadcrumbs-link-hover);
  /*text-decoration-color: var(--color-breadcrumbs-link-hover);*/
}

.breadcrumbs__print-text {
  margin-left: 1ch;
}


/*** FOOTER ***/

.footer {
  background-color: var(--color-footer-background);
  padding-top: var(--spacing);
  padding-bottom: var(--spacing-2x);
  padding-left: var(--spacing-page-border);
  padding-right: var(--spacing-page-border);

  text-align: center;
  font-family: var(--font-sans);
  font-size: 0.7rem;
}

.footer p {
  margin-top: var(--spacing);
}

.footer a {
  text-decoration: underline var(--color-link-underline);
  text-decoration-thickness: 1px;
  -webkit-text-decoration: underline var(--color-link-underline);   /* color requires prefix on Safari as of 6 Aug 2020 */
}

.footer a:hover {
  color: var(--color-link-hover);
  text-decoration-color: var(--color-link-hover);
}


/*** EVENT SUMMARY, CALENDAR PAGE ***/

.event-summary {
  margin-bottom: 2.8em;
  font-size: 1.4em;
  clear: both;
}

.calendar-page {
  display: flex;
  flex-direction: column;
  float: left;

  width: 3.6em;
  margin-top: 0.45em;
  /*vertical-align: middle;*/
  text-align: center;

  border-radius: 0.3em;
  overflow: hidden;

  box-shadow: var(--calendar-shadow);
  border: var(--calendar-border);

  font-family: var(--font-sans);
  font-size: 0.5em;
  font-weight: var(--weight-normal);
  margin-right: 1em;
}

.event-summary .calendar-page {
  font-size: 0.8em;
}

.calendar-page__month {
  font-size: 0.75em;
  text-transform: uppercase;
  background-color: var(--color-calendar-month-background);
  color: var(--color-calendar-month-foreground);
}

.calendar-page__day {
  font-size: 2.5em;
  line-height: 0.9;
  background-color: var(--color-calendar-day-background);
  color: var(--color-calendar-day-foreground);
}

.calendar-page__year {
  font-size: 0.65em;
  background-color: var(--color-calendar-year-background);
  color: var(--color-calendar-year-foreground);
}


/*** STORY ***/

/*** Story: overall ***/

.story {
  --spacing-page-border: 7vw;
  --indent: min(5vw, 4ch);

  --p-font-size: 1.05rem;
  --aside-font-size: calc(var(--p-font-size) * 0.9);
  --marginal-font-size: calc(var(--p-font-size) * 0.8);

  --p-spacing: var(--p-font-size);
  --p-spacing-half: calc(var(--p-font-size) * 0.5);
  --p-spacing-third: calc(var(--p-font-size) * 0.3);

  --max-width: 80ch;
  --marginalia-margin: 0 0 var(--p-spacing-third) var(--p-spacing);
  --marginalia-padding: var(--p-spacing-third) 0 var(--p-spacing-third) 0;


  /* Used for responsive margin */
  --margin-width: 0vw;
  --margin-padding: 0vw;
  --margin-usable-width: calc(var(--margin-width) - var(--margin-padding));
  --margin-right: calc(var(--margin-width) * -1);

  margin: var(--spacing-5x) var(--spacing-page-border) var(--spacing-5x) var(--spacing-page-border);
  font-size: var(--p-font-size);

  /* prevent text from extending beyond border by forcing breaks where necessary (particularly URLs) */
  overflow-wrap: anywhere;
}

.story.story--ui {  /* 'UI' variant (for system messages) */
  font-family: var(--font-sans);
}

/* deleted text */
.story del {
  text-decoration-thickness: 0.1em;
  font-style: italic;
}

.story::after {
  content: "";
  display: block;
  clear: both;
}


/*** Story: margins ***/

.story__body {
  margin-top: 2.5em;
  clear: both;
}

.story__body > * {
  max-width: var(--max-width);
}

.story .story__title {
  font-size: calc(var(--p-font-size) * 1.9);
  font-weight: var(--weight-normal);
}

.story .story__date {
  font-size: calc(var(--p-font-size) * 1.2);
  font-style: italic;
  font-weight: var(--weight-normal);
  margin-top: 1em;
}


/*** Story: Headers and paragraphs ***/

.story h2 {
  font-size: calc(var(--p-font-size) * 1.6);
  font-style: normal;
  font-weight: var(--weight-normal);
  margin-top: 2.5em;
  margin-bottom: var(--p-spacing);
}

.story h3 {
  font-size: calc(var(--p-font-size) * 1.4);
  font-style: italic;
  font-weight: var(--weight-normal);
  margin-top: 2.5em;
  margin-bottom: var(--p-spacing);
}

.story h4 {
  font-size: calc(var(--p-font-size) * 1.15);
  font-style: italic;
  font-weight: var(--weight-normal);
  margin-top: 1.7em;
  margin-bottom: var(--p-spacing);
}

.story h5 {
  font-size: calc(var(--p-font-size) * 1);
  font-style: italic;
  font-weight: var(--weight-normal);
  margin-top: 1.7em;
  margin-bottom: var(--p-spacing);
}

.story p {
  line-height: 1.65;
  margin-top: var(--p-spacing);
}


/*** Story: Character styles ***/

/* We use 'story' for links rather than 'story__body' because the title is a link on some index pages */
.story a {
  color: var(--color-link);
  text-decoration: underline var(--color-link-underline);
  text-decoration-thickness: 1px;
  -webkit-text-decoration: underline var(--color-link-underline);   /* see previous -webkit- note */
}
.story a:hover {
  color: var(--color-link-hover);
  text-decoration-color: var(--color-link-hover);
}
.story a[href^="#"] {
  /* internal (fragment) links */

  text-decoration: none;
  border-bottom: dashed 1px var(--color-link-underline-dashed);
  /*text-decoration: underline dashed var(--color-link-underline-dashed);*/
  /*text-decoration-thickness: 1px;*/
  /*-webkit-text-decoration: underline dashed var(--color-link-underline-dashed);*/
}

.story a.no-decoration {
  /* useful when the link is an emoji */
  text-decoration: none;
}

.story sup, .story sub {
  font-size: 0.7em;
}

.story code {
  color: var(--color-inline-code);
  font-family: var(--font-inline-mono);
  font-size: 0.8em;
}


/*** Story: Images and IFrames ***/

/* Many blog entries have images and iframes with inline sizes, so we make sure they can't break out here */
.story img, .story iframe, .story video {
  max-width: 100%;
}

.story img {
  /* Without "height:auto", images without dimensions will have incorrect aspect ratio on Chrome 89.
   * (It's fine on Firefox 86.) However, this also seems to mess up YouTube embeds,
   * However, using "height:auto" on YouTube embeds seems causes their height to be truncated, so
   * we only want to apply it to <img> tags.
   */
  height: auto;
}

.story iframe {
  margin-top: var(--p-spacing);
}


/*** Story: Site Notice ***/

.story .site-notice {
  margin-left: calc(var(--spacing-page-border) * -1);
  margin-right: calc((var(--margin-width) + var(--spacing-page-border)) * -1);
  margin-bottom: 3em;

  /* use full width */
  max-width: unset;
  clear: right;   /* don't let marginalia overlap us */

  padding: 1em var(--spacing-page-border);

  background-color: var(--color-sitenotice-background);
  color: var(--color-sitenotice-foreground);
}
.story .site-notice > :first-child {
  margin-top: 0;
}

/* Prevent floated elements from escaping site-notice box */
.story .site-notice > *:last-child::after {
  display:block;
  content: "";
  clear: both;
}


/*** Story: Generic lists ***/

.story ul, .story ol {
  padding-left: var(--indent);
  line-height: 1.3;
  margin-top: 1em;
}

.story li > ul, .story li > ol {
  margin-top: 0;
}

.story ul p, .story ol p {
  margin-top: var(--p-spacing-half);
}

.story ol.no-number {
  list-style-type: none;
}


/*** Story: Checklists ***/

.story ul.checklist, .story ol.checklist {
  list-style-type: '☐  ';
}

.story ul.checklist li::marker, .story ol.checklist li::marker {
  font-size: 115%;
}


/*** Story: Instruction lists ***/

.story ol.instructions > li {   /* Level 1 */
	list-style-type: upper-roman;
	margin-bottom: var(--p-spacing);
  font-style: italic;
}

.story ol.instructions > li > ol > li {  /* Level 2 */
	list-style-type: decimal;
  font-style: normal;
}

.story ol.instructions ol { /* all levels but first */
  margin-top: 0;
}

.story ol.instructions li {
  margin-top: 0.5em;
}


/*** Story: Table of Contents ***/

.story .toc {
  list-style-type: none;
  padding-left: 0;
}

.story .toc ul, .story .toc ol {
  list-style-type: none;
  margin-top: 0;
  margin-bottom: var(--p-spacing-third);
}

.story .toc__part {
  margin-top: var(--p-spacing-half);
  font-weight: var(--weight-serif-bold);
}

.story .toc__part ul, .story .toc__part ol {
  font-weight: var(--weight-normal);
}


/*** Story: 'Full text' marker in AoAD table of contents ***/

.aoad-full-text::after {
  content: "📖";
  padding-left: 1ch;
}

.aoad2-er::before {
  content: "📖";
  padding-right: 1ch;
}


/*** Story: Definition List ***/

.story dl {
  margin-top: var(--p-spacing);
  margin-left: calc(var(--indent) * 0.5);
}

.story dt {
  margin-top: var(--p-spacing);
  font-style: italic;
}

.story dd {
  margin-left: var(--indent);
  line-height: 1.4;
}

.story dd + dd {
  margin-top: var(--p-spacing-half);
}



/*** Story: Article List ***/

/* regular list variant */
.story ol.article-list {
  list-style-type: none;
  padding-left: 0;
}

.story ol.article-list li {
  margin-top: var(--p-spacing-half);
}

/* definition list variant */
.story dl.article-list {
  margin-top: unset;
  margin-left: unset;
}

.story .article-list dt {
  font-style: italic;
  margin-top: var(--p-spacing);
}

.story .article-list dd {
  margin-top: var(--p-spacing-third);
  margin-left: unset;
  line-height: 1.4;
}

/* other elements */
.story .article-list__date {
  font-size: var(--aside-font-size);
}

.story .article-list__date::before {
  padding-left: 1ch;
  content: "(";
}

.story .article-list__date::after {
  content: ")"
}

.story .article-list__popular::before {
  content: "⭐";
  font-style: normal;
  margin-right: 1ch;
}


/*** Story: Translations ***/

.story ul.translations {
  padding-left: 0;
  font-size: calc(var(--p-font-size) * 0.9);
  margin-bottom: 3em;
}

.story ul.translations::before {
  content: "Translations";
  letter-spacing: .1em;
  font-variant: small-caps;
  text-decoration: underline;
}

.story ul.translations > li {
  list-style: none;
  font-family: var(--font-sans);
}
.story ul.translations > li > a {
  text-decoration: none;
}
.story ul.translations > li > a::after {
  content: " »";
}


/*** Story: Series ***/

.series {
  margin-bottom: 2em;
  font-style: italic;
}


/*** Story: Tables ***/

.story table {
  --column-gap: 3ch;
  --row-gap: 0.2em;

  margin-top: var(--p-spacing);
  margin-left: var(--indent);
  line-height: 1.2;
}

.story th {
  font-style: italic;
  font-weight: var(--weight-normal);
  padding-top: var(--row-gap);
  padding-right: var(--column-gap);
  text-align: left;
}

.story td {
  padding-right: var(--column-gap);
  padding-top: var(--row-gap);
  text-align: left;
  vertical-align: top;
}

.story table.list th {
  text-decoration: underline;
}

table.left th {
  --column-gap: 1ch;

  white-space: nowrap;
  text-align: right;
  vertical-align: top;
}

table.left th:after {
  content: ":";
}

table.left td {
  vertical-align: top;
  text-align: left;
}


/*** Story: Block quotes ***/

.story blockquote {
  margin-top: var(--p-spacing);
  margin-left: var(--indent);
}

.story blockquote h3 {
  margin-top: var(--p-spacing);
  font-size: calc(var(--p-font-size) * 1.1);
}

.story .sig {
  text-align: right;
  font-size: 0.85em;
  font-style: italic;
  line-height: 1.3;
  margin-top: 0.7em;
}


/*** Story: Pull quotes ***/

/* .pullquote and .coach are identical; .coach was used in AoAD1 HTML only as a hedge against changes.
 AoAD2 doesn't use it because the HTML is generated at runtime, so it's already insulated against changes. */
.story blockquote.pullquote, .story blockquote.coach {
  float: right;
  clear: right;

  margin: var(--marginalia-margin);
  margin-top: var(--p-spacing);
  padding: var(--marginalia-padding);

  border-top: 3px double;
  border-bottom: 3px double;

  font-size: calc(var(--p-font-size) * 1.2);
  width: 23ch;
  text-align: center;
}


/*** Story: Sidebar ***/

.story .sidebar {
  margin-top: calc(var(--p-spacing) * 2);
  margin-bottom: calc(var(--p-spacing) * 1.5);
  margin-left: unset;
  padding-bottom: calc(var(--p-spacing) * 1.5);
  padding-left: var(--indent);
  padding-right: var(--indent);
  border: solid 1px var(--color-page-foreground);
}

.story .sidebar > *:first-child {
  margin-top: calc(var(--p-spacing) * 1.5);
}

.story .sidebar h3 {
  font-size: calc(var(--p-font-size) * 1.1);
}


/*** Story: Code blocks ***/

.story pre, .story .code {  /* sometimes we use blockquote.code instead of pre */
  margin-top: var(--p-spacing);
  margin-bottom: var(--p-spacing);
  font-family: var(--font-mono);
  font-size: 0.71em;

  /* use full width of page, including scrolling code all the way to left edge of browser window */
  margin-right: calc((var(--margin-width) + var(--spacing-page-border)) * -1);  /* remove right margin */
  margin-left: calc(var(--spacing-page-border) * -1);             /* replace left margin, which doesn't scroll... */
  padding-left: calc(var(--spacing-page-border) + var(--indent)); /* ...with padding, which does */
  max-width: max-content;     /* stop highlights at right edge of code */
  overflow-x: auto;           /* allow scrolling if the screen is narrow */
  clear: right;               /* don't let marginalia overlap us */
}

.story pre code {   /* override character style */
  font-size: 1em;
  tab-size: 2;
}

.story blockquote.code {
  white-space: nowrap;        /* only <br /> tags wrap */
}

.story pre code em, .story .code em, .story .code div.em {
  font-style: normal;
  background-color: var(--color-highlighter);
}

.story pre code > .caption, .story .code > .caption {
  margin-top: var(--p-spacing);
  font-family: var(--font-serif);
}

/* Syntax highlighting with Prism */
.token.property,
.token.tag,
.token.constant,
.token.symbol {
  color: var(--color-syntax-default);
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
	color: var(--color-syntax-comment);
  font-style: italic;
}

.token.punctuation {
	color: var(--color-syntax-punctuation);
}

.token.namespace {
	opacity: .7;
}

.token.boolean,
.token.number,
.token.deleted {
	color: var(--color-syntax-number);
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
	color: var(--color-syntax-string);
  font-weight: bold;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
	color: var(--color-syntax-operator);
}

.token.atrule,
.token.attr-value,
.token.keyword {
	color: var(--color-syntax-keyword);
  font-weight: bold;
}

.token.function,
.token.class-name {
	color: var(--color-syntax-function);
}

.token.annotation {
  color: var(--color-syntax-annotation);
  font-weight: bold;
}

.token.regex,
.token.important,
.token.variable {
	color: var(--color-syntax-variable)
}

.token.important,
.token.bold {
	font-weight: bold;
}
.token.italic {
	font-style: italic;
}

.token.entity {
	cursor: help;
}


/*** Story: Footnotes ***/

.story .footnote {
  font-style: italic;
  font-size: var(--marginal-font-size)
}

.story .footnote > em, .story .footnote > cite {
  font-style: normal;
}


/*** Story: Figures ***/

.story .figure {
  float:right;
  clear:right;
  margin: var(--marginalia-margin);
  /*padding: var(--marginalia-padding);*/   /* causes white bars to appear on .framed images; not necessary? */
  max-width: 40%;

  font-style: italic;
  font-size: var(--marginal-font-size);
}

.story .figure * {
  margin-top: 0;
}

.story .caption {
  font-style: italic;
  font-size: var(--marginal-font-size);
  margin-top: 0em;
}

.story .caption > em, .story .caption > cite {
  font-style: normal;
}

/* It'd be good to get rid of this class, or improve it, or something. There's a lot of captions related to it that don't look good at all. Maybe it's a figure? Maybe not. */
.story .framed {
	box-shadow: var(--image-shadow-light);
}


/*** Story: Postscript ***/

.story .postscript {
  margin-top: calc(var(--p-spacing) * 2);
  font-style: italic;
  font-size: var(--aside-font-size);
}

.story .postscript > em, .story .postscript > cite {
  font-style: normal;
}


/*** Story: Update ***/

.story .update {
  font-style: italic;
  font-size: var(--aside-font-size);
}

.story .update > em, .story .update > cite {
  font-style: normal;
}


/*** Story: Aside ***/

.story .aside {
  font-style: italic;
  font-size: var(--aside-font-size);
}

.story .aside > em, .story .aside > cite {
  font-style: normal;
}


/*** Story: Return to top ***/

.story .to-top {
  font-size: var(--aside-font-size);
}

.story .to-top::before {
  content: "⇪ ";
}


/*** Story: YouTube videos ***/

.story .youtube {   /* Makes YouTube player scale uniformly as space available changes */
  aspect-ratio: 16 / 9;
  height: 100%;
  width: 100%;
}

/* Padding around YouTube videos causes frame to look weird. There's probably something
else going on here that needs to be addressed in a better way. */
.story .youtube.figure.framed {
  padding: 0;
}


/*** Story: API docs ***/

.story details > summary {
  cursor: pointer;
}

.story details > *:not(summary) {
  margin-left: var(--indent);
}

.story details p {
  margin-top: var(--p-spacing-half);
}

.story details > summary + p {
  margin-top: var(--p-spacing-third);
}

.story details > :last-child {
  margin-bottom: var(--p-spacing);
}

.story details pre {
  margin-top: var(--p-spacing-half);
  margin-bottom: var(--p-spacing-half);
  margin-left: calc((var(--spacing-page-border)) * -1);   /* replace left margin, which doesn't scroll... */
  padding-left: calc((var(--spacing-page-border) + (var(--indent)) * 2)); /* ...with padding, which does */
}

.story ul.api {
  margin-top: var(--p-spacing-third);
  list-style: inside;
  padding-left: 0;
}


/*** Story: Course hints ***/

.story .course-hint {
  border-top: solid black 0.075rem;
  margin-bottom: var(--spacing-3x);
}

.story .course-hint details > * {
  margin-left: 0;
}

.story .course-hint > details > summary {
  line-height: 0.75;
}

.story .course-hint summary {
  margin-top: var(--p-spacing);
  list-style: none;
}

.story .course-hint details > summary::after {
  display: block;
  margin-top: var(--p-spacing-half);
  content: "⊕";
  font-family: var(--font-serif);
  font-size: var(--p-font-size);
}

.story .course-hint > details > summary::after {
  display: inline;
  padding-left: 1ch;
}

.story .course-hint details.course-hint__solution > summary::after {
  content: "⊛";
}

.story .course-hint details[open] > summary::after {
  content: "";
}

.story .course-hint > details > summary {
  font-family: var(--font-sans);
  font-size: 3em;
}

.story .course-hint details.course-hint__solution > * {
  margin-top: var(--p-spacing);
}

.story .course-hint details pre {
  margin-top: var(--p-spacing);
  margin-left: calc(var(--spacing-page-border) * -1);     /* replace left margin, which doesn't scroll... */
  padding-left: calc(var(--spacing-page-border));         /* ...with padding, which does */
}


/*** Story: Course solutions ***/

.story .course-solution summary {
  list-style: none;
  margin-bottom: var(--p-spacing);
}

.story .course-solution summary::after {
  display: block;
  content: "⊛";
  font-weight: var(--weight-normal);
}

.story .course-solution[open] summary::after {
  display: none;
}

.story .course-solution pre {
  margin-top: var(--p-spacing);
  margin-left: calc(var(--spacing-page-border) * -1);             /* replace left margin, which doesn't scroll... */
  padding-left: calc(var(--spacing-page-border) + var(--indent)); /* ...with padding, which does */
}



/*** BOOK (AoAD 1st ed.) ***/

/* Book: Chapter navigation */

.story .book_nav {
  margin-top: 3em;
  list-style-type: none;
  padding-left: 0;
  font-size: var(--aside-font-size);
  font-style: italic;
}


/* Book: "in 99 words" */

.story blockquote.ninetynine_words {
  margin-left: 0;
}


/* Book: "as haiku" */

.story blockquote.haiku {
  /* no special markup; uses blockquote */
}


/* Book: Goal */

.story .goal {
  font-style: italic;
}


/* Book: Audience, Allies (aka .practice) */

.story .audience, .story .practice {
  float: right;
  clear: right;

  margin: var(--marginalia-margin);
  padding: var(--marginalia-padding);
  padding-left: 1ch;
  padding-right: 1ch;
  width: max-content;

  font-size: var(--marginal-font-size);
  border: solid 1px var(--color-page-foreground);
  text-align: center;
}

.story .practice {
  margin-top: calc(var(--p-spacing) * 1.3);
}

.story .audience dt, .story .practice dt {
  text-align: center;
  font-weight: var(--weight-serif-bold);
  border-bottom: 1px solid var(--color-page-foreground);
  line-height: 1.4;
  margin-top: unset;
  padding-left: 4ch;
  padding-right: 4ch;
}

.story .audience dd, .story .practice dd {
  margin-left: 0;
  padding-left: 4ch;
  padding-right: 4ch;
}

.story .audience dd:first-of-type, .story .practice dd:first-of-type {
  padding-top: 0.3em;
}

.story .practice dd {
  margin-top: 0;
}


/* Book: Notetip */

.story blockquote.notetip  {
  font-size: var(--aside-font-size);
  margin-left: var(--indent);
  margin-right: var(--indent);
}

.story blockquote.notetip::before {
  display: block;
  content: "Note";
  margin-top: var(--p-spacing);
  font-style: italic;
  font-size: var(--aside-font-size);
  text-decoration: underline;
}

.story blockquote.notetip > *:first-child {
  margin-top: 0.3em;
}


/* Book: Questions (.faq) */

.story .faq {
  font-size: var(--p-font-size);
  font-style: italic;
  font-weight: normal;
  margin-top: var(--p-spacing);
}



/*** RESPONSIVE STORIES ***/

/* Small screen: turn off floats so figure flows vertically */
@media screen and (max-width: 650px) {
  .story .figure, .story .audience, .story .practice {
    float: unset;
    clear: unset;
    margin-top: var(--p-spacing);
    margin-left: 0;
    margin-right: 0;
  }

  /* Use entire width of screen */
  .story .figure {
    max-width: 100%;
  }

  /* Disable pullquotes entirely; they don't work if they're not set to the side */
  .story blockquote.pullquote, .story blockquote.coach {
    display: none;
  }

}

/* Large screen: put asides in right margin */
/* If you change min-width, be sure to update other uses of @media! */
@media (min-width: 1200px), print {

  /** Provide margin **/
  .story {
    --margin-width: 35vw;
    --margin-padding: 7vw;
  }
  .story__body {  /* Use .story__body instead of .story so title overlaps margin */
    margin-right: var(--margin-width);
  }

  /** Use margin; requires .story__body, which provides margin **/

  .story__body blockquote.pullquote, .story__body blockquote.coach, .story__body .footnote, .story__body ul.translations, .story__body .figure, .story__body .audience, .story__body .practice {
    float: right;
    clear: right;
    margin-right: var(--margin-right);
    width: var(--margin-usable-width);
  }

  /* Not entirely sure why this works, but without it, the figure won't be left-aligned. */
  .story__body .figure {
    max-width: unset;
  }

  /* Correct interaction that occurs when sidebar contains a figure. Without this line,
     the figure won't left-align with other marginalia.
   */
  .story .sidebar .figure {
    padding-left: var(--indent);
  }

  /* Allow site-notice to contain figures */
  .story__body .site-notice .figure {
    margin-right: calc(var(--margin-right) + var(--margin-width));
    padding-left: var(--margin-padding);
    max-width: var(--margin-width);
  }
}
