/* Common styles for ICARUS blog */

:root {
  --blue: #007f86;
  --icarus-blue: #1e40af;
  --icarus-orange: #f59e0b;
  --orange: #f59e0b;
  --red: #ef402c;
  --purple: #856ad1;
  --green: #8ac926;
  --gray-100: #f5f5f5;
  --gray-200: #e5e5e5;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* Advanced UI component variables */
  --bg_h: #faf9f5;
  --bg: #faf9f5;
  --bg_s: #f7f5f0;
  --bg_code: #f3f3f2;
  --bg1: #ebdbb2;
  --bg2: #d5c4a1;
  --bg3: #bdae93;
  --bg4: #a89984;
  --fg: #141414;
  --fg_code: #64a24e;
  --fg1: #1f1f1f;
  --fg2: #2f2b27;
  --fg3: #47413a;
  --fg4: #5b5750;
  --fg5: #7d7972;
  --red: #EF402C;
  --green: #9CC355;
  --yellow: #b57614;
  --blue: #0E9EE4;
  --purple: #8f3f71;
  --aqua: #427b58;
  --orange: #af3a03;
  --gray: #817d79;
  --red-dim: #cc2412;
  --green-dim: #98971a;
  --yellow-dim: #d79921;
  --blue-dim: #458598;
  --purple-dim: #b16286;
  --aqua-dim: #689d6a;
  --orange-dim: #d65d0e;
  --gray-dim: #817d79;
  --hover-bg: rgba(128, 128, 128, 0.12);
  --font-sans-fallback: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-heading: 'Space Grotesk', var(--font-sans-fallback);
  --font-body: 'Inter', var(--font-sans-fallback);
  --font-sans: var(--font-heading);
  --font-serif: 'IowanOldSt BT', 'Iowan Old Style', 'EB Garamond', serif;
  --font-serif-accent: var(--font-serif);
  --link-color: #141414;
  --link-color-hover: #2c2c2c;
  --highlight-red: #C35657;
  --brand-accent: var(--highlight-red);
}

/* Dark mode variables */
.darkmode {
  --bg_h: #000000;
  --bg: #000000;
  --bg_s: #1a1a1a;
  --bg_code: #1a1a1a;
  --bg1: #2a2a2a;
  --bg2: #3a3a3a;
  --bg3: #4a4a4a;
  --bg4: #5a5a5a;
  --fg: #ffffff;
  --fg_code: #8ec07c;
  --fg1: #f0f0f0;
  --fg2: #e0e0e0;
  --fg3: #d0d0d0;
  --fg4: #c0c0c0;
  --fg5: #b0b0b0;
  --red: #EF402C;
  --green: #9CC355;
  --yellow: #fabd2f;
  --blue: #0E9EE4;
  --purple: #d3869b;
  --aqua: #8ec07c;
  --gray: #817d79;
  --orange: #fe8019;
  --red-dim: #cc2412;
  --green-dim: #98971a;
  --yellow-dim: #d79921;
  --blue-dim: #458588;
  --purple-dim: #b16286;
  --aqua-dim: #689d6a;
  --gray-dim: #a89984;
  --orange-dim: #d65d0e;
  --hover-bg: rgba(128, 128, 128, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  line-height: 1.65;
  color: var(--fg);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header styles */
#header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 249, 245, 0.7);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid #eee;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1.5rem;
  min-height: 44px;
  width: 100%;
}

 .navbar-logo a {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--link-color);
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1;
}

/* Ensure logo text (even without an <a>) is vertically centered and styled */
.navbar-logo {
  display: flex;
  align-items: center;
  line-height: 1;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--link-color);
  letter-spacing: 0.03em;
}

/* Keep anchor inside logo inheriting color and centering */
.navbar-logo a {
  color: inherit;
}

.navbar-logo img {
  width: 20px;
  display: block;
}

.nav-group {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.top-nav {
  display: flex;
  gap: 2rem;
}

.top-nav a {
  font-family: var(--font-sans);
  font-weight: 500;
  text-decoration: none;
  color: var(--link-color);
  transition: color 0.2s;
  font-size: 15px;
}

.top-nav a:hover {
  color: var(--link-color-hover);
}

/* Mobile menu */
.hamburger {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
}

.hamburger span {
  width: 20px;
  height: 2px;
  background: #333;
  margin: 2px 0;
  transition: 0.3s;
}

.mobile-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: none;
}

.mobile-menu-nav {
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 100%;
  background: #fff;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.menu-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.menu-close:hover {
  transform: scale(1.1);
}

.mobile-menu-nav a {
  font-family: var(--font-heading);
  font-weight: 500;
  text-decoration: none;
  color: #333;
  font-size: 16px;
}

/* Main content */
#main {
  flex: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2rem;
}

#main:not(.post) {
  padding: 2rem 1.25rem 3rem;
}

.page-shell {
  max-width: 820px;
  margin: 0 auto;
}

.page-section {
  margin-bottom: 2rem;
}

.hero-intro {
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero-image-wrapper {
  width: 100%;
  max-width: 900px;
  margin: 0 auto 1.5rem;
}

.hero-image-wrapper img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.hero-subtitle {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hero-subtitle .hero-tagline,
.hero-subtitle .hero-powered {
  font-family: var(--font-body);
  margin: 0;
  font-size: 17px;
  line-height: 1.6;
  color: var(--fg1);
}

.hero-subtitle .hero-powered a {
  color: var(--fg2);
}

.section-title {
  font-family: var(--font-heading);
  letter-spacing: 0.02em;
  margin: 0 0 0.35rem;
  color: var(--fg);
}

.serif-lede {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--fg2);
  margin: 0 0 1rem;
}

.blog-list .blog-item .section-title {
  font-size: 1.2rem;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.blog-index-main .page-shell {
  padding-top: 0;
}

.blog-list .blog-item p {
  margin: 0;
}

.post-heading {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e5e5e5;
}

.post-title {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.9rem 0;
  color: var(--fg);
}

.publish-metadata {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: #666;
  font-size: 0.95rem;
}

.author a {
  color: var(--link-color);
  text-decoration: none;
  font-weight: 500;
}

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

/* Content styles */
.content {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
  font-size: 17px; /* normalize to exact 17px */
  line-height: 1.65;
}

.content p {
  margin: 0rem 0;
}

.content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 1.75rem 0 0.75rem 0;
  color: var(--fg);
  border-bottom: 1px solid #eee;
  padding-bottom: 0.35rem;
}

.content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1.1rem 0 0.5rem 0;
  color: var(--fg1);
}

/* Blockquotes */
.epigraph {
  border-left: 3px solid var(--brand-accent);
  padding-left: 1rem;
  margin: 1.25rem 0;
  font-style: italic;
  color: var(--fg2);
  font-family: var(--font-serif-accent);
  letter-spacing: 0.02em;
}

/* Code blocks */
.highlight {
  background: #f8f9fa;
  border: 1px solid #ececec;
  border-radius: 8px;
  margin: 1.25rem 0;
  overflow-x: auto;
}

.highlight pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-family: 'Chakra Petch', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.5;
}

.highlight code {
  background: none;
  padding: 0;
  font-size: inherit;
}

/* Inline code */
code {
  background: #f1f3f4;
  padding: 0.15rem 0.3rem;
  border-radius: 0.25rem;
  font-family: 'Chakra Petch', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9em;
  color: #b4235a;
}

/* Sidenotes and margin notes */
.sidenote-number {
  color: #007f86;
  font-weight: 600;
  cursor: pointer;
}

.margin-toggle {
  display: none;
}

.sidenote {
  display: none;
  position: absolute;
  right: -200px;
  width: 180px;
  font-size: 0.875rem;
  line-height: 1.4;
  color: #666;
  background: #f8f9fa;
  padding: 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid #e9ecef;
}

.marginnote {
  position: absolute;
  right: -200px;
  width: 180px;
  font-size: 0.875rem;
  line-height: 1.4;
  color: #666;
  background: #f8f9fa;
  padding: 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid #e9ecef;
}

.margin-toggle:checked + .sidenote {
  display: block;
}

/* Paginator */
.paginator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding: 1rem 0;
  border-top: 1px solid #e5e5e5;
}

.paginator .link {
  color: var(--link-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease-in-out;
}

.paginator .link:hover {
  color: var(--link-color-hover);
  text-decoration: underline;
}

/* Footer */
#footer {
  background: #141414;
  padding: 1.25rem 1.25rem 2rem;
  text-align: center;
  color: var(--bg_code);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font-sans), var(--font-sans-fallback);
}

.footer-separator {
  margin: 0 0.5rem;
}

#footer a {
  color: var(--bg_code);
  text-decoration: none;
  transition: color 0.2s ease;
}

#footer a:hover {
  color: #ffffff;
  text-decoration: underline;
  text-decoration-thickness: 0.025rem;
}

#footer .footer-logo {
  width: auto;
  height: 1.5rem;
  vertical-align: -0.5em;
  margin-right: 0.4rem;
  filter: brightness(0) saturate(100%) invert(96%);
}

/* Responsive design */
@media (max-width: 768px) {
  .site-header {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .nav-group {
    gap: 1rem;
  }
  
  .top-nav {
    display: none;
  }
  
  .hamburger {
    display: flex;
  }
  
  .post-title {
    font-size: 2rem;
  }
  
  .content {
    font-size: 17px; /* Keep 17px on mobile matching blog posts */
  }
  
  /* Ensure 1.3rem padding left/right on mobile for all pages */
  #main:not(.post) {
    padding-left: 1.3rem !important;
    padding-right: 1.3rem !important;
  }
  
  /* Override inline padding styles on homepage and blog index */
  #main:not(.post)[style*="padding"] {
    padding-left: 1.3rem !important;
    padding-right: 1.3rem !important;
  }
  
  /* Override padding on inner divs with max-width */
  #main:not(.post) > div[style*="max-width"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  .sidenote,
  .marginnote {
    position: static;
    width: 100%;
    margin: 1rem 0;
  }
}

@media (max-width: 480px) {
  /* Ensure 1.3rem padding left/right on all pages at this breakpoint */
  #main {
    padding-left: 1.3rem !important;
    padding-right: 1.3rem !important;
  }
  
  #main:not(.post) {
    padding-left: 1.3rem !important;
    padding-right: 1.3rem !important;
  }
  
  .post-title {
    font-size: 1.75rem;
  }
}

/* Blog list layout */
.blog-list {
  display: grid;
  gap: 1rem;
}

.blog-list .blog-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: start;
  gap: 0.75rem;
  border-bottom: 1px solid #e5e5e5;
  padding: 0.9rem 0;
}

.blog-list .blog-item .blog-date {
  color: #888;
  font-size: 15px;
}

.blog-item-title {
  font-family: var(--font-heading);
}

.blog-list .blog-item .blog-content h2 {
  font-size: 30px;
  margin: 0 0 0.25rem 0;
}

.blog-list .blog-item .blog-content p {
  margin: 0 0 0.4rem 0;
  color: #666;
  font-size: 17px;
}

.blog-list .blog-item .blog-meta {
  color: #888;
  font-size: 15px;
}

@media (max-width: 768px) {
  .blog-list .blog-item {
    grid-template-columns: 1fr;
  }
  .blog-list .blog-item .blog-date {
    order: 2;
    margin-top: 0.5rem;
  }
}

/* Citations section */
.citations {
  max-width: 800px;
  margin: 1.5rem auto 0;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e5e5;
  color: #444;
}

.citations h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #777;
}

.citations p,
.citations ul {
  margin: 0.5rem 0 0 0;
  font-size: 0.95rem;
  color: #555;
}

/* Unified citation component styles */
#main.post .citation-block {
  max-width: 680px; /* match article.content width */
  margin-left: auto;
  margin-right: auto;
  margin-top: 1.5rem;
}

.citation-block .citation-heading {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.25rem; /* closer to in-article section heading */
  line-height: 1.35;
  margin: 0 0 0.5rem 0;
  color: var(--fg);
}

.citation-block .citation-lead {
  font-family: var(--font-sans);
  font-size: 1.06rem; /* match .content base font size */
  line-height: 1.65;
  margin: 0 0 0.5rem 0;
  color: var(--fg1);
}

.citation-box {
  background: #f5f5f5;
  border: 1px solid #ececec;
  border-radius: 8px;
  padding: 0.75rem 1rem; /* Increased padding for better spacing */
  font-family: 'Chakra Petch', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13px; /* exact box font size */
  line-height: 1.65;
  color: #333;
  margin-top: 0;
  margin-bottom: 0;
}

.bibtex-box {
  font-family: 'Chakra Petch', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13px; /* match citation box */
  line-height: 1.4; /* Tighter line-height */
  overflow-x: auto;
  margin: 0 !important; /* Remove all margins aggressively */
  padding: 0.75rem 1rem !important; /* Increased padding for better spacing */
  position: relative; /* For absolute-positioned copy button */
  display: block; /* Ensure block display */
}

/* Remove any extra spacing from code elements inside BibTeX box */
.bibtex-box code {
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1.4 !important;
  display: block;
  font-size: 13px; /* Match parent */
  font-family: inherit; /* Match parent */
  white-space: pre; /* Preserve whitespace and line breaks */
}

/* Copy button styling for citation boxes */
.citation-box .copy-button,
.bibtex-box .copy-button {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  background-color: rgba(245, 245, 245, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #666;
  border: 1px solid rgba(233, 233, 233, 0.8);
  border-radius: 0.2rem;
  padding: 0.25rem 0.35rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease-in-out, background-color 0.15s ease-in-out, color 0.15s ease-in-out;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.65rem;
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  line-height: 1;
}

.citation-box {
  position: relative; /* For absolute-positioned copy button */
}

.citation-box:hover .copy-button,
.bibtex-box:hover .copy-button {
  opacity: 1;
}

.citation-box .copy-button:hover,
.bibtex-box .copy-button:hover {
  opacity: 1 !important;
  background-color: rgba(245, 245, 245, 0.95);
  color: #333;
  border-color: rgba(208, 208, 208, 0.9);
}

.citation-box .copy-button svg,
.bibtex-box .copy-button svg {
  width: 0.75rem;
  height: 0.75rem;
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
}

.citation-box .copy-button .copy-text,
.bibtex-box .copy-button .copy-text {
  margin: 0;
}

/* Dark mode support for copy buttons */
.darkmode .citation-box .copy-button,
.darkmode .bibtex-box .copy-button {
  background-color: rgba(26, 26, 26, 0.8);
  color: #c0c0c0;
  border-color: rgba(233, 233, 233, 0.3);
}

.darkmode .citation-box .copy-button:hover,
.darkmode .bibtex-box .copy-button:hover {
  background-color: rgba(26, 26, 26, 0.95);
  color: #e0e0e0;
  border-color: rgba(208, 208, 208, 0.5);
}

@media (max-width: 1170px) {
  #main.post .citation-block {
    max-width: min(100%, 660px);
    padding-left: 0;
    padding-right: 0;
  }
}
