/* === Base Reset & Typography === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --text: #1a1a2e;
  --text-light: #555770;
  --bg: #f8f7f4;
  --bg-card: #ffffff;
  --accent: #e07a5f;
  --accent-dark: #c4613f;
  --accent-light: #fdf0ec;
  --accent2: #3d5a80;
  --accent2-light: #e8eef4;
  --green: #81b29a;
  --green-light: #e9f5ef;
  --border: #e2dfd9;
  --max-width: 760px;
  --font-body: 'Source Serif 4', 'Georgia', serif;
  --font-heading: 'Inter', 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  /* Per-page accent (overridden by body classes) */
  --page-accent: #e07a5f;
  --page-accent-dark: #c4613f;
  --page-accent-light: #fdf0ec;
}

/* === Per-page color accents === */
body.page-about { --page-accent: #e07a5f; --page-accent-dark: #c4613f; --page-accent-light: #fdf0ec; }
body.page-writing { --page-accent: #1a5632; --page-accent-dark: #0f3d22; --page-accent-light: #e9f5ef; }
body.page-projects { --page-accent: #3d5a80; --page-accent-dark: #2c4360; --page-accent-light: #e8eef4; }
body.page-materials { --page-accent: #555770; --page-accent-dark: #3a3c50; --page-accent-light: #eeeef2; }

html {
  font-size: 17px;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* === Subtle dot grid background === */
body::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  background-image: radial-gradient(circle, var(--border) 0.8px, transparent 0.8px);
  background-size: 28px 28px;
  opacity: 0.45;
  will-change: auto;
}

/* === Decorative top bar (uses per-page accent) === */
body::before {
  content: '';
  display: block;
  height: 4px;
  background: var(--page-accent);
}

/* === Layout === */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* === Header & Navigation === */
header {
  padding: 1.5rem 0;
  margin-bottom: 2.5rem;
  background: rgba(248, 247, 244, 0.97);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.site-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  transition: color 0.2s;
}

.site-title:hover {
  color: var(--accent);
}

nav {
  display: flex;
  gap: 1.75rem;
}

nav a {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--text-light);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 0.2s;
  position: relative;
}

nav a:hover,
nav a.active {
  color: var(--text);
}

nav a.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--page-accent);
  border-radius: 1px;
}

/* === Page Content === */
main {
  padding-bottom: 4rem;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.page-subtitle {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 2.5rem;
  line-height: 1.6;
}

/* === Section dividers === */
.divider {
  border: none;
  height: 2px;
  margin: 2.5rem 0;
  background: #1a5632;
  opacity: 0.45;
}

/* === About / Photo Section === */
.about-photo-section {
  text-align: center;
  margin-bottom: 2rem;
}

.about-photo {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center center;
  border: 2px solid #1a1a2e;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-bottom: 1.25rem;
}

.about-photo-section h1 {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}

.about-photo-section .tagline {
  font-size: 1rem;
  color: var(--text-light);
  line-height: 1.5;
}

/* === Bio Section === */
.bio {
  margin-bottom: 2rem;
}

.bio a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

.bio a:hover {
  color: var(--accent-dark);
}

.bio p {
  margin-bottom: 1rem;
}

.bio p:last-child {
  margin-bottom: 0;
}

/* === Bio aside image === */
.bio-aside {
  float: right;
  margin: 0.25rem 0 1rem 1.5rem;
  max-width: 360px;
}

.bio-aside img {
  width: 100%;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transition: transform 0.3s, box-shadow 0.3s;
}

.bio-aside img:hover {
  transform: scale(1.02) rotate(-0.5deg);
  box-shadow: 0 8px 28px rgba(0,0,0,0.16);
}

.bio-aside .caption {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  color: var(--text-light);
  text-align: center;
  margin-top: 0.5rem;
  font-style: italic;
}

/* Currently thinking about list */
.currently-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.currently-list li {
  font-size: 0.92rem;
  color: var(--text-light);
  line-height: 1.55;
  padding: 0.2rem 0;
}

.currently-list li::before {
  content: '\2022';
  color: var(--text);
  font-weight: 700;
  margin-right: 0.5rem;
}

/* Links inside currently-list (for materials page etc) */
.currently-list a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

.currently-list a:hover {
  color: var(--accent-dark);
}

@media (max-width: 900px) {
  .bio-aside {
    max-width: 280px;
  }
}

@media (max-width: 600px) {
  .bio-aside {
    float: none;
    margin: 1rem auto;
    max-width: 320px;
  }
}

/* === Currently Section (decorative aside) === */
.currently {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.currently::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 10px 10px 0 0;
  background: var(--text);
}

.currently h2 {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
  margin-bottom: 0.6rem;
}

.currently p {
  font-size: 0.92rem;
  color: var(--text-light);
  line-height: 1.55;
}

/* === Interests / Tags === */
.interests {
  margin-top: 2rem;
}

.interests h2 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
}

.tag-list li {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  padding: 0.3rem 0.75rem;
  border-radius: 2rem;
  transition: transform 0.15s, box-shadow 0.15s;
}

.tag-list li:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* Alternating tag colors */
.tag-list li:nth-child(3n+1) {
  background: var(--accent-light);
  color: var(--accent-dark);
}
.tag-list li:nth-child(3n+2) {
  background: var(--green-light);
  color: #4a8a6e;
}
.tag-list li:nth-child(3n) {
  background: var(--accent2-light);
  color: var(--accent2);
}

/* === Review / Post Cards === */
.post-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.post-card {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}

.post-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--page-accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.post-card:hover {
  border-color: var(--text-light);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.post-card:hover::before {
  opacity: 1;
}

.post-card h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}

.post-card .meta {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.post-card .meta .category {
  color: var(--accent);
  font-weight: 500;
}

.post-card .excerpt {
  font-size: 0.92rem;
  color: var(--text-light);
  line-height: 1.55;
}

/* Upcoming / placeholder cards */
.post-card.upcoming {
  opacity: 0.45;
  cursor: default;
  padding: 1rem 1.5rem;
}

.post-card.upcoming:hover {
  border-color: var(--border);
  box-shadow: none;
  transform: none;
}

.post-card.upcoming:hover::before {
  opacity: 0;
}

/* === Project Cards === */
.project-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.project-card {
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  transition: box-shadow 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}

.project-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--page-accent);
  opacity: 0;
  transition: opacity 0.3s;
}

.project-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.07);
  transform: translateY(-2px);
}

.project-card:hover::after {
  opacity: 1;
}

.project-card h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.project-card .project-status {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.6rem;
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 2rem;
}

.project-card .project-status.ongoing {
  background: var(--green-light);
  color: #4a8a6e;
}

.project-card .project-status.completed {
  background: var(--accent2-light);
  color: var(--accent2);
}

.project-card p {
  font-size: 0.92rem;
  color: var(--text-light);
  line-height: 1.55;
  margin-bottom: 0.75rem;
}

.project-card a {
  color: var(--accent);
  text-decoration: none;
}

.project-card a:hover {
  color: var(--accent-dark);
}

.project-card .tag-list {
  margin-top: 0.5rem;
}

.project-card .tag-list li {
  font-size: 0.72rem;
}

/* === Individual Review / Article === */
article.review {
  max-width: var(--max-width);
}

article.review .review-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid #1a5632;
  opacity: 1;
}
article.review .review-header ~ h2:first-of-type {
  border-top: none;
}

article.review h1 {
  font-family: var(--font-heading);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

article.review .review-meta {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

article.review .review-edited {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--text-light);
  opacity: 0.7;
}

article.review h2 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 2.75rem;
  margin-bottom: 0.75rem;
  padding-top: 1.25rem;
  border-top: 2px solid #1a5632;
  letter-spacing: -0.02em;
}

article.review p {
  margin-bottom: 1.1rem;
}

article.review blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 0 0.75rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-light);
  font-style: italic;
  background: var(--accent-light);
  border-radius: 0 6px 6px 0;
}

article.review code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--accent2-light);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

article.review .back-link {
  display: inline-block;
  margin-top: 2.5rem;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

article.review .back-link:hover {
  color: var(--accent-dark);
}

/* === Latest Review on homepage === */
.latest-review {
  margin: 2rem 0;
}

.latest-review h2 {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
  margin-bottom: 0.75rem;
}

/* === Contact Section === */
.contact-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
}

.contact-section h2 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.contact-section p {
  font-size: 0.92rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.contact-section a {
  color: var(--accent);
  text-decoration: none;
}

.contact-section a:hover {
  color: var(--accent-dark);
}

/* === Animated center-out link underlines === */
.bio a,
.contact-section a,
.currently-list a,
article.review .back-link {
  position: relative;
  text-decoration: none;
}

.bio a::after,
.contact-section a::after,
.currently-list a::after,
article.review .back-link::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.25s ease, left 0.25s ease;
}

.bio a:hover::after,
.contact-section a:hover::after,
.currently-list a:hover::after,
article.review .back-link:hover::after {
  width: 100%;
  left: 0;
}

/* === Footnote tooltip === */
.fn-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #f8f7f4;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.5;
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  max-width: 360px;
  width: max-content;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.fn-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text);
}

sup {
  position: relative;
}

sup:hover .fn-tooltip {
  opacity: 1;
}

/* === Reading progress bar (review pages) === */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: #1a5632;
  z-index: 200;
  width: 0%;
  transition: width 0.1s linear;
}

/* === Colophon footer === */
.colophon {
  text-align: center;
  padding: 2rem 0 1.5rem;
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  color: var(--text-light);
  letter-spacing: 0.02em;
  opacity: 0.6;
}

/* === Decorative geometric accent shapes === */
.page-about .page-title::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--page-accent);
  border-radius: 50%;
  margin-right: 0.6rem;
  vertical-align: middle;
  position: relative;
  top: -2px;
}

/* === Sticky section headings in reviews === */
article.review h2.sticky-heading {
  position: sticky;
  top: 4rem;
  background: rgba(248, 247, 244, 0.97);
  z-index: 50;
  margin-left: -1.5rem;
  margin-right: -1.5rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  padding-bottom: 0.5rem;
}


/* === Smooth fade-in on page load === */
main {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Selection color === */
::selection {
  background: var(--accent-light);
  color: var(--accent-dark);
}

/* === Container needs relative for geo shapes === */
main.container {
  position: relative;
  overflow: visible;
}

/* === Responsive === */
@media (max-width: 800px) {
  .post-list {
    grid-template-columns: 1fr;
  }
  .divider {
    margin: 2rem 0;
  }
}

@media (max-width: 600px) {
  html { font-size: 16px; }
  header .container {
    flex-direction: column;
    gap: 0.75rem;
  }
  nav { gap: 1.25rem; }
  .page-title { font-size: 1.5rem; }
  body::after {
    background-size: 22px 22px;
    opacity: 0.3;
  }
  .fn-tooltip {
    max-width: 260px;
    font-size: 0.68rem;
  }
  .colophon {
    padding: 1.5rem 0 1rem;
  }
}
