/* Layout map / booking page — extends the shared tokens in home.css */

/* Stretch the page to the full viewport height so the map can fill down
   to the bottom edge instead of leaving dead white space beneath it. The
   sticky bar/sheet/confirmation screen are all position:fixed, so they sit
   outside this flow and keep overlaying on top exactly as before. */
.book-body {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
}

.book-body main {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.topbar__back {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: var(--radius);
	color: var(--color-ink);
	flex: 0 0 auto;
}

.topbar__back:hover {
	background: var(--color-surface);
}

.topbar__title {
	flex: 1 1 auto;
	min-width: 0;
	padding: 0 10px;
}

.topbar__title h1 {
	font-family: var(--font-heading);
	font-weight: 700;
	font-size: 1rem;
	margin: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.topbar__title p {
	font-size: 0.78rem;
	color: var(--color-muted);
	margin: 2px 0 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* .button/.button--primary live in home.css — shared with the login page,
   which doesn't otherwise need to link this map-specific stylesheet. */

/* Empty / unavailable states */
.state-message {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 10px;
	padding: 64px 24px;
	color: var(--color-muted);
}

.state-message .icon {
	color: var(--color-border);
}

.state-message h2 {
	font-family: var(--font-heading);
	color: var(--color-ink);
	margin: 0;
}

.state-message p {
	margin: 0 0 8px;
	max-width: 40ch;
}

.state-note {
	margin: 4px 20px 0;
	color: var(--color-muted);
	font-size: 0.85rem;
}

/* Map canvas — fills all remaining vertical space down to the sticky bar,
   which overlays on top rather than sitting below a gap. */
.map-page {
	padding: 12px 0 0;
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.map-canvas {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
}

.map-canvas__viewport {
	/* `height: 100%` doesn't reliably resolve against a flex-grown parent's
	   used size — absolute + inset against .map-canvas's `position:
	   relative` box does. */
	position: absolute;
	inset: 0;
	min-height: 320px;
	overflow: hidden;
	background: var(--color-surface);
	touch-action: none;
	cursor: grab;
}

.map-canvas__viewport:active {
	cursor: grabbing;
}

.map-canvas__surface {
	position: absolute;
	top: 0;
	left: 0;
	will-change: transform;
}

.map-canvas__surface svg {
	display: block;
}

/* Every stroke in the map SVG keeps a constant on-screen width regardless
   of the current fit/zoom scale (zoom-controller.js applies pan/zoom as a
   CSS transform on .map-canvas__surface, which would otherwise shrink raw
   SVG stroke-widths proportionally). Without this, decorative/infra paths
   that aren't bound to a Plot record (e.g. a layout's canal lines and any
   unmatched shapes like "Park") fall below 1 device pixel at typical
   fit-zoom and anti-alias into near-invisible hairlines — plot boundaries
   already avoid this via the same property, set inline per matched
   element in plot-renderer.js; this covers every other shape the same
   way.

   geometricPrecision: even at a fixed, non-shrinking width, a DIAGONAL
   edge (an irregular plot boundary, a road cutout, "Park"'s slanted
   sides) can anti-alias into a dotted/broken look at low zoom, while
   axis-aligned edges render cleanly regardless — that's a rendering
   quality tradeoff the browser makes by default for speed, not a
   dasharray or a missing line. This asks for accuracy instead; safe to
   apply everywhere since it only affects anti-aliasing, never color or
   width. */
.map-canvas__surface svg path,
.map-canvas__surface svg line,
.map-canvas__surface svg polyline,
.map-canvas__surface svg polygon {
	vector-effect: non-scaling-stroke;
	shape-rendering: geometricPrecision;
}

/* Shapes with no authored stroke-width (e.g. "Park") fall back to the SVG
   default of 1 — technically non-shrinking now, but still thin enough
   that a diagonal edge can look faint even with geometricPrecision above.
   Bump it a bit, matching the weight already used for plot boundaries
   (.plot--available's 1.25) plus a little more headroom for diagonals
   specifically. Scoped to skip: plot elements, already styled correctly
   by .plot--* below; and any element that declares its own stroke-width
   (e.g. a canal line's explicit "5") so this only adds weight where none
   was authored at all, never downgrades one that was. */
.map-canvas__surface svg path:not(.plot):not([stroke-width]),
.map-canvas__surface svg line:not(.plot):not([stroke-width]),
.map-canvas__surface svg polyline:not(.plot):not([stroke-width]),
.map-canvas__surface svg polygon:not(.plot):not([stroke-width]) {
	stroke-width: 1.5;
}

.plot {
	transition: fill 150ms ease, stroke 150ms ease, filter 150ms ease;
}

.plot--unavailable {
	fill: var(--color-unavailable);
	fill-opacity: 1;
	/* Same default line color as every other plot on the map — no special
	   grey override. Only the flat fill distinguishes "unavailable". */
	stroke: var(--color-ink);
	stroke-width: 1;
	cursor: default;
	pointer-events: none;
}

.plot--available {
	fill: #FFFFFF;
	fill-opacity: 1;
	stroke: var(--color-ink);
	stroke-width: 1.25;
	cursor: pointer;
}

.plot--filter-match {
	/* Radial gradient fill (plot-renderer.js's ensureGlowGradient) — a soft
	   inner glow, near-white at the center warming to gold at the edge,
	   rather than a border effect. Fill is inherently contained by the
	   path it's painted into, so it can't bleed onto neighboring plots. */
	fill: url(#yp-plot-glow-fill);
	fill-opacity: 1;
	/* Same stroke as every other plot state — no second stroke color. */
	stroke: var(--color-ink);
	stroke-width: 1.25;
	cursor: pointer;
}

.plot--selected {
	fill: var(--color-accent);
	fill-opacity: 1;
	stroke: var(--color-accent);
	stroke-width: 1.25;
	cursor: pointer;
}

/* Zoom controls */
.map-zoom {
	position: absolute;
	right: 12px;
	bottom: 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	z-index: 5;
}

.map-zoom__btn {
	width: 38px;
	height: 38px;
	border: none;
	border-radius: 50%;
	background: #FFFFFF;
	color: var(--color-ink);
	box-shadow: var(--shadow-soft);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.map-zoom__btn:hover {
	background: var(--color-surface);
}

/* View Settings (CLAUDE.md's "SVG in-plot overlays" section, ported from
   Manage Plots) — top-right, its own small group, deliberately separate
   from .map-zoom's bottom-right stack so the two never compete for the
   same corner. */
.map-view-settings {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 5;
}

.map-view-settings__btn {
	width: 38px;
	height: 38px;
	border: none;
	border-radius: 50%;
	background: #FFFFFF;
	color: var(--color-ink);
	box-shadow: var(--shadow-soft);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.map-view-settings__btn:hover {
	background: var(--color-surface);
}

/* Guest gating (CLAUDE.md: "disabled/non-interactive for guests... a
   visually disabled/greyed treatment is expected") — the `disabled`
   attribute itself (set server-side in index.html) is what actually
   stops clicks; this is only the visual half. */
.map-view-settings__btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

/* Anchored popover — fixed positioning computed in view-settings.js
   (top/left in viewport coordinates), same below-and-right-aligned-to-
   the-anchor default (flipping above / clamping to the viewport edge
   when there isn't room) as Manage Plots' own popover-shell.js. This is
   a separate, from-scratch implementation for this page (see
   view-settings.js's own header comment on why), not a shared file. */
.view-settings-popover {
	position: fixed;
	z-index: 40;
	max-width: 220px;
	padding: 14px 16px;
	border-radius: var(--radius);
	border: 0.5px solid var(--color-border);
	background: #FFFFFF;
	box-shadow: var(--shadow-soft);
}

.view-settings-popover[hidden] {
	display: none;
}

.view-settings-popover__heading {
	margin: 0 0 8px;
	font-family: var(--font-heading);
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	color: var(--color-muted);
}

.view-settings-popover__option {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 4px;
	font-family: var(--font-body);
	font-size: 0.9rem;
	color: var(--color-ink);
	cursor: pointer;
}

.view-settings-popover__option input {
	accent-color: var(--color-accent);
}

/* Text-selectability fix (CLAUDE.md) — every text element inside the
   number/plotdimension/plotinfo SVG groups never behaves like normal
   page text: user-select:none stops native browser text-highlighting on
   a click-drag across a label, and pointer-events:none makes a click
   landing directly on a label pass through to the plot shape underneath
   it (map-viewer.js's onTap resolves the tapped element via
   elementFromPoint, which skips a pointer-events:none element entirely)
   instead of the label silently absorbing a click meant for the plot. */
.plot-label-text {
	user-select: none;
	pointer-events: none;
}

/* Hides the plotdimension/plotinfo groups' own placeholder text (e.g.
   "-", kept in the source SVG purely so a designer can see/select those
   elements while positioning them in an editor) from the very first
   paint — a plain CSS rule in this stylesheet, not something JS toggles
   on later. This matters specifically on this page because
   {{ svg_markup|safe }} renders the SVG straight into the initial HTML
   response, so the browser paints it (at its raw, un-fit-to-screen
   scale, before any module script has even downloaded) the instant the
   HTML is parsed — a JS-only fix (view-settings.js clearing textContent
   once it runs) would still let the placeholder flash visible for that
   window. The `number` group is deliberately NOT included here — plot
   numbers are real, always-visible content, not placeholders.
   view-settings.js sets visibility:visible inline, per element, only
   when it has just written real content into that element; it reverts
   to this default (by clearing the inline style, not setting it to
   "hidden" again) the moment that content is cleared. */
#plotdimension text,
#plotinfo text {
	visibility: hidden;
}

/* Sticky selection bar */
.selection-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 14px 20px;
	background: #FFFFFF;
	border-top: 0.5px solid var(--color-border);
	box-shadow: 0 -8px 24px rgba(26, 26, 26, 0.08);
	transform: translateY(100%);
	transition: transform 220ms ease;
	z-index: 30;
}

.selection-bar.is-visible {
	transform: translateY(0);
}

.selection-bar__count {
	font-family: var(--font-heading);
	font-weight: 700;
	font-size: 0.92rem;
	color: var(--color-ink);
}

@media (min-width: 640px) {
	.selection-bar {
		padding: 16px 32px;
	}
}

/* Prevent background scroll while the sheet/confirmation screen is open */
body.no-scroll {
	overflow: hidden;
}

/* Booking sheet (in-page modal — no confirm()/alert()) */
.sheet-overlay {
	position: fixed;
	inset: 0;
	z-index: 50;
	display: flex;
	align-items: flex-end;
	justify-content: center;
}

.sheet-overlay__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(26, 26, 26, 0.45);
}

.sheet {
	position: relative;
	width: 100%;
	max-width: 480px;
	max-height: 88vh;
	overflow-y: auto;
	background: #FFFFFF;
	border-radius: 16px 16px 0 0;
	padding: 28px 20px 24px;
	box-shadow: 0 -8px 32px rgba(26, 26, 26, 0.16);
}

.sheet__close {
	position: absolute;
	top: 14px;
	right: 14px;
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 50%;
	background: var(--color-surface);
	color: var(--color-ink);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.sheet__title {
	font-family: var(--font-heading);
	font-weight: 700;
	font-size: 1.1rem;
	margin: 0 28px 14px 0;
}

.sheet__copy {
	color: var(--color-muted);
	font-size: 0.9rem;
	line-height: 1.5;
	margin: 0 0 20px;
}

.sheet__step[data-step="login"] .icon--lg {
	color: var(--color-accent);
	margin-bottom: 12px;
}

.sheet__total {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 0;
	border-top: 0.5px solid var(--color-border);
	font-family: var(--font-heading);
	font-weight: 700;
	margin: 4px 0 16px;
}

.sheet__total span {
	font-family: var(--font-body);
	font-weight: 500;
	color: var(--color-muted);
	font-size: 0.85rem;
}

.sheet__action {
	width: 100%;
}

.sheet__action:disabled {
	opacity: 0.6;
	cursor: default;
}

.sheet__submit-error {
	color: var(--color-error);
	font-size: 0.82rem;
	margin: 0 0 12px;
}

/* Shared plot list (used in the sheet and the confirmation recap) */
.plot-list {
	list-style: none;
	margin: 0 0 4px;
	padding: 0;
	border: 0.5px solid var(--color-border);
	border-radius: var(--radius);
	overflow: hidden;
}

.plot-row {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 10px 14px;
	font-size: 0.85rem;
}

.plot-row + .plot-row {
	border-top: 0.5px solid var(--color-border);
}

.plot-row__top {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
}

.plot-row__label {
	font-family: var(--font-heading);
	font-weight: 700;
	flex: 0 0 auto;
}

.plot-row__subtotal {
	font-weight: 700;
	color: var(--color-ink);
	flex: 0 0 auto;
}

.plot-row__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 10px;
	color: var(--color-muted);
	font-size: 0.78rem;
}

/* .form-field* lives in home.css — shared with the login page. */

/* Optional-field hint (seller booking form's reference field) */
.form-field__optional {
	font-weight: 400;
	text-transform: none;
	color: var(--color-muted);
}

/* Lightweight, non-blocking confirmation toast for the seller booking flow.
   The seller stays on the map and can immediately book the next plot,
   rather than being sent to a full-screen confirmation like the buyer flow
   below — that interstitial makes sense once per buyer, not the dozens of
   times a day a sales team member books a plot. */
.toast {
	position: fixed;
	left: 50%;
	top: 16px;
	transform: translateX(-50%);
	z-index: 70;
	max-width: calc(100% - 32px);
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px 12px 16px;
	border-radius: var(--radius);
	background: var(--color-badge-bg);
	color: var(--color-badge-text);
	box-shadow: var(--shadow-soft);
}

.toast__icon {
	display: flex;
	flex: 0 0 auto;
}

.toast__icon .icon {
	width: 18px;
	height: 18px;
}

.toast__message {
	flex: 1 1 auto;
	font-family: var(--font-body);
	font-weight: 600;
	font-size: 0.85rem;
}

.toast__close {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	border: none;
	background: none;
	padding: 0;
	color: var(--color-badge-text);
	cursor: pointer;
}

.toast__close .icon {
	width: 14px;
	height: 14px;
}

/* Full-screen confirmation */
.confirmation-screen {
	position: fixed;
	inset: 0;
	z-index: 60;
	background: #FFFFFF;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow-y: auto;
	padding: 32px 20px;
}

.confirmation-screen__panel {
	max-width: 440px;
	width: 100%;
	text-align: center;
}

.confirmation-screen__panel .icon--xl {
	color: var(--color-accent);
	margin-bottom: 16px;
}

.confirmation-screen__panel h1 {
	font-family: var(--font-heading);
	font-weight: 800;
	font-size: 1.5rem;
	margin: 0 0 10px;
}

.confirmation-screen__copy {
	color: var(--color-muted);
	line-height: 1.55;
	margin: 0 0 28px;
}

.confirmation-screen__recap {
	text-align: left;
	margin-bottom: 28px;
}

.confirmation-screen__recap h2 {
	font-family: var(--font-heading);
	font-size: 0.85rem;
	color: var(--color-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	margin: 0 0 10px;
}

/* [hidden] ties in specificity with the display:flex rules above (for each
   of these selectors), so it must come after them in source order to
   actually win — otherwise the element renders (and, for the two overlays,
   intercepts clicks) from the very first paint regardless of its `hidden`
   attribute. Every other `hidden`-toggled element in this page has no
   competing `display` declaration, so the UA stylesheet's `[hidden]` rule
   already applies to them unopposed. */
.sheet-overlay[hidden],
.confirmation-screen[hidden],
.sheet__total[hidden],
.toast[hidden] {
	display: none;
}
