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

:root {
  --bg: #f2f2f2;
  --text: #222;
  --text-muted: #868686;
  --border: #d6d6d6;
  --white: #fff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- Header ---- */
.header { padding: 40px 0 0; }
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
}
.header h1 { font: inherit; font-size: 15px; font-weight: 500; line-height: 1; }
.header-about {
  display: inline;
  font: inherit;
  line-height: 1.3;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  text-align: left;
  transition: opacity 0.15s ease;
}
/* Where the title can't fit on one line, the role gets its own line */
@media (max-width: 480px) {
  .title-name, .title-role { display: block; }
  .title-sep { display: none; }
}
/* Last word and icon never split, so the icon follows "Products" when the title wraps */
.header-about-last { white-space: nowrap; }
.header-about svg { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; margin-left: 6px; color: var(--text-muted); }
.header-about:hover { opacity: 0.6; }

.langs { flex: none; display: flex; gap: 8px; margin-left: 16px; font-size: 12px; color: var(--text-muted); }
.langs a:hover, .langs [aria-current] { color: var(--text); }
/* On phones the links sit in the empty space above the title, which keeps the full width */
@media (max-width: 640px) {
  .header-inner { position: relative; }
  .langs { position: absolute; top: -32px; right: 0; margin-left: 0; gap: 4px; }
  .langs a { padding: 6px 4px; }
}

/* ---- About modal ---- */
/* Same model as the project modal: the overlay scrolls, the close button is sticky */
.about-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(225,225,225,0.7);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.about-overlay.open { opacity: 1; pointer-events: auto; }
.about-wrap { width: 100%; padding: 60px 20px 80px; display: flex; justify-content: center; }
.about-box {
  background: var(--white);
  border-radius: 16px;
  padding: 36px 40px;
  max-width: 580px;
  width: 100%;
  box-shadow: 0 12px 48px rgba(0,0,0,0.1);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
}
.about-hero {
  display: block;
  width: calc(100% + 80px);
  margin: -36px -40px 24px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 16px 16px 0 0;
}
.about-box a { color: var(--text-muted); text-decoration: none; }
.about-box a:hover { color: var(--text); }
.about-services-title { margin-top: 20px; font-size: 13px; font-weight: 500; }
.about-services { margin: 6px 0 0 16px; columns: 2; column-gap: 28px; font-size: 13px; line-height: 1.5; color: #555; }
.about-services li { break-inside: avoid; margin-bottom: 4px; }
.about-links {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  font-size: 14px;
}
@media (max-width: 480px) {
  .about-box { padding: 28px 24px; font-size: 15px; }
  .about-hero { width: calc(100% + 48px); margin: -28px -24px 20px; }
}
/* ---- Grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 12px 0 80px;
}
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr; }
}

.card { display: block; cursor: pointer; transition: opacity 0.15s ease; }
.card:hover { opacity: 0.92; }

.card-thumb {
  width: 100%;
  display: block;
  border-radius: 12px;
  background: #ebebeb;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.card-body { padding: 6px 0 0; }
.card-body h3 { font-size: 13px; font-weight: 500; line-height: 1.35; }

/* ---- Project modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(225,225,225,0.7);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal-close-wrap {
  position: sticky;
  top: 20px;
  height: 0;
  z-index: 1010;
  pointer-events: none;
}
.modal-close {
  position: absolute;
  top: 0;
  right: 24px;
  pointer-events: auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s, backdrop-filter 0.15s;
}
.modal-nav-wrap {
  position: sticky;
  top: 50vh;
  height: 0;
  z-index: 1010;
  pointer-events: none;
}
.modal-nav {
  position: absolute;
  top: -22px;
  pointer-events: auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s, backdrop-filter 0.15s, opacity 0.15s;
  padding: 0;
}
.modal-nav:disabled { opacity: 0.35; cursor: default; }
.modal-nav svg { width: 26px; height: 26px; }
.modal-nav-prev { left: 24px; }
.modal-nav-next { right: 24px; }
@media (max-width: 768px) {
  .modal-nav-wrap { display: none; }
}

.modal { width: 100%; padding: 60px 20px 80px; }
.modal-info-wrap {
  position: sticky;
  top: 60px;
  height: 0;
  z-index: 1005;
}
.modal-info {
  position: absolute;
  top: 0;
  left: 0;
  /* Fills the margin beside the images (at most 60vw wide), leaving a 24px gap */
  width: min(320px, calc(20vw - 52px));
}
.modal-info h1, .modal-info h2 { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.modal-info p {
  margin-top: 8px;
  font-size: 13px;
  color: #3a3a3a;
  line-height: 1.6;
  white-space: pre-wrap;
  max-width: 440px;
}
.modal-info p a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.modal-info p a:hover { text-decoration: none; }
.modal-images { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.modal-images img {
  max-width: 60vw; max-height: 90vh;
  object-fit: contain;
  display: block;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
/* Below this the margin gets too narrow for the text, so it moves above the images */
@media (max-width: 1320px) {
  .modal-info-wrap { position: static; height: auto; top: auto; }
  .modal-info { position: static; width: auto; left: auto; margin-bottom: 24px; }
  .modal-info p { max-width: 560px; }
  .modal-images img { max-width: 100%; }
}

.modal-meta { margin-top: 4px; font-size: 12px; color: var(--text-muted); }

/* ---- Motion ---- */
/* Modal content rises into place while the overlay fades; images fade in once loaded */
.modal, .about-wrap {
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}
/* Project modal zooms out of (and back into) its thumbnail; transform-origin is set from JS */
.modal { transform: scale(0.94); transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1); }
.modal-overlay.open .modal, .about-overlay.open .about-wrap { opacity: 1; transform: none; }
.js .card-thumb, .modal-overlay .modal-images img { opacity: 0; transition: opacity 0.4s ease; }
.js .card-thumb.loaded, .modal-overlay .modal-images img.loaded { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .modal, .about-wrap { transform: none; }
  .js .card-thumb, .modal-overlay .modal-images img { opacity: 1; transition: none; }
}

/* ---- Footer ---- */
footer { padding: 16px 0; font-size: 12px; color: var(--text-muted); }
footer .container { display: flex; gap: 16px; }
footer a { font-size: 12px; }

/* ---- Project pages (the modal's layout as a normal page) ---- */
.project-page .modal { opacity: 1; transform: none; padding-top: 24px; }
.project-page .modal-close { text-decoration: none; }
.project-page .header-home { font-size: 15px; font-weight: 500; line-height: 1.3; }
