/* ---------- Design tokens ---------- */
:root {
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --ink: #141414;
  --ink-muted: #5c5c58;
  --line: #e2e1dc;
  --accent: #141414;

  --font-display: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --gutter: clamp(20px, 4vw, 48px);
  --max-width: 1400px;

  color-scheme: light dark;
}

:root[data-theme="dark"] {
  --bg: #141412;
  --bg-elevated: #1c1c19;
  --ink: #f2f1ec;
  --ink-muted: #a8a79f;
  --line: #302f2a;
  --accent: #f2f1ec;
}

* { box-sizing: border-box; }

html { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

a {
  color: inherit;
  text-decoration: none;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 470px;
  height: auto;
  display: block;
}

.header-right {
  display: flex;
  align-items: center;
  gap: clamp(20px, 3vw, 40px);
  flex-wrap: wrap;
}

.site-nav {
  display: flex;
  gap: clamp(16px, 2.4vw, 28px);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}

.site-nav a:hover { color: var(--ink-muted); }

.social-links {
  display: flex;
  align-items: center;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  color: rgb(153, 153, 153);
  transition: color 0.2s ease;
}

/* Padding alone would leave 20px between tiles; pull them to 10px apart */
.social-links a + a {
  margin-left: -10px;
}

.social-links a:hover,
.social-links a:focus-visible {
  color: rgb(249, 214, 17);
}

.social-links svg {
  width: 24px;
  height: 24px;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: clamp(20px, 3vw, 40px);
  padding-block: clamp(40px, 6vw, 72px) clamp(48px, 8vw, 96px);
}

.card {
  position: relative;
  aspect-ratio: 925 / 919;
  overflow: hidden;
  background: var(--tile-color, #222);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(18px, 2.4vw, 28px);
}

.card img.cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.card:hover::after,
.card:focus-visible::after {
  opacity: 1;
}

.card-info {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover .card-info,
.card:focus-visible .card-info {
  opacity: 1;
  transform: translateY(0);
}

.card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  line-height: 1.15;
  color: var(--ink);
}

.card-description {
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
  max-width: 90%;
}

.card-meta {
  font-size: 13px;
  color: rgb(130, 130, 130);
}

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

.about-main {
  padding-block: clamp(40px, 8vw, 88px) clamp(64px, 10vw, 120px);
}

.about-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.6fr) minmax(0, 1.4fr) minmax(0, 0.4fr);
}

.about-content {
  grid-column: 2;
  max-width: 700px;
}

.about-lead {
  font-size: 1.1rem;
}

.about-content p {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  margin: 0 0 1.4em;
}

.about-content a {
  color: #d9a441;
}

.about-content a:hover {
  color: var(--ink);
}

.about-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  margin: clamp(48px, 8vw, 88px) 0 clamp(24px, 4vw, 40px);
}

.about-heading.small {
  font-size: clamp(1.4rem, 2.2vw, 1.8rem);
}

.experience-list {
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 4vw, 36px);
}

.about-content .experience-date {
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin: 0 0 2px;
}

.about-content .experience-role {
  font-weight: 600;
  margin: 0 0 4px;
}

.experience-company {
  font-weight: 600;
  color: var(--ink);
}

a.experience-company:hover {
  color: var(--ink-muted);
}

.about-content .experience-desc {
  color: var(--ink-muted);
  line-height: 1.5;
  margin: 0;
  max-width: 62ch;
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 40px;
}

.skills-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin: 0 0 8px;
}

.skills-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@media (max-width: 560px) {
  .skills-grid { grid-template-columns: minmax(0, 1fr); }
}

.experience-desc-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

abbr {
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  cursor: help;
}

@media (max-width: 900px) {
  .about-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .about-content {
    grid-column: 1;
    max-width: 100%;
  }
}

/* ---------- Case study template ---------- */

.cs-hero {
  padding-block: clamp(40px, 8vw, 80px) clamp(24px, 4vw, 40px);
  text-align: center;
}

.cs-hero .back-link {
  text-align: left;
}

.cs-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 28px auto 16px;
  max-width: 900px;
  text-wrap: balance;
}

.cs-dek {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--ink);
  margin: 0 0 14px;
}

.cs-hero .cs-dek {
  font-weight: 500;
}

.cs-meta {
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin: 0;
}

.case-study {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(28px, 4vw, 44px);
  max-width: 1100px;
  padding-block: 0 clamp(48px, 8vw, 96px);
}

.cs-text {
  width: 100%;
  max-width: 760px;
}

.cs-text p {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 1em;
}

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

.cs-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.4rem, 2.4vw, 1.7rem);
  margin: 0 0 12px;
}

.cs-subheading,
.cs-role-heading {
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 6px;
}

.cs-text > * + .cs-heading {
  margin-top: 48px;
}

.cs-text > * + .cs-subheading,
.cs-text > * + .cs-role-heading {
  margin-top: 32px;
}

.cs-text > .cs-list {
  margin-bottom: 1em;
}

.cs-text > :last-child {
  margin-bottom: 0;
}

.cs-subheading.center {
  text-align: center;
  margin-block: 16px;
}

.cs-list p {
  color: var(--ink);
  line-height: 1.6;
  margin: 0 0 0.9em;
}

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

.cs-divider {
  width: 120px;
  height: 0;
  border: none;
  border-top: 1px solid var(--line);
  margin: 0;
}

.cs-text a {
  color: #d9a441;
}

.cs-text a:hover {
  color: var(--ink);
}

.cs-note {
  color: var(--ink-muted);
}

.cs-text p.cs-number {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.2rem, 4vw, 2.8rem);
  line-height: 1;
  color: #f0c419;
  margin: 56px 0 16px;
}

.cs-text > .cs-number:first-child {
  margin-top: 0;
}

.cs-text > .cs-number + .cs-subheading {
  margin-top: 0;
}

.cs-sub-light {
  font-weight: 400;
}

.cs-text p.cs-callout {
  text-align: center;
  font-weight: 500;
  margin-top: 1em;
}

.cs-note::before {
  content: "*";
  color: #f0c419;
  font-size: 1.6em;
  line-height: 0;
  margin-right: 4px;
  vertical-align: -0.35em;
}

.cs-image,
.cs-gallery {
  width: 100%;
  max-width: 1100px;
  margin: 0;
}

.cs-image img,
.cs-gallery img {
  width: 100%;
  display: block;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 10px 28px rgba(0, 0, 0, 0.07);
}

.cs-image.text,
.cs-gallery.text {
  max-width: 760px;
}

/* 120% of the content column, but never wider than the screen */
.cs-gallery.wide {
  width: 120%;
  max-width: calc(100vw - 2 * var(--gutter));
}

.cs-image.narrow,
.cs-gallery.narrow {
  max-width: 640px;
}

.cs-image.narrow img,
.cs-image.plain img,
.cs-gallery.plain img {
  border-radius: 0;
  box-shadow: none;
}

.cs-gallery-row {
  display: grid;
  gap: clamp(16px, 2.5vw, 32px);
  align-items: start;
}

.cs-gallery-row.centered {
  --gap: clamp(16px, 2.5vw, 32px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
}

.cs-gallery-row.centered > .cs-gallery-item {
  width: calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
}

.cs-gallery-item img {
  width: 100%;
}

.cs-gallery-item .cs-caption {
  margin-top: 10px;
}

.cs-image.framed img {
  box-sizing: border-box;
  padding: clamp(16px, 3vw, 40px) clamp(16px, 6vw, 96px);
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 8px 30px rgba(0, 0, 0, 0.06);
}

.cs-section {
  text-align: center;
  max-width: 760px;
  margin-top: 24px;
}

.cs-section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  margin: 0 0 14px;
}

.cs-section .cs-dek a {
  color: #d9a441;
}

.cs-button-row {
  text-align: center;
}

.cs-button {
  display: inline-block;
  padding: 16px 44px;
  border-radius: 999px;
  background: #f5d94a;
  color: var(--ink);
  font-weight: 600;
}

.cs-button:hover {
  background: #f0c419;
}

.cs-expand-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 40px;
  margin-top: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #222;
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.cs-expand-button:hover {
  background: #000;
}

.cs-video video {
  width: 100%;
  display: block;
  background: #000;
  border-radius: 8px;
}

.cs-caption a {
  color: #d9a441;
}

.cs-caption {
  margin: 10px 0 0;
  text-align: center;
  font-size: 14px;
  color: #999999;
}

@media (max-width: 640px) {
  .cs-gallery-row {
    grid-template-columns: 1fr !important;
  }
}

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

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 32px;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}

/* ---------- Project page ---------- */

.project-hero {
  padding-block: clamp(40px, 8vw, 80px) clamp(28px, 5vw, 48px);
  border-bottom: 1px solid var(--line);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-bottom: clamp(28px, 5vw, 48px);
}

.back-link:hover { color: var(--ink); }

.project-hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.4rem, 7vw, 5rem);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0 0 20px;
}

.project-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(20px, 4vw, 48px);
  margin-top: clamp(24px, 5vw, 40px);
}

.project-meta-row dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.project-meta-row dd {
  margin: 0;
  font-size: 0.98rem;
}

.project-cover {
  aspect-ratio: 16 / 9;
  background: var(--tile-color, #222);
  margin-top: clamp(28px, 5vw, 48px);
  overflow: hidden;
}

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

.project-body {
  padding-block: clamp(48px, 8vw, 96px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(24px, 6vw, 80px);
}

.project-body .col-text p {
  font-size: clamp(1rem, 1.3vw, 1.1rem);
  color: var(--ink-muted);
  margin: 0 0 1.4em;
  max-width: 60ch;
}

.project-body .col-text p:last-child { margin-bottom: 0; }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: clamp(24px, 4vw, 40px);
}

.tag-list span {
  font-size: 0.78rem;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-muted);
}

.gallery {
  display: flex;
  flex-direction: column;
  gap: clamp(2px, 0.5vw, 4px);
  padding-bottom: clamp(48px, 8vw, 96px);
}

.gallery figure {
  margin: 0;
}

.gallery .plate {
  aspect-ratio: 16 / 10;
  background: var(--plate-color, #333);
  overflow: hidden;
}

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

.gallery figcaption {
  padding-top: 10px;
  font-size: 14px;
  color: #999999;
}

.more-projects {
  border-top: 1px solid var(--line);
  padding-block: clamp(28px, 5vw, 48px);
}

.more-projects-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  margin: 0 0 20px;
}

/* Five square cards that shrink to fit the row; fewer per row on small screens */
.more-projects-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 280px));
  justify-content: center;
  gap: 20px;
}

.more-projects .card {
  aspect-ratio: 1;
  padding: 16px;
}

@media (max-width: 900px) {
  .more-projects-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .more-projects-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.more-projects .card-info { gap: 6px; }
.more-projects .card-title { font-size: 20px; }
.more-projects .card-description { font-size: 14px; max-width: 100%; }
.more-projects .card-meta { font-size: 12px; }

.not-found {
  padding-block: clamp(64px, 14vw, 140px);
  text-align: center;
}

.not-found h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin-bottom: 12px;
}

.not-found p { color: var(--ink-muted); }

/* ---------- Responsive ---------- */

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

  .project-meta-row {
    gap: 20px 32px;
  }


}

.cs-expand {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.cs-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  overflow-y: auto;
  padding: 32px 16px;
  background: rgba(0, 0, 0, 0.8);
  cursor: zoom-out;
}

/* margin: auto centers the image both ways; when it is taller than the
   screen it starts at the top and scrolls instead of being cut off */
.cs-lightbox img {
  flex: none;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: auto;
}

.about-cv-link {
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.about-cv-link:hover {
  text-decoration-thickness: 2px;
}

/* ---------- Writings & Talks page ---------- */

.writings-main {
  padding-block: clamp(40px, 8vw, 88px) clamp(48px, 8vw, 80px);
}

.writings-wrap {
  max-width: 1100px;
}

.writings-heading {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 4vw, 2.8rem);
  margin: 0 0 clamp(32px, 5vw, 56px);
}

.writing-list {
  display: flex;
  flex-direction: column;
  gap: clamp(32px, 5vw, 56px);
}

.writing-item {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: clamp(24px, 5vw, 64px);
  align-items: center;
}

.writing-art {
  width: 100%;
}

.writing-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 6px;
}

.writing-title a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.writing-body p {
  margin: 0 0 4px;
  line-height: 1.6;
}

.writing-cta {
  display: inline-block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.writing-body .writing-meta {
  margin-top: 16px;
  font-size: 13px;
  color: var(--ink-muted);
}

.writing-meta a {
  color: #d9a441;
  text-decoration: underline;
}

.writings-divider {
  width: min(100%, 980px);
  margin: clamp(48px, 8vw, 88px) auto;
}

@media (max-width: 640px) {
  .writing-item {
    grid-template-columns: minmax(0, 1fr);
  }

  .writing-art {
    max-width: 260px;
  }
}

.cs-lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.cs-lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.3);
}

.cs-lightbox-nav.prev { left: 50px; }
.cs-lightbox-nav.next { right: 50px; }
