/* ============================================================
   The Sinatra Chronology — archival reading-room design
   Palette: vintage paper, ink navy, brass-gold accent
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Source+Serif+4:ital,wght@0,400;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --paper: #EFE7D6;
  --paper-raised: #F7F1E4;
  --ink: #201C16;
  --ink-soft: #4A4338;
  --rule: #D8CBAE;
  --navy: #1F3050;
  --navy-soft: #3A537C;
  --gold: #9C7A32;
  --gold-bright: #C79A3E;
  --sidebar-bg: #1B2233;
  --sidebar-text: #D9DEE8;
  --sidebar-muted: #8892A6;
  --sidebar-active: #C79A3E;
  --sidebar-width: 280px;
  --shadow: 0 8px 24px rgba(27, 22, 12, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Source Serif 4', Georgia, serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* ---------------- Sidebar ---------------- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 28px 22px 30px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: #333e54; border-radius: 4px; }

.sidebar-head { border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 20px; }

.brand {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  font-weight: 500;
  color: #F4EFE2;
  text-decoration: none;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.brand:hover { color: var(--gold-bright); }

.nav-group-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  margin-bottom: 10px;
}

.part-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 8px 10px;
  margin: 2px -10px;
  border-radius: 6px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.part-link:hover { background: rgba(199,154,62,0.12); color: var(--gold-bright); }

.part-link.active {
  background: rgba(199,154,62,0.16);
  color: var(--gold-bright);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--gold-bright);
}

.part-range {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--sidebar-muted);
}

.part-link.active .part-range { color: var(--gold-bright); opacity: 0.8; }

.year-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.year-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--sidebar-text);
  background: rgba(255,255,255,0.05);
  padding: 4px 9px;
  border-radius: 5px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.year-link:hover, .year-link.current {
  background: var(--gold-bright);
  color: #1B2233;
}

.year-link.section-jump {
  display: block;
  width: 100%;
  text-align: left;
  white-space: normal;
}

.global-search-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--sidebar-text);
  font-family: 'Source Serif 4', serif;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.global-search-btn:hover {
  background: rgba(199,154,62,0.14);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

.global-search-btn kbd {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  background: rgba(255,255,255,0.12);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--sidebar-muted);
}

.search-box {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.search-box input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: #F4EFE2;
  font-family: 'Source Serif 4', serif;
  font-size: 0.92rem;
}

.search-box input::placeholder { color: var(--sidebar-muted); }
.search-box input:focus { outline: 2px solid var(--gold-bright); outline-offset: 1px; }

.search-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--sidebar-muted);
  margin-top: 8px;
  min-height: 14px;
}

/* ---------------- Main content ---------------- */

.content {
  flex: 1;
  max-width: 900px;
  padding: 56px 64px 100px;
}

.content-header {
  margin-bottom: 44px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--ink);
}

.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}

.page-title {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 2.1rem;
  margin: 0;
  color: var(--ink);
}

.entry {
  padding: 28px 0;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 24px;
}

.entry:first-child { padding-top: 0; }

.entry h1,
.entry .entry-title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--navy);
  margin: 0 0 14px;
}

.entry h2,
.entry .entry-cat {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  background: var(--gold);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 3px;
  margin: 18px 10px 10px 0;
}

.entry .entry-cat.section-badge {
  background: var(--navy);
  margin: 0 0 14px;
}

.entry p {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 1rem;
}

.entry strong { color: var(--ink); }

.entry em { color: var(--navy-soft); }

.entry-img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: var(--shadow);
  margin: 10px 0;
  display: block;
  border: 1px solid var(--rule);
}

.entry.search-hidden { display: none; }

.part-pagination {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 2px solid var(--ink);
}

.pn-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  color: var(--navy);
  text-decoration: none;
  padding: 10px 16px;
  border: 1px solid var(--navy);
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.pn-link:hover { background: var(--navy); color: var(--paper-raised); }

/* ---------------- Sidebar toggle (mobile) ---------------- */

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 50;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: none;
  background: var(--sidebar-bg);
  color: #F4EFE2;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

@media (max-width: 880px) {
  .sidebar-toggle { display: block; }

  .sidebar {
    position: fixed;
    left: 0; top: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open { transform: translateX(0); }

  .content { padding: 80px 24px 60px; max-width: 100%; }

  .page-title { font-size: 1.6rem; }
}

/* ---------------- Global search modal ---------------- */

.gs-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 10, 0.55);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 20px 20px;
}

.gs-overlay.hidden { display: none; }

.gs-modal {
  width: 100%;
  max-width: 640px;
  background: var(--paper-raised);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 72vh;
  border: 1px solid var(--rule);
}

.gs-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--rule);
}

.gs-input-row input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'Source Serif 4', serif;
  font-size: 1.05rem;
  color: var(--ink);
  outline: none;
}

.gs-input-row input::placeholder { color: #A79E8C; }

.gs-esc {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
}

.gs-status {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--ink-soft);
  padding: 8px 18px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.gs-results {
  overflow-y: auto;
  padding: 6px;
}

.gs-result {
  display: block;
  text-decoration: none;
  padding: 12px 12px;
  border-radius: 8px;
  margin: 2px 0;
  transition: background 0.12s ease;
}

.gs-result:hover, .gs-result.active {
  background: rgba(156,122,50,0.12);
}

.gs-result-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}

.gs-result-date {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--navy);
}

.gs-result-part {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(156,122,50,0.12);
  padding: 2px 7px;
  border-radius: 4px;
}

.gs-result-snippet {
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

.gs-result-snippet mark {
  background: var(--gold-bright);
  color: #201C16;
  padding: 0 2px;
  border-radius: 2px;
}

.gs-empty {
  padding: 30px 18px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.92rem;
}
