/* ==========================================================================
   AF Referentsid – frontend  v1.2.0
   Overlay-stiilis galeriigrid Alfalendi kaubamärgis.
   Pildid katavad terve kasti; tekst on paigutatud gradientil kaardi allossa.
   ========================================================================== */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
.af-ref-wrapper {
	--af-ink:         #3D1A00;
	--af-green:       #7DC242;
	--af-green-d:     #4C7A1F;
	--af-muted:       #8A7F73;
	--af-border:      #DDD6CC;
	--af-card-bg:     #EDE7DF;
}

/* ── Filter bar ──────────────────────────────────────────────────────────── */
.af-ref-filter {
	display:     flex;
	flex-wrap:   wrap;
	gap:         8px;
	margin:      0 0 26px;
}

.af-ref-filter__btn {
	display:         inline-flex;
	align-items:     center;
	padding:         8px 20px;
	border-radius:   999px;
	border:          1.5px solid var(--af-border);
	background:      transparent;
	color:           var(--af-muted);
	font-family:     "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
	font-size:       0.875rem;
	font-weight:     500;
	cursor:          pointer;
	transition:      background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
	white-space:     nowrap;
	letter-spacing:  0.01em;
}

.af-ref-filter__btn:hover {
	border-color: var(--af-ink);
	color:        var(--af-ink);
	background:   rgba(61, 26, 0, 0.05);
}

.af-ref-filter__btn.is-active {
	background:   var(--af-green);
	border-color: var(--af-green);
	color:        #fff;
}

.af-ref-filter__btn:focus-visible {
	outline:        3px solid var(--af-green);
	outline-offset: 2px;
}

/* ── Grid ────────────────────────────────────────────────────────────────── */
.af-references {
	display: grid;
	gap:     16px;
}

.af-references--cols-1 { grid-template-columns: 1fr; }
.af-references--cols-2 { grid-template-columns: repeat(2, 1fr); }
.af-references--cols-3 { grid-template-columns: repeat(3, 1fr); }
.af-references--cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 960px) {
	.af-references--cols-3,
	.af-references--cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
	.af-references            { grid-template-columns: 1fr !important; gap: 14px; }
	.af-ref-filter            { gap: 6px; }
	.af-ref-filter__btn       { font-size: 0.8rem; padding: 6px 14px; }
}

/* ── Card shell ──────────────────────────────────────────────────────────── */
/* aspect-ratio keeps images perfectly proportional regardless of card width */

.af-ref-card {
	position:      relative;
	border-radius: 12px;
	overflow:      hidden;
	aspect-ratio:  4 / 3;
	background:    var(--af-card-bg);
	cursor:        pointer;
	/* transition on opacity is used by the JS filter fade */
	transition:    opacity 0.26s ease, box-shadow 0.3s ease;
}

.af-ref-card:hover {
	box-shadow: 0 10px 32px rgba(61, 26, 0, 0.22);
}

/* ── Card link – fills the entire card ──────────────────────────────────── */

.af-ref-card__link {
	position:        absolute;
	inset:           0;
	display:         block;
	text-decoration: none;
}

/* ── Image ───────────────────────────────────────────────────────────────── */

.af-ref-card__link > img {
	display:     block;
	width:       100%;
	height:      100%;
	object-fit:  cover;
	transition:  transform 0.6s ease;
}

.af-ref-card:hover .af-ref-card__link > img {
	transform: scale(1.07);
}

/* ── Gradient overlay (bottom 60 %) ─────────────────────────────────────── */
/* Separate div so it never interferes with the link's own ::after */

.af-ref-card__gradient {
	position:        absolute;
	inset:           0;
	background:
		linear-gradient(
			to bottom,
			rgba(0, 0, 0, 0)   30%,
			rgba(8, 3, 0, 0.68) 68%,
			rgba(8, 3, 0, 0.92) 100%
		);
	pointer-events:  none;
}

/* ── Overlay: badges + centred zoom icon ────────────────────────────────── */

.af-ref-card__overlay {
	position:        absolute;
	inset:           0;
	display:         flex;
	align-items:     center;
	justify-content: center;
	pointer-events:  none;
}

/* Corner badges */
.af-ref-card__badge {
	position:      absolute;
	border-radius: 999px;
	font-family:   "Inter", sans-serif;
	font-size:     0.73rem;
	font-weight:   600;
	letter-spacing: 0.03em;
	line-height:   1;
	padding:       5px 11px;
}

.af-ref-card__badge--count {
	top:               10px;
	left:              10px;
	background:        rgba(12, 5, 0, 0.55);
	backdrop-filter:   blur(6px);
	-webkit-backdrop-filter: blur(6px);
	color:             rgba(255, 255, 255, 0.92);
}

.af-ref-card__badge--year {
	top:        10px;
	right:      10px;
	background: var(--af-green);
	color:      #fff;
}

/* Centred zoom circle */
.af-ref-card__zoom {
	display:         flex;
	align-items:     center;
	justify-content: center;
	width:           52px;
	height:          52px;
	border-radius:   50%;
	background:      rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	color:           #fff;
	opacity:         0;
	transform:       scale(0.8);
	transition:      opacity 0.3s ease, transform 0.3s ease;
}

.af-ref-card:hover .af-ref-card__zoom {
	opacity:   1;
	transform: scale(1);
}

/* ── Footer: title + client at the card bottom ──────────────────────────── */

.af-ref-card__footer {
	position:        absolute;
	bottom:          0;
	left:            0;
	right:           0;
	padding:         14px 16px 15px;
	pointer-events:  none;
}

.af-ref-card__title {
	font-family:  "Poppins", "Inter", sans-serif;
	font-weight:  600;
	font-size:    0.95rem;
	line-height:  1.3;
	color:        #fff;
	margin:       0 0 3px;
	text-shadow:  0 1px 5px rgba(0, 0, 0, 0.3);
}

.af-ref-card__client {
	font-family: "Inter", sans-serif;
	font-size:   0.79rem;
	color:       rgba(255, 255, 255, 0.65);
	margin:      0;
}

/* ── Placeholder (no image) ──────────────────────────────────────────────── */

.af-ref-card__placeholder {
	position: absolute;
	inset:    0;
	background-image:
		repeating-linear-gradient(45deg, rgba(61,26,0,.05) 0 2px, transparent 2px 11px),
		repeating-linear-gradient(-45deg, rgba(61,26,0,.05) 0 2px, transparent 2px 11px);
}

/* ── Scroll reveal (only when no filter is present; JS adds these) ───────── */

.af-ref-card--pre-reveal {
	opacity:   0;
	transform: translateY(16px);
	transition: opacity 0.6s ease, transform 0.6s ease;
}

.af-ref-card--pre-reveal.is-visible {
	opacity:   1;
	transform: none;
}

@media (prefers-reduced-motion: reduce) {
	.af-ref-card--pre-reveal {
		opacity:   1;
		transform: none;
		transition: none;
	}
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.af-ref-empty {
	color:       var(--af-muted);
	font-style:  italic;
	font-family: "Inter", sans-serif;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Lightbox
   ═══════════════════════════════════════════════════════════════════════════ */

body.af-lightbox-open {
	overflow: hidden;
}

.af-ref-lightbox {
	position:    fixed;
	inset:       0;
	z-index:     99999;
	display:     flex;
	align-items: center;
	justify-content: center;
	background:  rgba(10, 4, 0, 0.94);
	padding:     24px;
	opacity:     0;
	visibility:  hidden;
	transition:  opacity 0.25s ease, visibility 0.25s ease;
}

.af-ref-lightbox.is-open {
	opacity:    1;
	visibility: visible;
}

.af-ref-lightbox__inner {
	display:     flex;
	flex-direction: column;
	align-items: center;
	max-width:   920px;
	width:       100%;
}

.af-ref-lightbox__inner > img {
	max-width:     100%;
	max-height:    calc(100vh - 160px);
	border-radius: 8px;
	object-fit:    contain;
	display:       block;
}

/* Caption below image */
.af-ref-lightbox__caption {
	padding:    14px 4px 0;
	text-align: center;
}

.af-ref-lightbox__caption-title {
	font-family: "Poppins", sans-serif;
	font-weight: 600;
	font-size:   1rem;
	color:       #fff;
	margin:      0 0 4px;
}

.af-ref-lightbox__caption-meta {
	font-family: "Inter", sans-serif;
	font-size:   0.83rem;
	color:       rgba(255, 255, 255, 0.5);
	margin:      0;
}

/* Shared button base */
.af-ref-lightbox__close,
.af-ref-lightbox__nav {
	position:    absolute;
	border:      0;
	border-radius: 50%;
	background:  rgba(255, 255, 255, 0.1);
	color:       #fff;
	cursor:      pointer;
	transition:  background 0.2s ease;
	line-height: 1;
}

.af-ref-lightbox__close:hover,
.af-ref-lightbox__nav:hover,
.af-ref-lightbox__close:focus-visible,
.af-ref-lightbox__nav:focus-visible {
	background: var(--af-green);
}

.af-ref-lightbox__close {
	top:      18px;
	right:    22px;
	width:    42px;
	height:   42px;
	font-size: 26px;
}

.af-ref-lightbox__nav {
	top:       50%;
	transform: translateY(-50%);
	width:     50px;
	height:    50px;
	font-size: 28px;
}

.af-ref-lightbox__nav--prev { left:  22px; }
.af-ref-lightbox__nav--next { right: 22px; }

@media (max-width: 600px) {
	.af-ref-lightbox__nav { width: 40px; height: 40px; font-size: 22px; }
	.af-ref-lightbox__nav--prev { left: 8px; }
	.af-ref-lightbox__nav--next { right: 8px; }
	.af-ref-lightbox__close { top: 10px; right: 12px; width: 36px; height: 36px; font-size: 20px; }
}
