/*
 * The whole look of the application, in one file.
 *
 * No framework, no reset library, no web font: the colours come from the
 * settings as custom properties set by app.js, and the type stack is whatever
 * the device already has. Nothing here loads anything from another host.
 */

:root {
	--theme-color: #2271b1;
	--accent-color: #2271b1;
	--background-color: #ffffff;

	--bg: #f6f7f9;
	--surface: #ffffff;
	--surface-muted: #f0f2f5;
	--text: #1d2327;
	--text-muted: #62707c;
	--line: #e3e7ec;
	--danger: #b32d2e;
	--good: #1a7f45;

	--radius: 14px;
	--radius-small: 8px;
	--gap: 16px;
	--shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
	--header-height: 56px;
	--nav-height: 60px;
	--content-width: 720px;

	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
	color-scheme: light;
}

html[data-font="serif"] {
	--font: Georgia, "Times New Roman", "PT Serif", "Noto Serif", serif;
}

html[data-font="sans"] {
	--font: "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

/* Dark palette: on by choice, or by the system when the setting says auto. */
html[data-scheme="dark"],
html[data-scheme="auto"] {
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	html[data-scheme="auto"] {
		--bg: #14171a;
		--surface: #1c2024;
		--surface-muted: #22272c;
		--text: #eceff2;
		--text-muted: #a3adb8;
		--line: #2e343a;
		--background-color: #14171a;
		--shadow: 0 1px 2px rgba(0, 0, 0, .4);
	}
}

html[data-scheme="dark"] {
	--bg: #14171a;
	--surface: #1c2024;
	--surface-muted: #22272c;
	--text: #eceff2;
	--text-muted: #a3adb8;
	--line: #2e343a;
	--background-color: #14171a;
	--shadow: 0 1px 2px rgba(0, 0, 0, .4);
	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

/* Several elements below are flex containers, and flex beats the hidden
   attribute unless it is said outright. */
[hidden] {
	display: none !important;
}

html,
body {
	margin: 0;
	padding: 0;
}

body {
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 17px;
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
	-webkit-text-size-adjust: 100%;
	overflow-wrap: break-word;
}

a {
	color: var(--accent-color);
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

img {
	max-width: 100%;
	height: auto;
}

:focus-visible {
	outline: 2px solid var(--accent-color);
	outline-offset: 2px;
	border-radius: 4px;
}

.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 100;
	background: var(--surface);
	padding: 10px 16px;
	border-radius: 0 0 var(--radius-small) 0;
}

.skip-link:focus {
	left: 0;
}

.icon {
	width: 22px;
	height: 22px;
	flex: none;
	display: block;
}

/* ---------- layout ---------- */

.app {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

.screen {
	flex: 1;
	width: 100%;
	max-width: var(--content-width);
	margin: 0 auto;
	padding: var(--gap) var(--gap) calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + var(--gap));
	outline: none;
}

.screen__title {
	font-size: 1.5rem;
	margin: 4px 0 16px;
}

/* ---------- header ---------- */

.header {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: var(--header-height);
	padding: 0 8px;
	padding-top: env(safe-area-inset-top, 0px);
	background: var(--theme-color);
	color: #fff;
	box-shadow: var(--shadow);
}

.header a,
.header button {
	color: #fff;
}

.header__home {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	padding: 0 4px;
}

.header__home:hover {
	text-decoration: none;
}

.header__title {
	font-weight: 600;
	font-size: 1.05rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.header__actions {
	display: flex;
	align-items: center;
	gap: 2px;
}

.icon-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-width: 40px;
	height: 40px;
	padding: 0 9px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.icon-button:hover {
	background: rgba(127, 127, 127, .18);
}

.icon-button__label {
	font-size: .9rem;
}

/* ---------- buttons ---------- */

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 10px 18px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-weight: 500;
	line-height: 1.2;
	cursor: pointer;
	text-decoration: none;
}

.button:hover {
	background: var(--surface-muted);
	text-decoration: none;
}

.button:disabled {
	opacity: .6;
	cursor: default;
}

.button--primary {
	background: var(--accent-color);
	border-color: transparent;
	color: #fff;
}

.button--primary:hover {
	background: var(--accent-color);
	filter: brightness(1.08);
}

.button--small {
	padding: 6px 12px;
	font-size: .9rem;
}

.button--link {
	border: 0;
	background: transparent;
	color: var(--accent-color);
	padding: 6px 8px;
}

.button--more {
	display: flex;
	width: 100%;
	margin: 8px 0 4px;
}

.button--install {
	border: 0;
	background: rgba(255, 255, 255, .18);
	color: #fff;
	padding: 8px 14px;
	font-size: .92rem;
}

/* ---------- feed ---------- */

.feed {
	display: grid;
	gap: var(--gap);
}

.feed__status {
	margin: 0 0 12px;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	font-size: .93rem;
	color: var(--text-muted);
}

.feed__status--offline,
.feed__status--error {
	background: var(--surface-muted);
	border: 1px solid var(--line);
	border-radius: var(--radius-small);
	padding: 8px 12px;
	color: var(--text);
}

.feed__sentinel {
	height: 1px;
}

.feed-heading {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 8px;
}

.feed-heading__title {
	font-size: 1.25rem;
	margin: 0;
}

.card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
	box-shadow: var(--shadow);
}

.card__media {
	display: block;
	background: var(--surface-muted);
}

.card__image {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	object-fit: cover;
}

.card__body {
	padding: 14px 16px 16px;
	display: grid;
	gap: 8px;
}

.card__title {
	margin: 0;
	font-size: 1.16rem;
	line-height: 1.3;
}

.card__link {
	color: var(--text);
}

.card__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	font-size: .85rem;
	color: var(--text-muted);
}

.card__excerpt {
	margin: 0;
	color: var(--text-muted);
	font-size: .97rem;
}

.card__terms {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.card__excerpt--locked,
.article__locked {
	color: var(--text-muted);
	font-style: italic;
}

.card--locked {
	border-style: dashed;
}

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: var(--gap);
}

.chip {
	display: inline-block;
	padding: 6px 14px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--surface);
	color: var(--text);
	font-size: .9rem;
}

.chip:hover {
	background: var(--surface-muted);
	text-decoration: none;
}

.chip--small {
	padding: 3px 10px;
	font-size: .82rem;
	color: var(--text-muted);
}

/* ---------- article ---------- */

.article {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 20px;
	box-shadow: var(--shadow);
}

.article__title {
	font-size: 1.7rem;
	line-height: 1.22;
	margin: 0 0 10px;
}

.article__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	font-size: .9rem;
	color: var(--text-muted);
	margin-bottom: 16px;
}

.article__image {
	display: block;
	width: 100%;
	border-radius: var(--radius-small);
	margin-bottom: 18px;
}

.article__content {
	font-size: 1.05rem;
}

.article__content img,
.article__content video {
	border-radius: var(--radius-small);
	margin: 12px 0;
}

.article__content figure {
	margin: 16px 0;
}

.article__content figcaption {
	font-size: .85rem;
	color: var(--text-muted);
}

.article__content blockquote {
	margin: 16px 0;
	padding: 4px 0 4px 16px;
	border-left: 3px solid var(--accent-color);
	color: var(--text-muted);
}

.article__content pre {
	overflow-x: auto;
	background: var(--surface-muted);
	padding: 12px;
	border-radius: var(--radius-small);
}

.article__content table {
	display: block;
	overflow-x: auto;
	border-collapse: collapse;
}

.article__content th,
.article__content td {
	border: 1px solid var(--line);
	padding: 6px 10px;
}

.article__terms {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 20px;
}

.article__footer {
	margin-top: 24px;
	padding-top: 16px;
	border-top: 1px solid var(--line);
}

.article__nocontent {
	color: var(--text-muted);
}

/* ---------- search ---------- */

.search__form {
	display: flex;
	gap: 8px;
	margin-bottom: 14px;
}

.search__input {
	flex: 1;
	min-width: 0;
	padding: 11px 16px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
}

.search__summary {
	margin: 0 0 12px;
	color: var(--text-muted);
	font-size: .92rem;
}

/* ---------- menu ---------- */

.menu-list {
	list-style: none;
	margin: 0;
	padding: 0;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
}

.menu-list__item + .menu-list__item {
	border-top: 1px solid var(--line);
}

.menu-list__link {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 15px 18px;
	color: var(--text);
}

.menu-list__item--empty {
	padding: 16px 18px;
}

/* Buttons registered by the subsystems: one look, wherever they were added. */
.actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.actions--feed-actions {
	margin-bottom: var(--gap);
}

.action.is-pressed {
	border-color: var(--accent-color);
	color: var(--accent-color);
}

.action[aria-busy="true"] {
	opacity: .7;
}

.menu-list__item--feature .menu-list__link {
	color: var(--accent-color);
}

.menu__footer {
	margin-top: 20px;
	display: grid;
	justify-items: start;
	gap: 10px;
}

.menu__version {
	margin: 0;
	font-size: .82rem;
	color: var(--text-muted);
}

/* ---------- states ---------- */

.state {
	text-align: center;
	padding: 44px 20px;
	max-width: 460px;
	margin: 0 auto;
}

.state__icon {
	display: flex;
	justify-content: center;
	margin-bottom: 14px;
	color: var(--text-muted);
}

.state__icon .icon {
	width: 42px;
	height: 42px;
}

.state__title {
	margin: 0 0 8px;
	font-size: 1.3rem;
}

.state__text {
	margin: 0;
	color: var(--text-muted);
}

.state__actions {
	margin-top: 20px;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: center;
}

.state--error .state__icon {
	color: var(--danger);
}

/* ---------- skeletons ---------- */

.card--skeleton {
	padding: 0 0 16px;
}

.skeleton {
	background: linear-gradient(90deg, var(--surface-muted) 25%, var(--line) 37%, var(--surface-muted) 63%);
	background-size: 400% 100%;
	animation: skeleton 1.4s ease infinite;
	border-radius: var(--radius-small);
}

.skeleton--image {
	aspect-ratio: 16 / 9;
	border-radius: 0;
	margin-bottom: 14px;
}

.skeleton--line {
	height: 14px;
	margin: 10px 16px;
}

.skeleton--title {
	height: 26px;
}

.skeleton--short {
	width: 55%;
}

@keyframes skeleton {
	0% {
		background-position: 100% 50%;
	}

	100% {
		background-position: 0 50%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.skeleton {
		animation: none;
	}
}

/* ---------- network, banners, toasts ---------- */

.net-bar {
	position: sticky;
	top: var(--header-height);
	z-index: 15;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px;
	padding: 8px 14px;
	background: #4b2e05;
	color: #ffe9c2;
	font-size: .92rem;
}

.net-bar .button--link {
	color: #ffd98a;
}

.net-bar__text {
	max-width: 60ch;
}

.banners {
	display: grid;
	gap: 1px;
}

.banner {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 14px;
	background: var(--surface);
	border-bottom: 1px solid var(--line);
	font-size: .93rem;
}

.banner__text {
	flex: 1;
}

.banner--update {
	background: var(--accent-color);
	color: #fff;
	border-bottom: 0;
}

.banner--update .button {
	background: #fff;
	color: var(--accent-color);
	border-color: transparent;
}

.notice {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	margin-bottom: 16px;
	border: 1px solid var(--line);
	border-radius: var(--radius-small);
	background: var(--surface-muted);
	font-size: .92rem;
	color: var(--text-muted);
}

.toasts {
	position: fixed;
	left: 50%;
	transform: translateX(-50%);
	bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 12px);
	z-index: 50;
	display: grid;
	gap: 8px;
	pointer-events: none;
}

.toast {
	padding: 10px 18px;
	border-radius: 999px;
	background: #1d2327;
	color: #fff;
	font-size: .92rem;
	box-shadow: var(--shadow);
}

.toast--good {
	background: var(--good);
}

/* ---------- bottom navigation ---------- */

.bottom-nav {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 30;
	display: flex;
	justify-content: space-around;
	padding-bottom: env(safe-area-inset-bottom, 0px);
	background: var(--surface);
	border-top: 1px solid var(--line);
}

.bottom-nav__item {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	height: var(--nav-height);
	color: var(--text-muted);
	font-size: .72rem;
}

.bottom-nav__item:hover {
	text-decoration: none;
}

.bottom-nav__item.is-active {
	color: var(--accent-color);
	font-weight: 600;
}

/* ---------- general-purpose pieces the subsystems reuse ---------- */

/*
 * A control that reads as a link and behaves as a button. `.button--link` above
 * is the same idea inside a row of buttons; this one is for a button sitting in
 * running text, where the padding of a button would push the line apart. It is
 * declared by the shell, like `.button` and `.state`, precisely so that a
 * subsystem does not have to bring its own.
 */
.link-button {
	display: inline;
	padding: 0;
	border: 0;
	background: none;
	color: var(--accent-color);
	font: inherit;
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.link-button:hover {
	text-decoration: none;
}

/*
 * A single-line text control. Declared by the shell so that a subsystem needing
 * one reuses it instead of inventing a fourth look for an input; `.nearby__field`
 * below is listed alongside rather than repeating the declarations, which is
 * what «переиспользует» has to mean in a file with no build step.
 */
.field,
.nearby__field {
	width: 100%;
	min-width: 0;
	padding: 11px 14px;
	border: 1px solid var(--line);
	border-radius: var(--radius-small);
	background: var(--surface);
	color: var(--text);
	font: inherit;
}

.field:focus-visible,
.nearby__field:focus-visible {
	outline: 2px solid var(--accent-color);
	outline-offset: 1px;
}

/* ---------- «Рядом»: the geolocation section ---------- */

/*
 * The map lays itself out inline, because it has to work in the record editor
 * in wp-admin as well, where this file is never loaded. Everything else on the
 * screen has only class names — and an unstyled list on a phone is not «looks
 * simpler», it is lines run together with no gap between one link and the next
 * and nothing big enough to hit with a thumb. That is what the rules below are
 * for: spacing, field widths, and a tap target of the size a finger needs.
 *
 * Messages and buttons on this screen reuse `.state`, `.state__text`, `.button`
 * and `.link-button`, which the shell already owns, so there is nothing about
 * them here.
 */

/*
 * One knob for the height of every map on this screen — the answer list has
 * one and the manual form has another, and they have no reason to differ.
 * `height` rather than `min-height`: the map sets `min-height: 240px` on itself
 * inline and reads `clientHeight` back to work out how many tiles to fetch, so
 * the box has to be settled before it draws rather than after.
 */
.nearby {
	--map-height: 260px;
}

.nearby__body {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.nearby__place {
	margin: 0;
	color: var(--text-muted);
	font-size: .92rem;
	line-height: 1.5;
}

.nearby__result {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.nearby__map {
	height: var(--map-height);
	border: 1px solid var(--line);
	border-radius: var(--radius);
}

.nearby__list {
	list-style: none;
	margin: 0;
	padding: 0;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
}

.nearby__item + .nearby__item {
	border-top: 1px solid var(--line);
}

.nearby__item {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 10px;
	padding: 14px 18px;
}

/*
 * The whole row is the target, not just the run of text in it. The link is one
 * of three children of the row and cannot wrap the other two, so it grows a
 * layer over the row instead: a title of two words is then a target about fifty
 * pixels tall and the full width of the screen, which is what a thumb needs.
 * Nothing else in the row is interactive, so the layer covers nothing that
 * could have been tapped.
 */
.nearby__link {
	flex: 1 1 60%;
	min-width: 0;
	color: var(--text);
	font-weight: 500;
	line-height: 1.35;
}

.nearby__link::after {
	content: "";
	position: absolute;
	inset: 0;
}

.nearby__item:hover {
	background: var(--surface-muted);
}

.nearby__distance {
	flex: 0 0 auto;
	margin-left: auto;
	color: var(--accent-color);
	font-size: .9rem;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.nearby__date {
	flex: 1 1 100%;
	color: var(--text-muted);
	font-size: .82rem;
}

.nearby__manual {
	display: flex;
	flex-direction: column;
	gap: 12px;
	align-items: flex-start;
}

.nearby__explain {
	margin: 0;
	color: var(--text-muted);
	line-height: 1.5;
}

.nearby__manual .nearby__map {
	width: 100%;
}

/*
 * Two labelled numbers. One column on a phone, because a label and its field
 * side by side leave neither of them room; two from the width where they fit.
 */
.nearby__fields {
	display: grid;
	grid-template-columns: 1fr;
	gap: 6px 14px;
	width: 100%;
	max-width: 420px;
}

.nearby__label {
	color: var(--text-muted);
	font-size: .9rem;
}

.nearby__hint {
	margin: 0;
	min-height: 1.2em;
	color: var(--danger);
	font-size: .9rem;
}

/* ---------- wider screens ---------- */

@media (min-width: 800px) {
	:root {
		--content-width: 960px;
	}

	.nearby {
		--map-height: 380px;
	}

	.nearby__fields {
		grid-template-columns: auto 1fr;
		align-items: center;
	}

	.feed {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.screen {
		padding-bottom: var(--gap);
	}

	.bottom-nav {
		position: static;
		border-top: 1px solid var(--line);
	}

	.toasts {
		bottom: 20px;
	}
}

.body--offline .screen {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
}

/* ---------- отложенные действия: очередь и то, чем её наполняют ---------- */

/*
 * The queue screen and the four screens a person acts on. Everything here is
 * spacing and a tap target: an unstyled form on a telephone is fields running
 * into each other with nothing big enough to hit with a thumb. Colours and
 * controls come from the shell's own `.button`, `.field` and `.notice`, which
 * is why there is no second look for an input in this section.
 */
.sync__summary,
.sync-form__about,
.sync-form__who,
.sync-form__hint {
	margin: 0 0 var(--gap);
	color: var(--text-muted);
	font-size: .94rem;
}

.sync-list {
	list-style: none;
	margin: 0 0 var(--gap);
	padding: 0;
	display: grid;
	gap: 8px;
}

.sync-list__item {
	display: grid;
	gap: 2px;
	padding: 12px 14px;
	border: 1px solid var(--line);
	border-radius: var(--radius-small);
	background: var(--surface);
}

.sync-list__state {
	color: var(--text-muted);
	font-size: .9rem;
}

.sync-list__error {
	color: var(--danger);
	font-size: .9rem;
}

.sync-form__head {
	margin-bottom: var(--gap);
}

.sync-form__row {
	display: grid;
	gap: 6px;
	margin-bottom: 14px;
}

.sync-form__label {
	color: var(--text-muted);
	font-size: .9rem;
}

.sync-form__text {
	min-height: 120px;
	resize: vertical;
	font: inherit;
	line-height: 1.5;
}

/*
 * The line that says what became of what was pressed. It keeps its height when
 * it is empty so that the button under it does not jump out from under the
 * finger that is about to press it a second time.
 */
.sync-form__state {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	min-height: 1.4em;
	margin: 0 0 12px;
	font-size: .94rem;
	color: var(--text);
}

.sync-login {
	color: var(--text);
}

.sync-rate {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 12px;
}

.sync-rate__star {
	min-width: 48px;
	min-height: 44px;
	justify-content: center;
	font-variant-numeric: tabular-nums;
}

.sync-rate__star.is-pressed {
	border-color: var(--accent-color);
	color: var(--accent-color);
}
