/* Statiophone Copilote — app shell styles.
   Reproduces the 2015 Cordova app's look (Florent Gosselin's UI design):
   tiled beige pattern background, logo on top, edge-to-edge gradient tiles
   (blue = places libres, orange = abonnés, grey = complet/fermé), dark brown
   tab bar with a raised centre tab for the voice guide, and "Retour" bars on
   the secondary screens.

   Tile backgrounds keep the exact original gradients. Text colours are the
   one deliberate deviation: the original white/pastel text on those
   gradients sits around 2:1, so names use a dark tint of the tile hue and
   counts/distances keep white with a dark halo — see the readme changelog. */

@font-face {
	font-family: 'Vevey';
	src: url('../fonts/vevey.otf') format('opentype');
	font-display: swap;
}

:root {
	/* Page */
	--stph-pattern: url('../images/bg-main.png');
	--stph-bg: #e6e2dd;
	--stph-text: #323232;
	--stph-text-muted: #5f5a56;
	--stph-panel: #fcfcfc;
	--stph-band: #f6f6f6;
	--stph-link: #1f6d91;

	/* Brown chrome (tab bar, back bar) sampled from the original PNGs */
	--stph-chrome: #3a3233;
	--stph-chrome-top: #4a3f40;
	--stph-chrome-bottom: #322a2b;
	--stph-chrome-text: #d6d0d0;

	/* Tiles — original gradients, top → bottom */
	--stph-available-top: #54b2da;
	--stph-available-bottom: #4993b7;
	--stph-available-border: #50a3cb;
	--stph-available-name: #0f3a52;

	--stph-soonfull-top: #ecae50;
	--stph-soonfull-bottom: #e6903c;
	--stph-soonfull-border: #da8f4a;
	--stph-soonfull-name: #5c2c08;

	--stph-unavailable-top: #e4e4e4;
	--stph-unavailable-bottom: #b8b5b1;
	--stph-unavailable-border: #c1c1c1;
	--stph-unavailable-name: #3d3d3d;

	--stph-tile-value: #ffffff;
	--stph-tile-halo: 0 1px 2px rgba(0, 0, 0, 0.55), 0 0 1px rgba(0, 0, 0, 0.6);

	/* Details */
	--stph-places-blue: #3f7fa6;
	--stph-places-grey: #7d7d7d;

	--stph-focus: #1a1a1a;
	--stph-tabbar-height: 55px;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
	background: var(--stph-bg) var(--stph-pattern) repeat;
	color: var(--stph-text);
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size: 16px;
	line-height: 1.4;
}

body {
	min-height: 100dvh;
}

a {
	color: var(--stph-link);
}

.stph-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

:focus-visible {
	outline: 3px solid var(--stph-focus);
	outline-offset: 2px;
	box-shadow: 0 0 0 2px #fff;
}

/* Header — logo centred on the pattern, as on the original home screen.
   Only shown on the home view; secondary screens get a "Retour" bar instead.
   It stays in the accessibility tree so the page always exposes its <h1>. */

#stph-header {
	display: flex;
	justify-content: center;
	align-items: flex-start;
	height: 85px;
	padding-top: 10px;
}

body:has(#home[hidden]) #stph-header {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
}

#stph-header h1 {
	margin: 0;
	line-height: 0;
}

#stph-header img {
	width: 142px;
	height: 65px;
}

/* Layout */

main#stph-app {
	max-width: 640px;
	margin: 0 auto;
	/* keeps the last row clear of the fixed tab bar (+ a little air) */
	padding-bottom: calc(var(--stph-tabbar-height) + env(safe-area-inset-bottom, 0px) + 16px);
}

/* Shown only while the browser blocks audio (no touch yet). Bottom padding
   lives on #stph-app, not body: theme styles printed by wp_head() may
   reset the body's padding. */
.stph-audio-unlock {
	display: flex;
	width: calc(100% - 20px);
	margin: 0 10px 10px;
	min-height: 56px;
	font-size: 1.1rem;
}

.stph-audio-unlock[hidden] {
	display: none;
}

#stph-status:empty {
	display: none;
}

#stph-status {
	color: var(--stph-text-muted);
	margin: 0 1rem 0.75rem;
	text-align: center;
}

/* Parking tiles: the two nearest get half-width tiles, the rest fall into
   rows of three — same layout as the original app (.pk1/.pk2 at 50%,
   .pkn33/.pkn34 at a third). Tiles sit edge to edge, no gutter. A 6-column
   base grid makes both ratios exact. */

#parkings {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(6, minmax(0, 1fr));
}

.pkg--big {
	grid-column: span 3;
}

.pkg--normal {
	grid-column: span 2;
}

.pkg-link {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 0.1rem;
	height: 100%;
	min-height: 96px;
	padding: 0.5rem 0.25rem;
	text-decoration: none;
	text-align: center;
	color: var(--stph-tile-value);
	box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.25);
}

.pkg--big .pkg-link {
	min-height: 140px;
}

.pkg.available .pkg-link {
	border: 1px solid var(--stph-available-border);
	background: linear-gradient(to bottom, var(--stph-available-top), var(--stph-available-bottom));
}

.pkg.soonfull .pkg-link {
	border: 1px solid var(--stph-soonfull-border);
	background: linear-gradient(to bottom, var(--stph-soonfull-top), var(--stph-soonfull-bottom));
}

.pkg.unavailable .pkg-link {
	border: 1px solid var(--stph-unavailable-border);
	background: linear-gradient(to bottom, var(--stph-unavailable-top), var(--stph-unavailable-bottom));
}

.pkg-link:focus-visible {
	position: relative;
	z-index: 1;
	outline-offset: -3px;
}

.parking-name,
.parking-slots,
.parking-distance {
	display: block;
	max-width: 100%;
	font-family: 'Vevey', "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-weight: normal;
	line-height: 1.1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Name: embossed dark tint of the tile hue (original used a mid tint
   with a white 1px emboss). */
.parking-name {
	font-size: clamp(1.05rem, 5.6vw, 1.75rem);
	text-shadow: 1px 1px rgba(255, 255, 255, 0.4);
	padding: 0 0.15rem;
}

.pkg.available .parking-name {
	color: var(--stph-available-name);
}

.pkg.soonfull .parking-name {
	color: var(--stph-soonfull-name);
}

.pkg.unavailable .parking-name {
	color: var(--stph-unavailable-name);
}

.parking-slots {
	font-size: clamp(1.15rem, 6vw, 1.9rem);
	text-shadow: var(--stph-tile-halo);
}

.parking-distance {
	font-size: clamp(1rem, 4.4vw, 1.35rem);
	text-shadow: var(--stph-tile-halo);
}

.pkg--big .parking-name {
	font-size: clamp(1.4rem, 8.5vw, 2.6rem);
}

.pkg--big .parking-slots {
	font-size: clamp(1.6rem, 9.5vw, 3rem);
}

.pkg--big .parking-distance {
	font-size: clamp(1.25rem, 6.8vw, 2.1rem);
}

/* "Retour" bar on secondary screens */

.stph-backbar {
	display: flex;
	align-items: center;
	height: 50px;
	padding-left: 20px;
	border-radius: 10px 10px 0 0;
	border-top: 1px solid #5a4e4f;
	background: linear-gradient(to bottom, var(--stph-chrome-top), var(--stph-chrome-bottom));
}

.stph-backbutton {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 54px;
	height: 32px;
	padding: 0 6px 0 12px;
	background: url('../images/back-button.png') center / 100% 100% no-repeat;
	color: #ffffff;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 13px;
	font-weight: bold;
	text-decoration: none;
}

.stph-backbutton:focus-visible {
	outline-color: #ffffff;
	box-shadow: 0 0 0 2px var(--stph-chrome);
}

/* White content panel (original #infos-inner / #details-inner) */

.stph-panel {
	margin: 10px;
	padding: 10px;
	border-radius: 10px;
	background: var(--stph-panel);
	text-align: left;
}

.stph-panel h2 {
	font-family: 'Vevey', "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-weight: normal;
	font-size: 2rem;
	line-height: 1.15;
	color: var(--stph-text);
	margin: 0.4rem 0 0.75rem;
}

/* Map */

#carte-inner {
	height: calc(100dvh - 50px - var(--stph-tabbar-height) - env(safe-area-inset-bottom, 0px) - 16px); /* 16px: #stph-app's extra bottom air */
	min-height: 300px;
}

/* Map markers — 2015 "P" picto with a coloured label over its lower half
   (original .label-dispo / .label-indispo / .label-abonnes). The label gets
   a full black outline rather than the original 1px shadow at 75% opacity,
   so it stays readable on any map tile. */

.stph-map-pin {
	position: relative;
	display: block;
	width: 35px;
	height: 43px;
}

.stph-map-pin img {
	display: block;
}

.stph-map-label {
	position: absolute;
	top: 18px;
	left: 50%;
	transform: translateX(-50%);
	font-family: "Lucida Grande", Arial, sans-serif;
	font-weight: bold;
	font-size: 20px;
	line-height: 1;
	white-space: nowrap;
	text-shadow:
		1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000,
		0 1px 2px #000;
	pointer-events: none;
}

.stph-map-label--dispo {
	color: #00ca00;
	font-size: 26px;
}

.stph-map-label--indispo {
	color: #ff3b3b; /* original #d40000 is too dark against its black outline */
}

.stph-map-label--abonnes {
	color: #ffcc00;
}

.stph-map-marker:focus-visible {
	outline: 3px solid var(--stph-focus);
	outline-offset: 2px;
	box-shadow: 0 0 0 2px #fff;
}

/* Settings form */

section#settings .stph-panel p {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin: 0;
	padding: 0.75rem 0;
	border-bottom: 1px solid #e3e0dc;
}

section#settings .stph-panel p:last-child {
	border-bottom: none;
}

section#settings label {
	flex: 1;
}

section#settings .stph-help {
	display: block;
	font-size: 0.85rem;
	color: var(--stph-text-muted);
}

section#settings input {
	accent-color: var(--stph-available-bottom);
}

section#settings input[type="checkbox"] {
	width: 24px;
	height: 24px;
	flex-shrink: 0;
}

section#settings input[type="range"] {
	flex: 1;
	min-height: 24px;
}

section#settings output {
	min-width: 2ch;
	text-align: right;
	color: var(--stph-text-muted);
}

/* Details */

.details-header {
	font-family: 'Vevey', "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size: 4rem;
	line-height: 1;
	text-align: center;
	margin: 0.25rem 0 0.75rem;
}

.details-places-bleu {
	color: var(--stph-places-blue);
}

.details-places-gris {
	color: var(--stph-places-grey);
}

/* Grey bands bleeding to the panel edges, with the original pictos */
.details-adresse,
.details-horaires {
	margin: 0 -10px 2px;
	padding: 8px 10px 8px 44px;
	background-color: var(--stph-band);
	background-repeat: no-repeat;
	background-position: 12px 8px;
	color: var(--stph-text-muted);
	font-size: 0.9rem;
	min-height: 44px;
}

.details-adresse {
	background-image: url('../images/icon-location.png');
}

.details-horaires {
	background-image: url('../images/icon-hours.png');
}

.details-horaires > :first-child {
	margin-top: 0;
}

.details-horaires > :last-child {
	margin-bottom: 0;
}

#details-map {
	height: 220px;
	border-radius: 10px;
	overflow: hidden;
	margin: 1rem 0;
}

.stph-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0.6rem 1.1rem;
	border-radius: 8px;
	border: 1px solid #2f6f8f;
	background: linear-gradient(to bottom, #3f8fb8, #2f6f8f);
	box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.25);
	color: #fff;
	font: inherit;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}

.stph-button[hidden] {
	display: none;
}

/* About */

section#about .stph-panel p {
	margin: 0 0 0.9rem;
	color: var(--stph-text-muted);
}

/* Tab bar — original PNGs: tabbar.png (310px, raised centre tab) centred
   over the tabbar-bg.png strip, plain brown below for the iOS home
   indicator safe area. Five equal slots, the voice guide in the middle. */

#stph-bottom-nav {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1000; /* above Leaflet panes and controls */
	display: flex;
	height: calc(var(--stph-tabbar-height) + env(safe-area-inset-bottom, 0px));
	padding: 4px 0 env(safe-area-inset-bottom, 0px);
	background:
		url('../images/tabbar.png') center top no-repeat,
		url('../images/tabbar-bg.png') left 4px / 100% 51px no-repeat, /* stretched: its edge column would seam if tiled */
		linear-gradient(var(--stph-chrome-bottom), var(--stph-chrome-bottom)) left 55px / 100% 100% no-repeat;
}

#stph-bottom-nav a,
#stph-bottom-nav button {
	flex: 1;
	max-width: 84px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-end;
	gap: 2px;
	padding: 0 2px 3px;
	border: none;
	background: transparent;
	color: var(--stph-chrome-text);
	text-decoration: none;
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size: 0.72rem;
	line-height: 1.1;
	cursor: pointer;
}

/* Centre the five slots over the 310px tabbar image on wide screens */
#stph-bottom-nav::before,
#stph-bottom-nav::after {
	content: "";
	flex: 1 1 0;
}

#stph-bottom-nav a[aria-current="page"] {
	color: #ffffff;
}

#stph-bottom-nav a:focus-visible,
#stph-bottom-nav button:focus-visible {
	outline-color: #ffffff;
	outline-offset: -2px;
	box-shadow: none;
}

#stph-bottom-nav svg {
	width: 26px;
	height: 26px;
	fill: none;
	stroke: #c4c4c4;
	stroke-width: 2.2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

#stph-bottom-nav img {
	display: block;
	flex-shrink: 0;
}

/* Guide toggle: grey megaphone when off, colour megaphone when on */
#stph-mute .stph-icon-unmuted,
#stph-mute[aria-pressed="true"] .stph-icon-muted {
	display: none;
}

#stph-mute[aria-pressed="true"] .stph-icon-unmuted {
	display: block;
}

#stph-mute[aria-pressed="true"] {
	color: #ffffff;
}

/* Screen-awake fallback video (old browsers without the Wake Lock API):
   must stay in the page and "playing", but never seen or reachable. */
.stph-keep-awake {
	position: fixed;
	left: 0;
	bottom: 0;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
	* {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
}
