/* =========================================================
   Theme tokens
   ========================================================= */
:root {
  --bg: #f6f4ef;
  --bg-elev: #fffdf9;
  --text: #14130f;
  --muted: #67635a;
  --faint: #9a958a;
  --border: rgba(20, 19, 15, 0.1);
  --accent: #b4532a;
  --glow: rgba(196, 98, 52, 0.22);
  --btn-bg: #14130f;
  --btn-text: #f6f4ef;

  --wide: 74rem;
  --narrow: 42rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);

  --font-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --font-sans: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0b;
    --bg-elev: #161613;
    --text: #f2efe8;
    --muted: #a6a195;
    --faint: #6e6a61;
    --border: rgba(242, 239, 232, 0.1);
    --accent: #e8935f;
    --glow: rgba(232, 147, 95, 0.16);
    --btn-bg: #f2efe8;
    --btn-text: #0d0d0b;
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Fine film grain for a tactile, printed feel */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--accent); color: var(--bg); }

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 0;
}

em { font-style: italic; }
.accent { color: var(--accent); }

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

.container {
  width: 100%;
  max-width: var(--wide);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.narrow { max-width: calc(var(--narrow) + 2 * var(--gutter)); }

.eyebrow {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.skip {
  position: absolute;
  left: -999px;
}
.skip:focus { left: 1rem; top: 1rem; z-index: 200; background: var(--bg-elev); padding: 0.5rem 1rem; }

/* =========================================================
   Header
   ========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}

.site-header.scrolled { border-bottom-color: var(--border); }

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 4.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-family: var(--font-display);
  font-size: 1.1rem;
  line-height: 1;
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2rem);
}

.nav a {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s var(--ease);
}

.nav a:not(.button)::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.35s var(--ease);
}

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

.nav a:hover::after,
.nav a[aria-current="page"]::after {
  transform: scaleX(1);
  transform-origin: left;
}

.nav .button { margin-left: 0.5rem; }

@media (max-width: 560px) {
  .nav .button { display: none; }
}

/* =========================================================
   Buttons & links
   ========================================================= */
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.4rem;
  border-radius: 999px;
  border: 1px solid var(--btn-bg);
  background: var(--btn-bg);
  color: var(--btn-text);
  text-decoration: none;
  font: 500 0.95rem/1 var(--font-sans);
  cursor: pointer;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px -10px var(--glow), 0 4px 12px -6px rgba(0, 0, 0, 0.25);
}

.button.small { padding: 0.55rem 1rem; font-size: 0.85rem; }
.nav a.button, .nav a.button:hover { color: var(--btn-text); }

.button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.button.ghost:hover { border-color: var(--text); box-shadow: none; }

.arrow {
  display: inline-block;
  transition: transform 0.35s var(--ease);
}

.button:hover .arrow,
.link-arrow:hover .arrow { transform: translateX(4px); }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
  transition: border-color 0.2s var(--ease);
}

.link-arrow:hover { border-color: var(--text); }

/* =========================================================
   Landing hero
   ========================================================= */
.hero {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100svh - 4.5rem);
  padding-block: clamp(3rem, 8vh, 6rem) 2rem;
}

.hero::before {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
  width: min(70rem, 140vw);
  aspect-ratio: 1;
  right: -20vw;
  top: -40vh;
  background: radial-gradient(circle at center, var(--glow), transparent 60%);
  filter: blur(20px);
  animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
  to { transform: translate(-8%, 10%) scale(1.08); }
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  width: fit-content;
  padding: 0.4rem 0.9rem 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-elev) 60%, transparent);
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

.status-dot {
  position: relative;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #3fae6a;
}

.status-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #3fae6a;
  animation: ping 2.2s var(--ease) infinite;
}

@keyframes ping {
  0% { transform: scale(1); opacity: 0.6; }
  80%, 100% { transform: scale(2.8); opacity: 0; }
}

.hero h1 {
  font-size: clamp(3.25rem, 11vw, 8.5rem);
  max-width: 14ch;
}

.hero h1 em { color: var(--accent); }

.hero .tagline {
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  color: var(--muted);
  max-width: 34rem;
  margin: 2rem 0 2.5rem;
  line-height: 1.55;
}

.actions {
  display: flex;
  align-items: center;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
}

.hero-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  margin-top: clamp(4rem, 10vh, 7rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.hero-meta span { display: block; }
.hero-meta .eyebrow { margin-bottom: 0.25rem; }

/* =========================================================
   Content pages
   ========================================================= */
main { flex: 1; }

.page-head {
  padding-block: clamp(3.5rem, 10vh, 7rem) clamp(2.5rem, 6vh, 4rem);
  border-bottom: 1px solid var(--border);
}

.page-head .eyebrow { display: block; margin-bottom: 1.25rem; }

.page-head h1 {
  font-size: clamp(3rem, 9vw, 6.5rem);
  max-width: 16ch;
}

.page-head h1 em { color: var(--accent); }

.page-head .lead {
  margin: 1.75rem 0 0;
  max-width: 36rem;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--muted);
}

/* About: two-column intro */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(2rem, 6vw, 6rem);
  padding-block: clamp(3rem, 8vh, 5rem);
  align-items: start;
}

@media (max-width: 760px) {
  .about-grid { grid-template-columns: 1fr; }
}

.portrait {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 1.25rem;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, var(--glow), transparent 60%),
    linear-gradient(160deg, var(--bg-elev), color-mix(in srgb, var(--text) 8%, var(--bg)));
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
}

.portrait span {
  font-family: var(--font-display);
  font-size: clamp(4rem, 10vw, 7rem);
  color: var(--faint);
}

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

@media (max-width: 760px) {
  .portrait { aspect-ratio: 4 / 3; }
}

.prose p { margin: 0 0 1.25rem; }
.prose p:first-child {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.2vw, 2.25rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

/* Numbered services */
.section { padding-block: clamp(3rem, 8vh, 5rem); border-top: 1px solid var(--border); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.section-head h2 { font-size: clamp(2.25rem, 5vw, 3.5rem); }

.services {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
}

.services li {
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--bg-elev) 50%, transparent);
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease);
}

.services li:hover { border-color: color-mix(in srgb, var(--text) 30%, transparent); transform: translateY(-3px); }

.services .num {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--accent);
}

.services h3 { font-size: 1.75rem; margin: 2.5rem 0 0.6rem; }
.services p { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* =========================================================
   Blog list
   ========================================================= */
.post-list { list-style: none; padding: 0; margin: 0 0 clamp(3rem, 8vh, 5rem); }

.post-list a {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: baseline;
  padding-block: 2rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: padding 0.4s var(--ease);
}

.post-list a:hover { padding-inline: 0.75rem; }

.post-list time { font-size: 0.85rem; color: var(--faint); }

.post-list h2 {
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  line-height: 1.1;
  transition: color 0.2s var(--ease);
}

.post-list a:hover h2 { color: var(--accent); }

.post-list p { margin: 0.6rem 0 0; color: var(--muted); max-width: 38rem; }

.post-list .arrow { font-size: 1.25rem; color: var(--faint); }
.post-list a:hover .arrow { transform: translate(4px, -4px); color: var(--text); }

@media (max-width: 640px) {
  .post-list a { grid-template-columns: 1fr; gap: 0.5rem; }
  .post-list .arrow { display: none; }
}

/* =========================================================
   Single post
   ========================================================= */
.post-head {
  padding-block: clamp(3.5rem, 10vh, 6rem) 2.5rem;
}

.post-head h1 { font-size: clamp(2.75rem, 7vw, 5rem); margin: 1.25rem 0; }

.post-body {
  padding-bottom: clamp(3rem, 8vh, 5rem);
  font-size: 1.125rem;
  line-height: 1.8;
}

.post-body p { margin: 0 0 1.5rem; }
.post-body > p:first-child::first-letter {
  float: left;
  font-family: var(--font-display);
  font-size: 4.2em;
  line-height: 0.85;
  padding: 0.08em 0.12em 0 0;
  color: var(--accent);
}

.post-dek {
  margin: 0 0 1.5rem;
  max-width: 36rem;
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--muted);
}

.post-body h2 { font-size: 2rem; margin: 3rem 0 1rem; }

.post-body ul { margin: 0 0 1.5rem; padding-left: 1.25rem; }
.post-body li { margin-bottom: 0.75rem; padding-left: 0.25rem; }
.post-body li::marker { color: var(--accent); }
.post-body a { color: var(--accent); text-underline-offset: 3px; }

.post-body code {
  font-size: 0.88em;
  padding: 0.15em 0.4em;
  border-radius: 0.35rem;
  background: color-mix(in srgb, var(--text) 7%, transparent);
}

.post-body blockquote {
  margin: 2.5rem 0;
  padding-left: 1.5rem;
  border-left: 2px solid var(--accent);
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1.3;
}

/* =========================================================
   CTA band
   ========================================================= */
.cta {
  padding-block: clamp(4rem, 12vh, 8rem);
  border-top: 1px solid var(--border);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.cta::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  bottom: -60%;
  width: min(60rem, 140vw);
  aspect-ratio: 1;
  transform: translateX(-50%);
  background: radial-gradient(circle, var(--glow), transparent 60%);
}

.cta h2 {
  font-size: clamp(2.75rem, 8vw, 6rem);
  margin: 1rem auto 2.25rem;
  max-width: 14ch;
}

.cta h2 em { color: var(--accent); }

.cta .actions { justify-content: center; }

/* =========================================================
   Footer
   ========================================================= */
.site-footer {
  padding-block: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}

.footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }

.site-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.site-footer a:hover { color: var(--text); }

/* =========================================================
   Contact form
   ========================================================= */
.contact-form { display: block; }

.form-body { display: grid; gap: 1.1rem; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
}

@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
}

.field { display: grid; gap: 0.45rem; }

.field > span {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.field .optional { font-style: normal; color: var(--faint); font-weight: 400; }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg-elev);
  color: var(--text);
  font: 400 1rem/1.4 var(--font-sans);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}

.field textarea { resize: vertical; min-height: 8rem; }
.field ::placeholder { color: var(--faint); }

.field select {
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23908a7f' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  cursor: pointer;
}

.field input:hover,
.field select:hover,
.field textarea:hover { border-color: color-mix(in srgb, var(--text) 25%, transparent); }

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--glow);
}

.was-validated .field :invalid { border-color: #c2412d; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.form-error {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: color-mix(in srgb, #c2412d 10%, transparent);
  color: #c2412d;
  font-size: 0.9rem;
}

@media (prefers-color-scheme: dark) {
  .form-error { color: #f08c78; }
}

.submit {
  justify-content: center;
  width: 100%;
  padding-block: 1rem;
  margin-top: 0.25rem;
}

.submit:disabled { opacity: 0.7; cursor: progress; transform: none; }

.form-note {
  margin: 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--faint);
}

.form-success {
  text-align: center;
  padding: 2rem 0 1rem;
  outline: none;
}

.form-success h3 { font-size: 2.5rem; margin: 1.25rem 0 0.5rem; }
.form-success p { margin: 0; color: var(--muted); }

.success-mark {
  display: inline-grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: 1.4rem;
  animation: pop 0.5s var(--ease);
}

@keyframes pop {
  from { transform: scale(0.6); opacity: 0; }
}

/* Modal */
.contact-dialog {
  width: min(36rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.35);
}

.contact-dialog[open] { animation: dialog-in 0.45s var(--ease); }

.contact-dialog::backdrop {
  background: rgba(13, 13, 11, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
}

.contact-dialog h2 { font-size: clamp(2.5rem, 7vw, 3.25rem); margin: 0.6rem 0 0.5rem; }

.dialog-lead { margin: 0 0 1.75rem; color: var(--muted); }

.dialog-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.3s var(--ease);
}

.dialog-close:hover { color: var(--text); border-color: var(--text); transform: rotate(90deg); }

html.modal-open { overflow: hidden; }

/* Contact page */
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
  gap: clamp(2rem, 6vw, 6rem);
  padding-block: clamp(3rem, 8vh, 5rem);
  align-items: start;
}

@media (max-width: 760px) {
  .contact-grid { grid-template-columns: 1fr; }
}

.contact-aside p { margin: 0 0 1.5rem; color: var(--muted); }
.contact-aside dl { margin: 0; display: grid; gap: 1.25rem; }
.contact-aside dt { margin-bottom: 0.2rem; }
.contact-aside dd { margin: 0; }

.contact-card {
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  background: color-mix(in srgb, var(--bg-elev) 60%, transparent);
}

/* =========================================================
   Entrance motion
   ========================================================= */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  animation: rise 1s var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 110ms + 80ms);
}

@keyframes rise {
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .reveal { opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}
