:root {
  --paper: #f3efe4;
  --paper-alt: #eae4d4;
  --ink: #1e1c18;
  --ink-muted: #6b6558;
  --line: #d8d0bb;
  --accent: #1f4e8c;
  --accent-ink: #ffffff;
  --card-bg: #fbf9f3;
  --grid-line: rgba(30, 28, 24, 0.05);
  --radius: 2px;
  --max-width: 980px;
  --font-display: "Fraunces", "Iowan Old Style", serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12151b;
    --paper-alt: #191d25;
    --ink: #ece7d9;
    --ink-muted: #9a9689;
    --line: #2c313b;
    --accent: #7ea0dd;
    --accent-ink: #0e1116;
    --card-bg: #171b22;
    --grid-line: rgba(236, 231, 217, 0.05);
  }
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

html { scroll-padding-top: 24px; }

body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 560;
  letter-spacing: -0.01em;
  margin: 0;
}

header.site-header {
  border-bottom: 1px solid var(--line);
  padding: 22px 0;
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.site-title {
  font-family: var(--font-display);
  font-weight: 560;
  font-size: 1.15rem;
  color: var(--ink);
}

nav { display: flex; gap: 22px; }

nav a {
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}
nav a:hover { color: var(--ink); text-decoration: none; }

/* Hero -------------------------------------------------- */

.hero {
  padding: 72px 0 44px;
  position: relative;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 34px 34px;
  background-position: center top;
}

.hero__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 36px;
  align-items: start;
}

@media (min-width: 760px) {
  .hero__grid { grid-template-columns: 1fr 240px; }
}

.hero__portrait {
  width: 100%;
  max-width: 240px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--paper-alt);
  justify-self: start;
}

@media (min-width: 760px) {
  .hero__portrait { justify-self: end; }
}

.hero h1 {
  font-size: clamp(2.2rem, 4vw, 2.9rem);
  margin: 0 0 14px;
}

.hero p.lead {
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--ink-muted);
  max-width: 62ch;
  margin: 0 0 32px;
}

@media (prefers-reduced-motion: no-preference) {
  .site-header,
  .hero h1,
  .hero .lead,
  .hero .titleblock,
  .hero__portrait {
    animation: riseIn 0.6s ease-out both;
  }
  .hero h1 { animation-delay: 0.05s; }
  .hero .lead { animation-delay: 0.15s; }
  .hero .titleblock { animation-delay: 0.25s; }
  .hero__portrait { animation-delay: 0.2s; }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* Title block -------------------------------------------- */

.titleblock {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  max-width: 760px;
}

@media (min-width: 640px) {
  .titleblock { grid-template-columns: repeat(3, 1fr); }
}

.titleblock__cell {
  padding: 12px 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.titleblock__label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-muted);
  letter-spacing: 0.03em;
}

.titleblock__value {
  font-size: 0.92rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.titleblock__value:hover { color: var(--accent); }

/* Sections ------------------------------------------------ */

section {
  padding: 40px 0;
}

section h2 {
  font-size: 1.6rem;
  margin-bottom: 8px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

#projects .container > h2,
#coursework .container > h2,
#about .container > h2 {
  display: block;
  margin-bottom: 28px;
}

/* Project grid / cards -------------------------------------------- */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 28px 24px;
}

.project-card {
  background: var(--card-bg);
  border-top: 1px solid var(--line);
  position: relative;
  display: flex;
  flex-direction: column;
}

.project-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.project-card:hover::before,
.project-card:focus-within::before {
  width: 100%;
}

.project-card a.card-link {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.project-card .thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--paper-alt);
  object-fit: cover;
  display: block;
}

.project-card .card-body {
  padding: 18px 4px 4px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.project-card h3 {
  font-size: 1.12rem;
  margin: 0 0 8px;
  line-height: 1.3;
}

.project-card .subtitle {
  font-family: var(--font-body);
  color: var(--ink-muted);
  font-size: 0.92rem;
  margin: 0 0 14px;
  max-width: 46ch;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-muted);
  padding: 4px 8px;
  border-radius: var(--radius);
}

/* Project detail -------------------------------------------- */

.project-detail .meta {
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin-bottom: 24px;
  max-width: 68ch;
}

.meta__sep {
  display: inline-block;
  width: 1px;
  height: 0.85em;
  background: var(--line);
  margin: 0 10px;
  vertical-align: middle;
}

.project-detail h1 {
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  margin-bottom: 10px;
}

.project-detail .hero-image {
  width: 100%;
  max-height: 460px;
  object-fit: cover;
  border-radius: 0;
  margin-bottom: 30px;
  background: var(--paper-alt);
  border: 1px solid var(--line);
}

.project-detail .tags { margin-bottom: 28px; }

.project-detail .body {
  max-width: 68ch;
}

.project-detail .body p {
  margin-bottom: 18px;
}

.project-detail .links {
  margin-top: 32px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.project-detail .links a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border: 1px solid var(--line);
  padding: 9px 16px;
  border-radius: var(--radius);
  color: var(--ink);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.project-detail .links a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.back-link {
  display: inline-block;
  margin-bottom: 28px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.back-link:hover { color: var(--accent); }

/* Project pager -------------------------------------------- */

.project-pager {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.project-pager__link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 46%;
  color: inherit;
}
.project-pager__link:hover { text-decoration: none; }

.project-pager__next {
  margin-left: auto;
  text-align: right;
  align-items: flex-end;
}

.project-pager__label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.project-pager__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink);
  line-height: 1.35;
}
.project-pager__link:hover .project-pager__title { color: var(--accent); }

@media (max-width: 560px) {
  .project-pager { flex-direction: column; }
  .project-pager__link,
  .project-pager__next {
    max-width: 100%;
    margin-left: 0;
    text-align: left;
    align-items: flex-start;
  }
}

/* About -------------------------------------------- */

#about .container p {
  max-width: 68ch;
}

.skills {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.skills__group { min-width: 220px; }

.skills__label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  margin: 0 0 12px;
}

/* Additional coursework -------------------------------------------- */

.section-note {
  color: var(--ink-muted);
  font-size: 0.95rem;
  margin: 18px 0 28px;
  max-width: 60ch;
}

.coursework-list {
  display: flex;
  flex-direction: column;
}

.coursework-item {
  display: flex;
  gap: 20px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.coursework-list .coursework-item:last-child { border-bottom: 1px solid var(--line); }
.coursework-item:hover { text-decoration: none; }
.coursework-item:hover h3 { color: var(--accent); }

.coursework-item__thumb {
  width: 180px;
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: cover;
  background: var(--paper-alt);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.coursework-item__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.coursework-item__body h3 {
  font-size: 1rem;
  margin: 0 0 6px;
  transition: color 0.15s ease;
}

.coursework-item__body .subtitle {
  font-family: var(--font-body);
  color: var(--ink-muted);
  font-size: 0.88rem;
  margin: 0 0 10px;
}

.coursework-item__body .tags { margin-top: 0; padding-top: 0; }

@media (max-width: 520px) {
  .coursework-item { gap: 14px; }
  .coursework-item__thumb { width: 110px; }
}

/* Footer -------------------------------------------- */

footer.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 48px;
  padding: 32px 0;
}

.footer__label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  margin: 0 0 12px;
}

.footer__row {
  font-family: var(--font-body);
  font-size: 1rem;
  margin: 0 0 6px;
}
.footer__row:last-child { margin-bottom: 0; }
.footer__row a { color: var(--ink); }
.footer__row a:hover { color: var(--accent); }

.empty-state {
  color: var(--ink-muted);
  font-style: italic;
}
