/* =============================================
   BENDRAS LAPAS / MODALAS — .vsheet

   Mobiliame kyla nuo ekrano apačios (bottom sheet), nuo 720px — centre,
   560px pločio langas. Anatomija pagal Geografijos minimalizmo dizainą
   (docs/todo/2026-09-01-geografija-minimalizmas.md, „Sistema" drobė):

     antraštė 52px  — mono etiketė + 44px uždarymo mygtukas (× arba ‹)
     turinys        — slenkamas, 16px paraštė
     pėda 68px      — neprivaloma, tik su pirminiu veiksmu

   ĮTRAUKIMAS: <link> rašomas PO režimo/puslapio CSS failo — perrašoma
   kaskados tvarka, ne !important.
   ============================================= */

.vsheet {
	position: fixed;
	inset: 0;
	z-index: var(--z-modal, 1100);
	display: flex;
	align-items: flex-end;
	justify-content: center;
}

.vsheet[hidden] {
	/* display:flex perrašytų [hidden] — būtina aiški taisyklė. */
	display: none !important;
}

.vsheet__backdrop {
	position: absolute;
	inset: 0;
	background: var(--color-bg-overlay, rgba(0, 0, 0, 0.85));
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
	border: 0;
	padding: 0;
	cursor: pointer;
	animation: vsheetFadeIn var(--duration-base, 250ms) var(--ease-default, cubic-bezier(0, 0, 0.2, 1)) forwards;
}

.vsheet__panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-height: min(88vh, 100% - 2rem);
	background: var(--color-bg-secondary, #1a1a2e);
	border: 1px solid var(--color-border-default, #2c2c42);
	border-bottom: 0;
	border-radius: var(--radius-modal, 1rem) var(--radius-modal, 1rem) 0 0;
	box-shadow: 0 -8px 32px var(--color-shadow-lg, rgba(0, 0, 0, 0.3));
	animation: vsheetSlideUp var(--duration-base, 250ms) var(--ease-default, cubic-bezier(0, 0, 0.2, 1)) forwards;
	/* Tempiant žemyn JS nustato --vsheet-drag; be gesto jis nulinis. */
	transform: translateY(var(--vsheet-drag, 0px));
}

.vsheet--closing .vsheet__panel {
	animation: vsheetSlideDown var(--duration-fast, 150ms) var(--ease-in, cubic-bezier(0.4, 0, 1, 1)) forwards;
	animation-duration: 200ms;
}

.vsheet--closing .vsheet__backdrop {
	animation: vsheetFadeOut 200ms var(--ease-in, cubic-bezier(0.4, 0, 1, 1)) forwards;
}

/* Tempimo metu animacijos nėra — panelė seka pirštą. */
.vsheet--dragging .vsheet__panel {
	animation: none;
	transition: none;
}

/* =====================
   ANTRAŠTĖ — 52px
   ===================== */
.vsheet__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--spacing-sm, 0.5rem);
	flex-shrink: 0;
	height: 52px;
	padding-left: var(--spacing-md, 1rem);
	padding-right: var(--spacing-xs, 0.25rem);
	background: var(--color-bg-tertiary, #252538);
	border-bottom: 1px solid var(--color-border-default, #2c2c42);
	border-radius: var(--radius-modal, 1rem) var(--radius-modal, 1rem) 0 0;
	/* Gestas žemyn imamas nuo antraštės. */
	touch-action: none;
	cursor: grab;
}

.vsheet__title {
	font-family: var(--font-mono, 'JetBrains Mono', 'Consolas', monospace);
	font-size: 11px;
	font-weight: var(--font-weight-semibold, 600);
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--color-accent-gold, #e7ca93);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.vsheet__close {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 44px;
	height: 44px;
	padding: 0;
	background: none;
	border: 0;
	border-radius: var(--radius-full, 9999px);
	color: var(--color-text-secondary, #adadc9);
	font-size: var(--font-size-lg, 1.25rem);
	line-height: 1;
	cursor: pointer;
	transition: color var(--duration-fast, 150ms) var(--ease-default, ease-out),
	            background-color var(--duration-fast, 150ms) var(--ease-default, ease-out);
}

.vsheet__close:hover,
.vsheet__close:focus-visible {
	color: var(--color-text-primary, #f5f5fa);
	background: var(--color-bg-elevated, #2c2c42);
}

.vsheet__close:focus-visible {
	outline: 2px solid var(--color-interactive-focus, #e7ca93);
	outline-offset: -2px;
}

/* =====================
   TURINYS
   ===================== */
.vsheet__content {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: var(--spacing-md, 1rem);
	color: var(--color-text-secondary, #adadc9);
	line-height: var(--line-height-relaxed, 1.625);
}

/* Numatytasis tarpas tarp perkelto turinio blokų: reset.css nunulina <p>
   maržas, o be jų pastraipos lape susilieja į vieną sieną. Specifiškumas
   tyčia žemas (0,1,0) — puslapio sava taisyklė (pvz. .geo-place__text p)
   ją perrašo. */
.vsheet__content > * + * {
	margin-top: var(--spacing-md, 1rem);
}

/* =====================
   PĖDA — tik su pirminiu veiksmu
   ===================== */
.vsheet__footer {
	display: flex;
	align-items: center;
	flex-shrink: 0;
	min-height: 68px;
	padding: var(--spacing-md, 1rem);
	background: var(--color-bg-tertiary, #252538);
	border-top: 1px solid var(--color-border-default, #2c2c42);
}

.vsheet__footer:empty {
	display: none;
}

/* Pirminis veiksmas pėdoje — per visą plotį. */
.vsheet__footer > * {
	width: 100%;
}

/* =====================
   NUO 720px — langas centre
   ===================== */
@media (min-width: 720px) {
	.vsheet {
		align-items: center;
	}

	.vsheet__panel {
		width: 560px;
		max-width: calc(100vw - 2rem);
		max-height: min(80vh, calc(100vh - 4rem));
		border-bottom: 1px solid var(--color-border-default, #2c2c42);
		border-radius: var(--radius-modal, 1rem);
		box-shadow: 0 20px 60px var(--color-shadow-lg, rgba(0, 0, 0, 0.3));
		animation: vsheetScaleIn var(--duration-base, 250ms) var(--ease-default, cubic-bezier(0, 0, 0.2, 1)) forwards;
	}

	.vsheet--closing .vsheet__panel {
		animation: vsheetScaleOut 200ms var(--ease-in, cubic-bezier(0.4, 0, 1, 1)) forwards;
	}

	.vsheet__header {
		border-radius: var(--radius-modal, 1rem) var(--radius-modal, 1rem) 0 0;
		cursor: default;
	}
}

/* =====================
   KEYFRAMES
   ===================== */
@keyframes vsheetFadeIn {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes vsheetFadeOut {
	from { opacity: 1; }
	to   { opacity: 0; }
}

@keyframes vsheetSlideUp {
	from { transform: translateY(100%); }
	to   { transform: translateY(0); }
}

@keyframes vsheetSlideDown {
	from { transform: translateY(0); }
	to   { transform: translateY(100%); }
}

@keyframes vsheetScaleIn {
	from { transform: scale(0.96); opacity: 0; }
	to   { transform: scale(1);    opacity: 1; }
}

@keyframes vsheetScaleOut {
	from { transform: scale(1);    opacity: 1; }
	to   { transform: scale(0.96); opacity: 0; }
}

/* =====================
   SUMAŽINTAS JUDESYS
   ===================== */
@media (prefers-reduced-motion: reduce) {
	.vsheet__panel,
	.vsheet--closing .vsheet__panel {
		animation-name: vsheetFadeIn;
	}

	.vsheet--closing .vsheet__panel {
		animation-name: vsheetFadeOut;
	}
}
