/* ============================================================
   SKY — premium theme for Selfish
   Social-feed energy, à la Bluesky. Clean single-column
   timeline, soft avatars, hairline separators, a confident
   sky-blue accent, and rounded multi-image mosaics.
   Uses the CardGridThemeRenderer (.post-card), styled as a
   single-column feed rather than a card grid.
   ============================================================ */

:root {
  --primary-color: #0f1419;
  --secondary-color: #536471;
  --text-color: #0f1419;
  --text-secondary: #536471;
  --background: #ffffff;
  --background-alt: #f5f8fa;
  --border-color: #e3e9ef;
  --link-color: #0d6bd0;
  --link-hover: #0a58ad;
  --accent-color: #0d6bd0;
  --accent-soft: #e8f2ff;

  /* generated abstract avatar (no image needed — one account) */
  --avatar-bg:
    radial-gradient(circle at 30% 28%, #8ed0ff 0%, transparent 55%),
    radial-gradient(circle at 74% 78%, #0a6ad6 0%, transparent 52%),
    linear-gradient(135deg, #4dabf7, #1083fe 60%, #0b62c6);
  --banner-bg:
    radial-gradient(130% 150% at 82% -20%, #6cc0ff 0%, transparent 55%),
    linear-gradient(120deg, #1d9bf0, #1083fe 55%, #0a5fcc);

  --max-width: 600px;
  --spacing-xs: 0.5rem;
  --spacing-sm: 0.75rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.6rem;
  --spacing-xl: 2.75rem;

  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, 'Helvetica Neue', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-color);
  background: var(--background-alt);
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
  background: var(--background);
}

a { color: var(--link-color); text-decoration: none; }
a:hover { color: var(--link-hover); }

/* ============================================================
   PROFILE HEADER  (Bluesky-style banner + avatar)
   ============================================================ */
.site-header {
  background: var(--background);
  max-width: var(--max-width);
  margin: 0 auto;
}
.site-header .container { position: relative; padding: 0 var(--spacing-md); }
.site-header .container::before {            /* banner */
  content: "";
  display: block;
  height: 150px;
  margin: 0 calc(-1 * var(--spacing-md));
  background: var(--banner-bg);
}
.site-header .container::after {             /* avatar */
  content: "";
  position: absolute;
  left: var(--spacing-md);
  top: 104px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--avatar-bg);
  border: 4px solid var(--background);
  box-shadow: 0 1px 5px rgba(15, 20, 25, 0.18);
}
.site-title {
  margin: 52px 0 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.site-title a { color: var(--text-color); }
.site-title a:hover { color: var(--text-color); opacity: 0.85; }
.site-description {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}
.site-nav a {
  position: relative;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.92rem;
}
.site-nav a:hover { color: var(--text-color); background: var(--background-alt); }
.site-nav a::after {
  content: "";
  position: absolute;
  left: 16px; right: 16px; bottom: -1px;
  height: 3px;
  border-radius: 3px;
  background: var(--accent-color);
  opacity: 0;
  transition: opacity .15s ease;
}
.site-nav a:hover::after { opacity: 1; }

/* ============================================================
   FEED  (CardGridThemeRenderer → single-column timeline)
   Also styles .post-preview, so the list renderer works too.
   ============================================================ */
.posts {
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--background);
  display: grid;
  grid-template-columns: 1fr;
}

.post-card,
.post-preview {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  transition: background .12s ease;
}
.post-card:hover,
.post-preview:hover { background: var(--background-alt); }

.post-card h2,
.post-preview h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  order: 1;
}
.post-card h2 a,
.post-preview h2 a { color: var(--text-color); }
.post-card h2 a:hover,
.post-preview h2 a:hover { color: var(--accent-color); }

.post-meta {
  margin: 0;
  order: 2;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.post-excerpt {
  margin: 2px 0 0;
  order: 3;
  color: var(--text-color);
  font-size: 0.96rem;
  line-height: 1.5;
}

/* the single featured thumbnail sits BELOW the text, Bluesky-style */
.post-card-thumb {
  order: 4;
  display: block;
  margin-top: var(--spacing-sm);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  aspect-ratio: 16 / 9;
  background: var(--background-alt);
}
.post-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* feed: the inline multi-image mosaic — one tap target wrapping the same
   .post-attachments component the post page uses (see MEDIA MOSAIC below) */
.post-card-mosaic {
  order: 4;
  display: block;
  margin-top: var(--spacing-sm);
}
.post-card-mosaic .post-attachments { margin-top: 0; }

.read-more {
  order: 5;
  align-self: flex-start;
  margin-top: 2px;
  color: var(--accent-color);
  font-size: 0.9rem;
  font-weight: 600;
}
.read-more:hover { text-decoration: underline; }

.empty-state {
  padding: var(--spacing-xl) var(--spacing-md);
  text-align: center;
  color: var(--text-secondary);
  font-size: 1rem;
  background: var(--background);
  border-bottom: 1px solid var(--border-color);
}

/* ============================================================
   ARCHIVE HEADER  (feed title bar)
   ============================================================ */
.archive-header {
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--background);
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}
.archive-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-color);
  margin-bottom: 2px;
}
.archive-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.archive-description {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ============================================================
   SINGLE POST  (detail view)
   ============================================================ */
.post {
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--background);
  padding: var(--spacing-md);
}
.post-header {
  margin-bottom: var(--spacing-md);
}
.post-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.post-header .post-meta {
  margin: 4px 0 0;
  font-size: 0.9rem;
}

.post-content {
  font-size: 1.06rem;
  line-height: 1.6;
  color: var(--text-color);
}
.post-content p { margin: 0 0 var(--spacing-md); }
.post-content a { color: var(--accent-color); }
.post-content a:hover { text-decoration: underline; }
.post-content h2,
.post-content h3 {
  margin: var(--spacing-lg) 0 var(--spacing-sm);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.post-content h2 { font-size: 1.3rem; }
.post-content h3 { font-size: 1.12rem; }

/* blockquote = a quoted-post card */
.post-content blockquote {
  margin: var(--spacing-md) 0;
  padding: var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--background);
  color: var(--text-color);
  font-size: 0.98rem;
}
.post-content blockquote p { margin: 0; }
.post-content blockquote p + p { margin-top: var(--spacing-sm); }

.post-content ul,
.post-content ol { padding-left: 1.4rem; margin: 0 0 var(--spacing-md); }
.post-content li { margin-bottom: var(--spacing-xs); }
.post-content li::marker { color: var(--text-secondary); }
.post-content code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--background-alt);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.08em 0.4em;
}
.post-content pre {
  background: var(--background-alt);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: var(--spacing-md);
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.55;
}
.post-content pre code { background: none; border: none; padding: 0; }
.post-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--spacing-lg) 0;
}

/* ============================================================
   MEDIA MOSAIC  (the Bluesky multi-image layout)
   One rounded container; layout adapts to image count via
   quantity queries — 1 full · 2 split · 3 tall+stack · 4 grid.
   ============================================================ */
.post-attachments {
  margin-top: var(--spacing-md);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--border-color);
}
.post-attachments figure {
  margin: 0;
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: var(--background-alt);
}
.post-attachments figure img,
.post-attachments figure video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* multi-image cells default to a pleasant landscape ratio */
.post-attachments .media-image { aspect-ratio: 3 / 2; }

/* 1 image — full width, natural height, no crop */
.post-attachments .media-image:only-child { grid-column: 1 / -1; aspect-ratio: auto; }
.post-attachments .media-image:only-child img {
  height: auto;
  max-height: 580px;
  object-fit: contain;
  background: var(--background-alt);
}

/* 3 images — first one is tall on the left */
.post-attachments .media-image:first-child:nth-last-child(3) {
  grid-row: span 2;
  aspect-ratio: auto;
}

/* video & audio always span full width */
.post-attachments .media-video { grid-column: 1 / -1; aspect-ratio: 16 / 9; }
.post-attachments .media-audio {
  grid-column: 1 / -1;
  background: var(--background-alt);
  padding: var(--spacing-sm) var(--spacing-md);
}
.post-attachments .media-audio audio { width: 100%; display: block; }

/* captions as a soft scrim, like a social alt badge */
.post-attachments figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 20px 12px 9px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #fff;
  background: linear-gradient(transparent, rgba(15, 20, 25, 0.8));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-attachments .media-audio figcaption {
  position: static;
  color: var(--text-secondary);
  background: none;
  padding: var(--spacing-xs) 0 0;
}

/* Photos placed inline in a post. Every rule above is scoped to the mosaic
   wrapper, which post pages no longer emit, so flow figures need their own:
   the scrim caption and cover-cropping only make sense on the mosaic's
   fixed-ratio tiles, while an inline photo keeps its own shape and puts its
   caption underneath. Direct-child selectors so the mosaic is untouched. */
.post-content > figure > img,
.post-content > figure > video { border-radius: 14px; }
.post-content > figure figcaption {
  margin-top: var(--spacing-xs);
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

/* ============================================================
   TAXONOMY  (pill chips)
   ============================================================ */
.post-taxonomy {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  align-items: center;
}
.post-categories,
.post-tags { display: flex; flex-wrap: wrap; gap: var(--spacing-xs); }
.category-pill {
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.3em 0.85em;
  border-radius: 999px;
  background: var(--accent-color);
  color: #fff;
}
.category-pill:hover { background: var(--link-hover); color: #fff; }
.tag-pill {
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.3em 0.7em;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-color);
}
.tag-pill:hover { background: #d6e9ff; color: var(--link-hover); }

/* ============================================================
   POST NAV / BACK
   ============================================================ */
.post-nav {
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--background);
  padding: var(--spacing-md);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-color);
  font-weight: 600;
  font-size: 0.92rem;
}
.back-link:hover { text-decoration: underline; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--background);
  border-top: 1px solid var(--border-color);
  padding: var(--spacing-lg) var(--spacing-md) var(--spacing-xl);
}
.site-footer p {
  margin: 0 0 2px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}
.powered-by a { color: var(--accent-color); font-weight: 600; }
.powered-by a:hover { text-decoration: underline; }

/* ============================================================
   DARK MODE  (Bluesky "dim" — deep navy, not pure black)
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #e7e9ea;
    --secondary-color: #8b98a5;
    --text-color: #e7e9ea;
    --text-secondary: #8b98a5;
    --background: #16202a;
    --background-alt: #1c2732;
    --border-color: #2d3b48;
    --link-color: #4a99e9;
    --link-hover: #6cb0f0;
    --accent-color: #4a99e9;
    --accent-soft: #1a2c40;
  }
  body { background: #0d141b; }
  .post-content blockquote { background: var(--background-alt); }
  /* Dark words on the lighter blue. */
  .category-pill, .category-pill:hover { color: var(--background); }
  .post-attachments figcaption { background: linear-gradient(transparent, rgba(0, 0, 0, 0.85)); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  body { font-size: 15px; }
  .site-header .container::before { height: 120px; }
  .site-header .container::after { top: 80px; width: 72px; height: 72px; }
  .site-title { margin-top: 44px; font-size: 1.35rem; }
  .post-title { font-size: 1.3rem; }
  .post-content { font-size: 1.02rem; }
}
/* inline media figures (shared across themes) */
.post-content figure { margin: 1.6em 0; }
.post-content figure img,
.post-content figure video { display: block; max-width: 100%; height: auto; }
.post-content figure audio { display: block; width: 100%; }

/* lists + code blocks (shared across themes) */
.post-content ul, .post-content ol { margin: 1em 0; padding-left: 1.6em; }
.post-content li { margin: 0.3em 0; }
.post-content li > ul, .post-content li > ol { margin: 0.3em 0; }
.post-content pre {
    margin: 1.2em 0;
    padding: 1em 1.2em;
    background: rgba(127, 127, 127, 0.12);
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.9em;
    line-height: 1.5;
}
.post-content pre code {
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    white-space: pre;
    background: none;
    color: inherit;
    padding: 0;
}

/* Readers who ask for less motion get none: no hover lifts or tilts. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* code highlighting (shared, E4): tints of the theme's own text colour,
   so they keep its contrast on light and dark themes alike */
.post-content pre .hl-k { color: color-mix(in srgb, currentColor 50%, #c2255c); }
.post-content pre .hl-t { color: color-mix(in srgb, currentColor 50%, #1971c2); }
.post-content pre .hl-s { color: color-mix(in srgb, currentColor 50%, #2b8a3e); }
.post-content pre .hl-n { color: color-mix(in srgb, currentColor 50%, #e8590c); }
.post-content pre .hl-a { color: color-mix(in srgb, currentColor 50%, #9c36b5); }
.post-content pre .hl-c { color: color-mix(in srgb, currentColor 62%, transparent); font-style: italic; }

/* inline code, dividers and footnotes (shared; :where() lets a theme's own rules win) */
:where(.post-content) code {
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    font-size: 0.9em;
    padding: 0.1em 0.3em;
    background: rgba(127, 127, 127, 0.14);
    border-radius: 4px;
}
:where(.post-content) hr {
    border: none;
    border-top: 1px solid rgba(127, 127, 127, 0.35);
    margin: 2em 0;
}
.footnote-ref { line-height: 0; }
.footnote-ref a { text-decoration: none; padding: 0 0.1em; }
.footnotes {
    margin-top: 2.5em;
    padding-top: 1em;
    border-top: 1px solid rgba(127, 127, 127, 0.35);
    font-size: 0.9em;
}
.footnotes ol { padding-left: 1.6em; }
.footnotes li { margin: 0.4em 0; }
.footnote-backref { text-decoration: none; }
.toc { margin: 1.5em 0; padding: 0.9em 1.2em; border-left: 3px solid rgba(127, 127, 127, 0.35); font-size: 0.95em; }
.toc ol { margin: 0; padding-left: 1.2em; }
.toc ol ol { margin: 0.2em 0 0.3em; }
.toc li { margin: 0.25em 0; }
/* chosen post thumbnails, list layout (shared across themes) */
.post-preview.has-thumb {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 8.5rem;
    column-gap: 1.5rem;
    align-items: start;
}
.post-preview.has-thumb > * { grid-column: 1; }
.post-preview.has-thumb > .post-preview-thumb {
    grid-column: 2;
    grid-row: 1 / span 4;
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 0;
    background: var(--background-alt);
    transition: border-color 0.2s ease;
}
.post-preview.has-thumb > .post-preview-thumb:hover {
    border-color: var(--accent-color, var(--link-color));
}
.post-preview-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}
.post-preview-thumb:hover img { transform: scale(1.04); }
@media (max-width: 600px) {
    .post-preview.has-thumb { grid-template-columns: minmax(0, 1fr); }
    .post-preview.has-thumb > .post-preview-thumb {
        grid-column: 1;
        grid-row: auto;
        aspect-ratio: 16 / 9;
        margin-bottom: 0.9rem;
    }
}
@media (prefers-reduced-motion: reduce) {
    .post-preview-thumb img,
    .post-preview.has-thumb > .post-preview-thumb { transition: none; }
    .post-preview-thumb:hover img { transform: none; }
}
/* pagination (shared across themes; links borrow each theme's .back-link) */
.pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem 1rem;
}
.pagination-newer { grid-column: 1; justify-self: start; }
.pagination-status {
    grid-column: 2;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
}
.pagination-older { grid-column: 3; justify-self: end; }
.pagination + .post-nav { margin-top: 0; padding-top: 0; border-top: none; }
@media (max-width: 600px) {
    .pagination { grid-template-columns: 1fr 1fr; }
    .pagination-status { grid-column: 1 / -1; grid-row: 1; }
    .pagination-newer { grid-column: 1; grid-row: 2; }
    .pagination-older { grid-column: 2; grid-row: 2; }
}
/* skip link, focus, neighbours and print (shared across themes) */
.skip-link {
    position: absolute;
    left: 0.75rem;
    top: -4rem;
    z-index: 100;
    padding: 0.5rem 0.9rem;
    background: var(--background, #fff);
    color: var(--text-color, #111);
    border: 2px solid currentColor;
}
.skip-link:focus { top: 0.75rem; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.adjacent-posts {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
}
.adjacent-newer { margin-left: auto; text-align: right; }
.adjacent-posts + .post-nav { margin-top: 0; padding-top: 0; border-top: none; }
@media print {
    .skip-link, .site-nav, .post-nav, .site-footer, .social-links { display: none !important; }
    body { background: #fff !important; color: #000 !important; }
    a { color: inherit !important; }
    img, video, figure { break-inside: avoid; max-width: 100% !important; }
}