/* ==========================================================================
   ICO Taxi Balchik - Gallery
   Modern, neutral, mobile-first. No external dependencies.
   ========================================================================== */

/* --- Reset & tokens ------------------------------------------------------ */
*,*::before,*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; tab-size: 4; }
body, h1, h2, p, figure, blockquote { margin: 0; }
img, picture, video { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; background: none; border: 0; color: inherit; padding: 0; }
a { color: inherit; }

:root {
  --bg: #fafaf9;
  --bg-elev: #ffffff;
  --fg: #18181b;
  --fg-muted: #52525b;
  --fg-soft: #71717a;
  --border: #e4e4e7;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --overlay: rgba(15, 17, 21, 0.94);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.16);
  --radius: 10px;
  --radius-lg: 14px;
  --space: 1rem;
  --maxw: 1280px;
  --header-h: 64px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --transition: 200ms cubic-bezier(.2,.7,.3,1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --bg-elev: #18181b;
    --fg: #f4f4f5;
    --fg-muted: #a1a1aa;
    --fg-soft: #71717a;
    --border: #27272a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,.4);
    --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
  }
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: .6rem 1rem;
  border-radius: 0 0 var(--radius) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* --- Header / nav -------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in oklab, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--fg);
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: 0;
}
.brand em { font-style: normal; color: var(--fg-muted); font-weight: 500; }
.primary-nav {
  margin-left: auto;
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  font-size: .95rem;
}
.primary-nav a {
  text-decoration: none;
  color: var(--fg-muted);
  padding: .4rem 0;
  position: relative;
  transition: color var(--transition);
}
.primary-nav a:hover { color: var(--fg); }
.primary-nav a[aria-current="page"] { color: var(--fg); }
.primary-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
@media (max-width: 640px) {
  .primary-nav { display: none; }
}

/* --- Hero ---------------------------------------------------------------- */
.hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4rem) max(1.25rem, env(safe-area-inset-left))
                 max(1.25rem, env(safe-area-inset-right));
  text-align: center;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .75rem;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: .75rem;
}
.hero h1 {
  font-size: clamp(1.85rem, 4.5vw, 3rem);
  letter-spacing: -.02em;
  line-height: 1.1;
  font-weight: 800;
  margin-bottom: 1rem;
}
.lede {
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  color: var(--fg-muted);
  max-width: 60ch;
  margin: 0 auto;
}
.meta {
  margin-top: 1.25rem;
  color: var(--fg-soft);
  font-size: .85rem;
}

/* --- Sections ------------------------------------------------------------ */
main { flex: 1; }
.gallery-section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem max(1.25rem, env(safe-area-inset-left))
                max(1.25rem, env(safe-area-inset-right));
}
.section-title {
  font-size: clamp(1.25rem, 2.5vw, 1.6rem);
  letter-spacing: -.01em;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

/* --- Gallery grid -------------------------------------------------------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  grid-auto-flow: dense;
  gap: 1rem;
}
@media (min-width: 768px) {
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
}
.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
  margin: 0;
  transition: transform var(--transition), box-shadow var(--transition);
  will-change: transform;
}
.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
/* Когато landscape -> заема 2 колони за по-добра композиция */
@media (min-width: 768px) {
  .gallery-item { --span: 1; }
  .gallery-item:has(.glink img[style*="aspect-ratio: 1.5"]) { grid-column: span 2; }
  .gallery-item:has(.glink img[style*="aspect-ratio: 1.6"]) { grid-column: span 2; }
  .gallery-item:has(.glink img[style*="aspect-ratio: 1.7"]) { grid-column: span 2; }
}
.glink {
  display: block;
  position: relative;
  text-decoration: none;
  color: inherit;
  outline-offset: 2px;
}
.glink img {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, #e4e4e7, #f4f4f5);
  transition: transform 500ms cubic-bezier(.2,.7,.3,1);
  will-change: transform;
}
.glink:hover img { transform: scale(1.04); }
.gallery-item figcaption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1rem 1rem .9rem;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.7) 70%);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--transition), transform var(--transition);
  pointer-events: none;
}
.gallery-item:hover figcaption,
.gallery-item:focus-within figcaption { opacity: 1; transform: translateY(0); }
.g-title {
  font-weight: 600;
  font-size: .95rem;
  line-height: 1.25;
  letter-spacing: -.01em;
}
.g-loc {
  font-size: .8rem;
  color: rgba(255,255,255,.85);
}

/* focus state */
.glink:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius);
}

/* --- Credits ------------------------------------------------------------- */
.credits {
  max-width: var(--maxw);
  margin: 2rem auto 4rem;
  padding: 1.5rem max(1.25rem, env(safe-area-inset-left))
                max(1.25rem, env(safe-area-inset-right));
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: .9rem;
}
.credits h2 { font-size: 1.1rem; margin-bottom: .5rem; color: var(--fg); }
.credits a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* --- Footer -------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem max(1.25rem, env(safe-area-inset-left))
                 max(1.5rem, env(safe-area-inset-bottom))
                 max(1.25rem, env(safe-area-inset-right));
  text-align: center;
  color: var(--fg-soft);
  font-size: .85rem;
}
.site-footer p { margin: .25rem 0; }
.site-footer a { color: var(--fg-muted); text-decoration: none; }
.site-footer a:hover { color: var(--fg); text-decoration: underline; }

/* --- Lightbox ------------------------------------------------------------ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--overlay);
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 2rem);
  opacity: 0;
  transition: opacity 200ms;
}
.lightbox[data-open="1"] { display: flex; opacity: 1; }

.lb-figure {
  position: relative;
  max-width: min(1600px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: 0;
}
.lb-img-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: calc(100vh - 220px);
  min-height: 0;
}
.lb-figure img {
  max-width: 100%;
  max-height: calc(100vh - 220px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.lb-cap {
  color: #f4f4f5;
  max-width: 60rem;
  text-align: center;
  padding: 0 .5rem;
}
.lb-cap h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-bottom: .15rem;
}
.lb-cap p { font-size: .9rem; color: #d4d4d8; margin: .1rem 0; }
#lb-loc { color: #a1a1aa; font-size: .85rem; }
.lb-cred { margin-top: .35rem !important; font-size: .8rem !important; }
.lb-cred a { color: #93c5fd; text-decoration: underline; }

.lb-close, .lb-prev, .lb-next {
  position: absolute;
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  transition: background var(--transition), transform var(--transition);
  z-index: 5;
}
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,.18); }
.lb-close:focus-visible, .lb-prev:focus-visible, .lb-next:focus-visible {
  outline: 2px solid #93c5fd; outline-offset: 2px;
}
.lb-close { top: 1rem; right: 1rem; }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.lb-prev:hover { transform: translateY(-50%) scale(1.05); }
.lb-next:hover { transform: translateY(-50%) scale(1.05); }

.lb-counter {
  position: absolute;
  top: 1rem; left: 1rem;
  color: #d4d4d8;
  font-size: .85rem;
  background: rgba(0,0,0,.4);
  padding: .3rem .6rem;
  border-radius: 999px;
}

body.lb-open { overflow: hidden; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .gallery-item:hover { transform: none; }
  .glink:hover img { transform: none; }
}

/* Print */
@media print {
  .site-header, .site-footer, .lightbox, .gallery-item figcaption { display: none !important; }
  .gallery-grid { display: block; }
  .gallery-item { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}
