/* ============================================================
   DIALECTICS — Main Stylesheet
   Aesthetic direction: Scholarly Archive
   A research notebook that ages well.
   ============================================================ */

/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,600;1,300;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables ── */
:root {
  --bg:            #f8f5ef;
  --bg-alt:        #f0ece2;
  --bg-code:       #edeae3;
  --text:          #1d1d1d;
  --text-muted:    #5c5c5c;
  --text-faint:    #8c8c8c;
  --accent:        #314e6e;
  --accent-light:  #e4ecf5;
  --accent-hover:  #203347;
  --link:          #1a4b7a;
  --link-visited:  #5a3a6e;
  --border:        #d8d2c5;
  --border-light:  #e8e3d9;

  --sidebar-w:     210px;
  --content-max:   680px;
  --gap:           3rem;

  --font-body: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-ui:   'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

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

/* ── Base ── */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-ui);
  line-height: 1.25;
  color: var(--text);
  margin-top: 2.2rem;
  margin-bottom: 0.6rem;
}

h1 { font-size: 2rem;   font-weight: 600; }
h2 { font-size: 1.35rem; font-weight: 600;
     border-bottom: 1px solid var(--border);
     padding-bottom: 0.3rem; }
h3 { font-size: 1.1rem;  font-weight: 600; }
h4 { font-size: 1rem;    font-weight: 600; color: var(--text-muted); }

p { margin-bottom: 1.25rem; }

strong { font-weight: 600; }
em     { font-style: italic; }

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.1s;
}
a:visited { color: var(--link-visited); }
a:hover   { color: var(--accent-hover); }

/* ── Block elements ── */
blockquote {
  margin: 1.75rem 0;
  padding: 0.6rem 1.5rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-alt);
  color: var(--text-muted);
  font-style: italic;
}
blockquote p:last-child { margin-bottom: 0; }

figure {
  margin: 2rem 0;
}
figcaption {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  text-align: center;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}
th {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--border);
}
td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

ul, ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}
li { margin-bottom: 0.25rem; }
li > ul, li > ol { margin-bottom: 0; margin-top: 0.25rem; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ── Code ── */
code {
  font-family: var(--font-mono);
  font-size: 0.83em;
  background: var(--bg-code);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--border-light);
}

pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.55;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}

/* ── Footnotes ── */
.footnotes {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.footnotes ol { margin: 0; padding-left: 1.5rem; }
.footnotes li { margin-bottom: 0.5rem; }
.footnote-backref { margin-left: 0.25rem; text-decoration: none; }

/* ── Math ── */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.25rem 0;
  margin: 1.5rem 0;
}

/* ── Site Header ── */
.site-header {
  border-bottom: 2px solid var(--text);
  padding: 1.25rem 2rem 0.9rem;
  background: var(--bg);
}

.site-header-inner {
  max-width: calc(var(--content-max) + var(--sidebar-w) + var(--gap) + 4rem);
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: 2.5rem;
  flex-wrap: wrap;
}

.site-title {
  font-family: var(--font-ui);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.site-title:visited { color: var(--text); }
.site-title:hover   { color: var(--accent); text-decoration: none; }

.site-nav {
  display: flex;
  gap: 1.6rem;
  flex-wrap: wrap;
  align-items: baseline;
}

.site-nav a {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-decoration: none;
}
.site-nav a:hover,
.site-nav a.active { color: var(--accent); }

/* ── Page Layout ── */
.site-container {
  max-width: calc(var(--content-max) + var(--sidebar-w) + var(--gap) + 4rem);
  margin: 0 auto;
  padding: 2.5rem 2rem;
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: var(--gap);
  align-items: start;
}

.site-main    { min-width: 0; }
.site-sidebar {
  position: sticky;
  top: 2rem;
  font-size: 0.855rem;
}

/* ── Sidebar ── */
.sidebar-section {
  margin-bottom: 2rem;
}

.sidebar-section h3 {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 0.55rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-section li {
  padding: 0.18rem 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.sidebar-section a {
  font-family: var(--font-ui);
  font-size: 0.855rem;
  color: var(--text-muted);
  text-decoration: none;
}
.sidebar-section a:hover { color: var(--accent); text-decoration: underline; }

.sidebar-count {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-faint);
  flex-shrink: 0;
}

.sidebar-search input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 0.35rem 0.6rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text);
  border-radius: 3px;
  outline: none;
}
.sidebar-search input:focus {
  border-color: var(--accent);
}

/* ── Homepage ── */
.home-intro {
  font-family: var(--font-ui);
  font-size: 0.93rem;
  color: var(--text-muted);
  line-height: 1.65;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.home-intro strong {
  color: var(--text);
  font-weight: 600;
}

.posts-list { margin-bottom: 1rem; }

.posts-year-label {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 1.75rem 0 0.6rem;
}

.post-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.42rem 0;
  border-bottom: 1px dotted var(--border-light);
}

.post-row-title a {
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}
.post-row-title a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.post-row-meta {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Article / Single ── */
.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.post-title {
  font-size: 2.1rem;
  font-weight: 600;
  margin-top: 0;
  line-height: 1.18;
  margin-bottom: 0.75rem;
}

.post-meta {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.post-summary {
  font-size: 1.05rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.8rem;
  line-height: 1.55;
}

/* Tags */
.post-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.75rem; }
.tag {
  font-family: var(--font-ui);
  font-size: 0.73rem;
  letter-spacing: 0.03em;
  color: var(--accent);
  background: var(--accent-light);
  padding: 0.2em 0.55em;
  border-radius: 2px;
  text-decoration: none;
  display: inline-block;
}
.tag:hover { background: var(--accent); color: #fff; }

/* ── Section List Pages ── */
.section-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.section-header h1 {
  margin-top: 0;
  margin-bottom: 0.4rem;
}

.section-desc {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}

/* ── Archive ── */
.archive-year {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin: 2rem 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border-light);
}

.archive-entry {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.38rem 0;
  border-bottom: 1px dotted var(--border-light);
}

.archive-entry-title a {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
}
.archive-entry-title a:hover { color: var(--accent); text-decoration: underline; }

.archive-entry-meta {
  font-family: var(--font-ui);
  font-size: 0.77rem;
  color: var(--text-faint);
  white-space: nowrap;
  flex-shrink: 0;
  text-align: right;
}

/* ── Citations / Bibliography ── */
.bibliography ol {
  list-style: decimal;
  padding-left: 2rem;
  margin: 0;
}

.bibliography li {
  margin-bottom: 1rem;
  font-size: 0.96rem;
  line-height: 1.55;
  padding-left: 0.25rem;
}

.bib-author { font-weight: 500; }
.bib-title  { font-style: italic; }
.bib-year   { color: var(--text-muted); }
.bib-pub    { color: var(--text-muted); font-size: 0.88rem; }
.bib-link   { font-family: var(--font-ui); font-size: 0.8rem; }

a.citation {
  font-family: var(--font-ui);
  font-size: 0.82em;
  color: var(--accent);
  text-decoration: none;
  vertical-align: super;
  font-weight: 600;
}
a.citation:hover { text-decoration: underline; }

/* ── Gallery ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.gallery-item { position: relative; overflow: hidden; }
.gallery-item img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--border);
  transition: opacity 0.2s;
}
.gallery-item:hover img { opacity: 0.9; }

.gallery-caption {
  font-family: var(--font-ui);
  font-size: 0.77rem;
  color: var(--text-faint);
  margin-top: 0.3rem;
  line-height: 1.4;
}

/* ── Search Page ── */
.search-container { max-width: var(--content-max); }
.search-input-wrap {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
}
#search-input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 0.6rem 0.9rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--text);
  border-radius: 3px;
  outline: none;
}
#search-input:focus { border-color: var(--accent); }

.search-results-list { list-style: none; padding: 0; }
.search-result {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border-light);
}
.search-result h3 {
  font-size: 1.05rem;
  margin: 0 0 0.3rem;
}
.search-result h3 a { text-decoration: none; color: var(--text); }
.search-result h3 a:hover { color: var(--accent); }
.search-result-excerpt {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-family: var(--font-ui);
  line-height: 1.5;
}
mark { background: #fff3b0; padding: 0 0.1em; }

/* ── Comments ── */
.comments-section {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 2px solid var(--border);
}

.comments-section > h2 {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  border: none;
  padding: 0;
  margin-top: 0;
  margin-bottom: 1.5rem;
}

/* Isso comment overrides */
#isso-thread .isso-comment-header { font-family: var(--font-ui); }
#isso-thread input, #isso-thread textarea {
  font-family: var(--font-body);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
}
#isso-thread .isso-submit-button {
  font-family: var(--font-ui);
  background: var(--accent);
  border: none;
  border-radius: 3px;
  color: #fff;
  cursor: pointer;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
}
#isso-thread .isso-submit-button:hover { background: var(--accent-hover); }

/* ── Comment Policy ── */
.comment-policy {
  background: var(--bg-alt);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.comment-policy summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

/* ── Site Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
  margin-top: 4rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-faint);
  text-align: center;
}
.site-footer a { color: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 820px) {
  .site-container {
    grid-template-columns: 1fr;
    padding: 1.75rem 1.25rem;
    gap: 2rem;
  }
  .site-sidebar { display: none; }
  .site-header { padding: 1rem 1.25rem; }
}

@media (max-width: 520px) {
  body { font-size: 17px; }
  .post-title { font-size: 1.6rem; }
  .site-nav { gap: 1rem; }
}

/* ── Print ── */
@media print {
  .site-header, .site-sidebar, .site-footer,
  .comments-section, .post-tags { display: none; }
  body { font-size: 11pt; color: #000; background: #fff; }
  a { color: #000; text-decoration: none; }
  .site-main { max-width: 100%; }
}
