:root{
  --bg: #fffdfb;
  --text: #23262b;
  --muted: #5b6472;
  --accent: #5d86b6;          /* soft blue replacing purple */
  --accent-strong: #3d6a9a;
  --rule: #e9ecf2;
}

@media (prefers-color-scheme: dark){
  :root{
    --bg: #0b0f16;
    --text: #e8eaee;
    --muted: #b3bdcc;
    --accent: #9fc0ea;
    --accent-strong: #c8dcf7;
    --rule: #1a2331;
  }
}

/* Explicit theme overrides via data-theme attribute */
html[data-theme="light"]{
  color-scheme: light;
  --bg: #fffdfb;
  --text: #23262b;
  --muted: #5b6472;
  --accent: #5d86b6;
  --accent-strong: #3d6a9a;
  --rule: #e9ecf2;
}
html[data-theme="dark"]{
  color-scheme: dark;
  --bg: #0b0f16;
  --text: #e8eaee;
  --muted: #b3bdcc;
  --accent: #9fc0ea;
  --accent-strong: #c8dcf7;
  --rule: #1a2331;
}

*{ box-sizing:border-box; }
html, body{ margin:0; padding:0; background:var(--bg); color:var(--text); }
body{
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, "Helvetica Neue", Arial, "Noto Sans";
  line-height:1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container{ max-width: 940px; margin: 0 auto; padding: 28px 20px; }

header.site{
  display:flex; align-items:center; justify-content:space-between;
  gap:12px;
}
a{ color: var(--accent); text-decoration: none; }
a:hover{ color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }

/* Hamburger button (hidden on desktop) */
.menu-btn{
  display:none;
  position: relative;
  width: 36px; height: 28px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.menu-btn .menu-icon,
.menu-btn .menu-icon::before,
.menu-btn .menu-icon::after{
  content: "";
  position: absolute;
  height: 2px;
  background: var(--muted);
}
.menu-btn .menu-icon{ top: 50%; transform: translateY(-50%); left: 8px; right: 8px; }
.menu-btn .menu-icon::before{ top: -6px; left: 0; right: 0; }
.menu-btn .menu-icon::after{ top: 6px; left: 0; right: 0; }

.nav a{
  letter-spacing: 0.06em;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  margin-left: 20px;
  position: relative;
  display: inline-block;
  padding-bottom: 4px;
  transition: color .2s ease, font-weight .2s ease;
}
.nav a::after{
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 80%;
  height: 2px;
  background: currentColor;
  transform: translateX(-50%) scaleX(0);
  transform-origin: center;
  transition: transform .25s ease;
}
.nav a.active, .nav a:hover{
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.nav a.active::after, .nav a:hover::after{
  transform: translateX(-50%) scaleX(1);
}

.brand a{
  font-weight: 900;
  color: var(--text);
  text-decoration: none;
}

.toggle{
  display:flex; align-items:center; gap:8px; user-select:none;
  font-size:12px; color:var(--muted);
}
.switch{
  width:46px; height:22px; border:1px solid var(--rule); border-radius:999px; position:relative;
}
.knob{
  position:absolute; top:1px; left:1px; width:20px; height:18px;
  background: var(--accent); border-radius: 999px; transition: transform .25s ease;
}
.switch[data-mode="light"] .knob{ transform: translateX(12px); }
.switch[data-mode="dark"] .knob{ transform: translateX(24px); }

/* Hero typography */
.hero{ padding: 80px 0 24px; }
.display{
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: -0.4px;
  font-size: clamp(34px, 5.5vw, 60px);
  line-height: 1.1;
  margin: 0 0 12px 0;
}
.lead{
  color: var(--muted);
  font-size: clamp(18px, 2.2vw, 22px);
  max-width: 820px;
}
.lead a{ color: var(--accent); }

/* Home-only centering */
.hero{ text-align:center; }
.hero .project-links{ display:inline-flex; gap:8px; flex-wrap:wrap; justify-content:center; }
.home-section{ text-align:center; }
.home-section .postlist{ display:inline-block; text-align:left; }
.home-section .projects{ margin-left:auto; margin-right:auto; }

/* Home grid: three columns */
.home-grid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  align-items: stretch;
  margin-bottom: 20px;
}
.home-card{
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--bg);
  text-align: left;
  padding: 14px 16px;
}
.home-card h3{
  margin: 4px 0 8px 0;
  font-size: 18px;
}
.home-card .eyebrow{
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.home-card p{ margin: 0 0 10px 0; color: var(--muted); }
.home-card .actions{ display:flex; flex-wrap:wrap; gap:8px; margin-top: 10px; }

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

/* Section headings like "Writing" page */
.center-title{
  text-align:center; margin: 80px 0 6px 0;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(44px, 7vw, 80px);
  letter-spacing: -0.6px;
}
.center-sub{
  text-align:center; color:var(--muted); max-width: 720px; margin: 0 auto 28px;
}

/* Writing list with year column */
.writing{
  display:block; max-width: 780px; margin: 0 auto;
}
.year{ color: var(--muted); font-weight:700; margin: 22px 0 6px; }
.postlist{ margin: 0 0 28px 0; padding:0; list-style:none; }
.postlist li{ margin: 10px 0; }
.postlist a{ color: var(--text); text-decoration:none; }
.postlist a:hover{ color: var(--accent); }
.date{ color: var(--muted); font-size: 14px; margin-left: 6px; font-style: italic; }

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

footer{ color: var(--muted); font-size: 14px; margin-top: 40px; padding: 40px 0 80px; border-top:1px solid var(--rule); }

/* Blog post layout (detail page) */
.post-container{ max-width: 1000px; margin: 0 auto; padding: 28px 20px; }
.post-hero{
  margin-top: 40px;
  text-align: center;
}
.post-title{
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.6px;
  font-size: clamp(44px, 6.5vw, 50px);
  line-height: 1.08;
  margin: 40px 0px;
  text-align: center;
}
.post-grid{
  display:grid; grid-template-columns: 220px 1fr; gap: 28px;
}
.post-meta{
  color: var(--muted);
  font-size: 14px;
}
.post-meta .card{ border-top: 1px solid var(--rule); padding-top: 14px; margin-top: 14px; }
.post-content p{ margin: 0 0 16px 0; }
.post-content h2{ margin: 28px 0 8px; }
.post-content strong{ font-weight: 700; }

/* Post layout: collapse sidebar on mobile */
@media (max-width: 720px){
  .post-grid{ grid-template-columns: 1fr; }
  .post-meta{ display: none; }
}

/* Mobile: dropdown nav with hamburger */
@media (max-width: 720px){
  header.site{ position: sticky; top: 0; background: var(--bg); z-index: 1000; }
  .menu-btn{ display:inline-block; }
  .nav{
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--bg);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    padding: 10px 20px;
    display: none;
  }
  .nav a{ display:block; margin: 8px 0; padding: 6px 0; }
  .nav a::after{ display: none; }
  .site.menu-open .nav{ display:block; }
}

/* Projects grid and cards */
.projects{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
  margin-bottom: 40px;
}
.project-card{
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}
.project-content{ padding: 12px 14px 16px; }
.project-title{ font-weight: 700; color: var(--text); text-decoration: none; display:inline-block; }
.project-title:hover{ color: var(--accent); }
.project-summary{ color: var(--muted); margin: 8px 0 10px; }
.project-links{ display:flex; flex-wrap: wrap; gap: 8px; }
.badge{
  display:inline-block; font-size:12px; padding:6px 10px; border:1px solid var(--rule); border-radius:999px;
  color: var(--muted); text-decoration:none;
}
.badge:hover{ color: var(--accent-strong); border-color: var(--accent); }

/* Project detail page */
.project-detail-hero{ margin-top: 40px; text-align:center; }
.project-gallery{ margin: 16px auto 10px; display:grid; grid-template-columns: 1fr; gap:12px; max-width: 980px; }
.project-gallery img{ width:100%; height:auto; border-radius: 8px; border:1px solid var(--rule); }
.project-meta .links{ display:flex; flex-wrap:wrap; gap:8px; margin-top: 8px; }

/* Recommendations (table-like list) */
.recs{ max-width: 980px; margin: 0 auto; }
.recs-head, .recs-row{ display: grid; grid-template-columns: 120px 1fr 110px; gap: 14px; align-items: center; }
.recs-item{ border-bottom: 1px solid var(--rule); padding: 12px 8px; }
.recs-head{
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  font-weight: 600;
}
.recs-type{
  display:inline-block;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--rule);
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.recs-title{ margin: 0; }
.recs-title a{ color: var(--text); text-decoration: none; font-weight: 600; }
.recs-title a:hover{ color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.recs-meta{ color: var(--muted); font-size: 14px; }
.recs-rating{ text-align: right; font-size: 18px; letter-spacing: 2px; }
.recs-rating .star{ position: relative; display: inline-block; width: 1em; }
.recs-rating .star::before{ content: '☆'; color: var(--rule); }
.recs-rating .star.filled::before{ content: '★'; color: var(--accent-strong); }
.recs-rating .star.half::before{ content: '☆'; color: var(--rule); }
.recs-rating .star.half::after{
  content: '★';
  position: absolute; left: 0; top: 0; width: 50%; height: 100%;
  color: var(--accent-strong);
  overflow: hidden;
}
.recs-note{
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
  opacity: .75;
  margin: 4px 0 12px 0;
  padding: 0 8px 0;
}

@media (max-width: 720px){
  .recs-head{ display:none; }
  .recs-item{ padding: 12px 0; }
  .recs-row{ grid-template-columns: 1fr auto; gap: 8px 12px; }
  .recs-type{ order: 2; justify-self: start; }
  .recs-rating{ order: 2; justify-self: end; }
  .recs-title{ order: 1; grid-column: 1 / -1; }
  .recs-note{ font-size: 12.5px; font-style: italic; opacity: .75; padding: 0 0 12px; }
}

/* About page: portrait hero */
.about-hero{
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 18px;
  align-items: center;
  margin: 60px 0 10px;
}
.about-portrait{
  width: 140px; height: 140px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--rule);
}
.about-hero .display{ margin: 0 0 8px 0; font-size: clamp(36px, 5vw, 54px); }
.about-hero p{ color: var(--muted); margin: 0; }

@media (max-width: 720px){
  .about-hero{ grid-template-columns: 1fr; text-align:center; }
  .about-portrait{ margin: 0 auto; width: 120px; height: 120px; }
}

/* About page: logos scroller */
.logos{ margin: 26px 0 0; }
.logos h3{ margin: 26px 0 10px; }
.logos-scroller{
  overflow: hidden;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 12px 0;
}
.logos-track{
  display: inline-flex;
  align-items: center;
  gap: 40px;
  will-change: transform;
  animation: logos-marquee 28s linear infinite;
}
.logo-item{
  height: 80px; width: auto;
  opacity: .85;
  filter: grayscale(100%);
  transition: opacity .2s ease, filter .2s ease;
}
.logo-item:hover{ opacity: 1; filter: grayscale(0%); }

@keyframes logos-marquee{
  from{ transform: translateX(0); }
  to{ transform: translateX(-50%); }
}

/* Make logos slightly brighter in dark mode so they don't blend into the bg */
html[data-theme="dark"] .logo-item{ filter: grayscale(100%) brightness(2); opacity: .92; }
@media (prefers-color-scheme: dark){
  /* Only apply when not explicitly forced to light */
  html:not([data-theme="light"]) .logo-item{ filter: grayscale(100%) brightness(2); opacity: .92; }
}

/* Services section */
.services{ margin: 28px 0 6px; }
.services-grid{
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
.service-card{
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 14px 16px 16px;
  background: var(--bg);
}
.service-card h4{ margin: 6px 0 8px; font-size: 18px; }
.service-card p{ margin: 0 0 10px; color: var(--muted); }
.service-icon{ font-size: 22px; }
.tool-badges{ display:flex; flex-wrap: wrap; gap:8px; }
.tool-badges .badge{ cursor: default; }
@media (max-width: 860px){ .services-grid{ grid-template-columns: 1fr; } }

/* Toolbox groups */
.toolbox{ margin: 22px 0 10px; }
.tool-groups{ display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.tool-group{ border: 1px solid var(--rule); border-radius: 10px; padding: 12px 14px; }
.tool-group h4{ margin: 0 0 8px; font-size: 16px; }
@media (max-width: 720px){ .tool-groups{ grid-template-columns: 1fr; } }