/* Theme Variables */
:root {
  color-scheme: light dark;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #24292e;
  --heading: #0f1419;
  --muted: #57606a;
  --border: #e1e4e8;
  --link: #0969da;
  --link-hover: #044289;
  --shadow: rgba(0, 0, 0, 0.05);
  --pill-fg: #6d28d9; --pill-bg: rgba(124, 58, 237, 0.08); --pill-edge: rgba(124, 58, 237, 0.35);
}

/* Dark mode: follows the visitor's system setting by default */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #111116;
    --text: #d2d2d7;
    --heading: #f5f5f7;
    --muted: #a1a1a6;
    --border: rgba(255, 255, 255, 0.12);
    --link: #a5b4fc;
    --link-hover: #ffffff;
    --shadow: rgba(0, 0, 0, 0.6);
    --pill-fg: #c4b5fd; --pill-bg: rgba(168, 85, 247, 0.1); --pill-edge: rgba(168, 85, 247, 0.35);
  }
}

/* Manual override:  or  */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #111116;
  --text: #d2d2d7;
  --heading: #f5f5f7;
  --muted: #a1a1a6;
  --border: rgba(255, 255, 255, 0.12);
  --link: #a5b4fc;
  --link-hover: #ffffff;
  --shadow: rgba(0, 0, 0, 0.6);
  --pill-fg: #c4b5fd; --pill-bg: rgba(168, 85, 247, 0.1); --pill-edge: rgba(168, 85, 247, 0.35);
}

:root[data-theme="light"] {
  color-scheme: light;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  padding: 20px;
}

/* Navigation */
nav {
  max-width: 760px;
  margin: 0 auto 24px auto;
}

/* Back button: same rounded pill as "Explore more" on the homepage */
nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--pill-fg);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.45rem 0.9rem;
  border-radius: 9999px;
  border: 1px solid var(--pill-edge);
  background: var(--pill-bg);
  white-space: nowrap;
  transition: transform 0.3s cubic-bezier(.16, 1, .3, 1), background 0.3s;
}

nav a:hover,
nav a:focus-visible {
  transform: translateX(-3px);
  background: var(--pill-edge);
  color: var(--pill-fg);
  text-decoration: none;
}

nav a:active {
  transform: scale(0.96);
  transition-duration: 0.12s;
}

/* Article Container */
.article-container {
  max-width: 760px;
  margin: 0 auto;
  background: var(--surface);
  padding: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px var(--shadow);
}

/* Header Section */
.article-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
  margin-bottom: 32px;
}

.article-date {
  font-size: 0.875rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.article-byline + .article-date { margin-bottom: 14px; }

.article-header h1 {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--heading);
  margin-bottom: 12px;
}

.article-subtitle {
  font-size: 1.2rem;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.4;
}

/* Article Content Body */
.article-content p {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.8;
}

.article-content h2 {
  font-size: 1.5rem;
  margin-top: 36px;
  margin-bottom: 16px;
  color: var(--heading);
}

.article-content blockquote {
  border-left: 4px solid var(--link);
  padding-left: 16px;
  margin: 24px 0;
  font-style: italic;
  color: var(--muted);
}

.article-content blockquote.instagram-media {
  border: 0;
  color: inherit;
  font-style: normal;
  margin: 24px auto;
  max-width: 658px !important;
  min-width: 0 !important;
  padding: 0;
  width: 100% !important;
}

.article-content blockquote.instagram-media iframe {
  display: block;
  max-width: 100% !important;
  min-width: 0 !important;
  width: 100% !important;
}

.article-content > iframe.instagram-media {
  display: block;
  margin: 24px auto;
  max-width: 658px !important;
  min-width: 0 !important;
  width: 100% !important;
}

.article-content ul {
  margin: 0 0 20px 24px;
}

.article-content li {
  font-size: 1.1rem;
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 12px;
}

.article-content .note {
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--muted);
}

/* All article images safety rule (prevents unhandled images from overflowing) */
.article-content img,
.article-hero img,
.article-figure img,
.article-content figure img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Hero Image */
.article-hero {
  margin: 0 0 32px 0;
  width: 100%;
}

.article-hero img {
  width: 100%;
  border-radius: 8px;
}

.article-figure img,
.article-content figure img {
  display: block;
  width: 100%;
  height: auto;
}

.article-hero figcaption {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* Base Article Figures */
.article-figure,
.article-content figure {
  margin: 32px auto;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center; /* centres images that are narrower than the article */
}

.article-figure img,
.article-content figure img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 640px; /* very tall images scale down to fit, never cropped */
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.article-figure figcaption,
.article-content figure figcaption {
  align-self: stretch; /* caption keeps the full article width */
  margin-top: 10px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Credits inside captions, and the empty second caption the editor leaves behind */
.article-figure figcaption span,
.article-content figure figcaption span {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  opacity: 0.85;
}
.article-figure figcaption + figcaption,
.article-content figure figcaption + figcaption {
  display: none;
}

.image-credit {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  opacity: 0.85;
}

.image-credit a {
  color: inherit;
  text-decoration: underline;
}

/* Site Footer */
.site-footer {
  max-width: 760px;
  margin: 40px auto 0 auto;
  padding: 24px 0;
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  border-radius: 9999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  color: var(--heading);
}

.site-footer p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
  opacity: 0.6;
}

/* Responsive Design */
@media (max-width: 600px) {
  body {
    padding: 12px;
  }

  .article-container {
    padding: 20px;
  }

  .article-header h1 {
    font-size: 1.75rem;
  }

  .article-subtitle {
    font-size: 1rem;
  }

  .article-figure,
  .article-content figure {
    margin: 24px 0;
  }

  .article-figure img,
  .article-content figure img {
    max-height: 480px; /* scales very tall images down on phones, never cropped */
  }
}

/* ---------- Byline, "updated" note and author box (added by add-author.js) ---------- */
.article-updated {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.article-byline {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 2px;
}
.article-byline a {
  color: var(--heading);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.article-byline a:hover { border-bottom-color: var(--link); color: var(--link); }

.author-box {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  max-width: 760px;
  margin: 40px auto 8px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.author-avatar {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #f59e0b);
}
img.author-avatar {
  display: block;
  object-fit: cover;
  object-position: 50% 20%;
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border: 2px solid var(--border);
}
.author-info { min-width: 0; }
.author-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.author-name { font-size: 1.15rem; font-weight: 700; color: var(--heading); margin: 2px 0 6px; }
.author-name a { color: inherit; text-decoration: none; }
.author-name a:hover { color: var(--link); }
.author-bio { font-size: 0.95rem; line-height: 1.6; color: var(--text); }
.author-contact { font-size: 0.88rem; margin-top: 10px; color: var(--muted); }
.author-contact a { color: var(--link); text-decoration: none; }
.author-contact a:hover { text-decoration: underline; }
@media (max-width: 600px) {
  .author-box { flex-direction: column; gap: 12px; padding: 18px; }
}

.footer-social {
  margin: 1.25rem 0 0.75rem 0;
  display: flex;
  justify-content: center;
}

.footer-x-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background-color: rgba(255, 255, 255, 0.08);
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.footer-x-btn:hover {
  background-color: var(--pill-bg);
  border-color: var(--pill-edge);
  color: var(--pill-fg);
}

.footer-x-btn:active {
  background-color: var(--pill-edge);
  border-color: var(--pill-fg);
}

.x-icon {
  flex-shrink: 0;
}
