/* Random Facts. Four page types: home, category, fact, other.
   Palette from the librarian: gold, green, ember, paper. */

:root {
  --gold: #eeb230;
  --green: #417600;
  --ember: #fc4911;
  --paper: #f8ecd4;
  --ink: #1c2614;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.5;
}

img { max-width: 100%; height: auto; }

#icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--gold);
  color: var(--green);
  padding: 0.5rem 1rem;
  z-index: 40;
  font-weight: 700;
}

.skip:focus { left: 0; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

::selection {
  background: var(--gold);
  color: var(--ink);
}

.wrap {
  width: min(980px, calc(100% - 2.5rem));
  margin-inline: auto;
}

.wrap-narrow {
  width: min(760px, calc(100% - 2.5rem));
  margin-inline: auto;
}

/* Header */
.site-header {
  background: var(--green);
  border-bottom: 4px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 20;
}

.nav {
  width: min(980px, calc(100% - 2.5rem));
  margin: 0 auto;
  min-height: 112px;
  padding: 0.7rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--paper);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1;
}

.brand img {
  width: 62px;
  height: auto;
  background: var(--green);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem 1.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-links a {
  color: var(--paper);
  text-decoration: none;
  font-weight: 700;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.nav-toggle {
  display: none;
  background: transparent;
  color: var(--paper);
  border: 2px solid var(--gold);
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* Hero (home and fact) */
.hero {
  background: var(--green);
  text-align: center;
  padding: 3.2rem 1.25rem 4rem;
}

.portrait {
  display: inline-block;
  line-height: 0;
  margin-bottom: 1.35rem;
}

.portrait img {
  display: block;
  width: 196px;
  height: auto;
  background: var(--green);
}

.hero h1,
.pagehead h1,
.masthead h1 {
  font-family: var(--serif);
  font-weight: 650;
  color: var(--paper);
}

.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.85rem);
  line-height: 1.22;
  max-width: 16em;
  margin: 0 auto;
}

.hero-by {
  margin: 1.05rem 0 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.hero-by a {
  color: var(--gold);
  text-decoration: none;
}

.hero-by a:hover { text-decoration: underline; }

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.4rem;
}

/* Bands */
.band { padding: 4.1rem 0; }

.band,
.hero,
.masthead,
.pagehead {
  scroll-margin-top: 8rem;
}

.home-intro {
  text-align: left;
  padding: 2.6rem 0 3rem;
}

.home-intro-row {
  width: min(980px, calc(100% - 2.5rem));
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2.4rem;
}

.home-logo {
  width: 300px;
  height: auto;
  flex: none;
  background: var(--green);
}

.home-intro-copy h1 {
  text-align: left;
  max-width: none;
  margin: 0 0 0.8rem;
}

.home-intro-copy .lede {
  text-align: left;
  margin: 0;
  max-width: 36rem;
  color: var(--paper);
}

.center-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.section-title {
  font-family: var(--serif);
  font-weight: 650;
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  color: var(--green);
  text-align: center;
  margin: 0 0 0.85rem;
}

.lede,
.today-date {
  max-width: 40rem;
  margin: 0 auto;
  text-align: center;
  font-family: var(--serif);
  font-size: 1.18rem;
  line-height: 1.6;
}

.today-date {
  font-family: var(--sans);
  margin-bottom: 1.2rem;
}

.center-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

.page-fact .portrait img { width: 150px; }
.page-fact .hero { padding-top: 2.4rem; padding-bottom: 3rem; }

.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.block-title {
  font-family: var(--serif);
  font-weight: 650;
  font-size: clamp(1.5rem, 2.5vw, 1.85rem);
  color: var(--green);
  margin: 0;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 2.2rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.stat { width: 132px; text-align: center; }

.stat-num {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 2.1rem;
  font-weight: 700;
  margin: 0 auto;
}

.stat-num.stat-word { font-size: 1.55rem; }

.stat-label {
  margin: 0.75rem 0 0;
  font-weight: 700;
  color: var(--green);
}

.band-count {
  background: #fff8ea;
  border-top: 4px solid var(--gold);
}

.band-today {
  background: var(--green);
  border-top: 4px solid var(--gold);
}

.band-today .section-title,
.band-today .today-date {
  color: var(--paper);
}

.band-today .button {
  background: var(--gold);
  color: var(--green);
  border-color: var(--gold);
}

.band-today .button:hover {
  background: var(--paper);
  color: var(--green);
  border-color: var(--paper);
}

/* Category grids */
.shelf-grid,
.keyword-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.shelf-card,
.keyword-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  background: var(--paper);
  border: 1px solid var(--gold);
  border-radius: 14px;
  text-decoration: none;
  color: var(--ember);
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(65, 118, 0, 0.08);
}

.shelf-card {
  padding: 1.35rem 1rem 1.15rem;
  font-size: 1.08rem;
}

.shelf-card span,
.keyword-card span {
  text-align: center;
  line-height: 1.25;
}

.keyword-card {
  min-height: 112px;
  padding: 0.9rem 0.75rem;
  font-size: 1.02rem;
}

.shelf-card:hover,
.keyword-card:hover {
  border-color: var(--ember);
  transform: translateY(-2px);
}

.grid-more { text-align: center; margin-top: 1.45rem; }

/* Buttons */
.button,
.button-ghost,
.button-gold {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.8rem 1.45rem;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid var(--green);
}

.button {
  background: var(--green);
  color: var(--paper);
}

.button:hover {
  background: var(--gold);
  color: var(--green);
  border-color: var(--gold);
}

.button-ghost {
  background: transparent;
  color: var(--ember);
  border-color: var(--ember);
}

.button-ghost:hover {
  background: var(--ember);
  color: var(--paper);
}

.button-gold {
  background: var(--gold);
  color: var(--green);
  border-color: var(--gold);
}

.button-gold:hover {
  background: var(--paper);
  color: var(--green);
}

.hero .button-ghost {
  color: var(--paper);
  border-color: var(--paper);
}

.hero .button-ghost:hover {
  background: var(--paper);
  color: var(--green);
  border-color: var(--paper);
}

/* Category masthead */
.masthead {
  background: var(--green);
  color: var(--paper);
  padding: 2.5rem 0;
}

.masthead-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.5rem;
  align-items: center;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0 0 0.55rem;
  padding: 0;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--paper);
}

.crumbs a {
  color: var(--gold);
  text-decoration: none;
}

.crumbs a:hover { text-decoration: underline; }

.crumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 0.35rem;
  color: var(--paper);
  font-weight: 400;
}

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

.masthead h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0 0 0.35rem;
  line-height: 1.05;
}

.masthead .lede {
  text-align: left;
  margin: 0;
  color: var(--paper);
  max-width: 36rem;
}

.masthead-count {
  margin: 0.7rem 0 0;
  color: var(--gold);
  font-family: var(--sans);
  font-weight: 700;
}

.masthead-librarian {
  width: 120px;
  height: auto;
  background: var(--green);
}

.shelf-list { padding: 2.4rem 0 4rem; }

.fact-card {
  background: var(--paper);
  border: 1px solid var(--gold);
  border-left: 6px solid var(--green);
  border-radius: 12px;
  padding: 1.2rem 1.35rem 1.05rem;
  margin: 0 0 1rem;
  box-shadow: 0 8px 20px rgba(65, 118, 0, 0.06);
}

.fact-card h2 {
  font-family: var(--serif);
  font-size: 1.45rem;
  line-height: 1.25;
  margin: 0 0 0.4rem;
}

.fact-card h2 a {
  color: var(--ember);
  text-decoration: none;
}

.fact-card h2 a:hover { text-decoration: underline; }

.fact-card p {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.55;
  margin: 0;
}

.fact-card .fact-text {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
}

.tag-list a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 0.2rem 0.7rem 0.2rem 0.3rem;
  color: var(--ember);
  text-decoration: none;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.92rem;
}

.tag-list a:hover { border-color: var(--ember); }

.empty-shelf {
  font-family: var(--serif);
  font-size: 1.2rem;
  text-align: center;
  margin: 1rem 0 0;
}

.related-queries {
  margin-top: 2.4rem;
}

.related-queries h2 {
  font-family: var(--serif);
  color: var(--green);
  font-size: 1.45rem;
  margin: 0 0 0.75rem;
}

.related-queries .tag-list a {
  padding: 0.35rem 0.85rem;
}

.more-facts {
  margin: 1.2rem 0 0;
  font-weight: 700;
}

.more-facts a {
  color: var(--ember);
}

/* Fact detail under the quote */
.fact-detail { padding: 2.5rem 0 4rem; }

.reference {
  font-weight: 700;
  color: var(--green);
  margin: 0 0 1rem;
}

.fact-body {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.6;
  margin: 0 0 1rem;
}

.detail-title {
  font-family: var(--serif);
  color: var(--green);
  font-size: 1.6rem;
  margin: 2rem 0 0.8rem;
}

/* Other pages: slim title band, narrow column */
.pagehead {
  background: var(--green);
  color: var(--paper);
  padding: 1.5rem 0;
}

.pagehead-row {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.pagehead img {
  width: 78px;
  height: auto;
  background: var(--green);
  flex: none;
}

.kicker {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  color: var(--gold);
  font-weight: 700;
  margin: 0 0 0.2rem;
}

.pagehead h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  margin: 0;
  line-height: 1.05;
}

.prose {
  width: min(42rem, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 2.4rem 0 4rem;
  font-family: var(--serif);
  font-size: 1.16rem;
  line-height: 1.65;
}

.prose h1,
.desk-title {
  font-family: var(--serif);
  font-weight: 650;
  color: var(--green);
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 1.05;
  margin: 0 0 0.85rem;
}

.prose h2 {
  font-family: var(--serif);
  color: var(--green);
  font-size: 1.55rem;
  margin: 2rem 0 0.55rem;
}

.prose a { color: var(--ember); }

.prose ul { padding-left: 1.2rem; }

.prose li { margin: 0.35rem 0; }

.prose .sitemap-list {
  list-style: none;
  padding: 0;
}

.sitemap-list a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--sans);
  font-weight: 700;
  text-decoration: none;
}

.sitemap-list a:hover { text-decoration: underline; }

.field { margin: 0 0 1rem; }

.field label {
  display: block;
  font-family: var(--sans);
  font-weight: 700;
  color: var(--green);
  margin-bottom: 0.3rem;
}

.field input,
.field textarea {
  width: 100%;
  background: var(--paper);
  border: 2px solid var(--green);
  color: var(--ink);
  font: inherit;
  font-family: var(--sans);
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
}

.field textarea { min-height: 7rem; resize: vertical; }

.optional {
  margin-left: 0.35rem;
  font-weight: 400;
  color: var(--ink);
}

.hp-field {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.field-error {
  color: var(--ember);
  font-family: var(--sans);
  font-size: 0.95rem;
  margin: 0.35rem 0 0;
}

.form-note {
  font-family: var(--sans);
  font-size: 0.98rem;
}

.icon { display: block; }
.icon-xl { width: 96px; height: 96px; }
.icon-lg { width: 72px; height: 72px; }
.icon-sm { width: 36px; height: 36px; }
.icon-xs { width: 22px; height: 22px; }

/* Footer */
.site-footer {
  background: var(--green);
  color: var(--paper);
  border-top: 4px solid var(--gold);
  padding: 2.8rem 0 1.4rem;
}

.footer-grid {
  width: min(980px, calc(100% - 2.5rem));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 1.8rem 2rem;
}

.site-footer h2 {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 650;
  color: var(--paper);
  margin: 0 0 0.85rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--gold);
  display: inline-block;
}

.site-footer p {
  margin: 0.55rem 0 0;
  max-width: 22rem;
  line-height: 1.5;
}

.site-footer a {
  color: var(--paper);
  text-decoration: none;
}

.site-footer a:hover { color: var(--gold); }

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

.site-footer li { margin: 0.4rem 0; }

.footer-base {
  width: min(980px, calc(100% - 2.5rem));
  margin: 1.8rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid rgba(248, 236, 212, 0.35);
  display: flex;
  justify-content: space-between;
  gap: 0.8rem 1.5rem;
  flex-wrap: wrap;
}

.footer-brand-row {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
}

.footer-brand-row img {
  width: 54px;
  height: auto;
  background: var(--green);
  flex: none;
}

@media (max-width: 800px) {
  .shelf-grid,
  .keyword-grid { grid-template-columns: 1fr 1fr; }

  .footer-grid { grid-template-columns: 1fr 1fr; }

  .masthead-row {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .masthead .lede { text-align: center; }
  .masthead .crumbs { justify-content: center; }
}

@media (max-width: 720px) {
  .nav { flex-wrap: wrap; padding: 0.75rem 0; }
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.2rem 0 0.6rem;
  }
  .nav-links.is-open { display: flex; }
  .nav-links a {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(248, 236, 212, 0.28);
  }
  .portrait img { width: 150px; }
  .hero { padding: 2.2rem 1rem 2.8rem; }
  .home-intro { padding: 1.8rem 0 2.2rem; }
  .home-intro-row {
    flex-direction: column;
    text-align: center;
    gap: 1.2rem;
  }
  .home-logo { width: min(220px, 70vw); }
  .home-intro-copy h1,
  .home-intro-copy .lede { text-align: center; }
  .band { padding: 2.8rem 0; }
}

@media (max-width: 520px) {
  .shelf-grid,
  .keyword-grid,
  .footer-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .shelf-card:hover,
  .keyword-card:hover { transform: none; }
}

.prose code {
  display: block;
  margin: 0.8rem 0 0;
  padding: 0.7rem 0.8rem;
  background: #fffdf6;
  border: 2px solid var(--gold);
  border-radius: 10px;
  color: var(--ink);
  font-size: 0.95rem;
  word-break: break-all;
}

.desk {
  width: min(1600px, calc(100% - 1.5rem));
  margin: 1.5rem auto 3rem;
}

.desk-who {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin: 0 0 1rem;
  color: var(--green);
  font-weight: 700;
}

.desk-who a { color: var(--ember); }

.desk-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.75rem;
}

.desk-bar label {
  font-weight: 700;
  color: var(--green);
}

.desk-bar input[type="search"] {
  flex: 1;
  min-width: 0;
  background: #fffdf6;
  border: 2px solid var(--green);
  color: var(--ink);
  font: inherit;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
}

.desk-count,
.desk-none { margin: 0 0 0.75rem; }

.desk-scroll {
  overflow-x: auto;
  border: 2px solid var(--gold);
  border-radius: 12px;
  background: #fffdf6;
}

.desk-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  line-height: 1.35;
}

.desk-table th {
  background: var(--green);
  color: var(--paper);
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
  padding: 0.55rem 0.7rem;
}

.desk-table td {
  vertical-align: top;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid rgba(238, 178, 48, 0.55);
  white-space: nowrap;
}

.desk-table td:nth-child(5),
.desk-table td:nth-child(6),
.desk-table td:nth-child(7),
.desk-table td:nth-child(11),
.desk-table td:nth-child(12),
.desk-table td:nth-child(13),
.desk-table td:nth-child(14) {
  white-space: normal;
  min-width: 12rem;
  max-width: 22rem;
  overflow-wrap: anywhere;
}

.desk-table tbody tr:hover td { background: rgba(238, 178, 48, 0.18); }

.desk-table tr[hidden] { display: none; }

.desk-table a { color: var(--ember); }

.desk-muted { color: #5c6b52; }

@media (max-width: 720px) {
  .desk-bar { flex-wrap: wrap; }
  .desk-bar input[type="search"] { flex-basis: 100%; }
  .desk-who { flex-direction: column; align-items: flex-start; }
}

.wiki-desk {
  margin: 0 0 2rem;
  padding-bottom: 1.4rem;
  border-bottom: 2px solid var(--gold);
}

.wiki-head {
  font-family: var(--serif);
  font-weight: 650;
  color: var(--green);
  font-size: 1.7rem;
  margin: 0 0 0.8rem;
}

.wiki-note {
  margin: 0 0 0.8rem;
}

.wiki-matches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 0.9rem;
}

.wiki-entity {
  margin: 0 0 0.8rem;
}

.wiki-entity a { color: var(--ember); }

.wiki-fact {
  border: 2px solid var(--gold);
  border-radius: 12px;
  background: #fffdf6;
  padding: 0.85rem 1rem 0.4rem;
  margin: 0 0 0.75rem;
}

.wiki-fact textarea { min-height: 4.5rem; }

.wiki-fact .button-ghost { margin: 0 0 0.8rem; }

.desk-count a { color: var(--ember); }

.wiki-use {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  color: var(--green);
  margin: 0 0 0.55rem;
}

.wiki-from {
  display: block;
  margin: -0.35rem 0 0.7rem;
  color: #5c6b52;
  font-size: 0.92rem;
}

.wiki-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.3rem 0 0.8rem;
}

@media (max-width: 720px) {
  .wiki-actions { flex-direction: column; align-items: stretch; }
}
