/* ============================================
   Google Fonts Import
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&display=swap');

/* ============================================
   Theme — overrides rheobook package defaults
   ============================================ */
:root {
  --theme-color: #529a64;

  --background-color: #f9f6f0;
  --sidebar-bg: #f9f6f0;
  --wine-dark: #3d2645;
  --link-color: var(--theme-color);
  --quote-color: #888;
  --text-color: #333;
  --sidebar-width: 338px;
  --topbar-height: 40px;
  --arrow-bg: #f9f6f0;
  --arrow-color: #3d2645;
  --border-color: #3d2645;
  --sidebar-link-color: #555;
  --accent-color: var(--theme-color);
}

/* ============================================
   Base Styles
   ============================================ */
body {
  background-color: var(--background-color);
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

h3 {
  margin-bottom: 0;
}

ul, ol {
  padding: 0;
  margin: 0 1em;
}

a {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.3s ease;
}

a:hover {
  text-decoration-color: var(--link-color);
}

video {
  max-width: 100%;
}

svg.typst-frame {
  display: block;
  margin: 1em auto;
}

blockquote {
  position: relative;
  width: 100%;
  padding: 1rem 1rem 1rem 2rem;
  margin: 1.5rem 0;
  font-size: 1.1rem;
  background: #fff;
  color: var(--text-color);
  border-left: 2px solid var(--quote-color);
}

blockquote::before {
  content: "\201C";
  position: absolute;
  top: .2rem;
  left: .3rem;
  font-size: 2rem;
  color: var(--quote-color);
  line-height: 1;
}

section[role="doc-endnotes"] ol li a[role="doc-backlink"] {
  padding-right: 0.2em;
}

/* ============================================
   Code Blocks
   ============================================ */
pre {
  max-width: 100%;
  overflow-x: auto;
  margin: 1em 0;
}

code {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

pre code {
  display: block;
  white-space: pre-wrap;
  background-color: #fff;
  border: 1px solid var(--wine-dark);
  padding: 1rem;
  border-radius: 4px;
  word-break: break-word;
}

@media (max-width: 768px) {
  pre {
    overflow-x: visible;
  }

  pre code {
    white-space: pre-wrap;
    word-break: break-all;
  }
}

/* ============================================
   Content Layout
   ============================================ */
.content {
  padding: 0 1rem;
  counter-reset: question;
}

[role="doc-endnotes"] {
  padding: 0 max(2rem, calc((100vw - var(--sidebar-width) - 750px) / 2));
}

/* Tablet and up */
@media (min-width: 768px) {
  .content {
    padding: 2rem max(2rem, calc((100vw - var(--sidebar-width) - 750px) / 2)) 0;
  }

  blockquote {
    max-width: 24rem;
    padding: 1rem 1.5rem 1rem 2.5rem;
    margin: 2rem auto;
    font-size: 16pt;
  }

  blockquote::before {
    top: .4rem;
    left: .5rem;
    font-size: 2.5rem;
  }
}

/* Desktop: when sidebar is closed, center content */
@media (min-width: 769px) {
  .sidebar-closed ~ .content,
  .sidebar-closed ~ [role="doc-endnotes"] {
    padding-left: max(2rem, calc((100vw - 750px) / 2));
    padding-right: max(2rem, calc((100vw - 750px) / 2));
  }
}

/* ============================================
   Content Typography
   ============================================ */
.content p,
.content ol,
.content ul {
  line-height: 1.45em;
}

/* ============================================
   Discussion Questions
   ============================================ */
.question {
  counter-increment: question;
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  border-left: 3px solid var(--theme-color);
  background-color: #fff;
}

.question-header {
  font-weight: 600;
  color: var(--wine-dark);
  margin-bottom: 0.6rem;
  line-height: 1.4;
}

.question-header::before {
  content: counter(question, upper-roman) ". ";
  color: var(--theme-color);
}

.question-body {
  color: var(--text-color);
  line-height: 1.6;
}

/* ============================================
   Sidebar — compact spacing overrides
   ============================================ */
.sidebar-nav li {
  margin-bottom: 0;
}

.sidebar-nav li > p {
  margin: 0;
}

.sidebar-nav li.section-label {
  margin-top: 0.75rem;
  margin-bottom: 0;
  padding: 0.25rem 12px 0.15rem;
}

.sidebar-nav a {
  padding: 3px 12px;
}

.subsection-nav {
  padding-left: 16px;
  margin-top: -2px;
}

.subsection-nav a {
  padding: 1px 12px;
}

/* ============================================
   Work in Progress
   ============================================ */
.wip {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  border-left: 3px solid #e6a817;
  background-color: #fffbeb;
  color: var(--text-color);
  line-height: 1.6;
}

.wip::before {
  content: "Under construction";
  display: block;
  font-weight: 600;
  color: #7a5200;
  margin-bottom: 0.6rem;
}
