/* Quattrocento, after Digital Dante: a black masthead, then on the parchment
   Pinturicchio's frescoes from the Borgia Apartments, each with its section's blackletter title and
   ruled grid of links laid over it. */

@font-face {
  font-family: "Quattrocento";
  src: url("/fonts/quattrocento-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Quattrocento";
  src: url("/fonts/quattrocento-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "UnifrakturMaguntia";
  src: url("/fonts/unifrakturmaguntia-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #1d1a16;
  --ink-soft: #4a4136;
  --night: #000;
  --charcoal-footer: #333;
  --charcoal-tagline: #222;
  --parchment: #eeddc4;
  --charcoal: #2c2b29;
  --printers-ink: #3a2619;
  /* Type laid on the frescoes: a hard one-pixel shadow as on Digital Dante, plus a tight dark halo. */
  --type-shadow: 1px 1px 0 #000, 0 0 3px rgb(0 0 0 / 0.9), 0 0 10px rgb(0 0 0 / 0.6);
  --type-shadow-strong: 1px 1px 0 #000, 2px 2px 0 rgb(0 0 0 / 0.6), 0 0 4px #000, 0 0 16px rgb(0 0 0 / 0.75);
  --overlay-rule: rgb(255 255 255 / 0.8);
  --text: "Quattrocento", Georgia, "Times New Roman", serif;
  --blackletter: "UnifrakturMaguntia", "Quattrocento", Georgia, serif;
}

/* Light and dark. The tools' colours (forms, rules, notices) are variables so that dark mode only has to
   change them here. Dark: the same parchment under a deep, nearly neutral charcoal wash, for reading at night. It follows the
   system setting unless the theme button chose one: theme.js puts data-theme on <html> before the page
   draws, and remembers the choice for every page of the site. */
:root {
  --sheet: rgb(253 251 247 / 0.55);
  --page-wash: transparent;
  --rule: rgb(29 26 22 / 0.18);
  --rule-soft: rgb(29 26 22 / 0.1);
  --control: rgb(29 26 22 / 0.3);
  --hover: rgb(29 26 22 / 0.06);
  --page-shadow: 0 1px 3px rgb(29 26 22 / 0.25), 0 4px 14px rgb(29 26 22 / 0.12);
  --field-bg: rgb(255 255 255 / 0.55);
  --field-border: #8a7a63;
  --surface: rgb(255 255 255 / 0.45);
  --solid-bg: #222;
  --solid-fg: #fff;
  --solid-hover: #000;
  --chosen: #222;
  --tick-bg: rgb(255 255 255 / 0.85);
  --ok: #2f5a2a;
  --error: #6e1f12;
  --error-rule: #8b2a1a;
  --unsure: #a3610b;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e7e5e1;
  --ink-soft: #a4a19c;
  --sheet: rgb(20 20 21 / 0.92);
  --page-wash: rgb(20 20 21 / 0.92);
  --rule: rgb(255 255 255 / 0.14);
  --rule-soft: rgb(255 255 255 / 0.08);
  --control: rgb(255 255 255 / 0.28);
  --hover: rgb(255 255 255 / 0.08);
  --page-shadow: 0 1px 3px rgb(0 0 0 / 0.5), 0 6px 20px rgb(0 0 0 / 0.35);
  --field-bg: rgb(0 0 0 / 0.28);
  --field-border: rgb(255 255 255 / 0.28);
  --surface: rgb(255 255 255 / 0.06);
  --solid-bg: #e7e5e1;
  --solid-fg: #141414;
  --solid-hover: #fff;
  --chosen: #e7e5e1;
  --tick-bg: rgb(28 28 29 / 0.9);
  --ok: #a6d496;
  --error: #f2a896;
  --error-rule: #d0705c;
  --unsure: #e0a64f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #e7e5e1;
    --ink-soft: #a4a19c;
    --sheet: rgb(20 20 21 / 0.92);
    --page-wash: rgb(20 20 21 / 0.92);
    --rule: rgb(255 255 255 / 0.14);
    --rule-soft: rgb(255 255 255 / 0.08);
    --control: rgb(255 255 255 / 0.28);
    --hover: rgb(255 255 255 / 0.08);
    --page-shadow: 0 1px 3px rgb(0 0 0 / 0.5), 0 6px 20px rgb(0 0 0 / 0.35);
    --field-bg: rgb(0 0 0 / 0.28);
    --field-border: rgb(255 255 255 / 0.28);
    --surface: rgb(255 255 255 / 0.06);
    --solid-bg: #e7e5e1;
    --solid-fg: #141414;
    --solid-hover: #fff;
    --chosen: #e7e5e1;
    --tick-bg: rgb(28 28 29 / 0.9);
    --ok: #a6d496;
    --error: #f2a896;
    --error-rule: #d0705c;
  --unsure: #e0a64f;
  }
}

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

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Footer at the bottom of the window on short pages (credits, account). */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
}

body > main {
  flex: 1 0 auto;
  width: 100%; /* auto margins (centred pages) would otherwise shrink it to its content */
}

body {
  margin: 0;
  font-family: var(--text);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--parchment);
  /* A real leaf, tiled: the back flyleaf of Walters Art Museum MS W.658 (public domain), lighting
     flattened and made seamless. See README.md, "Design". */
  background-image: linear-gradient(var(--page-wash), var(--page-wash)), url("/img/parchment.jpg");
  background-size: auto, 800px 800px;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* Masthead */

.masthead {
  background: var(--night);
  color: #fff;
  text-align: center;
}

.wordmark {
  display: inline-block;
  padding: 1.25rem 1rem 1.1rem;
  font-family: var(--blackletter);
  font-size: clamp(2.6rem, 7vw, 3.5rem);
  line-height: 1;
  text-decoration: none;
}

/* As on Digital Dante: one black band, the wordmark and menu split by a white hairline. */
.masthead nav {
  border-top: 1px solid rgb(255 255 255 / 0.8);
}

.masthead ul {
  list-style: none;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 2.25rem;
}

.masthead nav a {
  display: block;
  padding: 0.75rem 0.1rem;
  text-decoration: none;
}

.masthead nav a:hover {
  text-decoration: underline;
  text-underline-offset: 0.3em;
  text-decoration-thickness: 1px;
}

/* Tagline: Digital Dante's charcoal strip under the header, shown only on wide windows. */
.tagline {
  display: none;
  background: var(--charcoal-tagline);
  color: #b6b6b6;
  padding: 9px 1rem;
  text-align: center;
}

.tagline p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.tagline small {
  font-size: 0.8em;
}

.tagline a {
  color: #fff;
  text-decoration: none;
}

.tagline a:hover {
  text-decoration: underline;
  text-underline-offset: 0.25em;
  text-decoration-thickness: 1px;
}

/* Wide windows, as on Digital Dante above 1035px: wordmark left and menu right in one black row, no
   hairline, and the tagline strip beneath. */
@media (min-width: 1036px) {
  .masthead {
    display: flex;
    align-items: center;
  }
  .wordmark {
    margin-left: 20px;
    padding: 0.9rem 10px 0.8rem;
    font-size: 2.6rem;
  }
  .masthead nav {
    flex: 1;
    border-top: 0;
    padding-right: 15px;
  }
  .masthead ul {
    justify-content: flex-end;
    column-gap: 1.5rem;
  }
  .tagline {
    display: block;
  }
}

/* Cover: on small screens (under 800px) the home page opens like Digital Dante's: a fresco filling the width, a
   300px black column over it with the wordmark and the menu, ruled with grey hairlines. It replaces
   the masthead and tagline on those screens. */
.cover {
  display: none;
}

@media (max-width: 799px) {
  .cover {
    display: block;
    min-height: 100vh;
    min-height: 100svh; /* fills the first screen */
    padding-bottom: clamp(9rem, 25vh, 22rem); /* the fresco shows below the column */
    /* Zoomed in a little and set to the lower right, on the three soldiers by the tomb. */
    background: #000 url("/img/resurrection.jpg") 86% 100% / auto 118% no-repeat;
  }
  .cover ~ .masthead,
  .cover ~ .tagline {
    display: none;
  }
}

.cover__menu {
  width: 300px;
  max-width: calc(100% - 2rem);
  margin: 0 auto;
  padding: 2.5rem 20px 20px;
  background: #000;
  color: #fff;
  text-align: center;
}

.cover__wordmark {
  display: block;
  font-family: var(--blackletter);
  /* "Quattrocento" is about 5 em wide in this face: scale it to the column (screen less 72px of
     margins and padding) so it never touches the edges, up to 2.9rem. */
  font-size: min(2.9rem, calc((100vw - 72px) / 5.6));
  white-space: nowrap;
  line-height: 1;
  text-decoration: none;
}

.cover__sub {
  margin: 0.6rem 0 1.75rem;
  font-size: 0.85rem;
  line-height: 1.35;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

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

.cover__menu li a {
  display: block;
  padding: 4px 8px;
  border-top: 1px solid #555;
  font-size: 1.15rem;
  line-height: 1.7;
  text-decoration: none;
}

.cover__menu li a:hover {
  background: #333;
}

.cover__menu li a span {
  display: block;
  padding-bottom: 6px;
  font-size: 0.9rem;
  line-height: 1.1;
  color: #b6b6b6;
}

/* Bands and plates. A band is a row of plates on the parchment; each plate is a fresco with its
   title and links laid straight on the picture, as on Digital Dante. No overlay or fade: the type
   carries its own shadow. A plate is never wider than its scan (--plate-max), so the small
   public-domain reproductions stay sharp. */

.band {
  max-width: 82rem;
  margin: clamp(1rem, 3vw, 2rem) auto 0;
  padding: 0 clamp(0.75rem, 3vw, 2rem);
}

.band--pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 3vw, 2rem);
  align-items: start;
}

.plate {
  max-width: var(--plate-max, 100%);
  margin: 0 auto;
  width: 100%;
}

.plate--disputation {
  --plate-max: 1243px;
  --plate-ratio: 1243 / 800;
  --plate-top: 15%;
}
.plate--grammar {
  --plate-max: 719px;
  --plate-ratio: 719 / 800;
  --plate-top: 12%;
}
.plate--rhetoric {
  --plate-max: 721px;
  --plate-ratio: 721 / 800;
  --plate-top: 12%;
}

.plate__picture {
  position: relative;
  isolation: isolate;
  aspect-ratio: var(--plate-ratio);
  padding: var(--plate-top) clamp(0.75rem, 3vw, 2rem) 1.5rem;
  color: #fff;
  text-align: center;
  /* Shown until the fresco loads, so the white type is never on parchment. */
  background: var(--charcoal);
}

/* Dim the fresco while it is being read: on hover, or when a link in it has keyboard focus. Touch
   screens can't hover, so there it stays a little dimmed. */
.plate__picture img {
  transition: filter 220ms ease;
}

.plate__picture:hover img,
.plate__picture:focus-within img {
  filter: brightness(0.55) saturate(0.85);
}

@media (hover: none) {
  .plate__picture img {
    filter: brightness(0.78);
  }
}

@media (prefers-reduced-motion: reduce) {
  .plate__picture img {
    transition: none;
  }
}

/* The printed frame. frames.js draws it at the picture's on-screen size, as four canvases (one per side)
   that it places itself; this plain rule is only the fallback when scripts don't run. */
.plate__picture::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 3px solid var(--printers-ink);
  pointer-events: none;
}

.plate__picture--drawn::after {
  content: none;
}

.plate__frame {
  position: absolute;
  pointer-events: none;
}

.plate__picture img {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.plate__title {
  margin: 0 0 0.9rem;
  font-family: var(--blackletter);
  font-weight: 400;
  font-size: clamp(2.5rem, 5.5vw, 3.6rem);
  line-height: 1;
  text-shadow: var(--type-shadow-strong);
}

.plate__grid {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 60rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: clamp(1rem, 3vw, 2.5rem);
  row-gap: 0.15rem;
}

.plate__grid a {
  display: block;
  padding: 0.55rem 0.4rem 0.6rem;
  font-size: 1.3rem;
  line-height: 1.2;
  text-decoration: none;
  text-shadow: var(--type-shadow);
}

.plate__grid a:hover {
  text-decoration: underline;
  text-underline-offset: 0.25em;
  text-decoration-thickness: 1px;
}

.plate__line {
  max-width: 24rem;
  margin: 0 auto;
  font-size: 1.25rem;
  line-height: 1.4;
  text-shadow: var(--type-shadow);
}

.plate__line a {
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

.plate__status {
  width: fit-content;
  margin: 1rem auto 0;
  padding: 0.3rem 0 0.35rem;
  border-top: 1px solid var(--overlay-rule);
  border-bottom: 1px solid var(--overlay-rule);
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-shadow: var(--type-shadow);
}

/* Room between the last fresco and the footer. */
main {
  padding-bottom: clamp(1.5rem, 4vw, 3rem);
}

main.text-page {
  padding-bottom: 4rem;
}

/* Text pages (Credits) */

.text-page {
  max-width: 38rem;
  margin: 0 auto;
  padding: 3rem 1.25rem 4rem;
}

.text-page h1 {
  margin: 0 0 1.5rem;
  font-family: var(--blackletter);
  font-weight: 400;
  font-size: clamp(2.6rem, 6vw, 3.2rem);
  line-height: 1;
  text-align: center;
}

.text-page h2 {
  margin: 2.25rem 0 0.4rem;
  font-family: var(--blackletter);
  font-weight: 400;
  font-size: 1.75rem;
  line-height: 1.1;
}

.text-page p,
.text-page ul {
  margin: 0 0 0.75rem;
}

.text-page ul {
  padding-left: 1.2rem;
}

.text-page li + li {
  margin-top: 0.35rem;
}

.text-page a {
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

/* Colophon */

.colophon {
  background: var(--charcoal-footer);
  color: #b6b6b6;
  text-align: center;
  font-size: 0.9375rem;
  padding: 1.75rem 1.25rem 2rem;
}

.colophon p {
  margin: 0.25rem auto;
  max-width: 44rem;
}

.colophon a {
  color: #fff;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

@media (max-width: 52rem) {
  .band--pair {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 48rem) {
  .plate__grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .plate__grid a {
    font-size: 1.15rem;
  }
  .masthead ul {
    column-gap: 1.25rem;
  }
}

/* The theme button, at the end of each page's menu (the documents reader has it in its own bar). */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  color: #fff;
  background: transparent;
  border: 1px solid #666;
  border-radius: 2px;
  cursor: pointer;
}

.theme-toggle:hover {
  background: #000;
}

.theme-toggle svg {
  width: 1rem;
  height: 1rem;
}

.menu-theme {
  display: flex;
  align-items: center;
}

/* Text for screen readers only (the theme button's name). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* In the home page's cover menu the theme button is a row like the others: centred, under a hairline. */
.cover__menu .menu-theme {
  justify-content: center;
  padding: 8px;
  border-top: 1px solid #555;
}
