/* ============================================================
   Josiah Legg - Blog
   Self-contained: served from blog.josiahlegg.com, so it never
   references main-site assets. Shares the portfolio's design
   tokens (colors, fonts, grain) but has its own minimal layout.
   ============================================================ */

/* ---------- Color themes ---------- */
:root[data-theme="light"] {
  --text: #0f0d08;
  --background: #fefae7;
  --primary: #a69e5f;
  --secondary: #a3ccba;
  --accent: #80b4b8;
}

:root[data-theme="dark"] {
  --text: #f6f4ee;
  --background: #181501;
  --primary: #a19959;
  --secondary: #335c4a;
  --accent: #487c7f;
}

/* ---------- Design tokens ---------- */
:root {
  --font-secondary: "Cascadia Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-logo: "Bricolage Grotesque", system-ui, sans-serif;

  --ease-in-out-sine: cubic-bezier(.445, .05, .55, .95);
  --ease-out-cubic: cubic-bezier(.215, .61, .355, 1);

  --theme-transition-duration: 0.4s;

  /* Reading column: 46rem, centered. */
  --column-pad: max(1.5rem, calc(50% - 23rem));

  --hairline: color-mix(in srgb, var(--primary), transparent 70%);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

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

button {
  font: inherit;
}

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

/* ---------- Base ---------- */
html {
  font-family: var(--font-secondary);
  font-size: 17px;
  color: var(--text);
  background-color: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--primary), transparent 35%) transparent;
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 3px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--primary), transparent 35%);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Grain overlay, same recipe as the portfolio */
html::before,
html::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99999;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

html::after {
  mix-blend-mode: multiply;
  opacity: 0.5;
}

html::before {
  mix-blend-mode: screen;
  opacity: 0.4;
}

body {
  background-color: transparent;
  color: var(--text);
  transition:
    background-color var(--theme-transition-duration) var(--ease-in-out-sine),
    color var(--theme-transition-duration) var(--ease-in-out-sine);
  min-height: 100vh;
}

/* ---------- Header ---------- */
.blog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 2.5rem var(--column-pad) 0;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  color: var(--text);
  transition: color var(--theme-transition-duration) var(--ease-in-out-sine), opacity 0.2s ease;
}

.logo:hover {
  opacity: 0.7;
}

.logo-icon {
  height: 1.7em;
  width: 1.7em;
  flex-shrink: 0;
}

.logo-icon-bg {
  fill: var(--background);
  transition: fill var(--theme-transition-duration) var(--ease-in-out-sine);
}

.logo-icon-text {
  font-family: var(--font-logo);
  font-weight: 600;
  font-size: 48px;
  letter-spacing: -0.01em;
  fill: var(--text);
  transition: fill var(--theme-transition-duration) var(--ease-in-out-sine);
}

.logo-text {
  font-family: var(--font-logo);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  margin: -0.4rem;
  color: var(--text);
  border-radius: 99px;
  touch-action: manipulation;
  transition: color var(--theme-transition-duration) var(--ease-in-out-sine), opacity 0.2s ease;
}

.theme-toggle:hover {
  opacity: 0.65;
}

.theme-toggle svg {
  width: 0.9rem;
  height: 0.9rem;
  stroke: currentColor;
  fill: none;
}

.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle .icon-moon {
  display: inline-flex;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: inline-flex;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* ---------- Layout ---------- */
.blog-main {
  padding: 0 var(--column-pad) 5rem;
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.4;
  margin: 0 0 1rem;
}

/* ---------- Index: hero + post list ---------- */
.blog-hero {
  margin: 4.5rem 0 3.5rem;
}

.blog-title {
  font-family: var(--font-logo);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0;
}

.blog-intro {
  font-size: 1rem;
  line-height: 1.7;
  opacity: 0.65;
  max-width: 60ch;
  margin: 1rem 0 0;
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.post-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--hairline);
  transition: opacity 0.3s ease;
}

.post-list li:last-child .post-row {
  border-bottom: 1px solid var(--hairline);
}

.post-row-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-logo);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.post-row-arrow {
  width: 0.5em;
  height: 0.5em;
  fill: var(--text);
  opacity: 0;
  transition: opacity 0.2s ease, fill var(--theme-transition-duration) var(--ease-in-out-sine);
}

.post-row:hover .post-row-arrow,
.post-row:focus-visible .post-row-arrow {
  opacity: 1;
}

.post-row-date {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.45;
  flex-shrink: 0;
}

/* ---------- Post page ---------- */
.post-header {
  margin: 4.5rem 0 2.5rem;
}

.post-heading {
  font-family: var(--font-logo);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0;
}

.post-body {
  max-width: 65ch;
}

.post-body p {
  font-size: 1rem;
  line-height: 1.75;
  opacity: 0.8;
  margin: 0 0 1.25rem;
}

.post-body h2 {
  font-family: var(--font-logo);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 2.5rem 0 1rem;
}

.post-body a {
  font-weight: 500;
  border-bottom: 1px solid color-mix(in srgb, var(--primary), transparent 45%);
  padding-bottom: 0.1rem;
  transition: border-color 0.3s ease;
}

.post-body a:hover {
  border-color: var(--primary);
}

.post-body ul,
.post-body ol {
  margin: 0 0 1.25rem;
  padding-left: 1.4rem;
  line-height: 1.75;
  opacity: 0.8;
}

.post-body li {
  margin-bottom: 0.4rem;
}

.post-body code {
  font-family: var(--font-secondary);
  font-size: 0.9em;
  background: color-mix(in srgb, var(--primary), transparent 86%);
  padding: 0.1em 0.4em;
  border-radius: 0.3em;
}

.post-body pre {
  border: 1px solid color-mix(in srgb, var(--primary), transparent 55%);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin: 0 0 1.25rem;
  overflow-x: auto;
  line-height: 1.6;
  font-size: 0.875rem;
}

.post-body pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.post-body blockquote {
  border-left: 2px solid var(--primary);
  margin: 0 0 1.25rem;
  padding: 0.25rem 0 0.25rem 1.25rem;
  opacity: 0.7;
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--hairline);
  margin: 2.5rem 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: fit-content;
  margin-top: 3rem;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid color-mix(in srgb, var(--primary), transparent 45%);
  padding-bottom: 0.15rem;
  transition:
    gap 0.3s var(--ease-out-cubic),
    border-color 0.3s ease,
    color var(--theme-transition-duration) var(--ease-in-out-sine);
}

.back-link:hover {
  gap: 0.7rem;
  border-color: var(--primary);
}

.back-link svg {
  width: 0.7em;
  height: 0.7em;
  fill: currentColor;
}

/* ---------- Footer ---------- */
.blog-footer {
  padding: 0 var(--column-pad) 3rem;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.35;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
