/* ==========================================================================
   gallery.css — extends style.css (same colours, fonts and dark mode).
   Used by projects.html and project.html.
   ========================================================================== */

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 4px;
}

button.btn {
  font-family: inherit;
  cursor: pointer;
}
button.btn-ghost {
  background: transparent;
  color: var(--ink);
}
.btn-sm {
  padding: 9px 18px;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ============================
   Page frame
   ============================ */
.page {
  padding-top: 44px;
  padding-bottom: 96px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 30px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.2s ease;
}
.back-link:hover { color: var(--ink); }
.back-link svg { width: 18px; height: 18px; }

.page-head { margin-bottom: 36px; }

.page-title {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.1;
  max-width: 20ch;
}

.page-lead {
  margin: 18px 0 0;
  max-width: 58ch;
  font-size: 1.08rem;
  color: var(--ink-soft);
}

.sub-title {
  font-size: 1.35rem;
  margin: 0 0 14px;
}

/* ============================
   Filter chips
   ============================ */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 30px;
}

.chip {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.chip:hover { color: var(--ink); border-color: var(--ink-soft); }
.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.chip .n {
  margin-left: 8px;
  font-weight: 500;
  opacity: 0.6;
}

/* ============================
   Projects page — rows with photo mosaic
   ============================ */
.project-list { display: flex; flex-direction: column; }

.project-row {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 44px;
  align-items: center;
  padding: 34px 0;
  border-top: 1px solid var(--border);
  animation: fadeInUp 0.6s ease both;
  animation-delay: calc(var(--i, 0) * 90ms);
}
.project-row:last-child { border-bottom: 1px solid var(--border); }

.mosaic {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  overflow: hidden;
}
.mosaic.n1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.mosaic.n2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.mosaic-cell:first-child { grid-row: 1 / 3; }
.mosaic.n2 .mosaic-cell:first-child,
.mosaic.n1 .mosaic-cell:first-child { grid-row: auto; }

.mosaic-cell {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--accent-soft);
  min-height: 0;
}
.mosaic-cell img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.mosaic-cell:hover img,
.mosaic-cell:focus-visible img { transform: scale(1.06); }
.mosaic-cell:focus-visible { outline-offset: -4px; }

.mosaic-more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(12, 14, 16, 0.55);
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
}
.mosaic-empty {
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.row-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0 0 14px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.row-when + .row-when::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-soft);
  opacity: 0.5;
  margin-right: 14px;
  vertical-align: middle;
}

.row-title { font-size: clamp(1.5rem, 2.6vw, 2rem); line-height: 1.2; }
.row-title a { text-decoration: none; }
.row-title a:hover { color: var(--accent); }

.row-summary {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  max-width: 52ch;
}

.tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
}
.tool {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--ink-soft);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 28px;
  flex-wrap: wrap;
}
.photo-count { font-size: 0.9rem; color: var(--ink-soft); }

/* ============================
   Project page
   ============================ */
.project-head { max-width: 780px; margin-bottom: 48px; }
.project-head .pill { display: inline-block; margin-bottom: 18px; }

.project-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
  margin-bottom: 80px;
}

.project-body > p {
  margin: 0 0 36px;
  max-width: 62ch;
  font-size: 1.05rem;
  color: var(--ink-soft);
}

.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li {
  position: relative;
  padding: 12px 0 12px 32px;
  border-top: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 0.97rem;
}
.check-list li:last-child { border-bottom: 1px solid var(--border); }
.check-list li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 1.05rem;
  width: 12px;
  height: 6px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}
.check-list a { color: var(--ink); font-weight: 600; }

.facts {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 26px 26px;
}
.facts dl { margin: 0; }
.facts dl > div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.94rem;
}
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; text-align: right; font-weight: 600; }
.facts-title { font-size: 1rem; margin: 22px 0 0; }
.facts .tool-list { margin-top: 12px; }

.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}
.gallery-head .sub-title { margin: 0; }
.count {
  margin-left: 12px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.empty-note { color: var(--ink-soft); }

/* ============================
   Masonry gallery
   ============================ */
.gallery {
  column-count: 3;
  column-gap: 16px;
}

.tile {
  break-inside: avoid;
  margin: 0 0 16px;
}

.tile-btn {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--accent-soft);
  cursor: zoom-in;
  text-align: left;
  color: #fff;
}
.tile-btn img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.tile-btn img.is-loaded { opacity: 1; }
.tile-btn:hover img,
.tile-btn:focus-visible img { transform: scale(1.04); }
.tile-btn:focus-visible { outline-offset: -3px; }

.tile-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 44px 14px 12px;
  background: linear-gradient(to top, rgba(10, 12, 14, 0.75), rgba(10, 12, 14, 0));
  pointer-events: none;
}
.tile-title { font-size: 0.92rem; font-weight: 600; line-height: 1.3; }
.tile-tag {
  flex: 0 0 auto;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(4px);
}

/* ============================
   Project navigation + CTA
   ============================ */
.project-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 80px;
}
.pn {
  display: block;
  padding: 22px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.2s ease;
}
.pn:hover { border-color: var(--accent); }
.pn small { display: block; margin-bottom: 6px; font-size: 0.82rem; color: var(--ink-soft); }
.pn strong { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.pn.next { grid-column: 2; text-align: right; }

.cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 64px;
  padding: 44px 44px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
}
.cta h2 { font-size: 1.6rem; }
.cta p { margin: 8px 0 0; opacity: 0.75; }
.cta-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-light { background: var(--bg); color: var(--ink); }
.btn-outline {
  border: 1px solid color-mix(in srgb, var(--bg) 40%, transparent);
  color: var(--bg);
}

/* ============================
   Lightbox
   ============================ */
body.lb-open { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: #0b0d0f;
  color: #EDEBE6;
}
.lightbox:not([hidden]) { animation: lbFade 0.22s ease; }
@keyframes lbFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lbProgress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes lbSpin { to { transform: rotate(360deg); } }

.lb-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
}
.lb-count {
  margin: 0;
  font-size: 0.9rem;
  color: #B9B5AC;
  font-variant-numeric: tabular-nums;
}
.lb-tools { display: flex; gap: 8px; }

.lb-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: #EDEBE6;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.16); }
.lb-btn[aria-pressed="true"] {
  background: #6FC7B2;
  border-color: #6FC7B2;
  color: #10221D;
}
.lb-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.lb-btn .i-pause { display: none; }
.lb-btn.is-playing .i-play { display: none; }
.lb-btn.is-playing .i-pause { display: block; }
.lightbox :focus-visible { outline-color: #6FC7B2; }

.lb-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: #6FC7B2;
  transform: scaleX(0);
  transform-origin: left;
}

.lb-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  cursor: zoom-in;
}
.lb-stage.is-zoomed { cursor: zoom-out; }
.lb-stage.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: #6FC7B2;
  border-radius: 50%;
  animation: lbSpin 0.8s linear infinite;
}

.lb-img {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 0;
  transform: translateX(calc(var(--dir, 0) * 28px));
  transition: opacity 0.3s ease, transform 0.3s ease, scale 0.3s ease;
  user-select: none;
  -webkit-user-drag: none;
}
.lb-img.is-in { opacity: 1; transform: none; }

.lb-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-top: -26px;
  color: #fff;
  background: rgba(15, 17, 19, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s ease;
}
.lb-nav:hover { background: rgba(255, 255, 255, 0.18); }
.lb-nav svg { width: 24px; height: 24px; }
.lb-prev { left: 18px; }
.lb-next { right: 18px; }

.lb-info {
  width: 100%;
  max-width: 760px;
  min-height: 92px;
  margin: 0 auto;
  padding: 14px 24px 6px;
  text-align: center;
}
.lb-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
.lb-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
}
.lb-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(111, 199, 178, 0.18);
  color: #6FC7B2;
}
.lb-caption {
  margin: 6px 0 0;
  font-size: 0.94rem;
  color: #B9B5AC;
}

.lb-thumbs {
  display: flex;
  justify-content: safe center;
  gap: 8px;
  padding: 8px 18px 18px;
  overflow-x: auto;
}
.lb-thumb {
  flex: 0 0 auto;
  width: 76px;
  height: 54px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  background: #1d2023;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}
.lb-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.lb-thumb:hover { opacity: 0.85; }
.lb-thumb[aria-current="true"] { opacity: 1; border-color: #6FC7B2; }

/* ============================
   Responsive
   ============================ */
@media (max-width: 900px) {
  .gallery { column-count: 2; }
  .project-row { grid-template-columns: 1fr; gap: 26px; }
  .project-layout { grid-template-columns: 1fr; gap: 40px; margin-bottom: 64px; }
}

@media (max-width: 640px) {
  .page { padding-top: 30px; }
  .lb-btn span { display: none; }
  .lb-btn { padding: 10px; }
  .lb-nav { width: 42px; height: 42px; margin-top: -21px; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
  .lb-thumb { width: 60px; height: 44px; }
  .lb-info { min-height: 84px; padding-inline: 16px; }
  .cta { padding: 32px 24px; }
}

@media (max-width: 480px) {
  .gallery { column-count: 1; }
  .project-nav { grid-template-columns: 1fr; }
  .pn.next { grid-column: auto; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .mosaic-cell img,
  .tile-btn img { transition: none; }
  .mosaic-cell:hover img,
  .tile-btn:hover img { transform: none; }
  .lb-img { transform: none; }
  .lb-progress { display: none; }
}
