/*
  Site-wide styles. Pages combine the small classes below; there is no other stylesheet.
  Sections: 1 base, 2 page frame, 3 components, 4-5 utilities, 6 small screens.
*/

/* ---- 1. Base ---- */

:root {
  --text: #300;
  --accent: #230960;
  --menu: #6c5598;
  --menu-hover: #0e7490;
  --page-width: 974px;

  /* Type scale: use these, never raw pixel sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.75rem;
}

body {
  margin: 0;
  background: #fff url("/images/background_gradient.jpg") repeat-x top fixed;
  color: var(--text);
  font:
    var(--text-base) / 1.5 georgia,
    serif;
  overflow-wrap: break-word;
}

a:hover {
  color: #c00;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--menu-hover);
  outline-offset: 2px;
}

img,
iframe,
pre {
  max-width: 100%;
}

img {
  height: auto;
}

pre {
  overflow-x: auto;
}

hr {
  height: 0;
  border: 0;
  border-top: 1px solid gray;
}

h1 {
  margin: 0;
  font: inherit;
}

h2,
h3 {
  margin: 1rem 0 0.5rem;
  font: inherit;
}

h1.inline {
  display: inline;
}

/* Skip link: hidden until it gets keyboard focus */
.skip-link {
  position: absolute;
  z-index: 10;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  background: #fff;
}

.visually-hidden,
.skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- 2. Page frame: header, hero images, main content, footer ---- */

.site-header,
.hero,
.page,
.site-footer {
  max-width: var(--page-width);
  margin-inline: auto;
}

.site-header img {
  display: block;
  width: 100%;
}

.site-header nav {
  background: var(--menu);
  border-bottom: 1px solid #000;
  font:
    bold var(--text-xs) verdana,
    sans-serif;
}

.site-header ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-header a {
  display: block;
  padding: 8px 10px;
  border-right: 1px solid #778;
  color: #fff;
  text-decoration: none;
}

.site-header a:hover,
.site-header a[aria-current="page"] {
  background: var(--menu-hover);
  color: #fff;
}

.hero {
  display: flex;
  align-items: flex-start;
}

.hero img {
  flex: 0 1 auto;
  min-width: 0;
}

.page {
  box-sizing: border-box;
  padding: 12px;
}

.site-footer {
  padding-bottom: 1em;
}

.site-footer hr {
  margin: 1em 0;
}

.site-footer div {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1em;
}

.site-footer img {
  width: auto;
  height: 60px;
  border: 0;
}

.site-footer img.small {
  height: 50px;
}

.site-footer img.bookshop {
  width: 100px;
  height: 32px;
}

/* ---- 3. Components ---- */

/* Book page: cover, details and blurb in a row; reviews full width below */
.book {
  display: grid;
  grid-template-columns: 200px minmax(0, 300px) minmax(0, 1fr);
  gap: 0 12px;
  align-items: start;
}

.book-cover {
  margin: 0;
  text-align: center;
}

.book-details,
.book-blurb {
  min-width: 0;
}

.book-reviews {
  grid-column: 1 / -1;
}

/* Side by side; wraps onto separate lines on narrow screens. .row-main takes the leftover width. */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}

.row > * {
  min-width: 0;
  max-width: 100%;
}

/* A fixed-width column that still shrinks on narrow screens */
.row-side {
  flex: 0 1 490px;
}

.row-main {
  flex: 1 1 300px;
}

/* A heading with a floated icon: the heading contains its icon, so the next item starts below it */
.notice {
  display: flow-root;
}

/* Photos with captions floated beside the text */
.sidebar {
  float: right;
  width: 300px;
  max-width: 40%;
  margin: 0 0 12px 16px;
}

.sidebar-left {
  float: left;
  margin: 0 16px 12px 0;
}

.sidebar figure,
.gallery figure {
  margin: 0 0 16px;
  text-align: center;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}

.poem {
  box-sizing: border-box;
  max-width: 550px;
  margin: 0 auto;
  padding: 10px;
  background: #b09682;
}

.poem pre {
  margin: 0;
  overflow-x: auto;
}

/* Cover links with captions on the purple panel */
.cover-grid {
  padding: 12px;
  background: #755699;
  color: #fff;
  text-align: center;
}

.cover-grid-heading {
  margin: 8px 0 24px;
  font:
    bold var(--text-xl) georgia,
    serif;
}

.cover-grid-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 24px 12px;
  align-items: start;
}

.cover-grid figure {
  margin: 0;
}

.cover-grid figcaption {
  margin-top: 12px;
  font:
    var(--text-sm) / 1.5 tahoma,
    verdana,
    sans-serif;
}

.thumbnails {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  text-align: center;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 6px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Home page welcome text; the signature photo has a paper background, so blend it into the page */
.welcome {
  max-width: 42rem;
  margin: 24px auto 0;
}

.signature {
  margin-left: 7rem;
  mix-blend-mode: multiply;
}

/* ---- 4. Utilities: text (sizes come from the scale at the top) ---- */

.ui {
  font-family: tahoma, verdana, sans-serif;
}

.rust {
  color: #943415;
  font-family: arial, sans-serif;
}

.black {
  color: #000;
}

.gold {
  color: #ffd700;
}

.purple {
  color: var(--accent);
}

.white {
  color: #fff;
}

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

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

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

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

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

.text-2xl {
  font-size: var(--text-2xl);
}

.text-3xl {
  font-size: var(--text-3xl);
}

.lh-1 {
  line-height: 1;
}

.lh-1-2 {
  line-height: 1.2;
}

.lh-2-5 {
  line-height: 2.5;
}

.bold {
  font-weight: bold;
}

.italic {
  font-style: italic;
}

.pre-wrap {
  white-space: pre-wrap;
}

/* ---- 5. Utilities: layout and decoration ---- */

.ta-center {
  text-align: center;
}

.ta-right {
  text-align: right;
}

.mx-auto {
  margin-inline: auto;
}

.float-left {
  float: left;
}

.float-right {
  float: right;
}

.m-0 {
  margin: 0;
}

.m-10 {
  margin: 10px;
}

.ml-10 {
  margin-left: 10px;
}

.p-5 {
  padding: 5px;
}

.p-10 {
  padding: 10px;
}

.pt-5 {
  padding-top: 5px;
}

.pt-20 {
  padding-top: 20px;
}

.pr-10 {
  padding-right: 10px;
}

.pr-20 {
  padding-right: 20px;
}

.pb-20 {
  padding-bottom: 20px;
}

.flex {
  display: flex;
}

.inline-block {
  display: inline-block;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.bg-tan {
  background: #b09682;
}

/* Darker link colors keep enough contrast on the tan background */
.bg-tan a:link {
  color: #00008b;
}

.bg-tan a:visited {
  color: #4b0082;
}

.bg-tan a:hover {
  color: #000;
}

.border-red {
  border: 1px solid #c03;
}

.shadow {
  box-shadow: 0 0 30px rgb(0 0 0 / 65%);
}

.bottom-shadow {
  box-shadow: 0 8px 6px -6px black;
}

/* ---- 6. Small screens ---- */

@media (width <= 700px) {
  .hero {
    flex-direction: column;
  }

  .hero img {
    width: 100%;
  }

  .book {
    grid-template-columns: minmax(0, 1fr);
  }

  .signature {
    margin-left: 2rem;
  }

  .sidebar,
  .sidebar-left,
  .float-left,
  .float-right {
    float: none;
    width: auto;
    max-width: none;
    margin: 0 0 12px;
  }
}
