/* Modern Blog Stylesheet */

/* chivo-regular - latin */
@font-face {
  font-display: swap;
  font-family: 'Chivo';
  font-style: normal;
  font-weight: 400;
  src: url('/assets/fonts/chivo-v21-latin-regular.woff2') format('woff2');
}
/* chivo-italic - latin */
@font-face {
  font-display: swap;
  font-family: 'Chivo';
  font-style: italic;
  font-weight: 400;
  src: url('/assets/fonts/chivo-v21-latin-italic.woff2') format('woff2');
}
/* chivo-700 - latin */
@font-face {
  font-display: swap;
  font-family: 'Chivo';
  font-style: normal;
  font-weight: 700;
  src: url('/assets/fonts/chivo-v21-latin-700.woff2') format('woff2');
}
/* chivo-700italic - latin */
@font-face {
  font-display: swap;
  font-family: 'Chivo';
  font-style: italic;
  font-weight: 700;
  src: url('/assets/fonts/chivo-v21-latin-700italic.woff2') format('woff2');
}

/* chivo-mono-regular - latin */
@font-face {
  font-display: swap;
  font-family: 'Chivo Mono';
  font-style: normal;
  font-weight: 400;
  src: url('/assets/fonts/chivo-mono-v11-latin-regular.woff2') format('woff2');
}
/* chivo-mono-italic - latin */
@font-face {
  font-display: swap;
  font-family: 'Chivo Mono';
  font-style: italic;
  font-weight: 400;
  src: url('/assets/fonts/chivo-mono-v11-latin-italic.woff2') format('woff2');
}
/* chivo-mono-700 - latin */
@font-face {
  font-display: swap;
  font-family: 'Chivo Mono';
  font-style: normal;
  font-weight: 700;
  src: url('/assets/fonts/chivo-mono-v11-latin-700.woff2') format('woff2');
}
/* chivo-mono-700italic - latin */
@font-face {
  font-display: swap;
  font-family: 'Chivo Mono';
  font-style: italic;
  font-weight: 700;
  src: url('/assets/fonts/chivo-mono-v11-latin-700italic.woff2') format('woff2');
}

:root {
  --bg-color: #ffffff;
  --text-color: #2c3e50;
  --accent-color: #3498db;
  --secondary-color: #95a5a6;
  --border-color: #ecf0f1;
  --code-bg: #f8f9fa;
  --max-width: 800px;
  --spacing: 2rem;
  
  /* Font stacks with fallbacks */
  --font-base: 'Chivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Chivo Mono', 'Monaco', 'Courier New', monospace;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --accent-color: #66b3ff;
    --secondary-color: #7f8c8d;
    --border-color: #2c2c2c;
    --code-bg: #2d2d2d;
  }
}

/* Base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-base);
  line-height: 1.7;
  color: var(--text-color);
  background-color: var(--bg-color);
  font-size: 18px;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

/* Navigation */
.site-nav {
  background-color: var(--bg-color);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.site-nav .container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

/* Site header - title and nav on same line */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 0;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--accent-color);
  text-decoration: none;
  font-family: var(--font-mono);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  font-family: var(--font-mono);
}

.nav-links a {
  color: var(--text-color);
  text-decoration: none;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--accent-color);
}

/* Tagline - on its own line below the header */
.site-tagline {
  padding-top: 0.5rem;
  font-style: italic;
  color: var(--secondary-color);
  font-size: 0.9rem;
  text-align: left;
  width: 100%;
}

/* Content */
#content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--spacing);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  line-height: 1.3;
  color: var(--text-color);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

.title {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.subtitle {
  color: var(--secondary-color);
  font-size: 1.2rem;
  margin-bottom: 2rem;
}

p {
  margin-bottom: 1rem;
}

a {
  color: var(--accent-color);
  text-decoration: none;
  transition: opacity 0.2s;
}

a:hover {
  opacity: 0.8;
}

/* Blog post metadata */
.post-meta {
  color: var(--secondary-color);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  font-family: var(--font-mono);
}

.post-separator {
  margin: 1rem 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

/* Lists */
ul, ol {
  margin: 1rem 0 1rem 2rem;
}

li {
  margin-bottom: 0.5rem;
}

/* Post list (sitemap) */
#content ul {
  list-style: none;
  margin-left: 0;
}

#content ul li {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

#content ul li:last-child {
  border-bottom: none;
}

#content ul li a {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-color);
}

#content ul li a:hover {
  color: var(--accent-color);
}

/* Code blocks */
pre {
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: var(--code-bg);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
}

pre code {
  background: none;
  padding: 0;
}

/* Blockquotes */
blockquote {
  border-left: 4px solid var(--accent-color);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  color: var(--secondary-color);
  font-style: italic;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

th, td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  background-color: var(--code-bg);
}

/* Newsletter subscribe box - improved styling */
.subscribe-box {
  background: linear-gradient(135deg, var(--accent-color) 0%, #2980b9 100%);
  color: white;
  padding: 2rem;
  border-radius: 8px;
  margin: 2rem auto;
  text-align: center;
  max-width: 600px;
}

.subscribe-box h3 {
  margin-top: 0;
  color: white;
  font-size: 1.5rem;
}

.subscribe-box p {
  margin-bottom: 1.5rem;
  opacity: 0.95;
}

/* Newsletter form styling - works everywhere */
.embeddable-buttondown-form {
  display: flex;
  gap: 0.75rem;
  max-width: 500px;
  margin: 0 auto;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
}

.embeddable-buttondown-form input[type="email"] {
  flex: 1;
  min-width: 200px;
  padding: 0.875rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background-color: white;
  color: #2c3e50;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s;
}

.embeddable-buttondown-form input[type="email"]:focus {
  outline: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.embeddable-buttondown-form input[type="email"]::placeholder {
  color: #95a5a6;
}

.embeddable-buttondown-form input[type="submit"] {
  padding: 0.875rem 2rem;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid white;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.embeddable-buttondown-form input[type="submit"]:hover {
  background-color: white;
  color: var(--accent-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.embeddable-buttondown-form input[type="submit"]:active {
  transform: translateY(0);
}

/* Post subscribe box (at bottom of posts) */
.post-subscribe {
  margin: 3rem 0 2rem 0;
  padding-top: 2rem;
  border-top: 2px solid var(--border-color);
}

.post-subscribe .subscribe-box {
  margin: 0 auto;
  max-width: 600px;
}

/* Ensure centering in post footer */
.post-footer .subscribe-box {
  max-width: 600px;
  margin: 0 auto 3rem auto;
}

/* Homepage specific styles */
.home-post {
  margin-bottom: 3rem;
}

.read-more {
  margin-top: 1.5rem;
  font-weight: 600;
}

.read-more a {
  color: var(--accent-color);
  text-decoration: none;
}

.read-more a:hover {
  text-decoration: underline;
}

.archive-links {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin: 3rem 0;
  flex-wrap: wrap;
}

.archive-link-button {
  color: var(--accent-color);
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  border: 2px solid var(--accent-color);
  border-radius: 4px;
  display: inline-block;
  transition: all 0.2s;
  font-weight: 600;
  font-size: 1.1rem;
}

.archive-link-button:hover {
  background-color: var(--accent-color);
  color: var(--bg-color);
}

/* Tag styling */
.post-tags {
  margin: 1rem 0;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.post-tag {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--secondary-color);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.2s;
  font-family: var(--font-mono);
}

.post-tag:hover {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

/* Tag cloud */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin: 2rem 0;
  padding: 2rem;
  background-color: var(--code-bg);
  border-radius: 8px;
}

.tag-cloud .tag {
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  background-color: var(--bg-color);
  border: 2px solid var(--border-color);
  color: var(--text-color);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.tag-cloud .tag:hover {
  border-color: var(--accent-color);
  background-color: var(--accent-color);
  color: white;
  transform: translateY(-2px);
}

.tag-cloud .tag-count {
  background-color: var(--secondary-color);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  font-size: 0.8em;
  font-weight: bold;
}

.tag-cloud .tag:hover .tag-count {
  background-color: rgba(255, 255, 255, 0.3);
}

/* Tag sizes for cloud */
.tag-cloud .tag-small { font-size: 0.9rem; }
.tag-cloud .tag-medium { font-size: 1rem; }
.tag-cloud .tag-large { font-size: 1.2rem; }
.tag-cloud .tag-x-large { font-size: 1.4rem; }
.tag-cloud .tag-xx-large { font-size: 1.6rem; font-weight: 600; }

/* Series notice styling */
.series-notice {
  background: #e8f4f8;
  border-left: 4px solid #4a90e2;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 4px;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.series-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.series-notice p {
  margin: 0;
  line-height: 1.6;
}

.series-notice a {
  color: #4a90e2;
  text-decoration: none;
  border-bottom: 1px solid #4a90e2;
}

.series-notice a:hover {
  border-bottom-color: #357abd;
  color: #357abd;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-color);
  margin-top: 4rem;
  padding: 2rem 0;
  text-align: center;
  color: var(--secondary-color);
  font-size: 0.9rem;
  font-family: var(--font-mono);
}

/* Responsive design - Mobile optimized */
@media (max-width: 768px) {
  body {
    font-size: 16px;
  }

  .title {
    font-size: 2rem;
  }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .nav-links {
    gap: 1rem;
  }

  #content {
    padding: 1rem;
  }

  .embeddable-buttondown-form {
    flex-direction: column;
  }

  .embeddable-buttondown-form input[type="email"],
  .embeddable-buttondown-form input[type="submit"] {
    width: 100%;
  }

  .subscribe-box {
    padding: 1.5rem;
  }

  .home-post {
    margin-bottom: 2rem;
  }

  .post-separator {
    margin: 2rem 0;
  }
}

/* Print styles */
@media print {
  .site-nav,
  .site-footer {
    display: none;
  }

  body {
    font-size: 12pt;
  }

  a {
    color: #000;
    text-decoration: underline;
  }
}

/* Image utilities - responsive */
.img-right {
  float: right;
  margin: 0 0 1rem 1rem;
  max-width: 250px;
  border-radius: 8px;
}

.img-left {
  float: left;
  margin: 0 1rem 1rem 0;
  max-width: 250px;
  border-radius: 8px;
}

.img-center {
  display: block;
  margin: 2rem auto;
  max-width: 600px;
  border-radius: 8px;
}

.img-full-width {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 2rem 0;
}

/* Mobile: all floated images become block */
@media (max-width: 768px) {
  .img-right,
  .img-left {
    float: none;
    display: block;
    margin: 1.5rem auto;
    max-width: 100%;
    width: 100%;
  }
}

/* Clear floats after images */
.clear {
  clear: both;
}

/* Responsive images */
article img {
  max-width: 100%;
  height: auto;
}

.footer-nav {
  text-align: center;
  padding: 2rem 0 1rem 0;
  border-top: 1px solid var(--border-color);
  margin-top: 2rem;
}

.footer-nav a {
  color: var(--text-color);
  text-decoration: none;
  margin: 0 1rem;
  transition: color 0.2s;
}

.footer-nav a:hover {
  color: var(--accent-color);
}

/* Search page styles */
#search-container {
  max-width: 600px;
  margin: 2rem auto;
}

#search-input {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 2rem;
}

#search-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.search-result {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
}

.search-result h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.search-result p {
  color: var(--secondary-color);
  margin: 0;
}

/* Post footer wrapper - constrain width */
.post-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

/* Comments section styling */
.comments-section {
  margin: 3rem 0 2rem 0;
  padding-top: 2rem;
  border-top: 2px solid var(--border-color);
}

.comments-section h3 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: var(--text-color);
  font-size: 1.5rem;
}

/* Cusdis widget container */
#cusdis_thread {
  margin-top: 1.5rem;
}

/* Style the Cusdis iframe when it loads */
#cusdis_thread iframe {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 100%;
  min-height: 400px;
}

/* Cusdis success message styling */
.cusdis-approve-message,
.cusdis-success-message,
[class*="cusdis"][class*="approve"] {
  background-color: #d4edda;
  border: 2px solid #28a745;
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1rem 0;
  text-align: center;
  color: #155724;
}

.cusdis-success-message p {
  margin: 0.5rem 0;
}

.cusdis-success-message strong {
  font-size: 1.1rem;
}

/* Dark mode comments */
@media (prefers-color-scheme: dark) {
  #cusdis_thread iframe {
    border-color: var(--border-color);
  }
  
  .cusdis-success-message {
    background-color: #1e4620;
    border-color: #28a745;
    color: #9fdf9f;
  }
}

/* Mobile responsive for newsletter and comments */
@media (max-width: 768px) {
  .embeddable-buttondown-form {
    flex-direction: column;
    gap: 0.75rem;
  }

  .embeddable-buttondown-form input[type="email"],
  .embeddable-buttondown-form input[type="submit"] {
    width: 100%;
    min-width: unset;
  }

  .subscribe-box {
    padding: 1.5rem;
  }

  .subscribe-box h3 {
    font-size: 1.3rem;
  }
  
  .comments-section {
    margin: 2rem auto 1.5rem auto;
    padding: 1.5rem 1rem 0 1rem;
  }
  
  .comments-section h3 {
    font-size: 1.3rem;
  }
}

/* Comment notice */
.comment-notice {
  background-color: var(--code-bg);
  border-left: 4px solid var(--accent-color);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--secondary-color);
  border-radius: 4px;
}

.post-footer .subscribe-box .embeddable-buttondown-form {
  margin-top: 2rem;
}

/* Figure and caption styles */
figure {
  margin: 0;
  padding: 0;
}

figure img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
}

figure.img-right {
  float: right;
  margin: 0 0 1rem 1rem;
  max-width: 350px;
}

figure.img-left {
  float: left;
  margin: 0 1rem 1rem 0;
  max-width: 350px;
}

figure.img-center {
  display: block;
  margin: 2rem auto;
  max-width: 600px;
}

figure.img-full-width {
  width: 100%;
  margin: 2rem 0;
}

figcaption {
  font-size: 0.9rem;
  color: var(--secondary-color);
  font-style: italic;
  text-align: center;
  padding: 0.5rem 0.5rem 0 0.5rem;
  line-height: 1.4;
}

/* Mobile: figures become block like images */
@media (max-width: 768px) {
  figure.img-right,
  figure.img-left {
    float: none;
    margin: 1.5rem auto;
    max-width: 100%;
    width: 100%;
  }
}

/* Footnote styling */
.footref {
  font-size: 0.8em;
  vertical-align: super;
  text-decoration: none;
  color: var(--accent-color);
  padding: 0 0.2em;
}

.footref:hover {
  text-decoration: underline;
}

/* Footnotes section - works for multiple posts */
#footnotes,
div[id^="footnotes"] {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid var(--border-color);
  font-size: 0.9rem;
}

#footnotes h2,
div[id^="footnotes"] h2 {
  font-size: 1.2rem;
  color: var(--secondary-color);
  margin-bottom: 1rem;
}

.footdef {
  margin-bottom: 1rem;
}

.footnum {
  display: inline-block;
  min-width: 2em;
  color: var(--accent-color);
  font-weight: 600;
}

.footpara {
  display: inline;
}

/* Back to text link */
.footdef a {
  margin-left: 0.5em;
  color: var(--secondary-color);
  text-decoration: none;
}

.footdef a:hover {
  color: var(--accent-color);
}

/* Add spacing between posts' footnote sections */
.home-post #footnotes {
  border-top: 1px solid var(--border-color);
}
