.section.portfolio-section {
  padding: clamp(20px, 2.8vw, 42px) var(--page-pad) var(--gm-section-gap);
}
.portfolio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding-bottom: clamp(16px, 2vw, 28px);
  border-bottom: 1px solid var(--gm-line);
}
.portfolio-head h1 {
  color: var(--gm-ink);
  font-size: clamp(32px, 4.6vw, 62px);
  line-height: 1.04;
  letter-spacing: -.045em;
}
.portfolio-head p { max-width: 68ch; color: var(--gm-muted); margin-top: 8px; }
.portfolio-intro { max-width: 68ch; margin: 16px 0; color: var(--gm-muted); }
.portfolio-head #result-count { font-size: 15px; font-variant-numeric: tabular-nums; }
#portfolio-filter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 16px;
  background: var(--gm-paper);
  border: 1px solid var(--gm-control-edge);
  border-radius: var(--gm-radius);
  color: var(--gm-ink);
  font-size: 15px;
  font-weight: 600;
}
#portfolio-filter-toggle[aria-expanded=true] {
  color: var(--gm-accent-ink);
  border-color: currentColor;
}
#portfolio-filter-toggle[aria-expanded=true] .icon { rotate: 180deg; }
#portfolio-filters {
  margin: 0;
  padding: 20px 0;
  border-bottom: 1px solid var(--gm-line);
}
#portfolio-filters label { margin: 0 0 12px; }
#portfolio-filters input { margin-top: 4px; }
#portfolio-filters #clear-filters { margin-top: 12px; }
.portfolio-albums {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: clamp(24px, 3vw, 44px) clamp(20px, 2.6vw, 38px);
  margin-top: clamp(15px, 2vw, 28px);
}
.portfolio-albums .portfolio-card {
  min-width: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.album-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 12px;
  margin-bottom: 6px;
}
.album-heading h2 { font-size: clamp(20px, 1.8vw, 27px); line-height: 1.2; letter-spacing: -.025em; }
.album-heading a {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  color: var(--gm-ink);
}
.album-heading a:focus-visible { outline-offset: 2px; }
.album-heading a:hover { color: var(--gm-accent-ink); }
.album-heading .icon { width: .78em; height: .78em; flex: none; color: var(--gm-accent-ink); }
.album-heading p { margin: 0; color: var(--gm-muted); font-size: 14px; }
.album-photos {
  --tile-gap: clamp(4px, .55vw, 8px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--tile-gap);
}
.album-photos > a {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1.48;
  background: var(--gm-line);
  border-radius: 4px;
  cursor: zoom-in;
}
.album-photos img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: inherit; }
.album-photos > a:focus-visible { outline-offset: 1px; z-index: 1; }
.album-photos[data-photo-count="1"] { grid-template-columns: 1fr; }
.album-photos[data-photo-count="2"], .album-photos[data-photo-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.album-photos:is([data-photo-count="1"], [data-photo-count="4"]) > a { aspect-ratio: 1.9; }
.album-photos[data-photo-count="2"] > a { aspect-ratio: .95; }
.album-photos[data-photo-count="3"] {
  grid-template-columns: 1.6fr 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  aspect-ratio: 1.9;
}
.album-photos[data-photo-count="3"] > a { aspect-ratio: auto; }
.album-photos[data-photo-count="3"] > a:first-child { grid-row: span 2; }
.album-enlarge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 28px;
  height: 28px;
  padding: 5px;
  border-radius: 4px;
  color: white;
  background: rgb(14 25 29 / 84%);
  pointer-events: none;
}
#project-viewer {
  box-sizing: border-box;
  width: min(1010px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 28px);
  overflow: auto;
  border: 0;
  border-radius: var(--gm-radius);
  padding: 0;
  margin: auto;
  color: white;
  background: #1c2529;
}
#project-viewer::backdrop { background: rgb(11 17 20 / 87%); }
html:has(#project-viewer) { scrollbar-gutter: stable; }
html:has(#project-viewer[open]) { overflow: hidden; }
.viewer-head, .viewer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px clamp(12px, 2vw, 24px);
  gap: 8px;
}
.viewer-head h2 { color: white; font-size: clamp(18px, 2vw, 25px); line-height: 1.2; overflow-wrap: anywhere; }
.viewer-stage { display: grid; place-items: center; background: #101719; }
.viewer-stage img { display: block; width: 100%; height: min(65dvh, 63vw); object-fit: contain; touch-action: pan-y pinch-zoom; }
.viewer-foot { flex-wrap: wrap; }
.viewer-controls, .viewer-foot a, #project-viewer button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
#project-viewer button {
  border-radius: 50%;
  border: 1px solid #708084;
  background: transparent;
  color: white;
  width: 44px;
  height: 44px;
  flex: none;
}
#project-viewer button:hover { background: #37454a; }
#project-viewer :is(button, a):focus-visible { outline-color: white; outline-offset: 2px; }
.viewer-controls span { min-width: 7ch; font-size: 14px; text-align: center; font-variant-numeric: tabular-nums; }
.viewer-foot a { min-height: 44px; color: white; font-size: 14px; font-weight: 600; }
.viewer-foot a:hover { text-decoration: underline; }
.viewer-foot a .icon { width: 16px; height: 16px; }
@media (max-width: 700px) {
  .section.portfolio-section { padding-inline: clamp(16px, 4vw, 24px); }
  .portfolio-albums { grid-template-columns: minmax(0, 1fr); }
  .album-heading { gap: 0 8px; }
  .viewer-stage img { height: min(62dvh, 105vw); }
}
@media (max-width: 420px) {
  .portfolio-head { column-gap: 8px; }
  #portfolio-filter-toggle { font-size: 14px; padding-inline: 8px; gap: 5px; }
  #portfolio-filter-toggle .icon { width: 16px; height: 16px; }
  #project-viewer { width: calc(100% - 16px); }
  .viewer-head, .viewer-foot { padding-inline: 8px; }
  .viewer-controls { gap: 4px; }
}
@media (max-width: 365px) {
  .portfolio-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .portfolio-head > div { display: contents; }
  .portfolio-head h1 { grid-column: 1 / -1; }
  .portfolio-head #result-count { margin-top: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  #portfolio-filter-toggle, #project-viewer button { transition: scale 90ms var(--gm-ease-out); }
  :is(#portfolio-filter-toggle, #project-viewer button):is(:active, [data-touch-pressed]) { scale: var(--gm-press-scale); }
}
