/**
 * Sophia — floating booking module.
 *
 * A fixed, rounded "pill" that opens a paper disclosure panel (call / WhatsApp /
 * online booking + address / hours / email accordions + Escríbenos / social).
 * Brand only: terracotta accent, paper/cream surfaces, Fraunces headings,
 * JetBrains Mono kicker labels. Every colour/size comes from a theme.json token
 * via a CSS custom property — nothing is hard-coded.
 *
 * The pill is the site's ONE deliberately-rounded element; the panel echoes it
 * with an ~18px radius. Server-rendered: links work without JS; booking.js only
 * layers open/close, accordions, auto-open and focus.
 */

.sophia-booking {
	position: fixed;
	z-index: 9990;
	display: flex;
	flex-direction: column;
	gap: 12px;
	/* Both pill and panel align to the same corner-anchored column. */
	align-items: flex-start;
	max-width: calc(100vw - 32px);
	font-family: var(--wp--preset--font-family--sans);
}

/* --- Placement -------------------------------------------------------- */

.sophia-booking--bottom-right {
	right: 20px;
	bottom: 20px;
	align-items: flex-end;
}

.sophia-booking--bottom-left {
	left: 20px;
	bottom: 20px;
	align-items: flex-start;
}

/* Top placements sit below the sticky site header (height measured by JS into
   --sophia-header-h; the fallback matches the header's resting height). */
.sophia-booking--top-right {
	right: 20px;
	top: calc(var(--sophia-header-h, 96px) + 16px);
	align-items: flex-end;
}

.sophia-booking--top-left {
	left: 20px;
	top: calc(var(--sophia-header-h, 96px) + 16px);
	align-items: flex-start;
}

/* Panel opens upward from a bottom pill, downward from a top pill. */
.sophia-booking--bottom-right,
.sophia-booking--bottom-left {
	flex-direction: column-reverse;
}

/* --- Pill (closed state) ---------------------------------------------- */

.sophia-booking__pill {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 20px;
	border: none;
	border-radius: 999px;
	background-color: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--paper);
	font-family: var(--wp--custom--type--button--family);
	font-size: var(--wp--custom--type--button--size);
	font-weight: var(--wp--custom--type--button--weight);
	line-height: var(--wp--custom--type--button--line-height);
	letter-spacing: var(--wp--custom--type--button--letter-spacing);
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(23, 21, 19, 0.18);
	transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.sophia-booking__pill:hover {
	background-color: var(--wp--preset--color--accent-ink);
	transform: translateY(-1px);
	box-shadow: 0 10px 26px rgba(23, 21, 19, 0.22);
}

.sophia-booking__pill:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 3px;
}

.sophia-booking__pill-icon {
	display: inline-flex;
}

.sophia-booking__pill-icon svg {
	display: block;
	width: 20px;
	height: 20px;
}

.sophia-booking__pill-label {
	white-space: nowrap;
}

/* When open, soften the pill so the panel is the focus. */
.sophia-booking[data-open] .sophia-booking__pill {
	background-color: var(--wp--preset--color--accent-ink);
}

/* --- Panel (open state) ----------------------------------------------- */

.sophia-booking__panel {
	width: 340px;
	max-width: calc(100vw - 32px);
	max-height: calc(100vh - 120px);
	overflow-y: auto;
	box-sizing: border-box;
	padding: 22px;
	background-color: var(--wp--preset--color--paper);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 18px;
	box-shadow: 0 16px 44px rgba(23, 21, 19, 0.18);
	/* Closed visual state — JS un-hides, forces reflow, then adds [data-open]
	   on the root so this transitions in. On close it transitions back out and
	   JS re-applies [hidden] once the animation finishes. */
	opacity: 0;
	transform: translateY(8px) scale(0.98);
	transform-origin: bottom center;
	pointer-events: none;
	transition: opacity 0.22s ease, transform 0.22s ease;
}

.sophia-booking[data-open] .sophia-booking__panel {
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

.sophia-booking__panel[hidden] {
	display: none;
}

/* Header: serif title (italic emphasis) + close button. */
.sophia-booking__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 18px;
}

.sophia-booking__title {
	margin: 0;
	color: var(--wp--preset--color--ink);
	font-family: var(--wp--custom--type--heading-sm--family);
	font-size: var(--wp--custom--type--heading-sm--size);
	line-height: var(--wp--custom--type--heading-sm--line-height);
	letter-spacing: var(--wp--custom--type--heading-sm--letter-spacing);
	font-weight: var(--wp--custom--type--heading-sm--weight);
}

.sophia-booking__title em {
	color: var(--wp--preset--color--accent);
	font-style: italic;
}

.sophia-booking__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 34px;
	height: 34px;
	margin: -4px -4px 0 0;
	padding: 0;
	border: none;
	background: transparent;
	color: var(--wp--preset--color--dim);
	cursor: pointer;
	border-radius: 8px;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.sophia-booking__close:hover {
	background-color: var(--wp--preset--color--bg-alt);
	color: var(--wp--preset--color--ink);
}

.sophia-booking__close:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

.sophia-booking__close svg {
	display: block;
	width: 18px;
	height: 18px;
}

/* --- Actions stack ---------------------------------------------------- */

.sophia-booking__actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* Reuse the .sophia-button system but full-width inside the panel. */
.sophia-booking__action {
	width: 100%;
	justify-content: flex-start;
}

.sophia-booking__action .sophia-button__label {
	flex: 1 1 auto;
	text-align: left;
}

/* --- Divider + detail rows (accordions) ------------------------------- */

.sophia-booking__rows {
	margin-top: 18px;
	padding-top: 6px;
	border-top: 1px solid var(--wp--preset--color--line-soft);
}

.sophia-booking__row + .sophia-booking__row {
	border-top: 1px solid var(--wp--preset--color--line-soft);
}

.sophia-booking__row-toggle {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 14px 0;
	border: none;
	background: transparent;
	cursor: pointer;
	color: var(--wp--preset--color--ink);
	text-align: left;
}

.sophia-booking__row-toggle:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

.sophia-booking__row-icon {
	display: inline-flex;
	flex: none;
	color: var(--wp--preset--color--accent);
}

.sophia-booking__row-icon svg {
	display: block;
	width: 18px;
	height: 18px;
}

/* Kicker label: JetBrains Mono uppercase. */
.sophia-booking__row-label {
	flex: 1 1 auto;
	font-family: var(--wp--custom--type--kicker--family);
	font-size: var(--wp--custom--type--kicker--size);
	line-height: var(--wp--custom--type--kicker--line-height);
	letter-spacing: var(--wp--custom--type--kicker--letter-spacing);
	font-weight: var(--wp--custom--type--kicker--weight);
	text-transform: uppercase;
	color: var(--wp--preset--color--dim);
}

.sophia-booking__chevron {
	flex: none;
	width: 18px;
	height: 18px;
	color: var(--wp--preset--color--mute);
	transition: transform 0.2s ease;
}

.sophia-booking__row-toggle[aria-expanded="true"] .sophia-booking__chevron {
	transform: rotate(180deg);
}

/* Body: JS animates its actual height (0 ↔ content) for a reliable smooth
   collapse across browsers (the grid-template-rows 0fr trick didn't fully
   collapse — content stayed visible). overflow:hidden clips during the slide. */
.sophia-booking__row-body {
	overflow: hidden;
	transition: height 0.25s ease;
}

.sophia-booking__row-inner {
	padding-bottom: 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

/* Values = Fraunces (heading-sm token), like the contact block. */
.sophia-booking__value {
	font-family: var(--wp--preset--font-family--serif);
	font-size: var(--wp--preset--font-size--body-lg);
	line-height: 1.4;
	color: var(--wp--preset--color--ink);
	text-decoration: none;
}

a.sophia-booking__value:hover {
	color: var(--wp--preset--color--accent);
}

.sophia-booking__hours {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.sophia-booking__hours-line {
	display: block;
}

/* "Ver en el mapa" inline link. */
.sophia-booking__link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-family: var(--wp--custom--type--body-base--family);
	font-size: var(--wp--custom--type--body-base--size);
	line-height: var(--wp--custom--type--body-base--line-height);
	color: var(--wp--preset--color--accent);
	text-decoration: none;
}

.sophia-booking__link:hover {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.sophia-booking__link-icon {
	width: 14px;
	height: 14px;
}

/* --- Footer: Escríbenos + social -------------------------------------- */

.sophia-booking__footer {
	margin-top: 16px;
	padding-top: 16px;
	border-top: 1px solid var(--wp--preset--color--line-soft);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	text-align: center;
}

.sophia-booking__escribenos {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	color: var(--wp--preset--color--ink);
	text-decoration: none;
}

.sophia-booking__escribenos:hover {
	color: var(--wp--preset--color--accent);
}

.sophia-booking__escribenos .sophia-booking__row-icon svg {
	width: 18px;
	height: 18px;
}

.sophia-booking__escribenos-label {
	font-family: var(--wp--custom--type--button--family);
	font-size: var(--wp--custom--type--button--size);
	font-weight: var(--wp--custom--type--button--weight);
	letter-spacing: var(--wp--custom--type--button--letter-spacing);
}

.sophia-booking__social {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.sophia-booking__social-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 999px;
	color: var(--wp--preset--color--dim);
	text-decoration: none;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 11px;
	letter-spacing: 0.5px;
	transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.sophia-booking__social-link:hover {
	border-color: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--accent);
}

.sophia-booking__social-link:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

/* Visually-hidden label (theme has no global .screen-reader-text). */
.sophia-booking .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* --- Mobile ----------------------------------------------------------- */

@media (max-width: 520px) {
	.sophia-booking__panel {
		width: calc(100vw - 32px);
	}

	/* Keep the closed pill compact so it never covers critical content. */
	.sophia-booking:not([data-open]) .sophia-booking__pill {
		padding: 11px 18px;
		font-size: 13px;
	}
}

/* --- Reduced motion --------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.sophia-booking__pill,
	.sophia-booking__close,
	.sophia-booking__chevron,
	.sophia-booking__row-body,
	.sophia-booking__social-link,
	.sophia-booking__panel {
		transition: none;
	}

	/* No fade/slide when motion is reduced — but keep it visible when open. */
	.sophia-booking__panel {
		transform: none;
	}
}
