/* Enes Photography — mobile-first polish (Android / iOS) */

:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  -webkit-tap-highlight-color: transparent;
}

a, button, summary, .bento__trigger {
  touch-action: manipulation;
}

/* Sticky header clears Dynamic Island / status bar */
.site-chrome {
  padding-top: var(--safe-t);
}

.site-header {
  padding-top: 0;
  height: var(--header-h);
}

.scroll-progress {
  top: var(--safe-t);
}

/* Touch: captions always readable (no hover) */
@media (hover: none) {
  .bento__overlay {
    opacity: 1;
    transform: none;
    background: linear-gradient(transparent 35%, rgba(0, 0, 0, 0.72));
  }

  .bento__caption {
    font-size: 0.88rem;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .bento__tags,
  .bento__meta {
    display: none;
  }

  /* cam-badge sits at bottom — clashes with always-on caption */
  .bento__cam-badge {
    display: none;
  }
}

@media (max-width: 899px) {
  :root {
    --shell: min(72rem, calc(100% - 1.5rem));
    --shell-wide: min(90rem, calc(100% - 1rem));
  }

  /* Compact curated gallery: search desktop-only; tags via Filtre toggle */
  .gallery-tools .search-box,
  .search-box--desktop {
    display: none !important;
  }

  .gallery-filter-toggle {
    display: inline-flex !important;
  }

  .tag-row.is-collapsed-mobile:not(.is-open) {
    display: none !important;
  }

  .tag-row.is-open,
  .tag-row.is-collapsed-mobile.is-open {
    display: flex !important;
  }

  .gallery-tools {
    position: static;
    border-radius: 0.85rem;
    padding: 0.4rem 0.55rem;
    justify-content: space-between;
  }

  .nav-toggle,
  .theme-toggle {
    width: 2.75rem;
    height: 2.75rem;
  }

  .btn--sm {
    min-height: 2.75rem;
    padding: 0.55rem 0.95rem;
  }

  .site-nav__list a {
    min-height: 2.75rem;
    padding: 0.7rem 0.9rem;
  }

  .site-nav__list {
    right: max(0.75rem, var(--safe-r));
    max-height: calc(100dvh - var(--chrome-h) - var(--safe-t) - 1.5rem);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Gallery: denser browse — ALL tiles 2-col (no landscape full-bleed) */
  .bento {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .bento__item,
  .bento__item--tall,
  .bento__item--wide,
  .bento__item--hero,
  .bento__item--landscape {
    grid-column: span 1;
    min-height: 0;
    aspect-ratio: 4 / 5;
  }

  /* Only first hero spans full width once */
  .bento__item--hero:first-child {
    grid-column: 1 / -1;
    aspect-ratio: 3 / 2;
  }

  .gallery-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
  }

  .gallery-head .section-kicker {
    margin-bottom: 0.15rem;
  }

  .gallery-head h2 {
    font-size: clamp(1.65rem, 7vw, 2.1rem);
    margin: 0;
  }

  .gallery-head .section-lead {
    font-size: 0.92rem;
    margin: 0.15rem 0 0;
  }

  .gallery-head__actions {
    width: 100%;
  }

  .gallery-head__actions .btn {
    flex: 1;
    justify-content: center;
    min-height: 2.5rem;
    font-size: 0.82rem;
  }

  .gallery-stats {
    gap: 0.35rem;
  }

  .gallery-stat {
    font-size: 0.68rem;
  }

  /* Tags: single-row horizontal scroll — less chrome, more photos */
  .tag-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.35rem;
    margin-bottom: 0.85rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tag-row::-webkit-scrollbar {
    display: none;
  }

  .tag-btn {
    flex: 0 0 auto;
    min-height: 2.5rem;
    white-space: nowrap;
  }

  .gallery-tools {
    margin-bottom: 0.65rem;
  }

  .media-card__actions .btn {
    min-height: 2.75rem;
  }

  .about,
  .gear,
  .closing-block,
  .gallery,
  .media-hub {
    padding: 2.75rem 0;
    content-visibility: auto;
    contain-intrinsic-size: 1px 720px;
  }

  .film-drawer__panel {
    width: 100%;
    border-left: 0;
    border-radius: 1rem 1rem 0 0;
    top: auto;
    max-height: min(88dvh, 40rem);
    padding-top: 0.35rem;
  }
  .film-drawer__swipe { display: flex; }
  .film-drawer__layout {
    grid-template-columns: 7.5rem minmax(0, 1fr);
    gap: 0.85rem;
  }
  .film-drawer__title { font-size: 1.15rem; }

  .quick-links__chip {
    min-height: 2.5rem;
    padding: 0.4rem 0.95rem;
    font-size: 0.88rem;
  }
}

@media (max-width: 639px) {
  :root {
    --header-h: 3.5rem;
    --ql-h: 2.9rem;
    --shell: min(72rem, calc(100% - 1.25rem));
    --shell-wide: min(90rem, calc(100% - 0.85rem));
  }

  .brand__meta {
    max-width: 9.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hero--field {
    min-height: 100dvh;
    min-height: 100svh;
  }

  .hero__content {
    padding: calc(var(--chrome-h) + var(--safe-t) + 1.75rem) 0 calc(1.75rem + var(--safe-b));
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: inherit;
  }

  .hero__brand {
    font-size: 0.95rem;
  }

  .hero__title {
    font-size: clamp(2.4rem, 14vw, 3.35rem);
    margin-bottom: 0.55rem;
  }

  .hero__lead {
    font-size: 1rem;
    margin-bottom: 1.1rem;
  }

  /* Primary + one secondary: stacked full-width tap targets */
  .hero__actions {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-bottom: 0.85rem;
  }

  .hero__actions .btn {
    width: 100%;
    min-height: 3rem;
  }

  .hero__actions .btn--primary {
    grid-column: auto;
  }

  .hero__meta {
    font-size: 0.72rem;
    padding-bottom: 0.15rem;
  }

  .gallery-stats,
  .gallery-head__actions #slideshowToggle {
    display: none;
  }

  .gallery-head__actions .btn {
    flex: 1;
  }

  .bento__item,
  .bento__item--tall,
  .bento__item--wide,
  .bento__item--landscape {
    aspect-ratio: 4 / 5;
  }

  .bento__item--hero:first-child {
    aspect-ratio: 16 / 10;
  }

  .bento__overlay {
    padding: 0.55rem 0.65rem;
  }

  .bento__caption {
    font-size: 0.8rem;
  }

  .bento__recipe,
  .bento__raw-badge,
  .bento__cam-badge {
    font-size: 0.62rem;
    padding: 0.2rem 0.4rem;
  }

  /* ——— Full-bleed lightbox: maximize photo, minimize chrome ——— */
  .lightbox__close {
    top: calc(0.55rem + var(--safe-t));
    right: max(0.55rem, var(--safe-r));
    min-width: 2.65rem;
    min-height: 2.65rem;
  }

  .lightbox__toolbar {
    top: calc(0.55rem + var(--safe-t));
    left: max(0.55rem, var(--safe-l));
    gap: 0.3rem;
  }

  .lightbox__tool {
    min-height: 2.5rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.72rem;
  }

  /* Swipe primary — hide chevrons */
  .lightbox__nav {
    display: none;
  }

  .lightbox__counter {
    top: calc(0.85rem + var(--safe-t));
    right: calc(3.4rem + var(--safe-r));
    font-size: 0.72rem;
  }

  .lightbox__meta {
    max-height: none;
    padding: 2rem max(0.85rem, var(--safe-l)) calc(3.6rem + var(--safe-b)) max(0.85rem, var(--safe-r));
    background:
      linear-gradient(
        transparent 0%,
        rgba(0, 0, 0, 0.4) 30%,
        rgba(0, 0, 0, 0.82) 68%,
        rgba(0, 0, 0, 0.94) 100%
      );
    -webkit-overflow-scrolling: touch;
  }

  .lightbox.is-cover .lightbox__meta {
    background:
      linear-gradient(
        transparent 0%,
        rgba(0, 0, 0, 0.5) 26%,
        rgba(0, 0, 0, 0.86) 64%,
        rgba(0, 0, 0, 0.96) 100%
      );
  }

  .lightbox__meta > figcaption {
    font-size: 0.92rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7), 0 6px 18px rgba(0, 0, 0, 0.5);
  }

  .lightbox__strip {
    bottom: calc(0.35rem + var(--safe-b));
    max-width: calc(100vw - 1.25rem);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.3rem;
    gap: 0.28rem;
    background: rgba(0, 0, 0, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.16);
  }

  .lightbox.is-cover .lightbox__strip {
    background: rgba(0, 0, 0, 0.78);
  }

  .lightbox__strip-btn {
    width: 2.15rem;
    height: 2.15rem;
    opacity: 0.78;
  }

  .lightbox__hint {
    display: block;
    top: calc(3.85rem + var(--safe-t));
    font-size: 0.64rem;
    max-width: calc(100vw - 2rem);
    text-align: center;
  }

  .lightbox:not(.is-hint-visible) .lightbox__hint {
    display: none !important;
  }

  .lightbox__frame > img {
    max-width: 100vw;
    max-height: 100dvh;
  }

  .lightbox.is-landscape .lightbox__frame > img {
    width: 100vw;
    max-height: 100dvh;
  }

  .lightbox.is-portrait .lightbox__frame > img {
    height: 100dvh;
    max-width: 100vw;
  }

  .about__chips {
    display: none;
  }

  .about__process {
    gap: 0.4rem;
  }

  .gear-grid {
    grid-template-columns: 1fr;
  }

  .media-poster-strip__item {
    width: 4.1rem;
    height: 6.15rem;
  }

  .back-top {
    width: 3rem;
    height: 3rem;
  }

  .hero__scroll {
    margin-top: 1.1rem;
  }
}

/* Very narrow phones — keep 2-col mosaic */
@media (max-width: 379px) {
  .bento {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .bento__item,
  .bento__item--wide,
  .bento__item--tall,
  .bento__item--hero,
  .bento__item--landscape {
    grid-column: span 1;
    aspect-ratio: 3 / 4;
  }

  .bento__item--hero:first-child {
    grid-column: 1 / -1;
    aspect-ratio: 3 / 2;
  }
}
