html, body { margin: 0; height: 100%; background: #faf7ef; }

:root { --atlas-shadow: 0 14px 40px rgba(0,0,0,.28); }

/* Map fills the viewport; gestures go to the map, not the page */
#map {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	cursor: grab;
	touch-action: none;
	overscroll-behavior: none;
}
#map:active { cursor: grabbing; }

/* ─────────── Title bubble with Home link (row; icon vertically centered) ─────────── */
.atlas-header {
	position: fixed;
	top: calc(16px + env(safe-area-inset-top));
	left: calc(16px + env(safe-area-inset-left));
	z-index: 1200;
	background: rgba(255,255,255,0.62);
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	border-radius: 14px;
	padding: 10px 14px;
	box-shadow: var(--atlas-shadow);
	pointer-events: none;
	user-select: none;
	transform: translateZ(0);
	will-change: transform;
	
	display: flex;
	align-items: center;
	gap: 10px;
}

.atlas-home {
	pointer-events: auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px; height: 26px;
	color: #111; text-decoration: none;
	border-radius: 8px;
	-webkit-tap-highlight-color: transparent;
	background: transparent;
	transition: background 120ms ease, opacity 120ms ease;
	opacity: .95;
}
.atlas-home:hover { background: rgba(0,0,0,0.06); opacity: 1; }
.atlas-home:focus-visible { outline: 2px solid #111; outline-offset: 2px; }
.atlas-home-icon { width: 20px; height: 20px; display: block; }

.atlas-head { display: flex; flex-direction: column; padding-left: 0; }

.atlas-title {
	margin: 0 0 2px;
	font-family: Georgia, "Palatino Linotype", Palatino, "Times New Roman", Times, serif;
	font-size: clamp(18px, 2.4vw, 22px);
	font-weight: 700;
	letter-spacing: 0.2px;
	color: #111;
}
.atlas-subtitle {
	margin: 0; opacity: .9; color: #333;
	font-family: system-ui, -apple-system, "Avenir Next", Avenir, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
	font-size: 13px; font-weight: 600; letter-spacing: 0.2px;
}

/* MapLibre controls avoid the home bar / corners */
.maplibregl-ctrl-bottom-right {
	margin-right: calc(8px + env(safe-area-inset-right)) !important;
	margin-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
}
.maplibregl-ctrl-bottom-left {
	margin-left: calc(8px + env(safe-area-inset-left)) !important;
	margin-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
}

/* ─────────── Country chip (widget) ─────────── */
.atlas-info {
	position: fixed;
	bottom: calc(16px + env(safe-area-inset-bottom));
	left:  calc(16px + env(safe-area-inset-left));
	z-index: 1310;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	max-width: min(420px, 80vw);
	background: rgba(255,255,255,0.62);
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	border-radius: 18px;
	padding: 14px 18px 16px;
	box-shadow: var(--atlas-shadow);
	pointer-events: none;
	user-select: none;
	
	opacity: 0; visibility: hidden; transform: translateY(10px);
	transition: transform 160ms ease-out, opacity 160ms ease-out, visibility 0s linear 160ms, bottom 160ms ease-out;
}
.atlas-info.stacked {
	bottom: calc(16px + env(safe-area-inset-bottom) + var(--atlas-search-h, 56px) + 12px);
}
.atlas-info.is-visible {
	opacity: 1; visibility: visible; transform: translateY(0);
	transition: transform 160ms ease-out, opacity 160ms ease-out, visibility 0s linear 0s, bottom 160ms ease-out;
}
.atlas-info-row {
	display: inline-flex;
	align-items: center;
	gap: 10px;
}
.atlas-flag { font-size: 20px; line-height: 1; }
.atlas-name {
	font-family: Georgia, "Palatino Linotype", Palatino, "Times New Roman", Times, serif;
	font-weight: 700; letter-spacing: 0.2px; color: #111;
	font-size: clamp(14px, 2.2vw, 18px);
}

/* Hide flag + name row entirely in book-detail mode */
.atlas-info.is-book-detail .atlas-info-row {
	display: none;
}

/* Book list (covers +30%) */
.atlas-books {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 32vh;
	overflow-y: auto;
	overflow-x: hidden;
	padding-top: 2px;
	padding-right: 6px;
	padding-bottom: 6px;
	pointer-events: auto;
}

/* Give more room in detail mode so scroll feels better */
.atlas-info.is-book-detail .atlas-books {
	max-height: 48vh;
}

.atlas-book {
	display: grid;
	grid-template-columns: 44px 1fr;
	grid-column-gap: 10px;
	align-items: center;
	border-radius: 10px;
	padding: 6px 6px;
	cursor: pointer;
	user-select: none;
}
.atlas-book:hover { background: rgba(0,0,0,0.06); }
.atlas-book-cover {
	width: 44px;
	height: 68px;
	object-fit: cover;
	border-radius: 4px;
	box-shadow: 0 1px 4px rgba(0,0,0,.14);
	background: #eee;
}
.atlas-book-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.atlas-book-title {
	font-family: Georgia, "Palatino Linotype", Palatino, "Times New Roman", Times, serif;
	font-weight: 700; color: #111; font-size: 13px; line-height: 1.2;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.atlas-book-author {
	font: 600 11px/1.2 system-ui, -apple-system, "Avenir Next", Avenir, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
	color: #333; opacity: .9;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.atlas-empty {
	font: 600 12px/1.2 system-ui, -apple-system, "Avenir Next", Avenir, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
	color: #333; opacity: .95;
	pointer-events: auto;
}
.atlas-empty a { color: #111; text-decoration: underline; }

/* ─────────── Bottom-center Search (typeahead) ─────────── */
.atlas-search {
	position: fixed;
	left: 50%;
	bottom: calc(18px + env(safe-area-inset-bottom));
	transform: translateX(-50%);
	z-index: 1300;
	width: min(560px, 92vw);
	pointer-events: none;
}

.atlas-search-inner {
	pointer-events: auto;
	display: flex; align-items: center; gap: 10px;
	background: rgba(255,255,255,0.72);
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	border-radius: 999px;
	padding: 10px 14px;
	box-shadow: var(--atlas-shadow);
}

.atlas-search-icon { width: 18px; height: 18px; flex: 0 0 auto; fill: #333; opacity: .85; }
.atlas-search-input {
	appearance: none; border: 0; outline: 0; background: transparent;
	width: 100%;
	font: 600 14px/1.2 system-ui, -apple-system, "Avenir Next", Avenir, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
	color: #111;
}

.atlas-suggest {
	pointer-events: auto;
	position: absolute; left: 50%; transform: translateX(-50%);
	bottom: calc(52px + 6px);
	width: min(560px, 92vw);
	margin: 0; padding: 6px;
	list-style: none;
	background: rgba(255,255,255,0.92);
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	border-radius: 14px;
	box-shadow: var(--atlas-shadow);
	max-height: 50vh; overflow: auto;
}
.atlas-suggest[hidden] { display: none; }

.atlas-suggest-item {
	display: flex; align-items: center; gap: 10px;
	padding: 10px 12px; border-radius: 10px;
	cursor: pointer; user-select: none;
	font: 600 14px/1.2 system-ui, -apple-system, "Avenir Next", Avenir, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
	color: #111;
}
.atlas-suggest-item:hover, .atlas-suggest-item[aria-selected="true"] {
	background: rgba(0,0,0,0.06);
}
.atlas-suggest-flag { width: 18px; line-height: 1; }

/* Mobile small tweaks */
@media (max-width: 520px) {
	.atlas-header { left: calc(12px + env(safe-area-inset-left)); padding: 10px 12px; }
}

/* ─────────── Book detail view ─────────── */
.atlas-book-detail {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 6px 4px 4px;
}

.atlas-book-detail-header {
	display: flex;
	flex-direction: column;
	gap: 8px;
	position: relative;
}

.atlas-book-detail-toprow {
	position: absolute;
	top: 0;
	right: 0;
	display: flex;
	align-items: flex-start;
	justify-content: flex-end;
	margin-bottom: 0;
}

.atlas-book-back {
	appearance: none;
	border: 0;
	outline: 0;
	background: rgba(0,0,0,0.06);
	border-radius: 999px;
	padding: 4px 10px;
	font: 600 12px/1.2 system-ui, -apple-system, "Avenir Next", Avenir, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
	color: #111;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.atlas-book-back:hover {
	background: rgba(0,0,0,0.10);
}
.atlas-book-back:focus-visible {
	outline: 2px solid #111;
	outline-offset: 2px;
}

.atlas-book-detail-main {
	display: grid;
	grid-template-columns: 102px minmax(0, 1fr);
	grid-column-gap: 12px;
	align-items: center;
	margin-top: 0;
}

.atlas-book-detail-cover {
	width: 102px;
	height: 153px;
	object-fit: cover;
	border-radius: 10px;
	box-shadow: 0 1px 4px rgba(0,0,0,.14);
	background: #eee;
	align-self: flex-start;
}

.atlas-book-detail-meta {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	min-width: 0;
	width: 100%;
	padding-right: 4px;
	box-sizing: border-box;
	height: 100%;
	justify-content: space-between;
}

.atlas-book-detail-text {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-top: auto;
	margin-bottom: auto;
}

.atlas-book-detail-title {
	font-family: Georgia, "Palatino Linotype", Palatino, "Times New Roman", Times, serif;
	font-weight: 700;
	color: #111;
	font-size: 16px;
	line-height: 1.3;
	word-break: break-word;
}

.atlas-book-detail-author {
	font: 600 12px/1.2 system-ui, -apple-system, "Avenir Next", Avenir, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
	color: #333;
	opacity: .9;
}

.atlas-book-buy {
	align-self: flex-end;
	margin-top: 0;
	margin-right: 16px;
	margin-bottom: 10px;
	padding: 7px 18px;
	border-radius: 999px;
	text-decoration: none;
	font: 600 11px/1.2 system-ui, -apple-system, "Avenir Next", Avenir, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
	background: #301900;
	color: #fff;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	white-space: nowrap;
	max-width: 100%;
}
.atlas-book-buy:hover {
	background: #000;
}

/* Summary */
.atlas-book-detail-description {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.atlas-book-detail-description-text {
	font: 500 12px/1.4 system-ui, -apple-system, "Avenir Next", Avenir, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
	color: #222;
	opacity: .95;
	overflow: visible;
	max-height: none;
	word-wrap: break-word;
	box-sizing: border-box;
	padding-right: 2px;
}
