/* Shared styles for every page: tokens, layout, sidebar, lists, mobile menu. */

:root {
  --ink: #161616;
  --text: #525252;
  --muted: #6f6f6f;
  --dim: #8d8d8d;
  --line: #efefef;
  --chip: #f4f4f4;
  --accent: #0e5a3a;
  --accent-dark: #0a4429;
  --tint: #e7efe9;
  --cream: #f6f1e6;
  --sage: #ecede4;
  --live: #12a150;
  --serif: "Libertinus Serif", "Linux Libertine", Georgia, serif;
  --sans: Inter, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --mono: "Fragment Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
/* Always reserve the scrollbar's space, so short and long pages line up exactly */
html { scroll-behavior: smooth; scrollbar-gutter: stable; }
body {
  margin: 0;
  background: #fff;
  color: var(--text);
  font: 300 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p, ul { margin: 0; }
p, li { text-wrap: pretty; }
h1, h2 { text-wrap: balance; }
a { color: inherit; }
::selection { background: var(--tint); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Underlined green links in running text */
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(14, 90, 58, .35);
  transition: color .2s, text-decoration-color .2s;
}
.prose a:hover { color: var(--accent-dark); text-decoration-color: currentColor; }

/* ---------- Layout ---------- */
.shell {
  display: grid;
  grid-template-columns: 180px 672px;
  justify-content: center;
  min-height: 100vh;
}
main {
  border-left: 1px solid var(--line);
  padding: 64px 32px 32px 63px;
  min-width: 0;
}
section { scroll-margin-top: 48px; }

/* ---------- Sidebar ---------- */
.side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding-top: 72px;
}
.wordmark {
  display: block;
  font: 900 21px/26px var(--sans);
  letter-spacing: -.05em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.side .wordmark { margin-left: 16px; }
.side nav { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.side nav a {
  position: relative;
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 16px;
  color: var(--muted);
  text-decoration: none;
  transition: color .2s;
}
.side nav a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform .3s var(--ease);
}
.side nav a:hover { color: var(--ink); }
.side nav a.active { color: var(--ink); font-weight: 400; }
.side nav a.active::before { transform: scaleY(1); }
.sep { height: 1px; background: var(--line); margin: 12px 16px; }

/* ---------- Type ---------- */
h1 {
  font: 400 56px/1 var(--serif);
  letter-spacing: -.02em;
  color: var(--ink);
}
h2 {
  font: 400 32px/1.2 var(--serif);
  letter-spacing: -.02em;
  color: var(--ink);
}
.soft { color: var(--dim); }
.lead { margin-top: 24px; }
.block { margin-top: 64px; }
.block > p { margin-top: 8px; }

/* ---------- One-line rows: title left, mono date right ---------- */
.rows { list-style: none; margin-top: 24px; padding: 0; }
.rows a, .row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  color: var(--ink);
  font-weight: 400;
  line-height: 1.7;
  text-decoration: none;
}
.rows a { padding: 6px 0; }
.row-title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: transparent;
  transition: color .2s, text-decoration-color .2s;
}
@media (hover: hover) {
  .rows a:hover .row-title { color: var(--accent); text-decoration-color: currentColor; }
}
.meta { flex: none; font: 400 14px/1.7 var(--mono); color: var(--dim); white-space: nowrap; }

/* Quiet text link with an arrow, used for "All writing" */
.more-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  text-decoration: none;
  transition: color .2s;
}
.more-link:hover { color: var(--ink); }

/* ---------- Tags ---------- */
.tag { display: inline-block; padding: 1px 8px; border-radius: 16px; background: var(--chip); color: var(--text); line-height: 1.6; }
.tag[data-tag="Essay"] { background: var(--tint); }
.tag[data-tag="Project"] { background: var(--cream); }
.tag[data-tag="Note"] { background: var(--sage); }
.tag[data-tag="Draft"] { background: #fff; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* Message shown when posts can't be loaded */
.notice { margin-top: 40px; padding: 16px 20px; border-radius: 12px; background: var(--chip); color: var(--text); }
.notice code { font: 400 14px/1.6 var(--mono); color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: 400 16px/1.7 var(--sans);
  text-decoration: none;
  white-space: nowrap;
  transition: background .2s;
}
.btn:hover { background: var(--accent-dark); }

/* Chevron that grows a shaft on hover */
.arrow { width: 12px; height: 12px; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.arrow .shaft { opacity: 0; transform: scaleX(0); transform-origin: 1px 6px; transition: opacity .2s, transform .25s var(--ease); }
.arrow .head { transition: transform .25s var(--ease); }
@media (hover: hover) {
  a:hover > .arrow .shaft { opacity: 1; transform: scaleX(1); }
  a:hover > .arrow .head { transform: translateX(3px); }
}

/* ---------- Contact card + footer ---------- */
.cta { margin: 64px -32px 0; padding: 32px; border-radius: 16px; background: var(--cream); }
.cta p { margin-top: 8px; }
.cta .btn { margin-top: 32px; }

footer { margin-top: 64px; text-align: center; color: var(--muted); }

/* ---------- Mobile header + menu ---------- */
.topbar, .menu { display: none; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-right: -11px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--dim);
  cursor: pointer;
}
.icon-btn svg { fill: none; stroke: currentColor; stroke-width: 1.5; }

@media (max-width: 959px) {
  .shell { display: block; }
  .side { display: none; }
  main { max-width: 624px; margin: 0 auto; padding: 4px 24px 32px; border-left: 0; }
  section { scroll-margin-top: 90px; }
  .topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
    align-items: center;
    justify-content: space-between;
    height: 74px;
    padding: 0 24px;
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(10px);
            backdrop-filter: blur(10px);
  }
  .menu {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    padding: 0 24px;
    background: #fff;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s, visibility .25s;
  }
  .menu-open .menu { opacity: 1; visibility: visible; }
  .menu-open body { overflow: hidden; }
  .menu-head { display: flex; align-items: center; justify-content: space-between; height: 74px; }
  .menu nav { display: flex; flex-direction: column; margin-top: 40px; }
  .menu nav a { font-size: 28px; line-height: 1.75; color: var(--muted); text-decoration: none; }
  .menu nav a:hover, .menu nav a.active { color: var(--ink); }
  .menu .sep { margin: 12px 0; }
}
@media (max-width: 719px) {
  .cta { margin-left: 0; margin-right: 0; }
}
@media (max-width: 639px) {
  h1 { font-size: 40px; }
  h2 { font-size: 28px; }
  .cta { padding: 24px; }
}

/* ---------- Reveal on scroll (only when JS runs) ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .9s var(--ease), transform .9s var(--ease);
}
.js [data-reveal].in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js [data-reveal] { opacity: 1; transform: none; transition: none; }
}
