/* Portfolio theme. To restyle the whole site, start with the colors just below. */

:root {
  --bg: #eff0ec;
  --surface: #e2e4de;
  --ink: #14181a;
  --muted: #565e61;
  --line: rgb(20 24 26 / 0.22);
  --accent: #bf3a0b;
  --stage: #15191b; /* behind videos and letterboxed pictures */
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter: clamp(16px, 4vw, 48px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101315;
    --surface: #1b2023;
    --ink: #ebede8;
    --muted: #a0a8aa;
    --line: rgb(235 237 232 / 0.2);
    --accent: #ff8a57;
    --stage: #070909;
    color-scheme: dark;
  }
}

@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 24px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

img, video, iframe { display: block; max-width: 100%; }
figure { margin: 0; }
ul, ol { margin: 0; padding: 0; }
a { color: inherit; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.08; text-wrap: balance; }

.wrap { width: 100%; max-width: 1360px; margin-inline: auto; padding-inline: var(--gutter); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gutter); top: 8px; z-index: 10; background: var(--bg); padding: 8px 12px; }

/* The small monospace labels used throughout */
.meta, .topbar nav, .footer, .title-block dt, .project-side h2, .gallery h2, .card-skills,
.tags, .back, .row-side, figcaption, .about-block h3 {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
}
.meta { display: flex; gap: 1.5em; margin: 0; color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 24px;
  padding-block: 16px;
}
.topbar-name { font-weight: 600; text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.topbar nav a, .footer a, .back a { text-decoration: none; }
.topbar nav a:hover, .footer a:hover, .back a:hover { text-decoration: underline; }

/* ---------- Home: hero ---------- */
.hero { padding-block: clamp(24px, 4vw, 48px) clamp(32px, 4.5vw, 56px); }
.hero h1 {
  font-size: clamp(2.125rem, 3.6vw, 3rem);
  font-stretch: 106%;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
  gap: 32px clamp(32px, 7vw, 112px);
  align-items: start;
}
.hero-headline {
  margin: 6px 0 16px;
  font-size: clamp(1.0625rem, 1.5vw, 1.25rem);
  font-weight: 500;
  line-height: 1.3;
  color: var(--accent);
  text-wrap: balance;
}
.hero-text p:not(.hero-headline) { margin: 0; max-width: 62ch; }
.hero-photo { width: 120px; height: 120px; object-fit: cover; border-radius: 50%; margin-bottom: 20px; }

/* The block of facts is drawn like the title block of an engineering drawing */
.title-block { margin: 0; border: 1px solid var(--line); }
.title-block > div {
  display: grid;
  grid-template-columns: 7.5em minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
}
.title-block > div:last-child { border-bottom: 0; }
.title-block dt { padding: 9px 12px; color: var(--muted); border-right: 1px solid var(--line); }
.title-block dd { margin: 0; padding: 7px 12px; font-size: 0.9375rem; overflow-wrap: anywhere; }

/* ---------- Sections ---------- */
.section { padding-block: 0 clamp(56px, 8vw, 104px); }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 2px solid var(--ink);
  padding-top: 12px;
  margin-bottom: 28px;
}
.section-head h2 { font-size: 1.5rem; font-stretch: 112%; }

/* ---------- Project preview cards ---------- */
.cards {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 48px clamp(20px, 2.4vw, 32px);
}
.card a { display: block; height: 100%; text-decoration: none; }
.card a:hover { color: inherit; }
.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 12px;
}
.card-media img, .card-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.card a:hover .card-media img, .card a:hover .card-media video,
.card a:focus-visible .card-media img, .card a:focus-visible .card-media video { transform: scale(1.03); }
.card-empty {
  display: grid;
  place-items: center;
  height: 100%;
  font-size: 5rem;
  font-weight: 800;
  color: var(--muted);
}
.card-play {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 2px 8px;
  background: var(--stage);
  color: #fff;
  font: 500 0.6875rem/1.6 var(--mono);
}
.card-play::before { content: "▶ "; font-size: 0.8em; }
.card .meta { justify-content: space-between; }
.card h3 { margin-top: 6px; font-size: 1.3125rem; line-height: 1.15; transition: color 0.15s; }
.card a:hover h3, .card a:focus-visible h3 { color: var(--accent); }
.card-summary { margin: 8px 0 10px; color: var(--muted); font-size: 0.9875rem; line-height: 1.45; }
.card-skills { list-style: none; display: flex; flex-wrap: wrap; gap: 0 1.2em; color: var(--muted); }

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px clamp(32px, 6vw, 88px); }
.about-block { min-width: 0; }
.about-block h3 { color: var(--muted); font-weight: 400; margin-bottom: 12px; }
.about-block ul { list-style: none; }
.about-block li { padding-block: 10px; border-top: 1px solid var(--line); line-height: 1.4; }
.about-block li:last-child { border-bottom: 1px solid var(--line); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; align-items: baseline; }
.row-side { color: var(--muted); white-space: nowrap; }
.row-detail { grid-column: 1 / -1; color: var(--muted); font-size: 0.9375rem; }

/* ---------- Project page ---------- */
.project { padding-bottom: clamp(48px, 7vw, 88px); }
.back { margin: 12px 0 clamp(28px, 5vw, 56px); }
.project-head .meta { margin-bottom: 12px; }
.project-head h1 {
  font-size: clamp(1.875rem, 3.6vw, 3rem);
  font-stretch: 106%;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  max-width: 24em;
}
.project-summary {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 32px clamp(32px, 7vw, 104px);
  margin-block: clamp(28px, 4vw, 48px);
}
.lead p { margin: 0 0 0.8em; font-size: clamp(1.1875rem, 1.7vw, 1.375rem); line-height: 1.42; }
.lead p:last-child { margin-bottom: 0; }
.project-side > section + section { margin-top: 24px; }
.project-side h2, .gallery h2 {
  font-weight: 400;
  color: var(--muted);
  padding-bottom: 6px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.project-side p { margin: 0 0 6px; font-size: 0.9875rem; line-height: 1.45; }
.project-side ul:not(.tags) { list-style: none; font-size: 0.9875rem; line-height: 1.45; }
.project-side ul:not(.tags) li { padding-left: 1.1em; text-indent: -1.1em; margin-bottom: 6px; }
.project-side ul:not(.tags) li::before { content: "→"; display: inline-block; width: 1.1em; text-indent: 0; color: var(--accent); }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { padding: 1px 7px; border: 1px solid var(--line); }

.project-hero { background: var(--stage); margin-bottom: clamp(32px, 5vw, 64px); }
.project-hero a { display: block; }
.project-hero img, .project-hero video {
  width: 100%;
  max-height: min(82vh, 860px);
  object-fit: contain;
}

/* The written story */
.prose { max-width: 720px; margin-inline: auto; margin-bottom: clamp(40px, 6vw, 72px); }
.prose h2 {
  font-size: 1.625rem;
  font-stretch: 105%;
  margin: 2em 0 0.55em;
  scroll-margin-top: 24px;
}
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 1.25rem; margin: 1.6em 0 0.5em; }
.prose h4 { font-size: 1.0625rem; margin: 1.4em 0 0.4em; }
.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.2em; }
.prose li { margin-bottom: 0.45em; }
.prose li::marker { color: var(--accent); }
.prose a { color: var(--accent); }
.prose code { font: 0.9em var(--mono); background: var(--surface); padding: 0.1em 0.3em; }
.prose pre { overflow-x: auto; background: var(--surface); padding: 14px 16px; font-size: 0.875rem; }
.prose pre code { background: none; padding: 0; }
.prose figure, .media-row { margin-block: 1.75em; }
.prose figure img, .prose figure video { margin-inline: auto; max-height: 74vh; width: auto; }
.prose .media-row figure { margin: 0; }
.media-row { display: flex; flex-wrap: wrap; gap: 8px; }
.media-row figure { flex: 1 1 240px; min-width: 0; }
.embed { width: 100%; aspect-ratio: 16 / 9; border: 0; }
figcaption { margin-top: 6px; color: var(--muted); }
.prose figcaption { text-align: center; }
a.zoom { display: block; cursor: zoom-in; }

/* Gallery */
.gallery { margin-bottom: clamp(40px, 6vw, 72px); }
.gallery h2 { margin-bottom: 16px; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 24px 12px;
}
.tile { display: block; aspect-ratio: 4 / 3; background: var(--stage); overflow: hidden; }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: opacity 0.15s; }
a.tile:hover img { opacity: 0.86; }
.tile video { width: 100%; height: 100%; object-fit: contain; }

/* Previous / next */
.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  border-top: 2px solid var(--ink);
  padding-top: 12px;
}
.pager a { display: block; text-decoration: none; }
.pager-next { text-align: right; }
.pager-next .meta { justify-content: flex-end; }
.pager-title { display: block; margin-top: 2px; font-size: clamp(1.0625rem, 2vw, 1.5rem); font-weight: 700; line-height: 1.15; }
.pager a:hover .meta { color: inherit; }

/* Footer */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-block: 18px 28px;
  color: var(--muted);
}
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 18px; }

/* Enlarged pictures */
.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgb(7 9 9 / 0.96);
  color: #fff;
}
.lightbox[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.lightbox::backdrop { background: transparent; }
.lightbox-stage { position: relative; min-height: 0; }
.lightbox img {
  position: absolute;
  inset: 16px;
  width: calc(100% - 32px);
  height: calc(100% - 32px);
  max-width: none;
  object-fit: contain;
}
.lightbox-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px var(--gutter) max(10px, env(safe-area-inset-bottom));
  font: 0.8125rem/1.4 var(--mono);
}
.lightbox-caption { flex: 1; min-width: 0; }
.lightbox button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  background: none;
  border: 1px solid rgb(255 255 255 / 0.35);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.lightbox button:hover { background: rgb(255 255 255 / 0.14); }

/* ---------- Narrow screens ---------- */
@media (max-width: 820px) {
  .hero-grid, .project-summary, .about { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .row { grid-template-columns: minmax(0, 1fr); }
  .row-side { white-space: normal; }
}

/* ---------- A gentle entrance when a page opens ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.hero-text, .title-block, .card, .project-head, .project-summary {
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.title-block, .project-summary { animation-delay: 0.08s; }
.card:nth-child(1) { animation-delay: 0.12s; }
.card:nth-child(2) { animation-delay: 0.18s; }
.card:nth-child(3) { animation-delay: 0.24s; }
.card:nth-child(n + 4) { animation-delay: 0.3s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
