/* style.css: the look of the ostro web page.
 *
 * Two surfaces. The controls live on a dark "night" rail; what the program
 * draws and writes lies on light paper next to it. Colours of controls come
 * from the custom properties below, which the rail overrides, so a button or
 * a field is written once and fits both surfaces.
 *
 * The page has no inline styles (the Content-Security-Policy forbids them).
 */

:root {
	/* Night: the rail. */
	--night: #171c36;
	--night-raised: #1f2547;
	--night-field: #262d58;
	--night-line: #3b4479;
	--vellum: #f4f1e8;
	--vellum-dim: #b9bcd3;
	--brass: #dfb352;

	/* Paper: the drawing and the report. */
	--mist: #eceef2;
	--plate: #fcfcfa;
	--ink: #1c2030;
	--ink-dim: #5a6072;
	--rule: #d5d8e0;

	/* What controls use; these are the paper values. */
	--text: var(--ink);
	--muted: var(--ink-dim);
	--border: #c3c7d2;
	--control: var(--plate);
	--control-hover: #f1f2f5;
	--field: #ffffff;
	--primary: var(--night);
	--primary-text: var(--vellum);
	--focus: #1e4fa3;
	--error: #a3273f;

	--serif: ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;
	--sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

	--rail-pad: 1.5rem;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

/* Several elements below set their own display; hidden must still win. */
[hidden] {
	display: none !important;
}

/* No rubber-band bounce when a scroll reaches the top or the bottom. */
html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	overscroll-behavior: none;
}

body {
	margin: 0;
	background: var(--mist);
	color: var(--ink);
	font-family: var(--sans);
	font-size: 1rem;
	line-height: 1.5;
}

h1,
h2,
h3,
p,
ul,
figure,
fieldset {
	margin: 0;
	padding: 0;
}

:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

/* --- Page layout ---------------------------------------------------------- */

.app {
	display: grid;
	grid-template-columns: minmax(21rem, 25rem) minmax(0, 1fr);
	grid-template-areas:
		"rail stage"
		"rail report"
		"rail footer";
	grid-template-rows: auto 1fr auto;
	min-height: 100vh;
}

.rail {
	grid-area: rail;
	position: sticky;
	top: 0;
	align-self: start;
	height: 100vh;
	overflow-y: auto;
	overscroll-behavior: none;
	display: flex;
	flex-direction: column;
	background: var(--night);
	color: var(--vellum);
	color-scheme: dark;

	--text: var(--vellum);
	--muted: var(--vellum-dim);
	--border: var(--night-line);
	--control: transparent;
	--control-hover: var(--night-field);
	--field: var(--night-field);
	--primary: var(--brass);
	--primary-text: var(--night);
	--focus: var(--brass);
	--error: #ffb0b0;
}

.stage {
	grid-area: stage;
	width: 100%;
	/* The whole wheel fits the height of the window. */
	max-width: max(26rem, min(60rem, calc(100vh - 6rem)));
	margin: 0 auto;
	padding: 1.5rem 2rem 0;
}

.report {
	grid-area: report;
	width: 100%;
	max-width: 60rem;
	margin: 0 auto;
	padding: 2.5rem 2rem 1rem;
}

.footer {
	grid-area: footer;
	width: 100%;
	max-width: 60rem;
	margin: 0 auto;
	padding: 1.5rem 2rem 2.5rem;
	color: var(--ink-dim);
	font-size: 0.85rem;
}

.footer p {
	max-width: 70ch;
}

.footer p + p {
	margin-top: 0.5rem;
}

.footer a {
	color: inherit;
}

/* --- Rail: masthead ------------------------------------------------------- */

.masthead {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	padding: var(--rail-pad) var(--rail-pad) 1.25rem;
}

.brand h1 {
	font-family: var(--serif);
	font-size: 2.75rem;
	font-weight: 500;
	line-height: 1;
	letter-spacing: -0.02em;
}

.brand p {
	margin-top: 0.6rem;
	color: var(--muted);
	font-size: 0.9rem;
	line-height: 1.4;
	max-width: 22ch;
}

.lang {
	display: flex;
	flex: none;
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 2px;
}

.lang button {
	border: 0;
	border-radius: 999px;
	padding: 0.25rem 0.7rem;
	font-size: 0.8rem;
	color: var(--muted);
	white-space: nowrap;
}

.lang button[aria-pressed="true"] {
	background: var(--vellum);
	color: var(--night);
}

/* --- Rail: the form ------------------------------------------------------- */

.controls {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 1rem;
	padding: 0 var(--rail-pad);
}

.hint {
	color: var(--muted);
	font-size: 0.85rem;
	line-height: 1.45;
}

#charts {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.chart-card {
	background: var(--night-raised);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0.85rem 0.9rem 1rem;
}

.chart-card header {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.75rem;
}

/* A small ring in the colour this chart has in the drawing. */
.ring-mark {
	flex: none;
	width: 0.95rem;
	height: 0.95rem;
	border: 3px solid;
	border-radius: 50%;
}

.chart-card h2 {
	font-size: 0.95rem;
	font-weight: 600;
}

.ring-label {
	color: var(--muted);
	font-size: 0.8rem;
}

.chart-card header .link {
	margin-left: auto;
}

.grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.7rem 0.6rem;
}

.wide {
	grid-column: 1 / -1;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	min-width: 0;
}

.field > span,
.place > span {
	color: var(--muted);
	font-size: 0.8rem;
}

/* Says where an automatically filled UTC offset comes from. */
.zone-note {
	margin-top: -0.3rem;
	color: var(--muted);
	font-size: 0.8rem;
	line-height: 1.4;
}

.place {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	margin-top: 0.15rem;
}

input[type="text"],
input[type="search"],
input[type="date"],
input[type="time"] {
	width: 100%;
	min-width: 0;
	height: 2.4rem;
	padding: 0 0.6rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--field);
	color: var(--text);
	font: inherit;
	font-variant-numeric: tabular-nums;
}

input::placeholder {
	color: var(--muted);
	opacity: 0.75;
}

button,
.file-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.25rem;
	padding: 0.35rem 0.8rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--control);
	color: var(--text);
	font: inherit;
	font-size: 0.875rem;
	line-height: 1.2;
	cursor: pointer;
}

button:hover:not(:disabled),
.file-button:hover {
	background: var(--control-hover);
}

button:disabled {
	opacity: 0.55;
	cursor: default;
}

button.primary {
	border-color: var(--primary);
	background: var(--primary);
	color: var(--primary-text);
	font-weight: 600;
}

button.primary:hover:not(:disabled) {
	background: var(--primary);
	filter: brightness(1.08);
}

button.link {
	min-height: 0;
	padding: 0.1rem 0.2rem;
	border: 0;
	background: none;
	color: var(--muted);
	font-size: 0.8rem;
	text-decoration: underline;
	text-underline-offset: 2px;
}

button.link:hover:not(:disabled) {
	background: none;
	color: var(--text);
}

.row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

/* --- Rail: saved charts --------------------------------------------------- */

.saved {
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0.65rem 0.9rem;
}

.saved summary {
	cursor: pointer;
	font-size: 0.95rem;
	font-weight: 600;
}

.saved[open] summary {
	margin-bottom: 0.4rem;
}

.saved-list {
	max-height: 18rem;
	margin-top: 0.4rem;
	overflow-y: auto;
	overscroll-behavior: contain;
	list-style: none;
}

.saved-list li {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 0;
	border-top: 1px solid var(--border);
}

.saved-text {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.saved-name {
	overflow: hidden;
	font-size: 0.9rem;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.saved-details {
	color: var(--muted);
	font-size: 0.8rem;
	font-variant-numeric: tabular-nums;
}

.saved-list button:not(.link) {
	min-height: 2rem;
	padding: 0.25rem 0.7rem;
}

/* The real file input stays in the page (for the keyboard) but is not seen. */
.file-button {
	position: relative;
}

.file-button input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.file-button:focus-within {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

.options {
	display: flex;
	flex-direction: column;
	gap: 0.7rem;
	border: 0;
	border-top: 1px solid var(--border);
	padding-top: 0.9rem;
}

.options legend {
	float: left; /* keeps the legend inside the box, below the top border */
	width: 100%;
	padding: 0;
	font-size: 0.95rem;
	font-weight: 600;
}

.check {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.9rem;
}

.check input {
	width: 1rem;
	height: 1rem;
	margin: 0;
	accent-color: var(--brass);
}

/* The draw button stays in reach at the foot of the rail. */
.action {
	position: sticky;
	bottom: 0;
	margin: auto calc(-1 * var(--rail-pad)) 0;
	padding: 0.9rem var(--rail-pad) 1.1rem;
	border-top: 1px solid var(--border);
	background: var(--night);
}

.action .primary {
	width: 100%;
	min-height: 2.75rem;
	font-size: 1rem;
}

.status {
	margin-top: 0.6rem;
	color: var(--muted);
	font-size: 0.875rem;
	line-height: 1.4;
}

.status:empty {
	display: none;
}

.status.error {
	color: var(--error);
}

/* --- Stage: the drawing --------------------------------------------------- */

.toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.75rem 1.5rem;
	min-height: 2.25rem;
	margin-bottom: 0.9rem;
}

.caption {
	flex: 1 1 16rem;
}

.summary {
	font-family: var(--serif);
	font-size: 1.1rem;
	line-height: 1.4;
}

.warning {
	margin-top: 0.5rem;
	padding: 0.5rem 0.75rem;
	border-left: 3px solid #a85a00;
	border-radius: 0 6px 6px 0;
	background: #fdf4e7;
	color: #6b3900;
	font-size: 0.875rem;
}

.saves {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

/* The hidden field app.js copies from when the Clipboard API is missing. */
.copy-buffer {
	position: fixed;
	top: 0;
	left: -9999px;
	opacity: 0;
}

.plate {
	aspect-ratio: 1;
	overflow: hidden;
	border: 1px solid var(--rule);
	border-radius: 12px;
	background: var(--plate);
}

.plate img {
	display: block;
	width: 100%;
	height: auto;
}

/* --- The report ----------------------------------------------------------- */

.report h1,
.report h2,
.report h3 {
	font-family: var(--serif);
	font-weight: 500;
	line-height: 1.25;
}

.report h1 {
	font-size: 1.9rem;
	letter-spacing: -0.01em;
}

.report h2 {
	margin-top: 2.25rem;
	padding-top: 1.1rem;
	border-top: 1px solid var(--rule);
	font-size: 1.35rem;
}

.report h3 {
	margin-top: 1.5rem;
	font-size: 1.1rem;
}

.report p {
	max-width: 72ch;
	margin-top: 0.75rem;
}

.report blockquote {
	margin: 0.9rem 0 0;
	padding: 0.1rem 0 0.1rem 1rem;
	border-left: 3px solid var(--rule);
	color: var(--ink-dim);
	font-size: 0.925rem;
}

.report blockquote p {
	margin-top: 0;
}

.table-scroll {
	margin-top: 0.9rem;
	overflow-x: auto;
}

.report table {
	border-collapse: collapse;
	font-size: 0.9rem;
	font-variant-numeric: tabular-nums;
}

.report th,
.report td {
	padding: 0.4rem 1.25rem 0.4rem 0;
	border-bottom: 1px solid var(--rule);
	text-align: left;
	white-space: nowrap;
}

.report th {
	border-bottom-color: var(--ink);
	color: var(--ink-dim);
	font-size: 0.8rem;
	font-weight: 600;
}

.report tbody tr:last-child td {
	border-bottom: 0;
}

/* --- The map dialog ------------------------------------------------------- */

.map-dialog {
	width: min(44rem, calc(100vw - 1.5rem));
	max-height: calc(100vh - 1.5rem);
	padding: 1.25rem;
	border: 0;
	border-radius: 14px;
	background: var(--plate);
	color: var(--ink);
	box-shadow: 0 24px 60px rgba(23, 28, 54, 0.35);
}

.map-dialog::backdrop {
	background: rgba(23, 28, 54, 0.6);
}

.map-dialog h2 {
	font-family: var(--serif);
	font-size: 1.4rem;
	font-weight: 500;
}

.map-search {
	display: flex;
	align-items: flex-end;
	gap: 0.5rem;
	margin-top: 0.9rem;
}

.map-search .field {
	flex: 1;
}

.map-search button {
	height: 2.4rem;
}

.map-status {
	margin-top: 0.4rem;
	color: var(--ink-dim);
	font-size: 0.85rem;
}

.map-status:empty {
	display: none;
}

.map-results {
	max-height: 9.5rem;
	margin-top: 0.4rem;
	overflow-y: auto;
	list-style: none;
}

.map-results:empty {
	display: none;
}

.map-results button {
	display: block;
	width: 100%;
	min-height: 0;
	padding: 0.45rem 0.5rem;
	border: 0;
	border-bottom: 1px solid var(--rule);
	border-radius: 0;
	font-size: 0.875rem;
	line-height: 1.35;
	text-align: left;
}

.map-frame {
	position: relative;
	margin-top: 0.75rem;
}

.map-view {
	position: relative;
	height: min(26rem, 48vh);
	overflow: hidden;
	border: 1px solid var(--rule);
	border-radius: 8px;
	background: #dfe3ea;
	cursor: crosshair;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
}

.map-tiles img {
	position: absolute;
	top: 0;
	left: 0;
	max-width: none;
	pointer-events: none;
}

/* The pin is a point with no size; the drop shape hangs above it, tip on the place. */
.map-pin {
	position: absolute;
	top: 0;
	left: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

.map-pin::after {
	content: "";
	position: absolute;
	top: -29px;
	left: -12px;
	width: 24px;
	height: 24px;
	border: 2px solid #ffffff;
	border-radius: 50% 50% 50% 0;
	background: #a3273f;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
	transform: rotate(-45deg);
}

/* Shown when no tile server can be reached. */
.map-offline {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 2rem 3.5rem;
	color: var(--ink);
	text-align: center;
}

.map-zoom {
	position: absolute;
	top: 0.6rem;
	right: 0.6rem;
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.map-zoom button {
	width: 2.25rem;
	padding: 0;
	background: #ffffff;
	font-size: 1.15rem;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.map-credit {
	position: absolute;
	right: 1px;
	bottom: 1px;
	padding: 0.1rem 0.4rem;
	border-radius: 6px 0 7px 0;
	background: rgba(255, 255, 255, 0.85);
	color: var(--ink);
	font-size: 0.7rem;
}

.map-help,
.map-privacy {
	margin-top: 0.6rem;
	color: var(--ink-dim);
	font-size: 0.825rem;
}

.map-footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin-top: 0.9rem;
}

.map-readout {
	flex: 1 1 12rem;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

/* --- Narrow screens ------------------------------------------------------- */
/* One column. The rail dissolves, so that the drawing can sit between the
   masthead and the form: the first thing on the page is still a chart. */

@media (max-width: 900px) {
	.app {
		display: flex;
		flex-direction: column;
	}

	.rail {
		display: contents;
	}

	.masthead,
	.controls {
		background: var(--night);
		color: var(--vellum);
	}

	.masthead {
		order: 1;
		padding-bottom: var(--rail-pad);
	}

	.stage {
		order: 2;
		max-width: 40rem;
		padding: 1.25rem 1rem 1.5rem;
		scroll-margin-top: 0.5rem;
	}

	.controls {
		order: 3;
		flex: none;
		padding-top: var(--rail-pad);
	}

	.report {
		order: 4;
		padding: 2rem 1rem 1rem;
	}

	.footer {
		order: 5;
		padding: 1.5rem 1rem 2rem;
	}

	.brand h1 {
		font-size: 2.25rem;
	}

	.brand p {
		max-width: none;
	}

	.map-dialog {
		padding: 1rem;
	}

	.map-view {
		height: min(22rem, 42vh);
	}
}
