/* =====================================================
   notes-bach.css — refined scholarly layout
   Work Sans body + Source Serif 4 headings
   Classic parchment tone
   ===================================================== */


/* --- Body with warm parchment tone --- */
body {
  font-family: "Work Sans", "Helvetica Neue", "Segoe UI", sans-serif;
  font-size: 1.08rem;
  line-height: 1.7;
  color: #222;
  background: #f9f7f2;
  background-image: radial-gradient(
    circle at 30% 20%,
    rgba(255, 255, 255, 0.6),
    rgba(0, 0, 0, 0.02) 80%
  );
  background-attachment: fixed;
  margin: 0;
  padding: 0;
}

/* --- Headings --- */
h1, h2, h3, h4 {
  font-family: "Source Serif 4", "Georgia", serif;
  color: #111;
  line-height: 1.25;
  margin-top: 1.6em;
  margin-bottom: 0.4em;
}

h1 {
  font-size: 1.9rem;
  margin-top: 0;
  letter-spacing: 0.01em;
}

h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }

/* --- Paragraphs and lists --- */
p, ul, ol {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}

/* --- Links --- */
a {
  color: #2f3d8f;
  text-decoration: none;
}
a:hover, a:focus {
  text-decoration: underline;
}

/* --- Header with banner image and navigation --- */
.site-header {
  text-align: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e0dccc;
  background: #f4f1ea;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.site-header .header-image img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 200px;
  object-fit: contain; /* keeps proportions */
  margin: 0 auto;
  filter: contrast(95%) brightness(102%) saturate(85%);
}

.site-nav {
  font-family: "Work Sans", "Helvetica Neue", sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  background: #f4f1ea;
  padding: 0.4rem 0.8rem;
}

.site-nav a {
  color: #503a2c;
  text-decoration: none;
  padding: 0 0.3rem;
}

.site-nav a:hover {
  text-decoration: underline;
}
html {
  scroll-behavior: auto;
}


/* ---------------------------------------------------------- */
/* Universal responsive grid for images, links, and text      */
/* ---------------------------------------------------------- */

.flex-table {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--cell-min, 220px), 1fr));
  gap: var(--cell-gap, 1.2rem);
  max-width: var(--grid-max, 900px);
  margin: 2rem auto;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
}

.flex-table-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: var(--cell-align, left);
  background: var(--cell-bg, #fff);
  padding: var(--cell-padding, 0.8rem);
  border-radius: var(--cell-radius, 8px);
  box-shadow: var(--cell-shadow, 0 1px 3px rgba(0,0,0,0.08));
  border: var(--cell-border, 1px solid rgba(0,0,0,0.06));
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.flex-table-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}

/* links inside grid items */
.flex-table-item a {
  color: var(--link-color, #004080);
  text-decoration: none;
  font-weight: 600;
}
.flex-table-item a:hover {
  text-decoration: underline;
}

/* images */
.flex-table-item img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  transition: transform 0.2s ease;
}
.flex-table-item img:hover {
  transform: scale(1.05);
}

/* captions or secondary text */
.flex-table-item figcaption,
.flex-table-item small {
  font-size: 0.9rem;
  color: #555;
  margin-top: 0.3rem;
}

/* multi-column flowing text (newspaper style) */
.flex-columns {
  columns: var(--columns, 2) 300px;
  column-gap: 1.5rem;
  max-width: var(--grid-max, 900px);
  margin: 2rem auto;
  font-family: system-ui, sans-serif;
  line-height: 1.6;
  position: relative;
}

/* subtle vertical divider between columns */
.flex-columns::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(0,0,0,0.08);
  transform: translateX(-50%);
  pointer-events: none;
}

/* responsive adjustments */
@media (max-width: 600px) {
  .flex-table {
    --cell-gap: 0.75rem;
  }
  .flex-table-item {
    padding: 0.6rem;
  }
  .flex-columns {
    columns: 1;
  }
  .flex-columns::before {
    display: none;
  }
}



/* --- Table of Contents --- */
.table-of-contents {
  background: #f4f1ea;
  border: 1px solid #ddd;
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}
.table-of-contents ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.table-of-contents li {
  margin: 0.25rem 0;
}
.table-of-contents li.sub {
  margin-left: 1rem;
}
.table-of-contents a {
  color: #2f3d8f;
  text-decoration: none;
}
.table-of-contents a:hover {
  text-decoration: underline;
}


/* --- Layout grid (main + sidebar) --- */
/* Default: 3.3 : 0.9 ratio (main : sidebar) */
.wrap {
  display: grid;
  grid-template-columns: 2fr 1fr; /* Force wide-notes layout */
  /*grid-template-columns: 3.3fr 0.9fr;*/
  gap: 2rem;
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  align-items: flex-start;
}

@media (max-width: 900px) {
  .wrap {
    display: block;
  }
}
/* --- Sidebar notes --- */
.aside-notes {
  position: sticky;
  top: 1rem;
  align-self: flex-start;
  max-height: calc(100vh - 2rem); /* slightly safer than height */
  overflow-y: auto;
  border-left: 1px solid #ddd;
  padding-left: 1rem;
  background: #f9f7f2;
  scrollbar-width: thin;
  scrollbar-color: #bbb #f9f7f2;
  font-size: 0.9rem;
  line-height: 1.55;
  transform: translateZ(0);
  scroll-behavior: smooth; /* nice, but not jumpy */
  overscroll-behavior: contain; /* prevents parent scroll chaining */
}

/* WebKit scrollbar refinements */
.aside-notes::-webkit-scrollbar {
  width: 6px;
}
.aside-notes::-webkit-scrollbar-thumb {
  background-color: #bbb;
  border-radius: 3px;
}
.aside-notes::-webkit-scrollbar-track {
  background: #f9f7f2;
}

/* Notes list */
.aside-notes ol {
  list-style: none;
  padding-left: 0;
  margin: 0;
  counter-reset: note;
}

/* Each note */
.aside-notes li {
  counter-increment: note;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: flex-start;
  gap: 0.4em;
  transition: background-color 0.6s ease, color 0.6s ease;
  scroll-margin-top: 0.8rem; /* small offset for smoother visibility logic */
}

.aside-notes li::before {
  content: "[" counter(note) "]";
  color: #555;
  font-size: 0.85rem;
  flex-shrink: 0;
  line-height: 1.4;
}

.aside-notes li.active {
  background-color: #f4f2ec;
  color: #222;
  box-shadow: 0 0 0.3rem rgba(0, 0, 0, 0.05);
  animation: fadeInNote 0.6s ease;
}

/* avoid outlines when clicked */
.aside-notes:focus,
.aside-notes *:focus {
  outline: none;
}

@keyframes fadeInNote {
  from {
    background-color: #ffffff;
    box-shadow: none;
  }
  to {
    background-color: #f4f2ec;
    box-shadow: 0 0 0.3rem rgba(0, 0, 0, 0.05);
  }
}

/* --- Images, figures, tables --- */
img, figure {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
}

figcaption {
  font-family: "Source Serif 4", "Georgia", serif;
  font-size: 0.9rem;
  color: #555;
  text-align: center;
  margin-top: 0.4rem;
}

/* --- Blockquotes --- */
blockquote {
  font-family: "Source Serif 4", "Georgia", serif;
  border-left: 3px solid #ddd;
  margin: 1.2rem 0;
  padding: 0.4rem 1rem;
  font-style: italic;
  color: #444;
  background: rgba(255, 255, 255, 0.4);
}

/* --- Footer --- */
footer {
  border-top: 1px solid #eee;
  margin-top: 3rem;
  padding: 1rem 2rem;
  font-size: 0.9rem;
  color: #666;
  text-align: center;
  background: #f4f1ea;
}

footer a {
  color: inherit;
  text-decoration: underline;
}

/* --- Responsive refinements --- */
@media (max-width: 700px) {
  body { font-size: 1rem; }
  .wrap { padding: 0 1rem; }
  h1 { font-size: 1.6rem; }
  .aside-notes {
    position: static;
    border-left: none;
    height: auto;
  }
}

/* --- Optional layout variants --- */
body.wide-notes .wrap {
  grid-template-columns: 2fr 1fr;
}
body.wide-notes .aside-notes {
  font-size: 0.92rem;
  line-height: 1.55;
}
/* =====================================================
   Optional layout: no sidebar (single-column article)
   ===================================================== */
body.no-sidebar .wrap {
  display: block;             /* disables grid layout */
  max-width: 800px;           /* readable line length */
  margin: 2rem auto;
  padding: 0 1.5rem;
}

body.no-sidebar .aside-notes {
  display: none;              /* hides sidebar entirely */
}

body.no-sidebar article {
  margin: 0 auto;
}