/* Clarity — a clean editorial Ghost theme for science writing */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #16181d;
  --ink-soft: #4a4f59;
  --ink-faint: #8a8f98;
  --line: #e7e4dd;
  --accent: #1f6f55;
  --accent-ink: #ffffff;
  --accent-tint: #e6f0eb;

  /* Ghost Admin's custom font setting overrides these */
  --serif: var(--gh-font-heading, "Newsreader", Georgia, "Times New Roman", serif);
  --sans: var(--gh-font-body, "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);

  --wrap: 1120px;
  --read: 680px;
  --gutter: 24px;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121417;
    --surface: #1a1d21;
    --ink: #eceae5;
    --ink-soft: #b4b2ac;
    --ink-faint: #7d7b76;
    --line: #2a2d32;
    --accent: #5cc29b;
    --accent-ink: #0d1411;
    --accent-tint: #1b2a24;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a { color: inherit; text-decoration: none; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Header */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 68px;
}

.site-logo {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.site-logo img { max-height: 36px; width: auto; }

.site-nav { flex: 1; }

.site-nav ul {
  display: flex;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  font-size: 15px;
  color: var(--ink-soft);
  transition: color .15s;
}

.site-nav a:hover,
.site-nav .nav-current a { color: var(--ink); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 15px;
}

.header-actions .signin { color: var(--ink-soft); }

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 15px/1 var(--sans);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
}

.btn:hover { opacity: .88; }

/* Hero */

.hero {
  padding: 96px 0 72px;
  border-bottom: 1px solid var(--line);
}

.hero-kicker {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 20px;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(38px, 6vw, 64px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
  max-width: 820px;
}

.hero p {
  font-size: 19px;
  color: var(--ink-soft);
  max-width: 600px;
  margin: 0 0 36px;
}

/* Subscribe form */

.subscribe-form { max-width: 460px; }

.subscribe-row {
  display: flex;
  gap: 8px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.subscribe-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: 16px var(--sans);
  padding: 0 14px;
}

.subscribe-row input::placeholder { color: var(--ink-faint); }

.subscribe-note {
  font-size: 14px;
  color: var(--ink-faint);
  margin: 12px 0 0 16px;
}

.subscribe-form .msg { display: none; font-size: 14px; margin: 12px 0 0 16px; }
.subscribe-form.success .msg-success,
.subscribe-form.error .msg-error { display: block; }
.subscribe-form.success .msg-success { color: var(--accent); }
.subscribe-form.error .msg-error { color: #c0392b; }
.subscribe-form.loading .btn { opacity: .6; pointer-events: none; }

/* Topics */

.topics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}

.topics a {
  font-size: 14px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  transition: all .15s;
}

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

/* Section heading */

.section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 56px 0 24px;
}

/* Featured post */

.feature {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 48px;
  align-items: center;
  padding-bottom: 56px;
  border-bottom: 1px solid var(--line);
}

.feature-image {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--accent-tint);
}

.feature-image img { width: 100%; height: 100%; object-fit: cover; }

.feature h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 12px 0 16px;
}

.feature p { color: var(--ink-soft); margin: 0 0 20px; font-size: 18px; }

/* Post list */

.post-list { padding-bottom: 80px; }

.post-card {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 32px;
  padding: 32px 0;
  border-bottom: 1px solid var(--line);
}

.post-card:last-child { border-bottom: 0; }

.post-card.no-image { grid-template-columns: 1fr; }

.post-card h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 8px 0 10px;
}

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

.post-card p { color: var(--ink-soft); margin: 0 0 12px; }

.post-card-image {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--accent-tint);
}

.post-card-image img { width: 100%; height: 100%; object-fit: cover; }

.post-tag {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.post-meta {
  font-size: 14px;
  color: var(--ink-faint);
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 80px;
  font-size: 15px;
  color: var(--ink-soft);
}

.pagination a { color: var(--accent); font-weight: 600; }

/* Archive header (tag / author) */

.archive-header {
  padding: 72px 0 32px;
  border-bottom: 1px solid var(--line);
}

.archive-header h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 5vw, 52px);
  letter-spacing: -0.02em;
  margin: 8px 0 12px;
}

.archive-header p { color: var(--ink-soft); max-width: 600px; margin: 0; }

/* Article */

.article-header {
  max-width: var(--read);
  margin: 0 auto;
  padding: 72px var(--gutter) 40px;
}

.article-header h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 5vw, 50px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 14px 0 20px;
}

.article-excerpt {
  font-size: 21px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 28px;
}

.article-byline {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
}

.article-byline img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.article-byline .name { font-weight: 600; }

.article-image {
  max-width: 960px;
  margin: 0 auto 48px;
  padding: 0 var(--gutter);
}

.article-image img { width: 100%; border-radius: var(--radius); }

.article-image figcaption {
  font-size: 14px;
  color: var(--ink-faint);
  text-align: center;
  margin-top: 10px;
}

/* Article body */

.gh-content {
  max-width: var(--read);
  margin: 0 auto;
  padding: 0 var(--gutter) 64px;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.7;
}

.gh-content > * + * { margin-top: 1.4em; margin-bottom: 0; }
.gh-content > :first-child { margin-top: 0; }

.gh-content h2,
.gh-content h3 {
  font-family: var(--sans);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.gh-content h2 { font-size: 28px; font-weight: 700; margin-top: 2em; }
.gh-content h3 { font-size: 22px; font-weight: 600; margin-top: 1.8em; }

.gh-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.gh-content blockquote {
  margin-left: 0;
  padding-left: 24px;
  border-left: 3px solid var(--accent);
  font-style: italic;
  color: var(--ink-soft);
}

.gh-content ul, .gh-content ol { padding-left: 1.3em; }
.gh-content li + li { margin-top: .5em; }

.gh-content hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 2.5em 0;
}

.gh-content figure { margin-left: 0; margin-right: 0; }
.gh-content figure img { border-radius: var(--radius); margin: 0 auto; }

.gh-content figcaption {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-faint);
  text-align: center;
  margin-top: 10px;
}

.gh-content code {
  font-size: .85em;
  background: var(--accent-tint);
  padding: 2px 6px;
  border-radius: 4px;
}

.gh-content pre {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  font-size: 15px;
}

.gh-content pre code { background: none; padding: 0; }

/* "Key takeaway" style callouts */
.gh-content .kg-callout-card {
  font-family: var(--sans);
  font-size: 17px;
  border-radius: var(--radius);
}

/* Ghost card widths (required by Ghost) */

.kg-width-wide {
  position: relative;
  width: min(960px, calc(100vw - 2 * var(--gutter)));
  left: 50%;
  transform: translateX(-50%);
}

.kg-width-full {
  position: relative;
  width: 100vw;
  left: 50%;
  transform: translateX(-50%);
}

.kg-width-full img { border-radius: 0; }

/* Article footer: subscribe box */

.article-cta {
  max-width: var(--read);
  margin: 0 auto 96px;
  padding: 0 var(--gutter);
}

.cta-box {
  background: var(--accent-tint);
  border-radius: 16px;
  padding: 40px;
}

.cta-box h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 30px;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}

.cta-box p { color: var(--ink-soft); margin: 0 0 24px; }

.article-tags {
  max-width: var(--read);
  margin: 0 auto 48px;
  padding: 0 var(--gutter);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.article-tags a {
  font-size: 14px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 40px 0;
  font-size: 14px;
  color: var(--ink-faint);
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.site-footer ul {
  display: flex;
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-footer a:hover { color: var(--ink); }

/* Error page */

.error-page {
  text-align: center;
  padding: 120px 0;
}

.error-page h1 {
  font-family: var(--serif);
  font-size: 96px;
  font-weight: 500;
  margin: 0;
}

.error-page p { color: var(--ink-soft); margin: 8px 0 32px; }

/* Mobile */

@media (max-width: 760px) {
  :root { --gutter: 16px; }

  .site-header .wrap { gap: 16px; height: 60px; }
  .site-nav { display: none; }
  .header-actions { margin-left: auto; }
  .header-actions .signin { display: none; }

  .hero { padding: 56px 0 48px; }
  .hero p { font-size: 17px; }

  .feature { grid-template-columns: 1fr; gap: 24px; }

  .post-card { grid-template-columns: 1fr 96px; gap: 16px; padding: 24px 0; }
  .post-card h3 { font-size: 20px; }
  .post-card p { display: none; }

  .article-header { padding-top: 48px; }
  .article-excerpt { font-size: 19px; }
  .gh-content { font-size: 19px; }
  .cta-box { padding: 28px 24px; }
}

@media (max-width: 340px) {
  .subscribe-row { flex-direction: column; border-radius: var(--radius); }
  .subscribe-row input { height: 40px; }
}

/* Extras for Ghost templates */

.feature.no-image { grid-template-columns: 1fr; }

.article-comments {
  max-width: var(--read);
  margin: 0 auto 64px;
  padding: 0 var(--gutter);
}
