/* Typography + base tokens */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500;1,600&family=EB+Garamond:ital,wght@0,400;0,500;1,400&display=block");

:root {
  --bg: #fdfbf8;
  --bg-sidebar: #f7f5f0;
  --text: #1c1c1c;
  --text-light: #4a4a4a;
  --accent: #2c2c2c;
  --border: #e6e2da;
  --star-color: #333;

  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-serif: "Cormorant Garamond", serif;
  --font-body: "EB Garamond", "Cormorant Garamond", serif;

  --max-width: 1100px;
  --sidebar-width: 260px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  scrollbar-gutter: stable; /* Prevent layout shift when scrollbar appears */
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
}

/* Layout Shell */
.site {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 1fr auto; /* main fill, footer */
  min-height: 100vh;
  max-width: var(--max-width);
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 0 0 40px rgba(0,0,0,0.02);
}

/* Sidebar - The "Bookstore Counter" */
.site-sidebar {
  grid-column: 1;
  grid-row: 1 / -1; /* span all rows */
  padding: 60px 40px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background-color: var(--bg-sidebar);
  position: relative;
}

/* Decorative top line for sidebar */
.site-sidebar::before {
  content: "";
  position: absolute;
  top: 36px;
  left: 40px;
  right: 40px;
  height: 1px;
  background: var(--text);
  opacity: 0.1;
}

.site-sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.site-title-wrap {
  position: relative;
  text-align: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.site-title-wrap::after {
  content: "✦";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-sidebar);
  padding: 0 8px;
  font-size: 14px;
  color: var(--text-light);
  pointer-events: none; /* Allow clicks to pass through the star */
}

.site-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.site-tagline {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.6;
  font-weight: 400;
  text-align: left;
}

/* Navigation - "The Shelf" */
.site-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.site-nav a {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  text-decoration: none;
  color: var(--text-light);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--text);
}

.site-nav a.active {
  font-weight: 500;
}

/* Sidebar Spines */
.spine-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: 12px;
  margin: 4px 0 8px;
  border-left: 1px solid rgba(0,0,0,0.1);
}

.spine-list a {
  font-family: var(--font-serif);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
  line-height: 1.3;
  color: var(--text-light);
  opacity: 0.7;
  transition: opacity 0.2s ease, color 0.2s ease;
  padding: 0;
}

.spine-list a:hover {
  opacity: 1;
  color: var(--text);
}

.spine-list a.active {
  opacity: 1;
  color: var(--text);
  font-weight: 500;
}

/* Disable the hover dash for spine items */
.spine-list a::before {
  display: none;
}

.site-sidebar-bottom {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 4px; /* Tighter spacing */
  padding: 32px 60px;
  width: 100%;
  max-width: 800px;
  box-sizing: border-box;
  align-items: center;
  text-align: center;
  margin: 0 auto;
}

.footer-copyright {
  font-family: var(--font-sans);
  font-size: 0.65rem; /* Slightly smaller */
  color: var(--text-light);
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.75rem;
  color: var(--text-light); /* Softer color */
  opacity: 0.6;
  line-height: 1.2;
}

.footer-quote::after {
  content: " ✧";
  opacity: 0.5;
}

/* Main Content - "The Reading Room" */
.site-main {
  grid-column: 2;
  grid-row: 1;
  padding: 60px 60px;
  max-width: 800px; /* Optimal reading width */
  animation: fadeIn 0.5s ease-out;
}

.section-label {
  display: none; /* Hide label for cleaner look */
}

/* Essays List */
.essay-list {
  display: flex;
  flex-direction: column;
}

.essay-list-item {
  position: relative;
  padding: 48px 0;
  border-top: 1px solid var(--border);
  transition: opacity 0.2s ease;
}

.essay-list-item:first-child {
  border-top: none;
  padding-top: 0;
}

.essay-list-item:hover {
  opacity: 0.8;
}

.essay-list-item a {
  text-decoration: none;
  color: inherit;
  display: block;
}

.note-meta {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-light);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.note-meta::before {
  content: "☾";
  font-size: 0.8em;
}

.essay-title {
  font-size: 1.8rem;
  font-weight: 400;
  margin: 0 0 12px;
  line-height: 1.2;
  transition: color 0.2s ease;
}

.essay-list-item a:hover .essay-title {
  color: var(--text-light);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.essay-excerpt {
  font-size: 1.1rem;
  color: var(--text-light);
  font-style: italic;
  font-weight: 300;
  margin: 0;
  max-width: 90%;
}

/* Single Essay / Page Content */
.essay-header {
  margin-bottom: 48px;
  text-align: center;
}

.essay-header .note-meta {
  justify-content: center;
}

.essay-header h1 {
  font-size: 2.5rem;
  font-weight: 400;
  margin: 16px 0;
  line-height: 1.1;
}

.essay-subtitle {
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text-light);
  margin-top: 16px;
  font-weight: 300;
}

.essay-body, .about-body {
  font-size: 1.15rem;
  line-height: 1.6;
  font-weight: 400;
  color: #222;
}

.essay-body p, .about-body p {
  margin-bottom: 20px;
}

.essay-body .dropcap {
  float: left;
  font-family: var(--font-serif);
  font-size: 3.8rem;
  line-height: 0.8;
  padding-right: 8px;
  padding-top: 4px;
  font-weight: 400;
  color: var(--text);
}

.about-body .intro-paragraph {
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 16px;
  font-family: var(--font-serif);
}

/* Links in body */
.essay-body a, .about-body a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: all 0.2s;
}

.essay-body a:hover, .about-body a:hover {
  background: #f0f0f0;
  text-decoration-color: var(--text);
}

hr {
  border: 0;
  height: 1px;
  background-image: linear-gradient(to right, transparent, var(--border), transparent);
  margin: 48px 0;
}

hr::after {
  content: "✧";
  display: block;
  text-align: center;
  margin-top: -10px; /* Half of height + font-size adjustment */
  color: var(--text-light);
  background: var(--bg);
  width: 20px;
  margin-left: auto;
  margin-right: auto;
}

/* Responsive */
@media (max-width: 900px) {
  html,
  body {
    height: auto;
  }

  .site {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    border: none;
  }
  
  .site-sidebar {
    width: 100%;
    padding: 40px 24px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    position: relative;
    height: auto;
  }

  .site-sidebar::before {
    display: none;
  }

  .site-title-wrap {
    padding-bottom: 16px;
  }

  .site-sidebar-top {
    gap: 24px;
    align-items: center;
    text-align: center;
  }
  
  .site-tagline {
    text-align: center;
    max-width: 100%;
  }

  .site-nav {
    flex-direction: row;
    justify-content: center;
    gap: 24px;
  }

  .spine-list {
    display: none;
  }

  .site-sidebar-bottom {
    order: 3;
    align-items: center;
    text-align: center;
    padding: 32px 24px;
    max-width: none;
    width: 100%;
    border-right: none;
  }

  .site-main {
    order: 2;
    padding: 40px 24px 120px 24px; /* Extra bottom padding to prevent mobile scroll snap */
  }
  
  .essay-title {
    font-size: 1.5rem;
  }
  
  .essay-header h1 {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .site-sidebar {
    padding: 32px 16px;
  }

  .site-main {
    padding: 32px 16px;
  }

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

  .site-tagline {
    font-size: 0.8rem;
  }

  .essay-title {
    font-size: 1.3rem;
  }

  .essay-header h1 {
    font-size: 1.7rem;
  }

  .essay-body, .about-body {
    font-size: 1.1rem;
  }

  .intro-paragraph {
    font-size: 1.25rem;
  }
  
  .essay-body .dropcap {
    font-size: 3rem;
  }
}

/* Markdown Content Styles */
.essay-body h1 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 400;
  margin: 0 0 32px 0;
  line-height: 1.2;
  text-align: left;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.essay-body h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 600;
  font-style: italic;
  margin: 32px 0 16px 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.essay-body h3 {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 32px 0 16px 0;
  color: var(--text-light);
}

.essay-body ul {
  padding-left: 20px;
  margin-bottom: 24px;
  list-style: none; /* Custom bullets */
}

.essay-body ol {
  padding-left: 20px;
  margin-bottom: 24px;
  /* Keep default decimal list-style */
}

.essay-body li {
  margin-bottom: 12px;
  position: relative;
  padding-left: 8px;
}

/* Only add the em-dash for unordered lists */
.essay-body ul li::before {
  content: "—";
  position: absolute;
  left: -20px;
  color: var(--text-light);
  font-size: 0.9em;
}

/* Media embeds */
.essay-body video,
.essay-body img,
.about-body video,
.about-body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 32px 0;
  display: block;
}

/* Code blocks */
pre {
  background: var(--bg-sidebar);
  padding: 16px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  margin: 24px 0;
}

code {
  font-family: var(--font-sans);
  background: rgba(0,0,0,0.05);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}
