:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --text-main: #030712;
  --text-muted: #4b5563;
  --accent: #391000;
  --accent-soft: #e5e7eb;
  --accent-back: #030712;
  --border-subtle: #e5e7eb;
  --accent-hover: #e54101;
  --accent-soft-hover: #f6f6f6;
  /* Gap between intro section and projects section on home page */
  --intro-projects-gap: 1.5rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text-main);
}

/* Gradient only on the home page (no .project-page class on <div class="page">) */
body:has(.page:not(.project-page)) {
  background: radial-gradient(circle at top, #e8e3de 0, #f9fafb 55%, #f3f4f6 100%);
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

@media (min-width: 768px) {
  .page {
    padding: 3.5rem 2.5rem 4rem;
  }
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
}

main {
  display: flex;
  flex-direction: column;
  gap: var(--intro-projects-gap);
}

@media (min-width: 900px) {
  .page:not(.project-page) main {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 1.5rem;
    row-gap: var(--intro-projects-gap);
  }

  .page:not(.project-page) .intro,
  .page:not(.project-page) .projects {
    grid-column: 1 / -1;
  }
}

.intro {
  background: rgba(255, 255, 255, 0.9);
  padding: 2rem 1.75rem;
  border-radius: 0.6rem;
}

@media (min-width: 768px) {
  .intro {
    padding: 2.5rem 2.25rem;
  }
}

.eyebrow {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}

.intro h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(2rem, 3vw, 2.5rem);
  font-weight: 600;
}

.intro h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-muted);
}

.intro p {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  max-width: 40rem;
}

.intro p:last-of-type {
  margin-bottom: 1.5rem;
}

.intro a {
  color: var(--accent-hover);
  text-decoration: none;
}

.intro a:hover{
  color: var(--accent-hover);
  text-decoration: underline;
}

.intro a:visited {
  color: var(--accent-hover);
  text-decoration: none;
}

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

.pill-link span.icon {
  font-size: 0.9rem;
}

.section-title {
  padding: 1.3rem 2rem 1.3rem;
}

.projects {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* Generic project title image */
.main-project-image {
    background-color: #e5e7eb;
    border-radius: 0.6rem;
    border: 1px solid var(--border-subtle);
    width: 100%;
    margin-top: 1rem;
    margin-bottom: 1rem;
  }

/* Generic image placeholder */
.image-placeholder {
  background-color: #e5e7eb;
  border-radius: 0.6rem;
  border: 1px solid var(--border-subtle);
  width: 100%;
  height: auto;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

/* Generic GIF placeholder */
.project-gif {
    background-color: #e5e7eb;
    border-radius: 0.6rem;
    border: 1px solid var(--border-subtle);
    width: 100%;
    aspect-ratio: 3 / 2;
    margin-bottom: 1rem;
  }

.spacing-s ul li {
    padding-bottom: 0.5rem;
}

.project-card {
  padding: 1.3rem 2rem 1.3rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.project-card-text {
    display: flex;
    flex-direction: column;
}

.project-card-image {
    border-radius: 0.6em;
    overflow: hidden;
    aspect-ratio: 4 / 3;
}

.project-title {
  margin: 0 0 0.35rem;
  font-size: 1.3rem;
  font-weight: 550;
}

.project-description {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.project-footer {
  margin-top: 0.4rem;
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--accent-hover);
  text-decoration: none;
}

.project-link:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

.project-link span.arrow {
  transition: transform 0.15s ease;
}

.project-link:hover span.arrow {
  transform: translateX(2px);
}

footer {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

footer .note {
  font-style: regular;
}

footer a {
  color: var(--accent-hover);
  text-decoration: none;
}

footer a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

footer a:visited {
  color: var(--accent-hover);
  text-decoration: none;
}

@media (max-width: 600px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }
  footer {
    flex-direction: column-reverse;
    align-items: flex-start;
  }
}

/************ Project detail page ***********/

.project-page {
  gap: 2rem;
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.project-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.project-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent-back);
  text-decoration: none;
  margin-bottom: 1.5em;
  width: fit-content;
}

.project-back:hover {
color: var(--accent-hover);
}

.project-back-arrow {
  font-size: 1rem;
}

.nav-link {
  font-size: 0.9rem;
  color: var(--accent);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.8);
}

.nav-link:hover {
  background: var(--accent-soft);
}

.project-main {
  display: flex;
  align-items: flex-start;
  gap: 2.5rem;
}

.project-hero {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 0.6rem;
  padding: 2.2rem 1.75rem 2.1rem;
  border: 1px solid var(--border-subtle);
}

.project-title-lg {
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 3vw, 2.4rem);
  font-weight: 600;
}

.project-subtitle {
  margin: 0 0 1.75rem;
  max-width: 40rem;
  color: var(--text-muted);
}

.project-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.meta-group h2 {
  margin: 0 0 0.25rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
}

.meta-group p {
  margin: 0;
  font-size: 0.98rem;
}

.project-section {
  max-width: 720px;
  padding: 0 1.7rem 0 1.7rem;
}

.project-section-subitem {
    max-width: 720px;
}


.project-section h2 {
  margin: 0 0 0.75rem;
  font-size: 1.3rem;
}

.project-section h3 {
    font-size: 0.98rem;
  }

.project-section p {
  margin: 0 0 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.project-section ul,
.project-section ol {
  margin: 0.25rem 0 0.8rem 1.3rem;
  color: var(--text-muted);
  padding-left: 1.1rem;
  line-height: 1.6;
}

.spacing-small {
    padding-top: 0.8rem;
}

.project-section li + li {
  margin-top: 0.3rem;
}

/* In-page sticky table of contents */

.project-toc {
  flex: 0 0 190px;
  position: fixed;
  top: 6.5rem;
  left: calc(50% - 480px + 1.5rem);
  font-size: 0.85rem;
  color: var(--text-muted);
  z-index: 10;
}

.project-toc-inner {
  padding: 0.75rem 0.75rem 0.9rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.9);
}

.project-toc-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  margin-bottom: 0.4rem;
}

.project-toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.project-toc-list li + li {
  margin-top: 0.2rem;
}

.project-toc-link {
  display: inline-block;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.15rem 0;
  white-space: normal;
  word-break: break-word;
  max-width: 100%;
}

.project-toc-link:hover {
  color: var(--accent-hover);
}

.project-toc-link--active {
  font-weight: 600;
  color: var(--accent);
}

.project-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  margin-left: 210px;
}

@media (max-width: 700px) {
  .project-meta {
    grid-template-columns: 1fr;
  }

  .project-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .project-main {
    flex-direction: column;
  }

  .project-toc {
    display: none;
  }

  .project-content {
    margin-left: 0;
  }
}