/* ---------------------------------------------------------------------------
   Personal site — refined, content-forward, text-heavy.
   Type does the work; chrome stays out of the way.
   Identical between the Zola and Eleventy starters.
--------------------------------------------------------------------------- */

/* ---- Design tokens -------------------------------------------------------- */
:root {
  --font-body:
    'Atkinson Hyperlegible Next', ui-sans-serif, system-ui, -apple-system,
    'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono:
    'Atkinson Hyperlegible Mono', ui-monospace, 'SF Mono', Menlo, Consolas,
    'Liberation Mono', monospace;

  --measure: 40rem; /* reading column ~62ch at this size */
  --step: 1.5rem; /* base vertical rhythm */

  /* Dark (default) */
  --bg: #161512;
  --fg: #e9e5da;
  --muted: #968f80;
  --rule: #2b2924;
  --code-bg: #211f1a;
  --link: #7fb0ff;
  --link-hover: #a9c8ff;
  --accent: #ff6a3c;
}

/* OS preference when the visitor hasn't chosen explicitly */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #fcfbf8;
    --fg: #1b1a17;
    --muted: #6f6a60;
    --rule: #e7e3d9;
    --code-bg: #f1eee6;
    --link: #1652d6;
    --link-hover: #0b3da8;
    --accent: #c8431d;
  }
}

/* Explicit choice via the toggle */
[data-theme='light'] {
  --bg: #fcfbf8;
  --fg: #1b1a17;
  --muted: #6f6a60;
  --rule: #e7e3d9;
  --code-bg: #f1eee6;
  --link: #1652d6;
  --link-hover: #0b3da8;
  --accent: #c8431d;
}

[data-theme='dark'] {
  --bg: #161512;
  --fg: #e9e5da;
  --muted: #968f80;
  --rule: #2b2924;
  --code-bg: #211f1a;
  --link: #7fb0ff;
  --link-hover: #a9c8ff;
  --accent: #ff6a3c;
}

/* ---- Reset-ish ------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: var(--measure);
  padding: 0 1.25rem 4rem;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1.1875rem; /* ~19px */
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Smooth theme swap without animating page load */
body,
a,
button {
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ---- Links ---------------------------------------------------------------- */
a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
a:hover {
  color: var(--link-hover);
}

/* ---- Header / nav --------------------------------------------------------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding: 2rem 0 1.5rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--rule);
}
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  margin-right: auto; /* push nav to the right */
}
.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.01em;
}

/* PM brush monogram — P in ink (follows theme), M in accent. */
.brushmark {
  display: inline-flex;
  color: var(--fg);
  flex: none;
}
.pm-mark {
  width: 40px;
  height: 40px;
  display: block;
}
.pm-m {
  stroke: var(--accent);
}

/* Only the header instance gets a transition name (must be unique per page). */
.site-header .brushmark {
  view-transition-name: brushmark;
}

/* Enlarged mark on the landing page. */
.home-mark {
  color: var(--fg);
  margin-bottom: 0.75rem;
}
.home-mark .pm-mark {
  width: 116px;
  height: 116px;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.1rem;
  font-size: 0.9rem;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.site-nav a:hover {
  color: var(--accent);
}

#theme-toggle {
  background: none;
  border: none;
  padding: 0.2rem;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  line-height: 0;
}
#theme-toggle:hover {
  color: var(--accent);
}

/* ---- Typography in content ----------------------------------------------- */
h1,
h2,
h3 {
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.015em;
}
h1 {
  font-size: 2rem;
  margin: 0 0 1.5rem;
  border-left: 3px solid var(--accent);
  padding-left: 0.6rem;
}
h2 {
  font-size: 1.4rem;
  margin: 2.5rem 0 0.75rem;
}
h3 {
  font-size: 1.15rem;
  margin: 2rem 0 0.5rem;
}

.intro h1 {
  font-size: 2.4rem;
}
.lede {
  font-size: 1.2rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.post-meta,
time {
  color: var(--muted);
  font-size: 0.9rem;
}
.post-meta {
  margin: 0 0 2rem;
}

.prose > * + * {
  margin-top: var(--step);
}
.prose p,
.page p {
  margin: 0 0 var(--step);
}
.prose a {
  font-weight: 500;
}

blockquote {
  margin: var(--step) 0;
  padding-left: 1.1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 3rem 0;
}

/* ---- Code ----------------------------------------------------------------- */
code,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}
:not(pre) > code {
  background: var(--code-bg);
  padding: 0.12em 0.4em;
  border-radius: 4px;
}
pre {
  background: var(--code-bg);
  padding: 1rem 1.1rem;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.5;
}
pre code {
  background: none;
  padding: 0;
}

/* ---- Entry lists (5 Stars, Tech Notes, home) ------------------------------ */
.entries {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
}
.entries li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--rule);
}
.entries li:last-child {
  border-bottom: none;
}
.entries li a {
  text-decoration: none;
  font-weight: 500;
}
.entries li a:hover {
  color: var(--accent);
}
.entries time {
  white-space: nowrap;
}

.post-list h2 {
  margin-top: 3rem;
}

/* ---- Small screens -------------------------------------------------------- */
@media (max-width: 34rem) {
  body {
    font-size: 1.0625rem;
  }
  .intro h1 {
    font-size: 2rem;
  }
  .entries li {
    flex-direction: column;
    gap: 0.15rem;
  }
}

/* ---- Print (clean CV → PDF) ----------------------------------------------- */
@media print {
  :root {
    --bg: #fff;
    --fg: #000;
    --muted: #333;
    --rule: #ccc;
  }
  body {
    max-width: none;
    font-size: 11pt;
    padding: 0;
  }
  .site-nav,
  #theme-toggle,
  .site-footer {
    display: none;
  }
  .site-header {
    border: none;
    margin-bottom: 1rem;
    padding: 0;
  }
  a {
    color: #000;
    text-decoration: none;
  }
}

/* ---- View transitions (cross-document) ------------------------------------ */
/* Opt the whole site into smooth cross-fades on same-origin navigation. */
@view-transition {
  navigation: auto;
}

/* Slightly quicker than the default fade. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.22s;
}

/* Anchor the site title so it stays put while the rest of the page changes. */
.site-title {
  view-transition-name: site-title;
}

/* Honor reduced-motion for the transition pseudo-elements too — the global
   `* { transition: none }` rule above does not reach these. */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}
