/* DataSparkx blog theme -- one stylesheet, no framework. */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #16191d;
  --text-soft: #5c6570;
  --accent: #2f6fed;
  --accent-soft: #eaf0fe;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  --radius: 14px;
  --wrap: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-read: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --bg-soft: #14171d;
    --surface: #171b22;
    --border: #262c36;
    --text: #e8ebef;
    --text-soft: #9aa4b2;
    --accent: #6f9bff;
    --accent-soft: #1b2537;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px 72px;
}

/* ---------------------------------------------------------------- title bar */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header .bar {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  white-space: nowrap;
}

.brand:hover { text-decoration: none; }

.brand .mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: .95rem;
  font-weight: 800;
  flex: none;
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav a {
  padding: 8px 12px;
  border-radius: 9px;
  font-size: .93rem;
  font-weight: 500;
  color: var(--text-soft);
  white-space: nowrap;
}

.nav a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }

.nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-toggle {
  display: none;
  margin-left: auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px 14px; font-size: 1rem; }
}

/* ---------------------------------------------------------------- hero */
.hero { padding: 56px 0 28px; max-width: 720px; }

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: -.03em;
}

.hero-tagline { margin: 0; color: var(--text-soft); font-size: 1.12rem; }

/* ---------------------------------------------------------------- tags */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 26px;
}

.chip {
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
}

.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------------------------------------------------------------- tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}

.tile {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  color: inherit;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  text-decoration: none;
}

/* Fixed 16:9 box so the grid never reflows as covers load. The gradient is the
   fallback when an article has no cover image at all. */
.tile .cover {
  flex: none;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background:
    linear-gradient(135deg,
      hsl(var(--hue) 72% 58%) 0%,
      hsl(calc(var(--hue) + 42) 68% 48%) 100%);
  position: relative;
}

/* Decorative shapes only where there's no <img> to show. */
.tile .cover:empty::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 22% 78%, rgba(255, 255, 255, .28) 0 18%, transparent 19%),
    radial-gradient(circle at 76% 26%, rgba(255, 255, 255, .18) 0 12%, transparent 13%);
}

.tile .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile .body {
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
}

.tile h2 {
  margin: 0;
  font-size: 1.14rem;
  line-height: 1.32;
  letter-spacing: -.015em;
}

.tile p {
  margin: 0;
  color: var(--text-soft);
  font-size: .94rem;
}

.tile .tile-meta { margin-top: auto; }

.tile-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: .81rem;
}

.tile-meta .dot { opacity: .5; }

.tile-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .01em;
}

.state {
  grid-column: 1 / -1;
  padding: 40px 0;
  color: var(--text-soft);
  text-align: center;
}

/* ---------------------------------------------------------------- prose */
.page, .post { max-width: 720px; padding: 48px 0 0; }

.page h1, .post h1 {
  margin: 0 0 14px;
  font-size: clamp(1.9rem, 4.4vw, 2.6rem);
  line-height: 1.16;
  letter-spacing: -.03em;
}

.page h2, .post h2 {
  margin: 38px 0 12px;
  font-size: 1.32rem;
  letter-spacing: -.02em;
}

.page p, .page li { color: var(--text); }

.lede { font-size: 1.12rem; color: var(--text-soft); }

.meta { color: var(--text-soft); font-size: .9rem; }

.page ul, .post ul { padding-left: 22px; }
.page li, .post li { margin: 7px 0; }

.center { text-align: center; }
.center h1 { font-size: 4rem; }

.post .post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 0 0 8px;
  color: var(--text-soft);
  font-size: .9rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
}

/* Banner: wider crop than the tile, same asset. 3:1 on desktop, 16:9 on
   narrow screens where a letterbox would leave almost nothing visible. */
.post-hero {
  position: relative;
  margin: 0 0 30px;
  aspect-ratio: 3 / 1;
  overflow: hidden;
  border-radius: 14px;
  background: var(--bg-soft);
}

.post-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-credit,
.post-figure .credit {
  color: var(--text-soft);
  font-family: var(--font);
  font-size: .76rem;
}

.hero-credit {
  position: absolute;
  right: 10px;
  bottom: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
}

.post-figure {
  margin: 30px 0;
}

.post-figure img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  background: var(--bg-soft);
}

.post-figure figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 9px;
  color: var(--text-soft);
  font-family: var(--font);
  font-size: .86rem;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .post-hero { aspect-ratio: 16 / 9; }
}

.post-body { font-family: var(--font-read); font-size: 1.09rem; line-height: 1.75; }
.post-body h2 { font-family: var(--font); }
.post-body p { margin: 0 0 20px; }

.post-body blockquote {
  margin: 26px 0;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--accent);
  color: var(--text-soft);
  font-style: italic;
}

.post-body pre {
  margin: 24px 0;
  padding: 16px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88rem;
  line-height: 1.55;
}

/* ---------------------------------------------------------------- related */
.section-title {
  margin: 0 0 18px;
  font-size: 1.2rem;
  letter-spacing: -.02em;
}

.related, .comments {
  max-width: 720px;
  margin-top: 52px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.related-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: inherit;
  transition: border-color .18s ease, transform .18s ease;
}

.related-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  transform: translateY(-2px);
  text-decoration: none;
}

.related-card .stripe {
  height: 4px;
  width: 40px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    hsl(var(--hue) 72% 58%), hsl(calc(var(--hue) + 42) 68% 48%));
}

.related-cat {
  color: var(--text-soft);
  font-size: .74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.related-title {
  font-size: .99rem;
  font-weight: 600;
  line-height: 1.35;
  flex: 1;
}

/* ---------------------------------------------------------------- comments */
.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.comment { display: flex; gap: 14px; }

.comment .avatar {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg,
    hsl(var(--hue) 60% 52%), hsl(calc(var(--hue) + 40) 58% 44%));
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.comment-body { flex: 1; min-width: 0; }

.comment-byline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.comment-author { font-weight: 600; font-size: .94rem; }

.comment-role {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: .72rem;
}

.comment-date { color: var(--text-soft); font-size: .8rem; }

.comment-body p {
  margin: 0;
  color: var(--text);
  font-size: .96rem;
  line-height: 1.62;
}

/* A reader's own comment: subtle accent rule, and removable. */
.comment.is-mine .comment-body {
  padding-left: 12px;
  border-left: 2px solid var(--accent-soft);
}

.comment-delete {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-soft);
  font: inherit;
  font-size: .8rem;
  text-decoration: underline;
  cursor: pointer;
}

.comment-delete:hover { color: #d64545; }

/* ---------------------------------------------------------- comment form */
.comment-form {
  margin-top: 34px;
  padding: 22px 22px 20px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 520px;
}

.comment-form-title {
  margin: 0 0 6px;
  font-size: 1.02rem;
  letter-spacing: -.01em;
}

.comment-note {
  margin: 0 0 16px;
  color: var(--text-soft);
  font-size: .84rem;
  line-height: 1.5;
}

.comment-form .field { margin-bottom: 14px; }
.comment-form .field input,
.comment-form .field textarea { background: var(--surface); }

.post-nav {
  max-width: 720px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 48px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.post-nav a {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: inherit;
}

.post-nav a:hover { border-color: var(--accent); text-decoration: none; }
.post-nav .label { display: block; color: var(--text-soft); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.post-nav .title { font-weight: 600; }

/* ---------------------------------------------------------------- form */
.form { max-width: 520px; margin: 30px 0 12px; }

.field { margin-bottom: 18px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: .9rem;
  font-weight: 600;
}

.field input, .field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field .error {
  margin: 6px 0 0;
  min-height: 1em;
  color: #d64545;
  font-size: .84rem;
}

.button {
  display: inline-block;
  padding: 11px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button:hover { filter: brightness(1.07); text-decoration: none; }
.button:disabled { opacity: .6; cursor: progress; }

.form-status { margin: 14px 0 0; min-height: 1.4em; font-size: .93rem; }
.form-status.ok { color: #1a7f4b; }
.form-status.bad { color: #d64545; }

/* ---------------------------------------------------------------- footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: .9rem;
}

.site-footer .inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 28px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
}

.site-footer .links { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-left: auto; }
.site-footer a { color: var(--text-soft); }
.site-footer a:hover { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .tile:hover { transform: none; }
}
