/* ===========================================================================
   Design tokens — most visual changes are one-line edits in here.
   =========================================================================== */
:root {
  /* layout */
  --max: 1140px;
  --gap: 1.25rem;
  --tile-w: 160px;       /* min width of a cover tile in the gallery grid */
  --heading-scale: 0.95; /* multiplies all heading sizes (dialed in via dev tool) */

  /* type — Caudex (headings) + Manrope (body), per design.md */
  --font: 'Manrope', sans-serif;         /* body */
  --font-heading: 'Caudex', sans-serif;
  --font-size: 16px;
  --line-height: 1.6;

  /* color — design.md palette */
  --bg: #fafafa;       /* background + card surfaces */
  --fg: #221300;       /* primary text / headings (darkest, not pure black) */
  --muted: #413a31;    /* secondary text / metadata */
  --line: #ead570;     /* borders / dividers */
  --primary: #fde047;  /* CTAs, active states, accents */
  --accent: #523e00;   /* hover / pressed / deep emphasis */

  /* badges */
  --badge-bg: #f4ecc6;
  --badge-fg: #413a31;
  --hl-bg: #fde047;
  --hl-fg: #221300;

  /* shape */
  --radius: 10px;
}

* { box-sizing: border-box; }
html { font-size: var(--font-size); }
body {
  margin: 0;
  padding: var(--gap);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 500;            /* Manrope medium */
  line-height: var(--line-height);
}
h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 700;            /* Caudex bold */
  letter-spacing: -0.01em;
}
a { color: inherit; }
img { max-width: 100%; height: auto; display: block; }

/* ===========================================================================
   Homepage — header + view toggle
   =========================================================================== */
.masthead { max-width: var(--max); margin: 0 auto 3rem; display: flex; align-items: center; }
.masthead .logo { display: inline-flex; line-height: 0; }
.masthead .logo img { width: 36px; height: 36px; }

.site-header { max-width: var(--max); margin: 0 auto 2.5rem; }
.site-header h1 { margin: 0; font-size: calc(3rem * var(--heading-scale)); }
.hero-sub { margin: .4rem 0 0; font-size: 1.15rem; }
.hero-intro { margin: 1rem 0 0; max-width: 62ch; color: var(--muted); line-height: 1.6; }

.toolbar { max-width: var(--max); margin: 0 auto 1.5rem; display: flex; justify-content: flex-end; }
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.view-toggle button {
  border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: .9rem; color: var(--muted);
  padding: .4rem 1rem;
}
.view-toggle button.is-active { background: var(--primary); color: var(--fg); }

/* ===========================================================================
   Year groups
   =========================================================================== */
.library { max-width: var(--max); margin: 0 auto; }
.year-group {
  display: grid;
  grid-template-columns: 150px 1fr; /* year gutter | cover + text */
  column-gap: 2rem;
  border-top: 1px solid var(--line);
  margin-top: 1.5rem;
  padding-top: 1.75rem;
}
.year-heading {
  grid-column: 1;
  margin: 0;
  font-size: calc(1.75rem * var(--heading-scale));
}
.cards, .rows { grid-column: 2; }

/* ===========================================================================
   Gallery view — cover tiles
   =========================================================================== */
.cards {
  list-style: none; padding: 0; margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-w), 1fr));
  gap: 1.75rem 1.25rem;
}
.card-link { display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.card-cover { width: 100%; }
.cover {
  width: 100%; aspect-ratio: 2 / 3; object-fit: cover;
  border-radius: 4px; background: #f1ead2; border: 1px solid rgba(34, 19, 0, .14);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card-link:hover .cover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(34, 19, 0, .18); }
.card-body { padding-top: .55rem; }
.card-title { margin: 0; font-size: calc(1rem * var(--heading-scale)); font-weight: 500; line-height: 1.3; }
.card-link:hover .card-title { text-decoration: underline; }
.card-title .medal {
  display: inline-block; height: 1.2em; width: auto;
  vertical-align: -.28em; margin-left: 5px;
  filter: drop-shadow(0 1px 1.5px rgba(34, 19, 0, .3));
}
.card-author {
  margin: .1rem 0 0; font-size: .8rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* badges (shared with book page) */
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin: .45rem 0 0; }
.badge {
  display: inline-flex; align-items: center;
  font-size: .72rem; padding: 2px 7px;
  border-radius: 6px; background: var(--badge-bg); color: var(--badge-fg);
}
.badge-hl { background: var(--hl-bg); color: var(--hl-fg); }
.badge-physical { background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* ===========================================================================
   Award medals (top three of a year)
   =========================================================================== */
.medal { display: block; }
.medal-ribbon-a { fill: var(--ribbon-a); }
.medal-ribbon-b { fill: var(--ribbon-b); }
.medal-edge { fill: var(--medal-edge); stroke: rgba(34, 19, 0, .25); stroke-width: .6; }
.medal-disc { fill: var(--medal-disc); }
.medal-star { fill: var(--medal-edge); opacity: .85; }
.medal-shine { fill: #fff; opacity: .35; }

.medal--gold   { --ribbon-a: #f59f00; --ribbon-b: #ffd43b; --medal-edge: #e8a200; --medal-disc: #ffd43b; }
.medal--silver { --ribbon-a: #adb5bd; --ribbon-b: #dee2e6; --medal-edge: #9aa0a6; --medal-disc: #e9ecef; }
.medal--bronze { --ribbon-a: #b06a35; --ribbon-b: #e8915b; --medal-edge: #a8612f; --medal-disc: #dd9b67; }

/* ===========================================================================
   Table view
   =========================================================================== */
.rows { width: 100%; border-collapse: collapse; font-size: .9rem; }
.rows th {
  text-align: left; font-weight: 500; color: var(--muted);
  padding: .5rem .6rem; border-bottom: 1px solid var(--line);
}
.rows td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
.rows tr:hover td { background: #f7f1d6; }
.r-title a { font-weight: 500; text-decoration: none; }
.r-title a:hover { text-decoration: underline; }
.r-medal { display: inline-block; vertical-align: -.28em; margin-left: .35rem; }
.r-medal .medal { display: inline-block; height: 1.2em; width: auto; filter: drop-shadow(0 1px 1.5px rgba(34, 19, 0, .3)); }
.r-author { color: var(--muted); }
.r-num { text-align: right; white-space: nowrap; }

/* view switching */
.view-gallery .rows { display: none; }
.view-table .cards { display: none; }

/* narrow screens: year stacks above its content */
@media (max-width: 760px) {
  .year-group { grid-template-columns: 1fr; }
  .year-heading { grid-column: 1; margin-bottom: 1rem; }
  .cards, .rows { grid-column: 1; }
}

/* ===========================================================================
   Book page
   =========================================================================== */
.book-page { max-width: 760px; margin: 0 auto; }
.back { margin: 0 0 1.25rem; }
.back a { color: var(--accent); text-decoration: none; }
.back a:hover { text-decoration: underline; }

/* Banner header: pale-gold band with the cover overlapping its bottom edge. */
.book-banner {
  background: #f4f3ef;            /* same as the highlight boxes */
  border: 1px solid #e9e6dd;
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 3rem;            /* leaves room for the overhanging cover */
  position: relative;
}

/* Award medal pinned to the banner's top-right corner, with a small caption. */
.banner-award {
  position: absolute; top: 1.1rem; right: 1.25rem;
  display: flex; flex-direction: column; align-items: center;
  gap: .15rem; text-align: center;
}
.banner-award .medal { filter: drop-shadow(0 3px 6px rgba(34, 19, 0, .3)); }
.banner-award-text {
  font-family: var(--font-heading); font-weight: 700;
  font-size: .85rem; line-height: 1.1; color: var(--fg);
}
.banner-award-text small {
  display: block; font-family: var(--font); font-weight: 500;
  font-size: .68rem; color: var(--muted);
}
.book-banner.has-medal .book-meta { padding-right: 4.5rem; }
@media (max-width: 560px) {
  .book-banner.has-medal .book-meta { padding-right: 3.25rem; }
  .banner-award .medal { width: 36px; height: 50px; }
  .banner-award-text { display: none; }
}
.book-banner-inner { display: flex; gap: 1.5rem; align-items: flex-end; }
.book-banner .cover {
  width: 132px; flex: none; border-radius: 6px;
  border: 1px solid rgba(34, 19, 0, .14);
  box-shadow: 0 8px 22px rgba(34, 19, 0, .22);
  margin-bottom: -3rem;           /* hang below the band */
}
.book-meta { flex: 1; min-width: 0; }
.book-title { margin: 0 0 .35rem; font-size: calc(2.25rem * var(--heading-scale)); line-height: 1.15; }
.book-author { color: var(--muted); margin: 0 0 .9rem; }
.book-banner .badges { margin: 0; }
.book-banner .badge { background: #fafafa; border: 1px solid var(--line); color: var(--fg); }

/* Highlights: each one a boxed pull-quote with a quote mark + left accent. */
.highlights h2 { font-size: calc(1.5rem * var(--heading-scale)); font-weight: 500; margin: 0 0 1.25rem; }
.highlights ul { list-style: none; padding: 0; margin: 0; }
.highlights li {
  background: #f4f3ef;
  border: 1px solid #e9e6dd;
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem 1.25rem 1rem;
  margin: 0 0 1rem;
}
.highlights li::before {
  content: "\201C";                      /* opening quote mark */
  display: block;
  font-family: var(--font-heading);
  font-size: 2.2rem;
  line-height: .9;
  color: var(--line);
  margin-bottom: .1rem;
}
.hl-text { margin: 0; line-height: 1.6; }
.hl-loc { margin: .65rem 0 0; font-size: .8rem; color: #9a948a; }
