/* ---- Theme tokens -------------------------------------------------- */
/* Light is the base. Dark is applied either by the OS preference or by
   an explicit data-theme="dark" set by the toggle. */

:root {
  color-scheme: light;

  --bg:        #fcfbf9;
  --bg-soft:   #f3f0ea;
  --text:      #1b1a17;
  --muted:     #6b6760;
  --rule:      #e2ded6;
  --accent:    #8f3a1c;

  --font-serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, "Times New Roman", serif;
  --font-sans:  ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --measure: 34rem;
  --gutter:  1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:      #131312;
    --bg-soft: #1e1d1b;
    --text:    #e9e6df;
    --muted:   #9a958c;
    --rule:    #2c2b28;
    --accent:  #e3906a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:      #131312;
  --bg-soft: #1e1d1b;
  --text:    #e9e6df;
  --muted:   #9a958c;
  --rule:    #2c2b28;
  --accent:  #e3906a;
}

/* ---- Base ---------------------------------------------------------- */

* { box-sizing: border-box; }

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

body {
  margin: 0;
  padding-inline: var(--gutter);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  transition: background-color .2s ease, color .2s ease;
}

.wrap {
  max-width: var(--measure);
  margin-inline: auto;
}

a {
  color: inherit;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: var(--accent); color: var(--accent); }

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

/* ---- Header -------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  padding-block: 2.25rem 2rem;
}

.site-name {
  font-family: var(--font-sans);
  font-size: .9375rem;
  font-weight: 600;
  letter-spacing: .01em;
  text-decoration: none;
  margin-right: auto;
}

.nav {
  display: flex;
  align-items: baseline;
  gap: 1.125rem;
  font-family: var(--font-sans);
  font-size: .875rem;
}

.nav a { text-decoration: none; color: var(--muted); }
.nav a:hover { color: var(--accent); }
.nav a[aria-current="page"] { color: var(--text); }

/* ---- Theme toggle -------------------------------------------------- */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  align-self: center;
  transition: color .15s ease, border-color .15s ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 1rem; height: 1rem; display: block; }

/* Show the sun in dark mode (click to go light) and the moon in light mode. */
.theme-toggle .icon-sun  { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---- Typography ---------------------------------------------------- */

h1, h2, h3 { line-height: 1.25; font-weight: 600; }

h1 { font-size: 1.75rem; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.1875rem; margin: 2.5rem 0 .75rem; }

.lede { color: var(--muted); font-size: 1.0625rem; margin-top: 0; }

p { margin: 0 0 1.15rem; }

blockquote {
  margin: 1.5rem 0;
  padding-left: 1.125rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
}

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

/* ---- Home ---------------------------------------------------------- */

.intro h1 { font-size: 2rem; }

.home-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-family: var(--font-sans);
  font-size: .9375rem;
  margin-top: 2rem;
}

/* ---- Writing list -------------------------------------------------- */

.post-list { list-style: none; margin: 2rem 0 0; padding: 0; }

.post-list li { padding-block: 1.125rem; border-top: 1px solid var(--rule); }
.post-list li:last-child { border-bottom: 1px solid var(--rule); }

.post-list a { text-decoration: none; font-size: 1.125rem; }

.post-meta {
  display: block;
  font-family: var(--font-sans);
  font-size: .8125rem;
  color: var(--muted);
  margin-top: .25rem;
}

.post-list p { margin: .4rem 0 0; color: var(--muted); font-size: .9375rem; }

.empty { color: var(--muted); font-style: italic; }

/* ---- Single post --------------------------------------------------- */

.post-header { margin-bottom: 2rem; }
.post-header .post-meta { margin-top: .5rem; }

.back {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: .875rem;
  color: var(--muted);
  text-decoration: none;
  margin-top: 3rem;
}
.back:hover { color: var(--accent); }

/* ---- Footer -------------------------------------------------------- */

.site-footer {
  margin-top: 4rem;
  padding-block: 1.75rem 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-sans);
  font-size: .8125rem;
  color: var(--muted);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-footer a { color: var(--muted); }

/* ---- Small screens ------------------------------------------------- */

@media (max-width: 30rem) {
  .site-header { padding-block: 1.75rem 1.5rem; }
  .intro h1 { font-size: 1.625rem; }
}

/* ---- Portrait on the About page ------------------------------------ */

.portrait {
  float: right;
  width: 13rem;
  margin: .35rem 0 1.25rem 1.5rem;
  border-radius: 6px;
  display: block;
}

/* Too narrow to wrap text beside it — let it sit on its own. */
@media (max-width: 34rem) {
  .portrait {
    float: none;
    width: 11rem;
    margin: 0 0 1.5rem;
  }
}
