:root {
  --paper: #f3efe9;
  --paper-deep: #ebe5dd;
  --ink: #252522;
  --muted: #68665f;
  --line: rgba(37, 37, 34, 0.38);
  --line-soft: rgba(37, 37, 34, 0.16);
  --white: #fffdf9;
  --max: 1240px;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: Inter, "Avenir Next", Avenir, "Segoe UI", Helvetica, Arial, sans-serif;
  --header-height: 77px;
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }
::selection { background: var(--ink); color: var(--paper); }

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  padding: 0.7rem 1rem;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  width: min(calc(100% - 3rem), var(--max));
  margin: 0 auto;
  padding: 1.05rem 0;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(14px);
}
.brand {
  font-size: 0.8rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}
.nav { display: flex; align-items: center; gap: 1.7rem; font-size: 0.87rem; }
.nav a { position: relative; }
.nav a:not(.nav-cta)::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.25rem;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 180ms ease;
}
.nav a:hover::after { transform: scaleX(1); transform-origin: left; }
.nav-cta {
  border: 1px solid var(--ink);
  padding: 0.6rem 0.85rem;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease;
}
.nav-cta:hover {
  background: var(--ink);
  color: var(--paper);
}
.menu-button { display: none; border: 0; background: transparent; color: inherit; cursor: pointer; }

.section-shell {
  width: min(calc(100% - 3rem), var(--max));
  margin-inline: auto;
}

.hero {
  position: relative;
  min-height: auto;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.65fr);
  gap: 2.5rem 4rem;
  align-items: center;
  padding: 4.5rem 0 3.5rem;
  border-bottom: 1px solid var(--line);
}
.hero-copy {
  min-width: 0;
}
.eyebrow,
.section-number,
.project-index {
  margin: 0 0 1rem;
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3.7rem, 8vw, 7.5rem);
  line-height: 0.87;
  letter-spacing: -0.055em;
  font-weight: 500;
}
.hero-role {
  margin: 1rem 0 0;
  font-size: clamp(1.2rem, 2vw, 1.65rem);
  font-style: italic;
  letter-spacing: 0.01em;
  color: var(--muted);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2.5rem; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--ink);
  font-size: 0.88rem;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease;
}
.button:hover { transform: translateY(-2px); }
.button-primary { background: var(--ink); color: var(--paper); }
.button-ghost { background: transparent; }
.hero-portrait {
  align-self: center;
  justify-self: center;
  margin: 0;
  width: clamp(220px, 20vw, 290px);
  max-width: 100%;
}
.hero-portrait img {
  width: 100%;
  height: auto;
  aspect-ratio: 559 / 636;
  object-fit: contain;
  display: block;
}

.projects h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3rem, 6vw, 5.6rem);
  line-height: 0.95;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.projects {
  scroll-margin-top: var(--header-height);
  padding: 3.5rem 0 calc(5.5rem + env(safe-area-inset-bottom, 0px));
}
.section-heading {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: start;
  margin-bottom: 2.8rem;
}
.section-heading > p {
  max-width: 570px;
  margin: 0.6rem 0 0;
  color: var(--muted);
  line-height: 1.6;
}
.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 1rem;
}
.project-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 430px;
  border: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--white) 34%, transparent);
  overflow: hidden;
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), border-color 220ms ease, box-shadow 220ms ease;
}
@media (hover: hover) {
  .project-tile:hover {
    transform: translateY(-5px);
    border-color: var(--ink);
    box-shadow: 0 18px 45px rgba(37, 37, 34, 0.08);
  }
}
.project-tile:focus-visible {
  transform: translateY(-5px);
  border-color: var(--ink);
  box-shadow: 0 18px 45px rgba(37, 37, 34, 0.08);
  outline: none;
}
.project-tile:active {
  transform: scale(0.99);
}
.project-tile-featured {
  grid-column: span 2;
  grid-row: span 2;
  min-height: 650px;
}
.project-tile-visual {
  display: grid;
  place-items: center;
  min-height: 245px;
  aspect-ratio: 4 / 3;
  padding: 2rem;
  background: var(--paper-deep);
  overflow: hidden;
  border-bottom: 1px solid var(--line-soft);
}
.project-tile-featured .project-tile-visual {
  flex: 1 1 auto;
  min-height: 410px;
  aspect-ratio: auto;
  padding: clamp(2rem, 4vw, 4rem);
}
.project-tile-visual img {
  width: 100%;
  height: 100%;
  max-height: 300px;
  object-fit: contain;
  transition: transform 450ms cubic-bezier(.2,.8,.2,1);
}
.project-tile-featured .project-tile-visual img { max-height: 440px; }
.project-tile:hover .project-tile-visual img,
.project-tile:focus-visible .project-tile-visual img { transform: scale(1.045); }
.project-tile-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 1.35rem 1.4rem 1.45rem;
}
.project-tile-featured .project-tile-body { padding: 1.7rem 1.8rem 1.8rem; }
.project-tile-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.project-tile-meta span:first-child {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0;
}
.project-tile h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.65rem, 2.2vw, 2.45rem);
  line-height: 1.03;
  font-weight: 500;
  letter-spacing: -0.035em;
}
.project-tile-featured h3 {
  max-width: 770px;
  font-size: clamp(2.3rem, 4vw, 4rem);
}
.project-tile-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: auto;
  padding-top: 1.8rem;
  border-top: 1px solid transparent;
  font-size: 0.82rem;
  font-weight: 700;
}
.project-tile-action span {
  font-size: 1rem;
  transition: transform 180ms ease;
}
.project-tile:hover .project-tile-action span,
.project-tile:focus-visible .project-tile-action span { transform: translate(3px, -3px); }
.visual-beetle img, .visual-inflation img, .visual-pcb img, .visual-hydrogen img { max-width: 100%; }

.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 0.85rem 0 max(0.85rem, env(safe-area-inset-bottom, 0px));
  font-size: 0.84rem;
  transform: translateY(100%);
  will-change: transform;
  pointer-events: none;
  transition: transform 500ms cubic-bezier(0.16, 1, 0.3, 1);
}
.site-footer.is-visible {
  transform: translateY(0);
  pointer-events: auto;
}
.footer-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.5rem;
}
.footer-copy {
  margin: 0;
  color: var(--ink);
  justify-self: start;
}
.footer-socials {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.25rem;
  justify-self: center;
}
.footer-social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  padding: 0.35rem;
  opacity: 0.85;
  transition: opacity 160ms ease, transform 160ms ease;
}
.footer-social-link:hover,
.footer-social-link:focus-visible {
  opacity: 0.55;
  transform: translateY(-2px);
  outline: none;
}
.footer-social-link svg {
  display: block;
}

@keyframes iconWave {
  0% {
    transform: translateY(0) scale(1);
    opacity: 0.85;
  }
  35% {
    transform: translateY(-5px) scale(1.22);
    opacity: 1;
    filter: drop-shadow(0 4px 10px rgba(37, 37, 34, 0.35));
  }
  70% {
    transform: translateY(-1px) scale(1.05);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 0.85;
  }
}

.footer-socials.is-pulsing .footer-social-link {
  animation: iconWave 900ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.footer-socials.is-pulsing .footer-social-link:nth-child(1) {
  animation-delay: 0.35s;
}
.footer-socials.is-pulsing .footer-social-link:nth-child(2) {
  animation-delay: 0.5s;
}
.footer-socials.is-pulsing .footer-social-link:nth-child(3) {
  animation-delay: 0.65s;
}

.back-to-top {
  color: var(--ink);
  font-weight: 550;
  text-decoration: underline;
  text-underline-offset: 0.25em;
  justify-self: end;
  transition: opacity 150ms ease;
}
.back-to-top:hover { opacity: 0.65; }



.project-dialog {
  width: min(1100px, calc(100% - 2rem));
  max-height: calc(100dvh - 2.5rem);
  padding: 0;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.project-dialog::backdrop { background: rgba(20, 20, 18, 0.52); backdrop-filter: blur(5px); }
.dialog-shell { position: relative; padding: clamp(1.4rem, 4vw, 4rem); }
.dialog-close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 10;
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 0.5rem 0.85rem;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.dialog-close:hover {
  background: var(--ink);
  color: var(--paper);
}
.dialog-kicker { margin: 0 0 0.6rem; font-size: 0.76rem; font-weight: 750; letter-spacing: 0.14em; }
.dialog-content h2 { margin: 0; max-width: 850px; font-family: var(--serif); font-size: clamp(2.5rem, 5vw, 5rem); line-height: 0.98; font-weight: 500; letter-spacing: -0.04em; }
.dialog-hero { display: grid; place-items: center; min-height: 300px; margin: 2.5rem 0; padding: 2rem; border: 1px solid var(--line-soft); background: var(--paper-deep); }
.dialog-hero img { max-height: 350px; object-fit: contain; }
.dialog-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2.3rem; border-top: 1px solid var(--line); padding-top: 2rem; }
.dialog-columns h3 { margin: 0 0 1rem; font-family: var(--serif); font-size: 1.7rem; font-weight: 500; }
.dialog-columns ul { margin: 0; padding-left: 1.15rem; }
.dialog-columns li + li { margin-top: 0.6rem; }

@media (max-width: 900px) {
  .site-header {
    width: 100%;
    padding: 0.9rem 1.25rem;
    box-sizing: border-box;
  }
  .section-shell { width: min(calc(100% - 2rem), var(--max)); }
  .menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    min-width: 68px;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--ink);
    background: transparent;
    color: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
  }
  .menu-button:active {
    background: var(--ink);
    color: var(--paper);
  }
  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 16px 36px rgba(20, 20, 18, 0.12);
    max-height: calc(100dvh - 100%);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav.is-open { display: flex; }
  .nav a {
    padding: 1.05rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 500;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 150ms ease;
  }
  .nav a:active {
    background: var(--paper-deep);
  }
  .nav-cta {
    border: 0;
    font-weight: 600;
  }
  .nav-cta:hover {
    background: transparent;
    color: inherit;
  }
  .hero {
    min-height: auto;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    padding: 3rem 0 2.5rem;
    gap: 2rem;
  }
  .hero h1 {
    font-size: clamp(2.4rem, 7.5vw, 3.6rem);
    line-height: 0.95;
    word-break: normal;
    overflow-wrap: break-word;
  }
  .hero-portrait {
    width: min(65%, 260px);
    justify-self: center;
    margin: 0 auto;
  }
  .hero-actions {
    margin-top: 1.75rem;
  }
  .hero-actions .button {
    width: 100%;
    text-align: center;
  }
  .section-heading {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
  }
  .dialog-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .project-dialog {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    margin: 0;
  }
  .dialog-shell {
    padding: 1.25rem 1.25rem calc(3.5rem + env(safe-area-inset-bottom, 0px));
  }
  .dialog-close {
    min-height: 44px;
    min-width: 74px;
    padding: 0.55rem 0.95rem;
    font-size: 0.88rem;
  }
  .dialog-content h2 {
    font-size: clamp(1.75rem, 7vw, 2.5rem);
    line-height: 1.1;
    margin-top: 0.5rem;
  }
  .dialog-hero {
    min-height: 170px;
    margin: 1.5rem 0;
    padding: 1.25rem;
  }
  .dialog-hero img {
    max-height: 220px;
  }
  .dialog-columns {
    gap: 1.75rem;
    padding-top: 1.5rem;
  }
  .dialog-columns h3 {
    font-size: 1.35rem;
    margin-bottom: 0.5rem;
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: 0.75rem 1rem;
  }
  .brand {
    font-size: 0.78rem;
    letter-spacing: 0.1em;
  }
  .section-shell {
    width: calc(100% - 2rem);
  }
  .project-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .project-tile {
    min-height: 0;
  }
  .project-tile-visual {
    min-height: 210px;
    aspect-ratio: 4 / 3;
    padding: 1.5rem;
  }
  .project-tile-visual img {
    max-height: 240px;
  }
  .project-tile-body {
    padding: 1.35rem 1.25rem 1.45rem;
  }
  .project-tile h3 {
    font-size: clamp(1.3rem, 5.5vw, 1.55rem);
    line-height: 1.2;
    margin-bottom: 0.9rem;
  }
  .hero h1 {
    font-size: clamp(1.95rem, 8.5vw, 2.85rem);
    line-height: 0.95;
    word-break: normal;
    overflow-wrap: break-word;
  }
  .hero-role {
    font-size: 1.15rem;
    margin-top: 0.75rem;
  }
  .hero {
    padding: 2.5rem 0 2rem;
    gap: 1.75rem;
  }
  .section-heading h2 {
    font-size: clamp(2.35rem, 10vw, 3.6rem);
  }
  .section-heading {
    gap: 1rem;
    margin-bottom: 2rem;
  }
  .site-footer {
    padding: 0.75rem 0 max(0.75rem, env(safe-area-inset-bottom, 0px));
  }
  .footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    width: calc(100% - 1.75rem);
  }
  .footer-copy {
    font-size: 0.76rem;
    white-space: nowrap;
  }
  .footer-socials {
    display: flex;
    align-items: center;
    gap: 0.8rem;
  }
  .footer-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem;
    min-width: 36px;
    min-height: 36px;
  }
  .footer-social-link svg {
    width: 18px;
    height: 18px;
  }
  .back-to-top {
    font-size: 0.76rem;
    white-space: nowrap;
  }
}

@media (max-width: 380px) {
  .footer-copy .footer-year {
    display: none;
  }
  .footer-inner {
    gap: 0.35rem;
  }
  .footer-socials {
    gap: 0.45rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
