/* Design tokens (matching themaxh.com) */
:root {
  --radius: 0.5rem;
  --background: #f7f3eb;
  --foreground: #180f09;
  --ink: #121c26;
  --card: #fbf8f2;
  --popover: #fbf8f2;
  --primary: #154d8c;
  --navy: #132b60;
  --secondary: #ede7dd;
  --muted-foreground: #5d5449;
  --accent: #e7d4bb;
  --destructive: #cc272e;
  --border: #d6ccc0;
  --font-serif: "Playfair Display", "Cormorant Garamond", Georgia, serif;
  --font-sans: "Inter", system-ui, sans-serif;
  /* Name only: the hero and the Thoughts header mark. One weight exists, 400. */
  --font-name: "Instrument Serif", var(--font-serif);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "kern";
  -webkit-font-smoothing: antialiased;
}

h1, h2 {
  font-family: var(--font-serif);
  color: var(--ink);
  letter-spacing: -0.02em;
  margin: 0;
}

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

a { color: inherit; }

.shell { margin: 0 auto; max-width: 72rem; padding: 0 1.5rem; }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  gap: 2.5rem;
  padding: 3rem 0 2.5rem;
}

.portrait {
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: color-mix(in srgb, var(--card) 40%, transparent);
}

.portrait img { height: 100%; width: 100%; object-fit: cover; }

/* On a phone a full-width 3:4 photo fills the whole first screen, pushing the
   name below the fold. Keep it full width but cap the height; object-fit crops. */
.hero .portrait { aspect-ratio: auto; height: 42vh; }

.hero-copy { display: flex; flex-direction: column; justify-content: center; }

.hero-copy h1 { font-family: var(--font-name); font-size: 4.25rem; font-weight: 400; line-height: 0.95; }

.lede {
  margin: 2rem 0 0;
  max-width: 36rem;
  font-size: 1.0625rem;
  line-height: 1.7;
  /* keep the last line from dropping a single orphaned word */
  text-wrap: pretty;
  color: var(--muted-foreground);
}

.lede strong { color: var(--ink); font-weight: 500; }

.rule { margin: 2.5rem auto 0; height: 1px; width: 16rem; background-color: var(--border); }

.socials {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
}

.socials a {
  color: var(--muted-foreground);
  transition: color 0.15s ease;
  /* padding grows the tap target, the negative margin keeps the layout put */
  padding: 0.7rem;
  margin: -0.7rem;
}
.socials a:hover { color: var(--primary); }
.socials svg { height: 1.4rem; width: 1.4rem; }

/* ---------- Sections ---------- */
section + section, .work { border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }

.work { padding: 3rem 0; text-align: center; }

.work h2, .about h2 { font-size: 2.25rem; }

.work h2 .dot { color: var(--primary); }

.cards { margin: 3rem auto 0; display: flex; max-width: 36rem; flex-direction: column; gap: 1.5rem; }

.card {
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--card);
  padding: 1.25rem;
  text-align: left;
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  a.card:hover {
    transform: translateY(-4px);
    border-color: color-mix(in srgb, var(--primary) 40%, transparent);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  }
}

.card-logo {
  display: flex;
  height: 2.75rem;
  width: 2.75rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: calc(var(--radius) - 2px);
  background-color: var(--secondary);
}

.card-logo img { height: 100%; width: 100%; object-fit: contain; }

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

.card-head { display: flex; align-items: center; gap: 0.5rem; }

.card-name { font-weight: 600; letter-spacing: 0.025em; color: var(--ink); }

.tag {
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.125rem 0.5rem;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted-foreground);
}

.tag--destructive { color: var(--destructive); }

.card-blurb { margin: 0.125rem 0 0; font-size: 0.875rem; color: var(--muted-foreground); }

.card .arrow { height: 1rem; width: 1rem; flex-shrink: 0; color: var(--primary); transition: opacity 0.2s ease; }

/* Touch devices have no hover, so the arrow simply stays visible there. */
@media (hover: hover) and (pointer: fine) {
  .card .arrow { opacity: 0; }
  a.card:hover .arrow { opacity: 1; }
}

.card:focus-visible,
.socials a:focus-visible,
footer nav a:focus-visible,
.text-link:focus-visible,
.post-link:focus-visible,
.back-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Understated text link, used beside the social icons and in the footer */
.text-link {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: color 0.15s ease;
}
.text-link:hover { color: var(--primary); }

/* ---------- About ---------- */
.about { display: grid; gap: 3rem; padding: 3rem 0; }

.about-copy p {
  margin: 0 0 1.5rem;
  font-size: 1.0625rem;
  line-height: 1.7;
  text-wrap: pretty;
  color: var(--muted-foreground);
}

.about-copy .prose { margin-top: 2.5rem; }
.about-copy .prose p:last-child { margin-bottom: 0; }

/* Opening line of the About copy: the thesis the paragraphs below unpack, so
   it carries the darker ink and a little more weight than the prose. */
.about-copy .about-lede {
  margin-bottom: 1.75rem;
  font-weight: 600;
  color: var(--ink);
}

/* "A bit more..." fold holding the personal detail. Native <details>, so it works
   with no JavaScript and the triangle is drawn rather than loaded as an icon. */
.about-more > summary {
  /* full width on phones so the whole row is tappable, not just the words */
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 0;
  cursor: pointer;
  font-size: 1rem;
  color: var(--navy);
  /* a tap should open the fold, not start selecting the label */
  -webkit-user-select: none;
  user-select: none;
  /* hide the browser's own disclosure triangle in favour of the one below */
  list-style: none;
}

/* The dots echo the "What I do..." heading. */
.about-more > summary .dot { color: var(--navy); }

.about-more > summary::-webkit-details-marker { display: none; }

.about-more > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.2s ease;
}

.about-more[open] > summary::before { transform: rotate(90deg); }

.about-more > summary:hover { text-decoration: none; }
.about-more > summary:hover .summary-label { text-decoration: underline; }

.about-more > summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 2px;
}

.about-more-body { margin-top: 1.25rem; }

.about-more-body ul {
  margin: 0 0 1.5rem;
  padding-left: 1.25rem;
  font-size: 1.0625rem;
  line-height: 1.7;
  text-wrap: pretty;
  color: var(--muted-foreground);
}

/* Small caps labels heading the blocks under the places list. The size,
   letter-spacing and case match the post meta line used in Thoughts. */
.about-copy .about-more-body p.about-more-label {
  margin: 2rem 0 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink);
}

.about-more-body li { margin-bottom: 0.75rem; }
.about-more-body li:last-child { margin-bottom: 0; }
.about-more-body a { color: var(--primary); text-decoration: none; }
.about-more-body a:hover { text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .about-more > summary::before { transition: none; }
}

/* ---------- Footer ---------- */
footer {
  margin: 0 auto;
  max-width: 72rem;
  padding: 3rem 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

footer .hairline {
  margin: 0 auto;
  height: 1px;
  width: 100%;
  max-width: 20rem;
  background-color: color-mix(in srgb, var(--border) 60%, transparent);
}

footer nav { margin-top: 2rem; display: flex; align-items: center; justify-content: center; gap: 2rem; }
footer nav svg { height: 1.25rem; width: 1.25rem; }
footer nav a { display: flex; align-items: center; padding: 0.75rem; margin: -0.75rem; }
footer .copyright { margin-top: 1.5rem; }

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

.site-header-inner {
  margin: 0 auto;
  max-width: 42.5rem;
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-header-inner--wide { max-width: 60rem; }

.site-mark {
  display: inline-block;
  padding: 0.35rem 0;
  margin: -0.35rem 0;
  font-family: var(--font-name);
  font-size: 1.375rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  transition: color 0.15s ease;
}
.site-mark:hover { color: var(--primary); }

.site-header-social { display: flex; align-items: center; gap: 1.25rem; }

.site-header-social a {
  line-height: 0;
  color: var(--muted-foreground);
  transition: color 0.15s ease;
  padding: 0.85rem;
  margin: -0.85rem;
}
.site-header-social a:hover { color: var(--primary); }
.site-header-social svg { height: 1.125rem; width: 1.125rem; }

.site-mark:focus-visible,
.site-header-social a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 2px;
}

.reading {
  margin: 0 auto;
  max-width: 42.5rem; /* ~680px */
  padding: 2.25rem 1.25rem 1rem;
}

.reading--index { max-width: 60rem; }

.back-link {
  display: inline-block;
  padding: 0.4rem 0;
  margin: -0.4rem 0;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: color 0.15s ease;
}
.back-link:hover { color: var(--primary); }

.page-title { margin-top: 2.5rem; font-size: 2rem; font-weight: 700; line-height: 1.12; }

/* On the index the heading leads, centered over the grid */
.page-title--top { margin-top: 0; text-align: center; }

.reading--index .page-intro {
  margin-left: auto;
  margin-right: auto;
  max-width: 34rem;
  text-align: center;
}


.page-intro {
  margin: 0.875rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--muted-foreground);
}

/* Index grid of post cards */
.post-list {
  margin: 2.5rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2.5rem;
}

.post-item { display: flex; }

.post-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--card);
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .post-card:hover {
    transform: translateY(-4px);
    border-color: color-mix(in srgb, var(--primary) 40%, transparent);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  }
  .post-card:hover .post-thumb img { transform: scale(1.03); }
}

.post-thumb {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background-color: color-mix(in srgb, var(--secondary) 60%, transparent);
}

.post-thumb img {
  height: 100%;
  width: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.post-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 1.25rem;
}

.post-link {
  display: block;
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: -0.01em;
  transition: color 0.15s ease;
}
.post-card:hover .post-link { color: var(--primary); }

.post-meta {
  margin-top: 0.625rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted-foreground);
}

.post-lead figcaption a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.post-lead figcaption a:hover { color: var(--primary); }

.post-tag {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  letter-spacing: 0.15em;
  color: var(--ink);
}

.post-desc {
  display: block;
  margin: 0.875rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--muted-foreground);
}

.page-foot { margin-top: 3.5rem; }

.foot-links { display: flex; flex-wrap: wrap; gap: 1.75rem; }

/* Post reading layout */
.post-header { margin-bottom: 2.5rem; }

.post-lead { margin: 0 0 3rem; }

.post-lead img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: color-mix(in srgb, var(--card) 40%, transparent);
}

.post-lead figcaption {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--muted-foreground);
}

.post-body {
  font-size: 1.0625rem; /* 17px on phones, 18px from 768px up */
  line-height: 1.75;
  color: var(--muted-foreground);
  overflow-wrap: break-word;
}

.post-body h2 { margin: 3rem 0 1rem; font-size: 1.625rem; font-weight: 700; }
.post-body h3 { margin: 2.5rem 0 1rem; font-size: 1.25rem; font-weight: 600; }
.post-body p { margin: 0 0 1.5rem; }
.post-body a { color: var(--primary); text-decoration: none; }
.post-body a:hover { text-decoration: underline; }
.post-body strong { color: var(--ink); font-weight: 600; }

.post-body blockquote {
  margin: 2rem 0;
  padding-left: 1.5rem;
  border-left: 2px solid var(--accent);
  font-style: italic;
}
.post-body blockquote p:last-child { margin-bottom: 0; }

.post-body ul, .post-body ol { margin: 0 0 1.5rem; padding-left: 1.5rem; }
.post-body li { margin-bottom: 0.5rem; }

.post-body figure { margin: 2.5rem 0; }
.post-body img { border: 1px solid var(--border); border-radius: var(--radius); }

.post-body code {
  font-size: 0.9em;
  overflow-wrap: anywhere;
  background-color: var(--secondary);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.post-body pre {
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--card);
  font-size: 0.9375rem;
  line-height: 1.6;
}
.post-body pre code { background: none; padding: 0; }

.post-body hr {
  margin: 3rem auto;
  width: 6rem;
  height: 1px;
  border: 0;
  background-color: var(--border);
}

.post-foot {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

.more-posts { margin-bottom: 3rem; }
.more-posts-title { font-size: 1.375rem; font-weight: 700; }
.post-foot .post-list--more { margin-top: 1.5rem; }

/* "I also write occasionally" line, below the About section */
.write-note {
  margin: 0;
  padding: 0 0 3rem;
  text-align: center;
  font-size: 0.9375rem;
  color: var(--muted-foreground);
}
.write-note a {
  display: inline-block;
  padding: 0.3rem 0;
  margin: -0.3rem 0;
  color: var(--navy);
  text-decoration: none;
}
.write-note a:hover { text-decoration: underline; }

/* Hand-drawn arrow pointing back at the Thoughts link. It appears only while
   the "A bit more..." fold is open, so it rewards opening it rather than
   sitting there permanently. :has() does the state test with no JavaScript;
   where :has() is unsupported the arrow simply stays hidden. */
.write-link { position: relative; display: inline-block; }

/* Positioned off the link's left edge, so the link itself stays centered.
   Desktop only: on phones the link already sits plainly under the photo. */
.write-arrow {
  display: none;
  position: absolute;
  right: 100%;
  top: 50%;
  width: 3.5rem;
  margin-right: 1.25rem;
  color: var(--navy);
  opacity: 0;
  /* -64% puts the arrowhead level with the text; the tail rises toward the copy above */
  transform: translate(0.5rem, -64%);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}

.write-arrow svg { display: block; width: 100%; height: auto; overflow: visible; }

.shell:has(.about-more[open]) .write-arrow {
  opacity: 0.95;
  transform: translate(0, -64%);
}


@media (prefers-reduced-motion: reduce) {
  .write-arrow { transition: none; }
}

@media (min-width: 768px) {
  .write-arrow { display: block; width: 5rem; margin-right: 2.75rem; }
  /* With the fold open, close the gap so the arrow picks up where the reading ends. */
  .shell:has(.about-more[open]) .about { padding-bottom: 2.5rem; }
}

/* Rotating About photo */
.portrait--rotating { position: relative; }
.portrait--rotating img {
  transition: opacity 1s ease;
}
.portrait--rotating img:not(:first-child) {
  position: absolute;
  inset: 0;
}
.portrait--rotating img.is-hidden { opacity: 0; }

/* 404 */
.notfound { text-align: center; padding-top: 6rem; }
.notfound .page-intro { margin-left: auto; margin-right: auto; }
.notfound-links {
  margin-top: 2rem;
  display: flex;
  justify-content: center;
  gap: 1.75rem;
  font-size: 0.9375rem;
}
.notfound-links a { color: var(--primary); text-decoration: none; }
.notfound-links a:hover { text-decoration: underline; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Responsive ---------- */
@media (min-width: 768px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) 1.4fr;
    gap: 4rem;
    padding: 8rem 0 4rem;
  }
  .hero .portrait { aspect-ratio: 3 / 4; height: auto; }
  .about-more > summary { width: fit-content; min-height: 0; padding: 0.4rem 0; }
  .lede { font-size: 1.125rem; line-height: 1.75; }
  .about-copy p { font-size: 1.125rem; line-height: 1.75; }
  .about-more-body ul { font-size: 1.125rem; line-height: 1.75; }
  .rule { margin-top: 5rem; }
  .hero-copy h1 { font-size: 7rem; }
  .work { padding: 4rem 0; }
  .work h2, .about h2 { font-size: 3rem; }
  .about { grid-template-columns: 1.4fr minmax(0, 1fr); gap: 4rem; padding: 4rem 0; }
  .reading { padding: 4rem 1.5rem 1rem; }
  .site-header-inner { padding: 1rem 1.5rem; }
  .page-title { font-size: 2.75rem; }
  .page-intro { font-size: 1rem; }
  .post-body { font-size: 1.125rem; line-height: 1.8; }
  .post-header { margin-bottom: 3rem; }
  .post-list { margin-top: 3.5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3rem 2.5rem; }
  .post-link { font-size: 1.375rem; }
  .post-card-body { padding: 1.75rem; }
}
