// Questo file fa parte di MyTown.
// MyTown è software libero: puoi ridistribuirlo e/o modificarlo secondo
// i termini della GNU Affero General Public License come pubblicata dalla
// Free Software Foundation, versione 3.
// Distribuito senza ALCUNA GARANZIA; vedi la GNU AGPL v3 per i dettagli.
// Copyright (C) Kondor Consulting & Services S.r.l.
// SPDX-License-Identifier: AGPL-3.0-or-later

// ═══════════════════════════════════════════════════════════════
//  BACHECA — "Agenda" editoriale (eventi + luoghi, MyTown).
//  Cover card poster: immagine → scrim → date-stamp + azioni glass →
//  organizzatore/titolo sullo scrim → corpo bianco con CTA brand.
//  Search-zone brand + tab pill = shell condivisa con home.page.
//  Tutto su token --app-brand / --ion-color-* → adatta edil/cna.
// ═══════════════════════════════════════════════════════════════
@use '../../../theme/card-rise';
@use '../../../theme/detail-modal';

// ─── SEARCH ZONE (brand) ──────────────────────────────────────
.search-zone {
	background: var(--app-brand);
	padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px 12px;
}

.search-row {
	display: flex;
	align-items: center;
	gap: 6px;
}

.search-input {
	flex: 1;
	--background: rgba(255, 255, 255, 0.16);
	--color: var(--app-on-brand);
	--placeholder-color: rgba(var(--app-on-brand-rgb), 0.6);
	--icon-color: rgba(var(--app-on-brand-rgb), 0.6);
	--clear-button-color: rgba(var(--app-on-brand-rgb), 0.7);
	--border-radius: 12px;
	--box-shadow: none;
	--padding-top: 0;
	--padding-bottom: 0;
	padding-top: 0;
	padding-bottom: 0;
}

.filter-btn {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.16);
	color: var(--app-on-brand);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 0.18s;

	&:active {
		background: rgba(255, 255, 255, 0.3);
	}

	ion-icon {
		font-size: 19px;
	}
}

// ─── SEGMENT (pill tabs sul brand) ────────────────────────────
.seg-tabs {
	margin-top: 12px;
	--background: rgba(255, 255, 255, 0.16);
	border-radius: 14px;
	padding: 4px;
	min-height: 44px;

	ion-segment-button {
		--background: transparent;
		--background-checked: transparent;
		--background-hover: transparent;
		--background-focused: transparent;
		--color: rgba(var(--app-on-brand-rgb), 0.75);
		--color-checked: var(--app-brand);
		--indicator-color: #fff;
		--indicator-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
		--border-radius: 10px;
		--padding-top: 0;
		--padding-bottom: 0;
		min-height: 36px;
		font-size: 13.5px;
		font-weight: 600;
		letter-spacing: 0.1px;
		text-transform: none;

		ion-icon {
			font-size: 16px;
			margin-right: 5px;
		}
	}
}

// ─── BOARD (contenitore feed) ─────────────────────────────────
ion-segment-content {
	--background: var(--ion-color-light);
	background: var(--ion-color-light);
}

.board {
	padding: 16px 14px 132px;
	display: flex;
	flex-direction: column;
	gap: 18px;
}

#places-top {
	height: 0;
	margin: 0;
}

.board-eyebrow {
	padding: 2px 4px 0;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--ion-color-medium);
}

// ─── EV-CARD (cover poster + corpo) ───────────────────────────
.ev-card {
	background: #fff;
	border-radius: 24px;
	overflow: hidden;
	border: 1px solid rgba(0, 0, 0, 0.05);
	box-shadow: 0 12px 30px -16px rgba(17, 24, 39, 0.4);
	animation: card-rise 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;

	&:nth-child(2) { animation-delay: 0.04s; }
	&:nth-child(3) { animation-delay: 0.08s; }
	&:nth-child(4) { animation-delay: 0.12s; }
	&:nth-child(5) { animation-delay: 0.16s; }
	&:nth-child(6) { animation-delay: 0.2s; }
}

// ─── COVER ────────────────────────────────────────────────────
.cover {
	position: relative;
	width: 100%;
	aspect-ratio: 4 / 5;
	overflow: hidden;
	background: var(--ion-color-light);

	&.cover-place {
		aspect-ratio: 1 / 1;
	}

	// variante senza immagine: header compatto, contenuto in flusso
	// (niente aspect-ratio 4/5 → via lo spazio vuoto).
	&.is-empty {
		aspect-ratio: auto;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		padding: 16px;
		background: linear-gradient(150deg, rgba(var(--app-brand-rgb), 0.2) 0%, rgba(var(--app-brand-rgb), 0.05) 100%);

		.cover-scrim {
			display: none;
		}
		.cover-watermark {
			font-size: 84px;
			right: -8px;
			bottom: -12px;
			opacity: 0.1;
		}
		.cover-tl {
			position: static;
			max-width: calc(100% - 76px);
		}
		.datestamp {
			margin: 0;
		}
		.cover-actions {
			top: 14px;
			right: 14px;
		}
		.cover-head {
			position: static;
			left: auto;
			right: auto;
			bottom: auto;
			margin-top: 14px;
		}
		.cover-eyebrow {
			color: var(--app-brand-2);
			opacity: 0.7;
		}
		.cover-title {
			color: var(--ion-color-dark);
			text-shadow: none;
		}
		.ca-btn {
			background: rgba(0, 0, 0, 0.05);
			border-color: rgba(0, 0, 0, 0.08);
			color: var(--ion-color-dark);
		}
	}
}

.cover-media {
	position: absolute;
	inset: 0;
	z-index: 1;
	width: 100%;
	height: 100%;
	--swiper-navigation-color: #fff;
	--swiper-pagination-color: #fff;
	--swiper-navigation-size: 20px;

	swiper-slide {
		display: flex;
		align-items: center;
		justify-content: center;
		background: var(--ion-color-light);
	}

	img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
}

.cover-watermark {
	position: absolute;
	right: -14px;
	bottom: -22px;
	z-index: 1;
	font-size: 132px;
	line-height: 1;
	color: var(--app-brand);
	opacity: 0.16;
	transform: rotate(-8deg);
	pointer-events: none;
}

.cover-scrim {
	position: absolute;
	inset: 0;
	z-index: 2;
	background: linear-gradient(180deg, rgba(0, 0, 0, 0) 36%, rgba(0, 0, 0, 0.58) 100%);
	pointer-events: none;
}

// Date-stamp (firma visiva) — tile gelata leggibile su qualsiasi sfondo
// Contenitore alto-sx del cover: data evento + badge prenotazione impilati
.cover-tl {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 3;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	max-width: calc(100% - 92px);
}

.datestamp {
	min-width: 50px;
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 7px 10px 6px;
	border-radius: 14px;
	background: rgba(255, 255, 255, 0.94);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	border: 1px solid rgba(0, 0, 0, 0.06);
	box-shadow: 0 6px 18px -8px rgba(17, 24, 39, 0.5);
	line-height: 1;
}

.ds-day {
	font-size: 22px;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--ion-color-dark);
}

.ds-my {
	margin-top: 3px;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--app-brand-2);
}

.ds-range {
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 0.01em;
	text-transform: uppercase;
	white-space: nowrap;
	color: var(--ion-color-dark);
}

.datestamp-empty {
	padding: 10px;

	ion-icon {
		font-size: 20px;
		color: var(--app-brand-2);
	}
}

// stamp geo (luoghi): pill orizzontale città
.datestamp-geo {
	flex-direction: row;
	align-items: center;
	gap: 5px;
	min-width: 0;
	max-width: calc(100% - 24px);
	padding: 6px 11px;
	border-radius: 999px;

	ion-icon {
		font-size: 13px;
		color: var(--app-brand-2);
		flex-shrink: 0;
	}

	span {
		font-size: 12px;
		font-weight: 700;
		color: var(--ion-color-dark);
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
}

// Azioni glass (like / share)
.cover-actions {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 3;
	display: flex;
	gap: 7px;
}

.ca-btn {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: 1px solid rgba(255, 255, 255, 0.3);
	background: rgba(255, 255, 255, 0.22);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: transform 0.12s, opacity 0.12s;

	ion-icon {
		font-size: 17px;

		&.liked {
			color: var(--ion-color-danger);
			animation: like-pop 0.28s ease;
		}
	}

	&:active {
		transform: scale(0.86);
		opacity: 0.75;
	}
}

@keyframes like-pop {
	0% { transform: scale(0.6); }
	50% { transform: scale(1.25); }
	100% { transform: scale(1); }
}

// Organizzatore + titolo sopra lo scrim
.cover-head {
	position: absolute;
	left: 14px;
	right: 14px;
	bottom: 13px;
	z-index: 3;
}

.cover-eyebrow {
	display: block;
	margin-bottom: 3px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: rgba(255, 255, 255, 0.88);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.cover-title {
	margin: 0;
	font-size: 20px;
	font-weight: 800;
	line-height: 1.18;
	letter-spacing: -0.01em;
	color: #fff;
	text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
}

// ─── CORPO CARD ───────────────────────────────────────────────
.ev-body {
	padding: 14px 16px 16px;
}

.ev-desc {
	font-size: 13.5px;
	line-height: 1.55;
	color: var(--ion-color-medium);
	overflow-wrap: anywhere;
	word-break: break-word;

	&.is-clamped {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}

	::ng-deep p {
		margin: 0 0 6px;
	}
	::ng-deep p:last-child {
		margin-bottom: 0;
	}
}

.read-toggle {
	display: inline-block;
	margin-top: 5px;
	font-size: 12.5px;
	font-weight: 700;
	letter-spacing: 0.02em;
	color: var(--app-brand-2);
	cursor: pointer;

	&:active {
		opacity: 0.6;
	}
}

// Footer: Prenota (CTA piena) sopra, badge/like sotto
.ev-foot {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-top: 13px;
}

.badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 5px 11px;
	border-radius: 999px;
	font-size: 11.5px;
	font-weight: 700;
	line-height: 1.2;

	ion-icon {
		font-size: 13px;
	}

	&.badge-booking {
		background: rgba(var(--app-brand-rgb), 0.14);
		color: var(--app-brand-2);
	}

	// Variante su immagine/cover: chip gelato bianco, sempre leggibile
	&.badge-cover {
		background: rgba(255, 255, 255, 0.94);
		-webkit-backdrop-filter: blur(8px);
		backdrop-filter: blur(8px);
		border: 1px solid rgba(0, 0, 0, 0.06);
		box-shadow: 0 6px 18px -8px rgba(17, 24, 39, 0.5);
		color: var(--app-brand-2);
	}
}

.ev-likes {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 12.5px;
	font-weight: 700;
	color: var(--ion-color-medium);

	ion-icon {
		font-size: 13px;
		color: var(--ion-color-danger);
	}
}

.ev-reserve {
	margin: 0;
	height: 40px;
	font-weight: 700;
	font-size: 13.5px;
	--border-radius: 999px;
	--background: var(--app-brand);
	--color: var(--app-on-brand);
	--background-activated: var(--app-brand-3);
	--color-activated: var(--app-on-brand);
	--background-hover: var(--app-brand-3);
	--color-hover: var(--app-on-brand);
	--box-shadow: 0 6px 16px -8px rgba(var(--app-brand-rgb), 0.7);
}

// Link social
.link-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	margin-top: 13px;
}

.link-chip {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--ion-color-light);
	border: 1px solid rgba(0, 0, 0, 0.05);
	color: var(--ion-color-medium);

	ion-icon {
		font-size: 15px;
	}

	&:active {
		background: rgba(var(--app-brand-rgb), 0.12);
		color: var(--app-brand-2);
	}
}

.ev-published {
	margin-top: 13px;
	font-size: 10.5px;
	font-weight: 500;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--ion-color-medium);
	opacity: 0.7;
}

// Indirizzo (luoghi)
.ev-address {
	display: flex;
	align-items: flex-start;
	gap: 6px;
	margin-top: 13px;
	font-size: 13px;
	line-height: 1.45;
	color: var(--ion-color-medium);

	ion-icon {
		font-size: 15px;
		flex-shrink: 0;
		margin-top: 1px;
		color: var(--app-brand-2);
	}
}

// Audioguida — affordance "ascolta"
.audio-row {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	margin-top: 12px;
	padding: 9px 12px;
	border: none;
	border-radius: 14px;
	background: rgba(var(--app-brand-rgb), 0.1);
	color: var(--app-brand-2);
	text-align: left;
	cursor: pointer;
	transition: background 0.15s;

	&:active {
		background: rgba(var(--app-brand-rgb), 0.18);
	}

	.audio-ico {
		flex-shrink: 0;
		width: 30px;
		height: 30px;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		background: var(--app-brand);
		color: var(--app-on-brand);

		ion-icon {
			font-size: 16px;
		}
	}

	.audio-label {
		flex: 1;
		font-size: 13.5px;
		font-weight: 700;
	}

	.audio-play {
		font-size: 14px;
		opacity: 0.55;
	}
}

// ─── MAPPA (tab luoghi) ───────────────────────────────────────
.map-wrap {
	position: relative;
	border-radius: 20px;
	overflow: hidden;
	border: 1px solid rgba(0, 0, 0, 0.06);
	box-shadow: 0 12px 28px -16px rgba(17, 24, 39, 0.32);

	google-map {
		display: block;
	}
}

.map-locate {
	position: absolute;
	right: 12px;
	bottom: 12px;
	z-index: 5;
	width: 44px;
	height: 44px;
	margin: 0;
	--border-radius: 50%;
	--box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.fab-map {
	position: fixed;
	right: 16px;
	bottom: 90px;
	z-index: 50;
	width: 50px;
	height: 50px;
	margin: 0;
	--border-radius: 50%;
	--background: var(--app-brand);
	--color: var(--app-on-brand);
	--box-shadow: 0 8px 22px -6px rgba(var(--app-brand-rgb), 0.6);
}

// ─── EMPTY STATE ──────────────────────────────────────────────
.board-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	padding: 60px 32px;
	color: var(--ion-color-medium);

	ion-icon {
		font-size: 54px;
		color: rgba(var(--app-brand-rgb), 0.45);
		margin-bottom: 14px;
	}

	.empty-title {
		margin: 0 0 4px;
		font-size: 16px;
		font-weight: 700;
		color: var(--ion-color-dark);
	}

	.empty-sub {
		margin: 0;
		max-width: 260px;
		font-size: 13.5px;
		line-height: 1.5;
	}
}

// ─── MODALI (filtri / audio) ──────────────────────────────────
// .modal-toolbar / .modal-content arrivano dal partial condiviso
// src/theme/_detail-modal.scss.
.filter-section {
	background: #fff;
	border-radius: 18px;
	margin: 16px;
	padding: 16px;
	border: 1px solid rgba(0, 0, 0, 0.05);
	box-shadow: 0 10px 26px -18px rgba(17, 24, 39, 0.3);
}

.filter-section-title {
	display: block;
	margin: 0 0 10px;
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.6px;
	color: var(--ion-color-medium);
}

.filter-select {
	--background: var(--ion-color-light);
	border-radius: 12px;
	--padding-start: 14px;
	--padding-end: 14px;
}

.modal-apply {
	margin: 0 16px;
	height: 48px;
	font-weight: 700;
	--border-radius: 14px;
	--background: var(--app-brand);
	--color: var(--app-on-brand);
	--background-activated: var(--app-brand-3);
	--color-activated: var(--app-on-brand);
}

.audio-shell {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 20px;
	padding: 44px 24px;

	.audio-disc {
		width: 92px;
		height: 92px;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		background: rgba(var(--app-brand-rgb), 0.12);
		border: 1px solid rgba(var(--app-brand-rgb), 0.2);

		ion-icon {
			font-size: 42px;
			color: var(--app-brand-2);
		}
	}

	audio {
		width: 100%;
	}
}

// ─── SKELETON (caricamento) ───────────────────────────────────
// Placeholder neutro (nero-alpha → leggibile su qualsiasi brand);
// uno sweep chiaro ::after fa lo shimmer. Vive dentro .ev-card.sk-card.
.sk-block {
	position: relative;
	overflow: hidden;
	background: rgba(0, 0, 0, 0.06);

	&::after {
		content: '';
		position: absolute;
		inset: 0;
		transform: translateX(-100%);
		background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
		animation: sk-shimmer 1.3s ease-in-out infinite;
	}
}

@keyframes sk-shimmer {
	to {
		transform: translateX(100%);
	}
}

.sk-cover {
	width: 100%;
	aspect-ratio: 4 / 5;

	&.sk-cover-place {
		aspect-ratio: 1 / 1;
	}
}

.sk-line {
	height: 13px;
	border-radius: 7px;
	margin-bottom: 9px;

	&.w-92 { width: 92%; }
	&.w-70 { width: 70%; }
}

.sk-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-top: 13px;
}

.sk-chip {
	width: 130px;
	height: 24px;
	border-radius: 999px;
}

.sk-cta {
	width: 96px;
	height: 34px;
	border-radius: 999px;
}

// ─── ACCESSIBILITÀ: rispetta prefers-reduced-motion ───────────
@media (prefers-reduced-motion: reduce) {
	.ev-card {
		animation: none;
	}
	.ca-btn:active {
		transform: none;
	}
	.ca-btn ion-icon.liked {
		animation: none;
	}
	.sk-block::after {
		animation: none;
	}
}

/* ═══ Sotto-luoghi: miniature nella card + popup ═══ */
.sub-thumbs {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 6px 0 4px;
}

.sub-thumb {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	width: 76px;
	padding: 0;
	border: none;
	background: transparent;
	cursor: pointer;
}

.sub-thumb img,
.sub-thumb .sub-thumb__noimg {
	width: 72px;
	height: 72px;
	border-radius: 12px;
	object-fit: cover;
	background: var(--ion-color-light, #f2f2f2);
	display: flex;
	align-items: center;
	justify-content: center;
}

.sub-thumb .sub-thumb__noimg ion-icon {
	font-size: 26px;
	opacity: 0.5;
}

.sub-thumb__name {
	font-size: 11px;
	line-height: 1.2;
	text-align: center;
	max-width: 76px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sub-media {
	display: block;
	width: 100%;
	height: 220px;
}

.sub-media img {
	width: 100%;
	height: 220px;
	object-fit: cover;
}

.sub-desc {
	padding: 12px 16px;
	font-size: 14px;
	line-height: 1.5;
}

// ═══ RECENSIONI LUOGO ═══
.place-reviews {
	padding: 4px 0 8px;
}

.place-reviews-summary {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 8px;
}

.place-reviews-count {
	font-size: 13px;
	color: var(--ion-color-medium, #64748b);
}

.place-reviews-empty {
	font-size: 13px;
	color: var(--ion-color-medium, #64748b);
	margin: 0 0 8px;
}

// Stelle: base in global.scss, qui solo l'override di dimensione
.review-stars ion-icon {
	font-size: 16px;
}

.place-review-item {
	padding: 8px 0;
	border-top: 1px solid var(--ion-color-step-100, #f1f5f9);
}

.place-review-author {
	margin-left: 8px;
	font-size: 12px;
	color: var(--ion-color-medium, #64748b);
}

.place-review-title {
	font-weight: 600;
	font-size: 14px;
	margin-top: 4px;
}

.place-review-text {
	font-size: 13px;
	line-height: 1.5;
	color: var(--ion-color-medium, #64748b);
	margin: 4px 0 0;
}
