@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=Lora:ital,wght@0,400;0,600;1,400&family=DM+Sans:wght@300;400;500&display=swap');

:root {
  --cream:      #FAF7F2;
  --cream-dark: #F0EBE0;
  --ink:        #1C1409;
  --ink-mid:    #3A2E1F;
  --muted:      #6B5F4E;
  --red:        #8B1A1A;
  --gold:       #C9943A;
  --border:     #D4C5A9;
  --font-headline: 'Playfair Display', Georgia, serif;
  --font-body:     'Lora', Georgia, serif;
  --font-ui:       'DM Sans', -apple-system, sans-serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--red); text-decoration: none; transition: color .2s; }
a:hover { color: var(--gold); }

img { max-width: 100%; display: block; }

/* ── MASTHEAD ─────────────────────────────────────── */
.masthead {
  background: var(--ink);
  color: #fff;
  padding: .75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--gold);
}
.masthead-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.masthead-logo {
  display: flex;
  align-items: center;
}
.masthead-logo-img {
  height: 50px;
  width: auto;
}
.masthead-nav { display: flex; gap: 1.5rem; align-items: center; }
.masthead-nav a {
  font-family: var(--font-ui);
  font-size: .85rem;
  font-weight: 500;
  color: rgba(255,255,255,.8);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.masthead-nav a:hover { color: var(--gold); }

/* Month dropdown */
.month-dropdown { position: relative; }
.month-dropdown-toggle { cursor: pointer; }
.month-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 4px;
  padding: .5rem 0;
  min-width: 160px;
  z-index: 200;
  /* Bridge the hover gap: invisible padding extends the hover zone upward */
  padding-top: calc(.5rem + 10px);
  margin-top: -10px;
  /* Smooth open/close with delay to survive quick cursor movements */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  transition-delay: 0.2s;  /* delay before closing */
  pointer-events: none;
}
.month-dropdown:hover .month-dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0.05s;  /* open quickly */
}
/* Mobile: tap to toggle via checkbox hack */
.month-dropdown-check { display: none; }
.month-dropdown-check:checked ~ .month-dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.month-dropdown-menu a {
  display: block;
  padding: .35rem 1rem;
  font-size: .8rem;
  color: rgba(255,255,255,.8);
  text-transform: none;
  letter-spacing: 0;
}
.month-dropdown-menu a:hover { background: rgba(255,255,255,.08); color: var(--gold); }

/* ── DAY NAV BAR ──────────────────────────────────── */
.day-nav {
  background: var(--ink);
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  padding: .5rem 1.5rem;
  font-family: var(--font-ui);
  font-size: .85rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.day-nav a {
  color: rgba(255,255,255,.7);
  font-weight: 500;
  letter-spacing: .03em;
}
.day-nav a:hover { color: var(--gold); }
.day-nav .current-label {
  color: var(--gold);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .8rem;
}

/* ── DATE HERO ────────────────────────────────────── */
.date-hero {
  text-align: center;
  padding: 3rem 1.5rem 2.5rem;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
}
.date-hero .month-label {
  font-family: var(--font-ui);
  font-size: .85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--red);
  margin-bottom: .25rem;
}
.date-hero .day-number {
  font-family: var(--font-headline);
  font-size: 7rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  margin-bottom: .5rem;
}
.date-hero .intro {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink-mid);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ── MAIN CONTENT GRID ────────────────────────────── */
.content-wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 3rem;
}

/* ── EVENT CARDS ──────────────────────────────────── */
.events-section h2 {
  font-family: var(--font-headline);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid var(--border);
  color: var(--ink);
}
.event-card {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.event-card:last-child { border-bottom: none; }
.event-year {
  font-family: var(--font-headline);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--red);
  line-height: 1.1;
  margin-bottom: .35rem;
}
.event-year.ancient { color: var(--gold); }
.event-badge {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: .65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: .2rem .6rem;
  border-radius: 3px;
  margin-bottom: .5rem;
}
/* Category badge colors */
.badge-politics    { color: #1B4F8A; background: #EEF3FA; }
.badge-war         { color: #5C4A2A; background: #F5F0E8; }
.badge-science     { color: #2D6A4F; background: #EEF7F2; }
.badge-space       { color: #2B2D7E; background: #EEEEF8; }
.badge-civil_rights{ color: #8B1A1A; background: #FAEAEA; }
.badge-exploration { color: #1A5C5C; background: #EEF5F5; }
.badge-disaster    { color: #6B2020; background: #FAF0F0; }
.badge-culture     { color: #6A1A6B; background: #F7EEFA; }
.badge-sports      { color: #C9520A; background: #FDF2EA; }
.badge-crime       { color: #4A4A4A; background: #F5F5F5; }
.badge-ancient     { color: #7A5C2A; background: #F5F0E8; }
.badge-invention   { color: #2A5C7A; background: #EEF3F8; }
.badge-religion    { color: #5C2A6A; background: #F5EEF8; }
.event-title {
  font-family: var(--font-headline);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: .4rem;
}
.event-desc {
  font-family: var(--font-body);
  font-size: .95rem;
  color: var(--ink-mid);
  line-height: 1.7;
}

/* ── RELATED VIEWING ─────────────────────────────── */
.related-viewing {
  margin-top: .75rem;
  border-left: 3px solid var(--gold);
  background: var(--cream-dark);
  border-radius: 0 4px 4px 0;
  padding: .6rem .85rem;
}
.related-viewing-link {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  text-decoration: none;
  color: inherit;
}
.related-viewing-link:hover .rv-title {
  color: var(--red);
}
.rv-icon {
  flex-shrink: 0;
  color: var(--gold);
  margin-top: 2px;
}
.rv-text {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.rv-title {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: .85rem;
  color: var(--ink);
  line-height: 1.3;
  transition: color .2s;
}
.rv-hook {
  font-family: var(--font-body);
  font-style: italic;
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.4;
}

/* ── RELATED READING (per-event books) ────────────── */
.related-reading {
  margin-top: .5rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.related-reading-link {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  text-decoration: none;
  color: inherit;
  border-left: 3px solid var(--navy);
  background: #f8f6f2;
  border-radius: 0 4px 4px 0;
  padding: .5rem .75rem;
}
.related-reading-link:hover .rb-title {
  color: var(--red);
}
.rb-icon {
  flex-shrink: 0;
  color: var(--navy);
  margin-top: 2px;
}
.rb-text {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.rb-title {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: .82rem;
  color: var(--ink);
  line-height: 1.3;
  transition: color .2s;
}
.rb-author {
  font-family: var(--font-body);
  font-size: .75rem;
  color: var(--muted);
}
.rb-hook {
  font-family: var(--font-body);
  font-style: italic;
  font-size: .75rem;
  color: var(--muted);
  line-height: 1.3;
}

/* ── SIDEBAR ──────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 2rem; }
.sidebar-section {
  background: var(--cream-dark);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
}
.sidebar-section h3 {
  font-family: var(--font-headline);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

/* Amazon product cards */
.product-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.product-card:last-of-type { border-bottom: none; }
.product-img {
  width: 80px;
  height: 120px;
  object-fit: contain;
  margin-bottom: .5rem;
  border-radius: 3px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.product-img-fallback {
  width: 80px;
  height: 120px;
  margin-bottom: .5rem;
  border-radius: 3px;
  background: linear-gradient(145deg, #3a2a1a, #5a3a2a);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .4rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.product-img-fallback span {
  font-family: var(--font-headline);
  font-size: .65rem;
  font-weight: 700;
  color: #d4a052;
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
}
.product-icon { font-size: 1.2rem; margin-bottom: .25rem; }
.product-title {
  font-family: var(--font-headline);
  font-size: .9rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}
.product-author {
  font-family: var(--font-ui);
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: .3rem;
}
.product-cta {
  font-family: var(--font-ui);
  font-size: .7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--red);
}
.product-card:hover .product-cta { color: var(--gold); }
.affiliate-notice {
  font-family: var(--font-ui);
  font-size: .7rem;
  color: var(--muted);
  margin-top: .75rem;
  line-height: 1.5;
  font-style: italic;
}

/* Browse month calendar in sidebar */
.month-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}
.month-cal-grid .day-label {
  font-family: var(--font-ui);
  font-size: .6rem;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: .25rem;
}
.month-cal-grid a {
  font-family: var(--font-ui);
  font-size: .75rem;
  color: var(--ink-mid);
  padding: .25rem;
  border-radius: 3px;
  display: block;
}
.month-cal-grid a:hover { background: var(--cream); color: var(--red); }
.month-cal-grid a.current {
  background: var(--red);
  color: #fff;
  font-weight: 500;
}

/* ── MONTH STRIP (BOTTOM) ─────────────────────────── */
.month-strip {
  max-width: 1140px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  border-top: 2px solid var(--border);
}
.month-strip h3 {
  font-family: var(--font-headline);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 1rem;
  text-align: center;
}
.month-strip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
}
.month-strip-grid a {
  font-family: var(--font-ui);
  font-size: .8rem;
  color: var(--ink-mid);
  padding: .35rem .7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all .2s;
}
.month-strip-grid a:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.month-strip-grid a.current {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  font-weight: 500;
}

/* ── FOOTER ───────────────────────────────────────── */
.footer {
  background: var(--ink);
  color: rgba(255,255,255,.6);
  padding: 2rem 1.5rem;
  text-align: center;
  font-family: var(--font-ui);
  font-size: .8rem;
  border-top: 3px solid var(--gold);
}
.footer a { color: var(--gold); }
.footer-links { margin-bottom: .5rem; }
.footer-links a { margin: 0 .75rem; }

/* ── HOMEPAGE ─────────────────────────────────────── */
.home-hero {
  text-align: center;
  padding: 4rem 1.5rem 3rem;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
}
.home-hero h1 {
  font-family: var(--font-headline);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .75rem;
}
.home-hero p {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink-mid);
  max-width: 600px;
  margin: 0 auto;
}
.featured-grid {
  max-width: 1140px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.featured-card {
  background: var(--cream-dark);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  transition: transform .2s, box-shadow .2s;
}
.featured-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.featured-card .fc-date {
  font-family: var(--font-ui);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--red);
  margin-bottom: .35rem;
}
.featured-card .fc-title {
  font-family: var(--font-headline);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .35rem;
}
.featured-card .fc-desc {
  font-family: var(--font-body);
  font-size: .85rem;
  color: var(--ink-mid);
  line-height: 1.6;
}

/* All months listing */
.months-grid {
  max-width: 1140px;
  margin: 2rem auto;
  padding: 0 1.5rem 3rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}
.month-card {
  background: var(--cream-dark);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
}
.month-card h3 {
  font-family: var(--font-headline);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .5rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}
.month-card-days {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.month-card-days a {
  font-family: var(--font-ui);
  font-size: .7rem;
  color: var(--ink-mid);
  padding: .2rem .4rem;
  border-radius: 2px;
}
.month-card-days a:hover { background: var(--red); color: #fff; }

/* ── PRIVACY PAGE ─────────────────────────────────── */
.prose {
  max-width: 760px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}
.prose h1 {
  font-family: var(--font-headline);
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--ink);
}
.prose h2 {
  font-family: var(--font-headline);
  font-size: 1.3rem;
  font-weight: 700;
  margin: 2rem 0 .75rem;
  color: var(--ink);
}
.prose p {
  margin-bottom: 1rem;
  color: var(--ink-mid);
}
.prose ul { margin: 0 0 1rem 1.5rem; color: var(--ink-mid); }
.prose li { margin-bottom: .4rem; }

/* ── EVENT IMAGES ────────────────────────────────── */
.event-image-wrap {
  margin: 0 0 .75rem;
  padding: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--cream-dark);
  border: 1px solid var(--border);
}
.event-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}
.event-image-wrap figcaption {
  padding: .35rem .6rem;
  font-size: .78rem;
  color: #666;
  line-height: 1.35;
  border-top: 1px solid var(--border);
  background: var(--cream-dark);
}

/* ── CROSS-DATE LINKS ────────────────────────────── */
a.date-crosslink {
  color: var(--red);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
a.date-crosslink:hover { color: var(--gold); text-decoration-style: solid; }

/* ── SEARCH TOGGLE ───────────────────────────────── */
.search-toggle-wrap { display: flex; align-items: center; }
.search-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  padding: .25rem;
  display: flex;
  align-items: center;
  transition: color .2s;
}
.search-toggle:hover { color: var(--gold); }

/* ── SEARCH OVERLAY ──────────────────────────────── */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 20, 9, .85);
  z-index: 300;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
}
.search-overlay.active { display: flex; }
.search-overlay-inner {
  width: 90%;
  max-width: 640px;
  background: var(--cream);
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
  overflow: hidden;
}
.search-form {
  display: flex;
  align-items: center;
  border-bottom: 2px solid var(--border);
}
.search-input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 1.1rem;
  padding: 1rem 1.25rem;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
}
.search-input::placeholder { color: var(--muted); }
.search-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--muted);
  cursor: pointer;
  padding: .5rem 1rem;
  transition: color .2s;
}
.search-close:hover { color: var(--red); }
.search-results {
  max-height: 55vh;
  overflow-y: auto;
}
.search-result-item {
  display: flex;
  flex-direction: column;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: background .15s;
}
.search-result-item:hover { background: var(--cream-dark); }
.sr-date {
  font-family: var(--font-ui);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--red);
  margin-bottom: .15rem;
}
.sr-title {
  font-family: var(--font-headline);
  font-size: .95rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}
.sr-snippet {
  font-family: var(--font-body);
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.5;
  margin-top: .15rem;
}
.search-no-results {
  padding: 1.5rem 1.25rem;
  font-family: var(--font-body);
  font-style: italic;
  color: var(--muted);
  text-align: center;
}

/* ── SEARCH PAGE ─────────────────────────────────── */
.search-page-form { margin-bottom: 1.5rem; }
.search-page-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1.15rem;
  padding: .85rem 1.25rem;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .2s;
}
.search-page-input:focus { border-color: var(--gold); }
.search-page-input::placeholder { color: var(--muted); }
.search-page-results { display: flex; flex-direction: column; gap: 1rem; }
.search-result-card {
  display: block;
  background: var(--cream-dark);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  text-decoration: none;
  transition: transform .15s, box-shadow .15s;
}
.search-result-card:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.08); }
.sr-card-date {
  font-family: var(--font-ui);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--red);
  margin-bottom: .25rem;
}
.sr-card-title {
  font-family: var(--font-headline);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: .25rem;
}
.sr-card-desc {
  font-family: var(--font-body);
  font-size: .85rem;
  color: var(--ink-mid);
  line-height: 1.6;
}

/* ── RESPONSIVE ───────────────────────────────────── */
@media (max-width: 900px) {
  .content-wrap {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .date-hero .day-number { font-size: 5rem; }
  .featured-grid { grid-template-columns: repeat(2, 1fr); }
  .months-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .masthead-inner { flex-direction: column; gap: .5rem; }
  .masthead-nav { gap: 1rem; }
  .day-nav { gap: 1rem; font-size: .75rem; }
  .date-hero .day-number { font-size: 4rem; }
  .date-hero { padding: 2rem 1rem 1.5rem; }
  .content-wrap { padding: 1.5rem 1rem; }
  .featured-grid { grid-template-columns: 1fr; }
  .months-grid { grid-template-columns: 1fr; }
  .event-title { font-size: 1.15rem; }
  .event-year { font-size: 1.8rem; }
  .home-hero h1 { font-size: 1.8rem; }
}
