/* =============================================
   SsfPack — Modern Academic Site Stylesheet
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* --- CSS Variables --- */
:root {
  --green-dark:    #1a3328;
  --green-mid:     #2d5c45;
  --green-light:   #4a8c68;
  --green-pale:    #dceee5;
  --green-faint:   #f0f7f3;
  --bg:            #f8f7f3;
  --surface:       #ffffff;
  --text:          #1c1c1a;
  --text-muted:    #5a5a54;
  --text-light:    #8a8a82;
  --border:        #dddbd3;
  --border-light:  #eceae3;
  --radius:        6px;
  --shadow:        0 2px 12px rgba(26,51,40,0.08);
  --shadow-lg:     0 6px 30px rgba(26,51,40,0.12);
  --nav-height:    64px;
  --max-width:     860px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
}

/* --- Header / Site Banner --- */
.site-header {
  background: var(--green-dark);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: calc(var(--max-width) + 64px);
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 32px;
  height: var(--nav-height);
}

.site-logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
  border-bottom: none;
}

.site-logo span {
  color: var(--green-pale);
  opacity: 0.8;
}

.site-logo:hover,
.site-logo:hover span {
  color: #ffffff;
  border-bottom: none;
  opacity: 1;
}

/* --- Navigation --- */
.site-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

.site-nav a {
  display: inline-block;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  border-radius: var(--radius);
  border-bottom: none;
  transition: color 0.18s, background 0.18s;
}

.site-nav a:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.08);
}

.site-nav a.active {
  color: #ffffff;
  background: rgba(255,255,255,0.13);
}

/* --- Page Layout --- */
.page-wrap {
  max-width: calc(var(--max-width) + 64px);
  margin: 0 auto;
  padding: 40px 32px 40px;
}

/* --- Page Hero (homepage) --- */
.page-hero {
  background: var(--green-dark);
  padding: 40px 32px 36px;
  margin-bottom: 0;
}

.page-hero-inner {
  max-width: calc(var(--max-width) + 64px);
  margin: 0 auto;
}

.page-hero h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.8rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.page-hero p {
  font-size: 1.05rem;
  color: var(--green-pale);
  max-width: 580px;
  line-height: 1.65;
  opacity: 0.85;
}

/* --- Section Headings --- */
h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--green-dark);
  letter-spacing: -0.01em;
  margin-top: 52px;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1.5px solid var(--border);
}

h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 32px;
  margin-bottom: 10px;
}

h4 {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--green-mid);
  margin-top: 28px;
  margin-bottom: 12px;
}

/* --- Book author subtitle --- */
.book-author {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-style: italic;
  margin-top: -4px;
  margin-bottom: 8px;
}

/* --- Body Text --- */
p {
  margin-bottom: 1.1em;
  color: var(--text);
}

p + p { margin-top: 0; }

/* --- Links --- */
a {
  color: var(--green-mid);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

a:hover {
  color: var(--green-dark);
  border-bottom-color: var(--green-light);
}

/* --- Author List (dl/dt/dd) --- */
dl {
  display: grid;
  gap: 28px;
  margin-top: 8px;
}

dt {
  font-weight: 600;
  font-size: 1rem;
  color: var(--green-dark);
  margin-bottom: 4px;
}

dt a {
  font-weight: 600;
  font-size: 1.05rem;
}

dd {
  padding-left: 0;
  margin-left: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* --- Author Cards --- */
.author-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 22px 26px;
  box-shadow: var(--shadow);
}

/* --- Span utilities --- */
span.title {
  font-style: italic;
  color: var(--text);
}

span.date {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--text-light);
  margin-left: 6px;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0 28px;
  font-size: 0.92rem;
}

table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
  color: var(--text);
}

table td:first-child {
  white-space: nowrap;
  color: var(--green-dark);
  font-weight: 500;
  width: 1%;
  padding-right: 24px;
}

table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--green-faint); }

/* --- Function tables (detail page) --- */
table code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85em;
  color: var(--green-dark);
  background: var(--green-faint);
  padding: 2px 6px;
  border-radius: 3px;
}

/* --- Lists --- */
ul, ol {
  padding-left: 1.5em;
  margin-bottom: 1.1em;
}

li {
  margin-bottom: 0.35em;
  line-height: 1.65;
}

ul li { color: var(--text); }
ul li::marker { color: var(--green-mid); }

/* News/changelog lists */
ul li span.date { display: inline; }

/* --- Code Blocks --- */
pre {
  background: var(--green-faint);
  color: var(--green-dark);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.65;
  padding: 22px 26px;
  border-radius: var(--radius);
  border-left: 3px solid var(--green-light);
  overflow-x: auto;
  margin: 18px 0 26px;
  position: relative;
}

code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.88em;
  color: var(--green-dark);
  background: var(--green-faint);
  padding: 2px 6px;
  border-radius: var(--radius);
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

/* BibTeX blocks — same style as code */
pre.bibtex {
  background: var(--green-faint);
  color: var(--green-dark);
  border-left: 3px solid var(--green-light);
}

/* Copy button */
.pre-wrap {
  position: relative;
  margin: 18px 0 26px;
}

.pre-wrap pre {
  margin: 0;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--green-pale);
  color: var(--green-dark);
  border: 1px solid var(--green-light);
  border-radius: var(--radius);
  padding: 3px 10px;
  font-size: 0.72rem;
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.copy-btn:hover {
  background: var(--green-light);
  color: #fff;
}

.copy-btn.copied {
  background: var(--green-mid);
  color: #fff;
}

/* --- Book pages: book image floats --- */
img.book {
  float: right;
  width: 110px;
  margin: 0 0 20px 28px;
  border-radius: 3px;
  box-shadow: var(--shadow-lg);
}

img.doc {
  float: right;
  width: 78px;
  margin: 0 0 16px 24px;
  border-radius: 3px;
  box-shadow: var(--shadow);
}

/* --- HR on book review pages --- */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* --- Blockquotes (reviews) --- */
q, blockquote {
  display: block;
  font-style: italic;
  color: var(--text-muted);
  border-left: 3px solid var(--green-light);
  padding: 10px 18px;
  margin: 16px 0;
  font-size: 0.95rem;
  line-height: 1.7;
  background: var(--green-faint);
  border-radius: var(--radius);
}

q::before, q::after { content: ''; }

/* --- Footer --- */
.site-footer {
  background: var(--green-dark);
  padding: 32px 32px;
  margin-top: 40px;
}

.footer-inner {
  max-width: calc(var(--max-width) + 64px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}

.footer-brand .logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.footer-brand p {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
  line-height: 1.5;
  margin: 0;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.footer-links span {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
  margin-right: 6px;
}

.footer-links a {
  display: inline-block;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.6);
  padding: 3px 10px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.footer-links a:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.06);
}

/* --- Responsive --- */
@media (max-width: 700px) {
  .header-inner {
    padding: 0 20px;
    gap: 16px;
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .site-nav {
    gap: 2px;
  }

  .site-nav a {
    padding: 5px 10px;
    font-size: 0.72rem;
  }

  .page-hero {
    padding: 40px 20px 36px;
  }

  .page-hero h1 { font-size: 2rem; }

  .page-wrap {
    padding: 40px 20px 60px;
  }

  .footer-inner {
    padding: 28px 20px;
    gap: 28px;
  }

  img.book, img.doc {
    float: none;
    display: block;
    margin: 0 0 20px;
  }
}
