/* ============================================
   Baystate Theme — Editorial Design
   chadmetcalf.com
   ============================================ */

:root {
  --color-bg: #F8F6F1;
  --color-text: #1a1917;
  --color-accent: #0056A7;
  --color-accent-hover: #004080;
  --color-muted: #6b6963;
  --color-border: #e2dfd8;
  --color-code-bg: #f0ede6;
  --color-card-bg: #ffffff;
  --font-serif: 'Bitter', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --max-width: 760px;
}

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

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-serif);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container-wide {
  max-width: 100%;
  margin: 0;
  padding: 0;
}

/* Header */
.site-header {
  padding: 1.5rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  max-width: 100%;
}

.site-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-title:hover {
  color: var(--color-text);
}

.site-nav {
  display: flex;
  gap: 1.75rem;
}

.site-nav a {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}

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

/* Footer */
.site-footer {
  padding: 3rem 0;
  margin-top: 4rem;
  text-align: center;
}

.site-footer p {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* Homepage Hero */
.hero {
  padding: 5rem 0 3rem;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1.15rem;
  color: var(--color-muted);
  max-width: 540px;
}

/* Section Headers */
.section-header {
  padding: 3rem 0 1.5rem;
  margin-bottom: 2rem;
}

.section-header h2 {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted);
}

/* Post List */
.post-list {
  list-style: none;
  padding-bottom: 2rem;
}

.post-item {
  padding: 2rem 0;
}

.post-item h3 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.post-item h3 a {
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.2s;
}

.post-item h3 a:hover {
  color: var(--color-accent);
}

.post-meta {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-bottom: 0.75rem;
}

.post-summary {
  color: var(--color-muted);
  font-size: 1rem;
  line-height: 1.6;
}

/* Homepage Post Cards (2/3 image + 1/3 content) */
.post-list-home {
  list-style: none;
  padding-bottom: 0;
}

.post-card {
  display: flex;
  min-height: 50vh;
}

.post-card-image {
  flex: 0 0 65%;
  display: block;
  overflow: hidden;
  position: relative;
}

.post-card-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to left, var(--color-bg) 0%, transparent 1%),
    linear-gradient(to bottom, var(--color-bg) 0%, transparent 10%),
    linear-gradient(to top, var(--color-bg) 0%, transparent 10%);
  pointer-events: none;
}

.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  mix-blend-mode: multiply;
}


.post-card-content {
  flex: 1;
  min-width: 0;
  padding: 3rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.post-card-content h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

.post-card-content h3 a {
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.2s;
}

.post-card-content h3 a:hover {
  color: var(--color-accent);
}

.post-card-content .post-summary {
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.post-card-content .post-summary p {
  margin-bottom: 0.75rem;
}

.post-summary-link {
  text-decoration: none;
  color: inherit;
}


/* Single Post / Page */
.page-header {
  padding: 4rem 0 2.5rem;
}

.page-header h1 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}

.page-header .post-meta {
  font-size: 0.85rem;
}

.page-content {
  padding-bottom: 3rem;
}

.page-content h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.page-content h3 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.page-content p {
  margin-bottom: 1.25rem;
}

.page-content a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.2s;
}

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

.page-content ul,
.page-content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.page-content li {
  margin-bottom: 0.4rem;
}

.page-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--color-muted);
  font-style: italic;
}

.page-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
}

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

/* Thanks page — full viewport art */
.thanks-hero {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  z-index: -1;
}

.thanks-hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  mix-blend-mode: multiply;
}

.thanks-hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    var(--color-bg) 0%,
    transparent 25%
  );
}

.thanks-text {
  position: fixed;
  bottom: 3rem;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 1;
}

.thanks-text h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

/* Hero Background (Blowfish-style fixed background with fade) */
.hero-spacer {
  height: 280px;
}

.hero-bg {
  position: fixed;
  inset: 0;
  height: 100vh;
  z-index: -2;
}

.hero-bg-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  mix-blend-mode: multiply;
}

.hero-bg-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    var(--color-bg) 0%,
    rgba(248, 246, 241, 0.4) 35%,
    transparent 60%
  );
}

.hero-bg-gradient-opacity {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    var(--color-bg) 0%,
    transparent 30%
  );
  opacity: 0.5;
}

.hero-bg-blur {
  position: fixed;
  inset: 0;
  height: 100%;
  z-index: -1;
  opacity: 0;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(248, 246, 241, 0.85);
}

/* Post Thumbnail (list items) */
.post-item.has-image {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.post-thumb {
  flex-shrink: 0;
  width: 160px;
}

.post-thumb img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 4px;
}

.post-item-content {
  flex: 1;
  min-width: 0;
}

/* Code Blocks */
.page-content code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  background: var(--color-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.page-content pre {
  background: #f0ede6;
  color: #1a1917;
  border: 1px solid #e2dfd8;
  padding: 1.25rem 1.5rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.5;
}

.page-content pre code {
  background: none;
  padding: 0;
  font-size: 0.82rem;
  color: inherit;
}

/* Chroma syntax highlighting — Baystate base16 (fountain pen inks on cotton) */
.highlight pre {
  background: #f0ede6;
  color: #1a1917;
  border: 1px solid #e2dfd8;
  padding: 1.25rem 1.5rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.5;
}

.highlight .chroma {
  background: #f0ede6;
}

/* Keywords — Concord Grape (base0E) */
.chroma .k,
.chroma .kc,
.chroma .kd,
.chroma .kn,
.chroma .kp,
.chroma .kr { color: #5E2D91; }
/* Keyword type — Heart of Gold (base0A) */
.chroma .kt { color: #8A6508; }
/* Strings — Hunter Green (base0B) */
.chroma .s,
.chroma .sa,
.chroma .sb,
.chroma .sc,
.chroma .dl,
.chroma .sd,
.chroma .s2,
.chroma .se,
.chroma .sh,
.chroma .si,
.chroma .sx,
.chroma .sr,
.chroma .s1,
.chroma .ss { color: #1A7A50; }
/* Numbers, constants — Habanero (base09) */
.chroma .m,
.chroma .mb,
.chroma .mf,
.chroma .mh,
.chroma .mi,
.chroma .il,
.chroma .mo { color: #BF4C0D; }
.chroma .kc { color: #BF4C0D; }
/* Comments — base03 warm gray */
.chroma .c,
.chroma .ch,
.chroma .cm,
.chroma .c1,
.chroma .cs,
.chroma .cp,
.chroma .cpf { color: #8A847A; font-style: italic; }
/* Functions, methods — Baystate Blue (base0D) */
.chroma .nf,
.chroma .fm { color: #0056A7; }
/* Classes, types — Heart of Gold (base0A) */
.chroma .nc,
.chroma .no,
.chroma .nd { color: #8A6508; }
/* Variables, tags — Cape Cod Cranberry (base08) */
.chroma .n,
.chroma .na,
.chroma .nb,
.chroma .ni,
.chroma .ne,
.chroma .nl,
.chroma .nn,
.chroma .nx,
.chroma .nt,
.chroma .nv,
.chroma .bp,
.chroma .vc,
.chroma .vg,
.chroma .vi { color: #8B1A3A; }
/* Operators — Ku-jaku teal (base0C) */
.chroma .o,
.chroma .ow { color: #08736E; }
/* Punctuation — base05 dark ink */
.chroma .p { color: #1a1917; }
/* Regex, escape sequences — Ku-jaku (base0C) */
.chroma .sr { color: #08736E; }
.chroma .se { color: #08736E; }
/* Deprecated — Black Swan (base0F) */
.chroma .gh,
.chroma .gu { color: #4A1028; }
/* Diff: inserted — Hunter Green, deleted — Cranberry */
.chroma .gi { color: #1A7A50; }
.chroma .gd { color: #8B1A3A; }
/* Selection background — base02 */
.highlight .chroma .hl { background: #e2dfd8; }

/* Contact Form */
.contact-form {
  max-width: 480px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  font-family: var(--font-serif);
  font-size: 1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-card-bg);
  color: var(--color-text);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

.form-group textarea {
  resize: vertical;
  min-height: 140px;
}

.btn {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.7rem 1.75rem;
  background: var(--color-accent);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background-color 0.2s;
}

.btn:hover {
  background: var(--color-accent-hover);
}

/* Tags */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tag {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--color-accent);
  background: rgba(0, 86, 167, 0.08);
  padding: 0.2em 0.65em;
  border-radius: 3px;
  text-decoration: none;
  transition: background 0.2s;
}

.tag:hover {
  background: rgba(0, 86, 167, 0.15);
}

/* Search Toggle */
.search-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-muted);
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.search-toggle:hover {
  color: var(--color-accent);
}

/* RSS Link */
.rss-link {
  color: var(--color-muted);
  display: flex;
  align-items: center;
  transition: color 0.2s;
}
.rss-link:hover {
  color: var(--color-accent);
}

/* Search Overlay */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.search-overlay.active {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
}

.search-overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 25, 23, 0.5);
}

.search-modal {
  position: relative;
  background: var(--color-bg);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 600px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 1.5rem;
}

.search-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
  transition: color 0.2s;
}

.search-close:hover {
  color: var(--color-text);
}

/* Pagefind UI Overrides */
:root {
  --pagefind-ui-scale: 0.9;
  --pagefind-ui-primary: var(--color-accent);
  --pagefind-ui-text: var(--color-text);
  --pagefind-ui-background: var(--color-bg);
  --pagefind-ui-border: var(--color-border);
  --pagefind-ui-tag: rgba(0, 86, 167, 0.08);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 4px;
  --pagefind-ui-font: var(--font-serif);
}

/* Responsive */
@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  .site-header {
    padding: 1.25rem 1.5rem;
  }

  .hero {
    padding: 3rem 0 2rem;
  }

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

  .hero-spacer {
    height: 200px;
  }

  .hero-bg {
    height: 100vh;
  }

  .page-header {
    padding: 2.5rem 0 1.5rem;
  }

  .page-header h1 {
    font-size: 1.8rem;
  }

  .post-item h3 {
    font-size: 1.3rem;
  }

  .post-item.has-image {
    flex-direction: column;
  }

  .post-thumb {
    width: 100%;
  }

  .post-thumb img {
    height: 180px;
  }

  .post-card {
    flex-direction: column;
    min-height: auto;
  }

  .post-card-image {
    flex: none;
    width: 100%;
    height: 250px;
  }

  .post-card-content {
    padding: 1.5rem;
  }

  .post-card-content h3 {
    font-size: 1.3rem;
  }

  .search-modal {
    width: 95%;
    padding: 1rem;
    padding-top: 1.5rem;
  }

  .search-overlay.active {
    padding-top: 5vh;
  }

}
