/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
	/* Colors */
	--color-bg:          #f8f7f4;
	--color-surface:     #ffffff;
	--color-border:      #ddd8ce;
	--color-text:        #1a1a1a;
	--color-text-muted:  #6b6459;
	--color-accent:      #1a6b4a;
	--color-accent-dark: #124d36;
	--color-error:       #c0392b;
	--color-focus:       #2563eb;

	/* Spacing */
	--space-xs:  0.25rem;
	--space-sm:  0.5rem;
	--space-md:  1rem;
	--space-lg:  1.5rem;
	--space-xl:  2rem;

	/* Typography */
	--font-sans: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
	--font-mono: "Courier New", Courier, monospace;
	--text-sm:   0.875rem;
	--text-base: 1rem;
	--text-lg:   1.25rem;
	--text-xl:   1.5rem;
	--text-2xl:  2rem;

	/* Layout */
	--header-height: 4rem;
	--panel-width:   320px;
}

/* ============================================================
   Reset / Base
   ============================================================ */
*, *::before, *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html, body {
	height: 100%;
}

body {
	font-family: var(--font-sans);
	font-size: var(--text-base);
	color: var(--color-text);
	background-color: var(--color-bg);
	line-height: 1.5;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

a {
	color: var(--color-accent);
	text-decoration: underline;
}

a:hover {
	color: var(--color-accent-dark);
}

/* Visible focus ring for keyboard navigation */
:focus-visible {
	outline: 3px solid var(--color-focus);
	outline-offset: 2px;
}

/* ============================================================
   Skip Link (accessibility)
   ============================================================ */
.skip-link {
	position: absolute;
	top: -100%;
	left: var(--space-md);
	background: var(--color-accent);
	color: #fff;
	padding: var(--space-sm) var(--space-md);
	text-decoration: none;
	font-weight: 600;
	z-index: 9999;
	border-radius: 0 0 4px 4px;
}

.skip-link:focus {
	top: 0;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
	background-color: var(--color-surface);
	border-bottom: 1px solid var(--color-border);
	padding: var(--space-sm) var(--space-lg);
	display: flex;
	align-items: center;
	gap: var(--space-lg);
	flex-shrink: 0;
	height: var(--header-height);
}

.site-title {
	font-size: var(--text-lg);
	font-weight: 700;
}

.site-title a {
	text-decoration: none;
	color: var(--color-text);
}

.site-tagline {
	font-size: var(--text-sm);
	color: var(--color-text-muted);
}

/* ============================================================
   Main Layout
   Mobile: map stacked above panel (column)
   Desktop (≥768px): map left, panel right (row)
   ============================================================ */
.main-layout {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0; /* allow flex children to shrink */
}

#map {
	flex: 1;
	min-height: 50vh;
	z-index: 0;
}

/* ============================================================
   Place Panel
   ============================================================ */
.place-panel {
	background-color: var(--color-surface);
	border-top: 1px solid var(--color-border);
	padding: var(--space-lg);
	overflow-y: auto;
}

.place-panel--empty .place-panel__content {
	display: none;
}

.place-panel__hint {
	color: var(--color-text-muted);
	font-size: var(--text-sm);
}

.place-name {
	font-size: var(--text-xl);
	font-weight: 700;
	margin-bottom: var(--space-sm);
}

/* ============================================================
   Pronunciation list
   ============================================================ */

/* Container for all pronunciation entries */
#pronunciations {
	margin-bottom: var(--space-md);
}

/* One row per language variant */
.pronunciation-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-sm);
	padding: var(--space-xs) 0;
	border-bottom: 1px solid var(--color-border);
}

.pronunciation-item:last-child {
	border-bottom: none;
}

/* Left side: language label + IPA text */
.pronunciation-meta {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0; /* allow truncation */
}

.pronunciation-lang {
	font-size: var(--text-sm);
	font-weight: 600;
	color: var(--color-text-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.pronunciation-ipa {
	font-family: var(--font-mono);
	font-size: var(--text-base);
	color: var(--color-text);
	word-break: break-all;
}

/* Play button — shared base style */
.play-btn {
	display: inline-flex;
	align-items: center;
	gap: var(--space-sm);
	background-color: var(--color-accent);
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-weight: 600;
	white-space: nowrap;
	flex-shrink: 0;
	/* Default size (used if .play-btn--sm is absent) */
	padding: var(--space-sm) var(--space-lg);
	font-size: var(--text-base);
}

/* Compact variant used inside pronunciation list rows */
.play-btn--sm {
	padding: var(--space-xs) var(--space-sm);
	font-size: var(--text-sm);
}

.play-btn:hover {
	background-color: var(--color-accent-dark);
}

.play-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Spinner shown while audio is loading */
.play-btn[data-loading="true"]::before {
	content: "";
	display: inline-block;
	width: 0.9em;
	height: 0.9em;
	border: 2px solid rgba(255,255,255,0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: spin 0.6s linear infinite;
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

/* Error message */
.place-error {
	color: var(--color-error);
	font-size: var(--text-sm);
	margin-bottom: var(--space-md);
}

/* Permalink */
.place-link {
	display: block;
	font-size: var(--text-sm);
	color: var(--color-text-muted);
}

/* ============================================================
   Desktop layout
   ============================================================ */
@media (min-width: 768px) {
	.main-layout {
		flex-direction: row;
	}

	#map {
		flex: 1;
		min-height: 0;
	}

	.place-panel {
		width: var(--panel-width);
		flex-shrink: 0;
		border-top: none;
		border-left: 1px solid var(--color-border);
	}
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
	background-color: var(--color-surface);
	border-top: 1px solid var(--color-border);
	padding: var(--space-sm) var(--space-lg);
	font-size: var(--text-sm);
	color: var(--color-text-muted);
	flex-shrink: 0;
}

/* ============================================================
   Screen-reader-only utility (keyboard accessibility for map)
   ============================================================ */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

/* ============================================================
   No-IPA message (shown when a place has no pronunciation data)
   ============================================================ */
.place-no-ipa {
	font-size: var(--text-sm);
	color: var(--color-text-muted);
	font-style: italic;
	margin-bottom: var(--space-md);
}

/* ============================================================
   Print styles
   ============================================================ */
@media print {
	.site-header,
	.site-footer,
	.skip-link,
	#map,
	.play-btn,
	.place-link {
		display: none !important;
	}

	.main-layout {
		display: block;
	}

	.place-panel {
		border: none;
		padding: 0;
	}

	.place-name {
		font-size: 1.5rem;
	}

	.place-ipa {
		font-size: 1rem;
	}
}
