/* Apron's design tokens (apron-web src/lib/design/tokens.css), the ones this page uses.
   Dark is the reference theme; light is its equal. The terminal's colors come from
   these too (src/screen.js terminalTheme), as in apron-web. */
:root {
	color-scheme: dark light;
	--bg-000: #10101a;
	--bg-100: #15151f;
	--bg-200: #1d1d29;
	--bg-rail: #0b0b12;
	--line: #2a2a38;
	--line-strong: #6d6d80;
	--ink: #ece9e4;
	--ink-muted: #a8a6b2;
	--accent: #f28a3c;
	--on-accent: #1c0f07;
	--denim: #8fb0f5;
	--denim-soft: #1e2b48;
	--danger: #ff6f86;
	--warn: #d6b24c;
	--ok: #62c287;
	--term-magenta: #d99be8;
	--term-cyan: #6cc9d1;
	--font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	--font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
	--text-sm: 12px;
	--text-ui: 13px;
	--text-field: 14px;
	--text-body: 15px;
	--text-title: 18px;
	--text-field-ios: 16px;
	--space-1: 4px;
	--space-2: 8px;
	--space-3: 12px;
	--space-4: 16px;
	--space-6: 24px;
	--radius-sm: 6px;
	--radius-md: 10px;
	--radius-full: 999px;
}

/* Light: the system's, unless the page is told dark (`theme=dark`); or told light (`theme=light`). */
@media (prefers-color-scheme: light) {
	:root:not([data-theme='dark']) {
		color-scheme: light;
		--bg-000: #ebe8e3;
		--bg-100: #f8f6f3;
		--bg-200: #f0ede8;
		--bg-rail: #dddad4;
		--line: #dfdad2;
		--line-strong: #7c776f;
		--ink: #1c1f33;
		--ink-muted: #5b5d6c;
		--accent: #a83c14;
		--on-accent: #ffffff;
		--denim: #2c56b6;
		--denim-soft: #e0e8f8;
		--danger: #b0173f;
		--warn: #7a5a00;
		--ok: #1c6c3d;
		--term-magenta: #8b3199;
		--term-cyan: #0e6a73;
	}
}

:root[data-theme='light'] {
	color-scheme: light;
	--bg-000: #ebe8e3;
	--bg-100: #f8f6f3;
	--bg-200: #f0ede8;
	--bg-rail: #dddad4;
	--line: #dfdad2;
	--line-strong: #7c776f;
	--ink: #1c1f33;
	--ink-muted: #5b5d6c;
	--accent: #a83c14;
	--on-accent: #ffffff;
	--denim: #2c56b6;
	--denim-soft: #e0e8f8;
	--danger: #b0173f;
	--warn: #7a5a00;
	--ok: #1c6c3d;
	--term-magenta: #8b3199;
	--term-cyan: #0e6a73;
}

:root[data-theme='dark'] {
	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	height: 100%;
}

body {
	margin: 0;
	height: 100%;
	display: flex;
	flex-direction: column;
	background: var(--bg-100);
	color: var(--ink);
	font: var(--text-body) / 1.5 var(--font-sans);
}

a {
	color: var(--denim);
}

code {
	font-family: var(--font-mono);
	font-size: 0.9em;
	overflow-wrap: anywhere;
}

[hidden] {
	display: none !important;
}

/* The bar: what it is, where it comes from, whether it is live. */
.bar {
	flex: none;
	display: flex;
	align-items: center;
	gap: var(--space-3);
	padding: calc(var(--space-2) + env(safe-area-inset-top, 0px)) max(var(--space-4), env(safe-area-inset-right, 0px)) var(--space-2) max(var(--space-4), env(safe-area-inset-left, 0px));
	border-bottom: 1px solid var(--line);
	background: var(--bg-200);
}

.brand {
	flex: none;
	display: flex;
}

.heading {
	flex: 1;
	min-width: 0;
}

.heading h1 {
	margin: 0;
	font-size: var(--text-body);
	font-weight: 600;
	line-height: 1.3;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	unicode-bidi: isolate;
}

.source {
	margin: 0;
	color: var(--ink-muted);
	font-size: var(--text-sm);
	line-height: 1.4;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.source strong {
	color: var(--ink);
	font-weight: 600;
}

.status {
	flex: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--ink-muted);
	font-size: var(--text-sm);
	white-space: nowrap;
}

.status[data-state='live'] {
	color: var(--accent);
	font-weight: 600;
}

.status[data-state='live']::before {
	content: '';
	width: 7px;
	height: 7px;
	border-radius: var(--radius-full);
	background: var(--accent);
	animation: blink 1.2s steps(1) infinite;
}

.status[data-state='failed'] {
	color: var(--danger);
}

@keyframes blink {
	50% {
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.status[data-state='live']::before {
		animation: none;
	}
}

.button {
	flex: none;
	padding: var(--space-1) var(--space-3);
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--ink);
	font: inherit;
	font-size: var(--text-ui);
	cursor: pointer;
}

.button:hover {
	background: var(--bg-100);
}

.button:focus-visible,
.field:focus-visible {
	outline: 2px solid var(--denim);
	outline-offset: 2px;
}

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

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

.app {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.app:focus {
	outline: none;
}

/* The stage: the screen, centered, as large as fits; it scrolls when the screen is larger, never the page. */
.stage {
	flex: 1;
	min-height: 0;
	overflow: auto;
	overscroll-behavior: contain;
	padding: var(--space-4) max(var(--space-4), env(safe-area-inset-right, 0px)) calc(var(--space-4) + env(safe-area-inset-bottom, 0px)) max(var(--space-4), env(safe-area-inset-left, 0px));
	background: var(--bg-000);
}

.screen {
	width: max-content;
	margin: 0 auto;
	overflow: hidden;
	background: var(--bg-rail);
	box-shadow: 0 0 0 var(--space-2) var(--bg-rail);
	color: var(--ink);
}

/* Scrolling is the stage's and src/screen.js's: xterm's own scrollbar would only duplicate it. */
.screen .xterm-viewport {
	overflow: hidden;
}

.note {
	margin: var(--space-4) auto 0;
	max-width: 36rem;
	color: var(--ink-muted);
	font-size: var(--text-ui);
	text-align: center;
}

/* Explanations: no stream, or one the page won't read. */
.card {
	width: 100%;
	max-width: 36rem;
	margin: var(--space-6) auto;
	padding: var(--space-6);
	border: 1px solid var(--line);
	border-radius: var(--radius-md);
	background: var(--bg-200);
}

@media (max-width: 600px) {
	.card {
		margin: var(--space-4) 0;
		border-left: 0;
		border-right: 0;
		border-radius: 0;
		padding: var(--space-4);
	}
}

.card h2 {
	margin: 0 0 var(--space-2);
	font-size: var(--text-title);
	line-height: 1.3;
}

.card p {
	margin: 0 0 var(--space-3);
}

.card p:last-child {
	margin-bottom: 0;
}

.card .muted {
	color: var(--ink-muted);
	font-size: var(--text-ui);
}

.open-box {
	margin: var(--space-4) 0;
}

.open-box:last-child {
	margin-bottom: 0;
}

.open {
	display: flex;
	gap: var(--space-2);
}

.field {
	flex: 1;
	min-width: 0;
	padding: var(--space-2) var(--space-3);
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-sm);
	background: var(--bg-100);
	color: var(--ink);
	font: inherit;
	font-size: var(--text-field);
}

@supports (-webkit-touch-callout: none) {
	.field {
		font-size: var(--text-field-ios);
	}
}

.field-error {
	margin-top: var(--space-2) !important;
	color: var(--danger);
	font-size: var(--text-ui);
}

/* In a chat message (an iframe, or `embed=1`): a slim bar over the screen, which shows only the rows written,
   as large as the width allows (src/screen.js INLINE_FIT). The page is as tall as that, and tells its parent
   (src/embed.js), which sizes the iframe to it. */
:root[data-embed],
:root[data-embed] body {
	height: auto;
}

:root[data-embed] body {
	background: var(--bg-rail);
}

:root[data-embed] .bar {
	gap: var(--space-2);
	padding: var(--space-1) var(--space-2);
}

:root[data-embed] .brand img {
	width: 16px;
	height: 16px;
}

:root[data-embed] .heading h1 {
	font-size: var(--text-ui);
}

:root[data-embed] .source {
	display: none;
}

:root[data-embed] .button {
	padding: 0 var(--space-2);
	font-size: var(--text-sm);
	line-height: 22px;
	text-decoration: none;
}

:root[data-embed] .app,
:root[data-embed] .stage {
	flex: none;
}

:root[data-embed] .stage {
	overflow: visible;
	padding: var(--space-2);
	background: var(--bg-rail);
}

:root[data-embed] .screen {
	margin: 0;
	box-shadow: none;
}

:root[data-embed] .note {
	margin: var(--space-2);
	text-align: left;
	font-size: var(--text-sm);
}

:root[data-embed] .stage .note {
	margin: var(--space-1) 0 0;
}
