/* page-galeria.css
   CSS desta página. Partilhado pelas versões PT e EN
   (galeria.html, gallery.html) — uma só fonte, para não divergirem. */

  .gallery-hero {
    padding: 180px var(--gutter) 60px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: end;
    border-bottom: 1px solid var(--line);
    position: relative;
    overflow: hidden;
    background-image:
      linear-gradient(to bottom,
        color-mix(in oklab, var(--bg) 92%, transparent) 0%,
        color-mix(in oklab, var(--bg) 85%, transparent) 100%),
      url("images/bodeguita_1.jpg");
    background-size: cover;
    background-position: center;
  }
  .gallery-hero > * { position: relative; z-index: 1; }
  .gallery-hero h1 {
    font-family: var(--serif);
    font-size: clamp(72px, 11vw, 180px);
    line-height: 0.85;
    letter-spacing: -0.025em;
    font-weight: 400;
    margin: 0;
  }
  .gallery-hero h1 em { font-style: italic; color: var(--accent); }
  .gallery-hero-aside .eyebrow { display: block; margin-bottom: 20px; }
  .gallery-hero-aside .eyebrow em { font-style: normal; color: var(--accent); }
  .gallery-hero-aside p {
    font-size: 17px;
    line-height: 1.6;
    color: var(--ink-2);
    max-width: 42ch;
    margin: 0;
  }
  @media (max-width: 820px) {
    .gallery-hero { grid-template-columns: 1fr; }
  }

  /* Gallery filter */
  .gf-bar {
    padding: 28px var(--gutter);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
  }
  .gf-filters {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .gf-filter {
    position: relative;
    padding: 10px 4px;
    margin: 0 14px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-3);
    border: none;
    border-radius: 0;
    transition: color .35s var(--ease), letter-spacing .45s var(--ease);
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
  }
  .gf-filter::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    bottom: 2px;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform .45s var(--ease);
  }
  .gf-filter:hover {
    color: var(--ink);
    letter-spacing: 0.20em;
  }
  .gf-filter:hover::after { transform: scaleX(1); }
  .gf-filter.is-active {
    color: var(--accent);
    font-family: var(--serif);
    font-style: italic;
    font-size: 17px;
    letter-spacing: 0;
    text-transform: none;
    font-weight: 400;
    padding: 8px 4px;
  }
  .gf-filter.is-active::after {
    transform: scaleX(1);
    background: var(--accent);
  }
  .gf-count {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-3);
  }
  @media (max-width: 720px) {
    .gf-bar { grid-template-columns: 1fr; text-align: center; }
    .gf-bar > .gf-count:first-child,
    .gf-bar > .gf-count:last-child { justify-self: center; }
  }

  /* ============================================
     Galeria — 4 layouts lineares (alternáveis)
     ============================================ */

  /* Layout switcher bar */
  .gl-switch {
    display: flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line-2);
    border-radius: 999px;
  }
  .gl-switch button {
    padding: 8px 14px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-3);
    border-radius: 999px;
    transition: all .25s var(--ease);
  }
  .gl-switch button:hover { color: var(--ink); }
  .gl-switch button.is-active { background: var(--ink); color: var(--bg); }

  /* Container */
  .gallery-grid {
    padding: 80px var(--gutter) 120px;
    display: grid;
    grid-auto-rows: auto;
  }

  /* Items: shared base */
  .gallery-item {
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 14px;
    /* <figure> traz margin: 1em 40px do browser. No telemóvel esses 40px de
       cada lado encolhiam a foto para 70% do ecrã. */
    margin: 0;
  }
  .gallery-item .ph {
    width: 100%;
    height: auto;
    transition: transform .6s var(--ease);
  }
  .gallery-item:hover .ph { transform: scale(1.015); }

  /* === Layout A: 3-column editorial === */
  [data-gallery-layout="three"] .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    column-gap: 24px;
    row-gap: 64px;
  }
  [data-gallery-layout="three"] .gallery-item .ph { aspect-ratio: 4/5; }

  /* === Layout B: 4-column dense square === */
  [data-gallery-layout="four"] .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
    column-gap: 16px;
    row-gap: 48px;
  }
  [data-gallery-layout="four"] .gallery-item .ph { aspect-ratio: 1; }

  /* === Layout C: 2-column cinematic === */
  [data-gallery-layout="two"] .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    /* O espaçamento vive todo aqui. Antes somava-se a margem que os <figure>
       trazem do browser (40px de cada lado), e o valor real era outro. */
    column-gap: 40px;
    row-gap: 40px;
  }
  [data-gallery-layout="two"] .gallery-item .ph { aspect-ratio: 3/2; }

  /* Proporção única (4/5) para TODAS as fotos. Misturar deitadas com
     em-pé deixava as colunas com alturas diferentes e abria buracos na
     grelha — em qualquer filtro. Igualar a altura resolve-o na origem.
     Nas fotos com pessoas o corte ancora no topo, para não decapitar. */
  .gallery-item .ph { aspect-ratio: 4/5 !important; }
  .gallery-item.is-portrait .ph-img { object-position: 50% 50%; }
  .gallery-item.is-portrait.anchor-top .ph-img { object-position: 50% 15%; }

  /* === Layout D: single-column storytelling === */
  [data-gallery-layout="single"] .gallery-grid {
    grid-template-columns: 1fr;
    row-gap: 80px;
    max-width: 920px;
  }
  [data-gallery-layout="single"] .gallery-item .ph { aspect-ratio: 16/9; }
  [data-gallery-layout="single"] .gallery-item {
    padding-bottom: 80px;
    border-bottom: 1px solid var(--line);
  }
  [data-gallery-layout="single"] .gallery-item:last-child {
    padding-bottom: 0;
    border-bottom: none;
  }

  @media (max-width: 900px) {
    [data-gallery-layout="three"] .gallery-grid,
    [data-gallery-layout="four"] .gallery-grid {
      grid-template-columns: repeat(2, 1fr);
      column-gap: 16px;
      row-gap: 40px;
    }
    [data-gallery-layout="two"] .gallery-grid {
      grid-template-columns: 1fr;
      row-gap: 48px;
    }
  }
  @media (max-width: 560px) {
    .gallery-grid { grid-template-columns: 1fr !important; row-gap: 40px !important; }
  }

  /* Hidden batch for infinite scroll */
  .gallery-item.is-batched {
    display: none !important;
  }

  /* Load more */
  .load-more-bar {
    padding: 40px var(--gutter) 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
  }
  .load-more-bar.is-done .load-more { opacity: 0.4; pointer-events: none; }
  .load-more-bar.is-done .lm-label::after {
    content: " · " attr(data-end);
  }
  .load-more {
    background: transparent;
    border: 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 12px 24px;
    color: var(--ink-2);
    transition: color .35s var(--ease);
  }
  .load-more:hover { color: var(--accent); }
  .lm-num {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.22em;
    color: var(--ink-3);
    transition: color .35s var(--ease);
  }
  .load-more:hover .lm-num { color: var(--accent); }
  .lm-label {
    font-family: var(--serif);
    font-style: italic;
    font-size: 24px;
    letter-spacing: 0;
    line-height: 1;
  }
  .lm-line {
    width: 1px;
    height: 32px;
    background: var(--ink-3);
    transform-origin: top;
    transition: background .35s var(--ease), transform .5s var(--ease);
  }
  .load-more:hover .lm-line { background: var(--accent); transform: scaleY(1.4); }
  .lm-sentinel { width: 1px; height: 1px; }
  .load-more-bar.is-done .lm-line { background: var(--line); }

  /* Lightbox */
  .lightbox {
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 8, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
    cursor: zoom-out;
  }
  .lightbox.is-open {
    display: flex;
    animation: fadeLb .3s var(--ease);
  }
  @keyframes fadeLb { from { opacity: 0; } to { opacity: 1; } }
  .lightbox-inner {
    position: relative;
    width: min(1100px, 94vw);
    max-height: 84vh;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .lightbox .ph {
    width: 100%;
    max-height: 84vh;
    aspect-ratio: 4/3;
    background: transparent;
  }
  .lightbox .ph:has(> img.ph-img) {
    aspect-ratio: auto;
    background: transparent;
    border-radius: 4px;
  }
  .lightbox .ph > img.ph-img {
    object-fit: contain;
    max-height: 84vh;
    position: relative;
    inset: auto;
  }
  .lightbox .ph.is-dark::before {
    background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 1px, transparent 1px 10px);
  }
  .lightbox .ph.is-dark:has(> img.ph-img)::before { display: none; }
  .lb-counter {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -40px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.1em;
    color: color-mix(in oklab, white 70%, transparent);
  }
  .lb-close {
    position: absolute;
    top: 24px; right: 24px;
    width: 52px; height: 52px;
    background: rgba(0,0,0,.55);
    border: 1.5px solid white;
    border-radius: 50%;
    color: white;
    font-size: 26px;
    line-height: 1;
    display: grid; place-items: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
    transition: background .25s, transform .25s;
    z-index: 2;
  }
  .lb-close:hover { background: var(--accent); border-color: var(--accent); transform: rotate(90deg); }
  .lb-prev, .lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 54px; height: 54px;
    /* Sem z-index, as setas ficavam à mercê da ordem do HTML e podiam cair
       atrás da foto. Em ecrãs estreitos elas sobrepõem a imagem, por isso
       precisam de fundo próprio para se lerem sobre fotos claras. */
    z-index: 2;
    background: rgba(0,0,0,.45);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 50%;
    color: white;
    font-size: 18px;
    display: grid; place-items: center;
    transition: background .25s, border-color .25s, transform .35s var(--ease);
  }
  .lb-prev:hover, .lb-next:hover { background: rgba(0,0,0,.7); border-color: white; }
  .lb-prev { left: 20px; }
  .lb-next { right: 20px; }
  .lb-prev:hover { transform: translateY(-50%) translateX(-4px); }
  .lb-next:hover { transform: translateY(-50%) translateX(4px); }
