/* CASTLE Lab site — Direction C (Magazine Showcase)
   Walnut header + topnav, collapsible sidebar, card-based content. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #2b2419;
  background: #f5ecd6;  /* parchment */
}

a { color: #8a3a1a; text-decoration: none; }
a:hover { text-decoration: underline; }

img, video { max-width: 100%; height: auto; display: block; }

/* ============================================================
   Site header — walnut, topnav
   ============================================================ */
.site-header {
  background: #3d2914;
  color: #f5ecd6;
  border-bottom: 4px solid #c9621e;
}
.site-header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand-block { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.brand {
  color: #f5ecd6;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: "Georgia", serif;
  letter-spacing: 0.5px;
}
.brand:hover { color: #fff; text-decoration: none; }
.brand-sub { color: #d4b88a; font-size: 0.9rem; }

.topnav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.95rem;
}
.topnav a {
  color: #d4b88a;
  padding: 0.3rem 0;
  border-bottom: 2px solid transparent;
}
.topnav a:hover {
  color: #f5ecd6;
  border-bottom-color: #c9621e;
  text-decoration: none;
}

/* ============================================================
   Layout — sidebar + content
   ============================================================ */
.layout {
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2rem;
  padding: 1.5rem;
}

/* ============================================================
   Sidebar — walnut, collapsible sections
   ============================================================ */
.sidebar {
  background: #3d2914;
  color: #f5ecd6;
  padding: 1.25rem 1rem;
  border-radius: 6px;
  align-self: start;
  position: sticky;
  top: 1rem;
  /* Cap height to viewport so long expanded sections (e.g. Teaching
     materials) get an internal scrollbar instead of running off-screen.
     `1rem` top offset + `1rem` breathing room at bottom = `2rem` subtrahend. */
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  /* Themed scrollbar — Firefox */
  scrollbar-width: thin;
  scrollbar-color: #8a5a30 #3d2914;
}
/* Themed scrollbar — WebKit (Chrome, Edge, Safari) */
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: #3d2914; }
.sidebar::-webkit-scrollbar-thumb {
  background: #8a5a30;
  border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: #a06b3a; }
.sidebar details {
  border-bottom: 1px solid #5a3e1f;
  padding: 0.4rem 0;
}
.sidebar details:last-child { border-bottom: none; }
.sidebar summary {
  cursor: pointer;
  font-weight: 600;
  color: #f5ecd6;
  padding: 0.35rem 0.5rem;
  list-style: none;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar summary::after {
  content: "+";
  color: #d4b88a;
  font-weight: 400;
  font-size: 1.1rem;
}
.sidebar details[open] summary::after { content: "−"; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0.3rem 0 0.5rem;
}
.sidebar li a {
  display: block;
  padding: 0.35rem 0.75rem 0.35rem 1.25rem;
  color: #e0c896;
  border-radius: 3px;
  font-size: 0.9rem;
}
.sidebar li a:hover {
  background: #5a3e1f;
  color: #fff;
  text-decoration: none;
}

/* Sub-grouping label inside an items list (e.g. "Books", "Videos"
   inside the Teaching materials section). */
.sidebar li.sidebar-subheader {
  list-style: none;
  margin: 0.6rem 0 0.15rem;
  padding: 0 0.5rem;
  color: #ede0bd;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.sidebar details > ul > li.sidebar-subheader:first-child { margin-top: 0; }

/* Placeholder item for pages Warren hasn't built yet. */
.sidebar li .sidebar-placeholder {
  display: block;
  padding: 0.35rem 0.75rem 0.35rem 1.25rem;
  color: #8a7050;
  font-size: 0.9rem;
  font-style: italic;
  cursor: default;
  opacity: 0.6;
}

/* CTA-style standalone link (kept for future use; currently unused) */
.sidebar-cta {
  display: block;
  text-align: center;
  background: #c9621e;
  color: #fff !important;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.6rem 0.9rem;
  border-radius: 5px;
  margin-bottom: 1rem;
  text-decoration: none;
  border: 1px solid #a84d12;
}
.sidebar-cta:hover { background: #a84d12; text-decoration: none; color: #fff !important; }

/* Plain standalone sidebar link — looks like a section header but goes
   straight to the page rather than expanding a nested list. */
.sidebar-link {
  display: block;
  font-weight: 600;
  color: #f5ecd6;
  padding: 0.35rem 0.5rem;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  border-radius: 3px;
  border-bottom: 1px solid #5a3e1f;
  margin-bottom: 0.4rem;
  padding-bottom: 0.55rem;
}
.sidebar-link:hover {
  background: #5a3e1f;
  color: #fff;
  text-decoration: none;
}

/* ============================================================
   Main content
   ============================================================ */
.content { min-width: 0; }

.page-title {
  margin: 0 0 1.25rem;
  font-size: 2rem;
  font-weight: 700;
  color: #3d2914;
  font-family: "Georgia", serif;
  border-bottom: 2px solid #c9621e;
  padding-bottom: 0.4rem;
}

.content h1, .content h2, .content h3, .content h4 {
  color: #3d2914;
  line-height: 1.3;
  font-family: "Georgia", serif;
}
.content h2 { margin-top: 2rem; }
.content p { margin: 0 0 1rem; }
.content ul, .content ol { padding-left: 1.5rem; }

.content blockquote {
  border-left: 4px solid #c9621e;
  margin: 1rem 0;
  padding: 0.5rem 1.25rem;
  color: #5a4a35;
  background: #ede0bd;
}

.content code {
  background: #ede0bd;
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.92em;
}
.content pre {
  background: #1a1208;
  color: #f5ecd6;
  padding: 1rem;
  border-radius: 5px;
  overflow-x: auto;
}
.content pre code { background: transparent; padding: 0; color: inherit; }

/* WordPress-import normalizations carried forward */
.content [style*="font-size: small"] { font-size: inherit !important; }
.content [style*="font-size: xx-small"] { font-size: 0.85em !important; }
.content [style*="font-size: 12pt"] { font-size: inherit !important; }
.content [style*="font-size: 14pt"] { font-size: 1.1em !important; }
.content [style*="font-size: 16pt"] { font-size: 1.2em !important; }
.content [style*="font-size: 18pt"] { font-size: 1.3em !important; }
.content img[width] { max-width: 100%; height: auto; }

/* ============================================================
   Homepage — lab intro
   ============================================================ */
.home-intro {
  background: #ede0bd;
  border-left: 4px solid #c9621e;
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.home-intro-eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8a6a3a;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.home-intro-body {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.6;
  color: #3d2914;
  font-family: "Georgia", serif;
}
.home-intro-body strong { color: #3d2914; }

/* ============================================================
   Homepage components — featured + cards
   ============================================================ */
.featured {
  display: grid;
  grid-template-columns: 180px 1fr;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(60, 40, 20, 0.12);
  margin-bottom: 1.25rem;
}
.featured-img {
  display: block;
  background: #ede0bd;
  overflow: hidden;
}
.featured-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  min-height: 180px;
  max-height: 220px;
}
.featured-body {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.featured-body .kicker {
  display: inline-block;
  background: #c9621e;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.15rem 0.55rem;
  border-radius: 3px;
  margin-bottom: 0.5rem;
  width: fit-content;
}
.featured-body h2 {
  font-family: "Georgia", serif;
  font-size: 1.35rem;
  line-height: 1.2;
  color: #3d2914;
  margin: 0 0 0.4rem;
}
.featured-body h2 a { color: inherit; }
.featured-body h2 a:hover { color: #8a3a1a; text-decoration: none; }
.featured-body p {
  color: #4b3a25;
  margin: 0 0 0.6rem;
  font-size: 0.93rem;
  line-height: 1.5;
}
.featured-body .read-more {
  font-size: 0.82rem;
  font-weight: 600;
  color: #c9621e;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Section heading */
.section-h {
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid #c9621e;
  font-family: "Georgia", serif;
  font-size: 1.25rem;
  color: #3d2914;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Card grid (3-up) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}
.card {
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(60, 40, 20, 0.1);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(60, 40, 20, 0.18);
}
.card-img {
  display: block;
  height: 160px;
  overflow: hidden;
  background: #ede0bd;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-body {
  padding: 1rem 1.1rem 1.2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.card-body .kicker {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #8a6a3a;
  margin-bottom: 0.4rem;
}
.card-body h3 {
  font-family: "Georgia", serif;
  font-size: 1.1rem;
  line-height: 1.3;
  margin: 0 0 0.5rem;
  color: #3d2914;
}
.card-body h3 a { color: inherit; }
.card-body h3 a:hover { color: #8a3a1a; text-decoration: none; }
.card-body p {
  font-size: 0.9rem;
  color: #5a4a35;
  margin: 0 0 0.75rem;
  flex: 1;
}
.card-body .meta {
  font-size: 0.8rem;
  color: #8a6a3a;
}

/* Two-up cards (book listings — image on left, body right) */
.two-up {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}
.two-up .card { flex-direction: row; }
.two-up .card-img { flex: 0 0 130px; height: auto; }
.two-up .card-img img { object-fit: contain; padding: 0.75rem; background: #fff; }

/* Home prose section (body content from home.md) */
.home-prose {
  background: #fff;
  border-radius: 6px;
  padding: 1.5rem 1.75rem;
  margin-top: 1rem;
  border: 1px solid #e5d8b5;
}
.home-prose h2 {
  font-family: "Georgia", serif;
  color: #3d2914;
  margin-top: 0;
  font-size: 1.4rem;
  border-bottom: 1px solid #ede0bd;
  padding-bottom: 0.35rem;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  background: #1a1208;
  color: #d4b88a;
  text-align: center;
  padding: 1.5rem;
  font-size: 0.9rem;
  margin-top: 2.5rem;
}
.site-footer a { color: #e0c896; }
.site-footer p { margin: 0; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
  }
  .sidebar {
    position: static;
    /* Collapse all sections by default on mobile to save space */
    /* Reset desktop's viewport-cap so the sidebar flows naturally above
       the content on phones/tablets instead of having an internal scrollbar. */
    max-height: none;
    overflow-y: visible;
  }
  .featured { grid-template-columns: 1fr; }
  .featured-img img { min-height: 160px; max-height: 180px; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .two-up { grid-template-columns: 1fr; }
  .topnav { width: 100%; gap: 1rem; flex-wrap: wrap; }
}
@media (max-width: 600px) {
  .card-grid { grid-template-columns: 1fr; }
  .featured-body { padding: 0.9rem 1rem; }
  .featured-body h2 { font-size: 1.2rem; }
}
