/*
  Flowdrive: first upload, from a dropped file to a link you can copy.
  Ported from flowdrive-v2 /onboard/3 (drop zone, file card, dot upload bar) and
  /onboard/4 (the link with Copy). Tokens are the light-mode values from src/app.css.
*/

:root {
	--stage: oklch(0.215 0.006 107);

	/* src/app.css, light mode */
	--background: oklch(0.985 0.001 106.4);
	--card: oklch(1 0 0);
	--stone-100: oklch(0.97 0.001 106.4);
	--stone-200: oklch(0.923 0.003 48.7);
	--stone-300: oklch(0.869 0.004 56.4);
	--stone-400: oklch(0.716 0.009 56.3);
	--stone-500: oklch(0.553 0.012 58.1);
	--stone-600: oklch(0.444 0.01 73.6);
	--stone-700: oklch(0.374 0.009 67.6);
	--stone-900: oklch(0.216 0.006 56);
	--primary: oklch(0.685 0.194 45);
	--primary-500: oklch(0.666 0.205 40.2);
	--emerald-500: oklch(0.696 0.17 162.48);

	/* One unit of the real layout: 1px in a 1000px tile (the product's own sizes), down
	   to 0.75px in a 320px one. Type never goes under 11px (see the --fs-* tokens). */
	--u: clamp(0.75px, 0.632px + 0.0368vw, 1px);
	--pad: clamp(14px, 6.2vw - 6px, 40px);
	--margin: clamp(14px, 4.4vw, 48px);

	--fs-base: max(11px, calc(16 * var(--u)));
	--fs-sm: max(11px, calc(14 * var(--u)));
	--fs-xs: max(11px, calc(12 * var(--u)));
	--fs-mono: max(11px, calc(13 * var(--u)));

	--ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html,
body {
	height: 100%;
	margin: 0;
	overflow: hidden;
}

body {
	background: var(--stage);
	color: var(--stone-900);
	font-family: 'Open Sans', 'Inter', ui-sans-serif, system-ui, sans-serif;
	font-size: var(--fs-base);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

p {
	margin: 0;
}

button {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

svg {
	display: block;
	flex: none;
}

[hidden] {
	display: none !important;
}

:focus {
	outline: none;
}

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

/* ── Stage and the page it sits on ─────────────────────────────────────────── */

.stage {
	display: grid;
	place-items: center;
	height: 100%;
}

/* The onboarding page's own background, cut down to the column that holds the upload */
.panel {
	width: min(calc(554 * var(--u) + 2 * var(--pad)), calc(100vw - 2 * var(--margin)));
	overflow: hidden;
	border-radius: calc(20 * var(--u));
	background: var(--background);
}

.panel.is-ready {
	transition: height 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.content {
	display: flex;
	flex-direction: column;
	gap: calc(12 * var(--u));
	padding: var(--pad);
	transition: opacity 180ms var(--ease);
}

.content.is-fading {
	opacity: 0;
}

.strong {
	font-size: var(--fs-base);
	line-height: 1.5;
	color: var(--stone-900);
}

.muted {
	font-size: var(--fs-sm);
	line-height: calc(20 / 14);
	color: var(--stone-500);
}

/* ── Dot-matrix tile (v3/dot-matrix.svelte): 48px, 9×9 dots of 2px ─────────── */

.tile {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: max(40px, calc(48 * var(--u)));
	height: max(40px, calc(48 * var(--u)));
	border: 1px solid var(--stone-200);
	border-radius: calc(8 * var(--u));
	background: var(--stone-100);
}

.tile.is-dashed {
	border-style: dashed;
}

.tile-grid {
	display: grid;
	/* Whole pixels at every size, so the glyph stays crisp */
	grid-template-columns: repeat(9, 2px);
	gap: 1px;
}

.tile-grid span {
	width: 2px;
	height: 2px;
	border-radius: 50%;
	background: var(--stone-300);
}

.tile-grid .o {
	background: var(--stone-400);
}

.tile-grid .O {
	background: var(--stone-500);
}

.tile[data-glyph='live'] .o {
	background: color-mix(in oklab, var(--emerald-500) 40%, transparent);
}

.tile[data-glyph='live'] .O {
	background: var(--emerald-500);
}

/* Tailwind's animate-pulse, on the light dots only */
.tile.is-pulse .O {
	animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
	50% {
		opacity: 0.5;
	}
}

/* ── Drop zone ─────────────────────────────────────────────────────────────── */

.zone {
	display: flex;
	align-items: center;
	gap: calc(16 * var(--u));
	width: 100%;
	padding: calc(16 * var(--u));
	border: max(1.5px, calc(2 * var(--u))) dashed var(--stone-200);
	border-radius: calc(16 * var(--u));
	background: var(--stone-100);
	cursor: pointer;
	transition:
		color 150ms var(--ease),
		background-color 150ms var(--ease),
		border-color 150ms var(--ease);
}

.zone:hover {
	border-color: var(--stone-300);
}

.zone.is-over {
	border-color: var(--primary);
}

.zone-text {
	flex: 1;
	min-width: 0;
}

.zone-text p {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ── File card ─────────────────────────────────────────────────────────────── */

.card {
	display: flex;
	align-items: center;
	gap: calc(16 * var(--u));
	width: 100%;
	padding: calc(16 * var(--u));
	border: 1px dashed var(--stone-200);
	border-radius: calc(16 * var(--u));
}

.card.is-done {
	border-style: solid;
	background: var(--card);
}

.card-body {
	flex: 1;
	min-width: 0;
}

.card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: calc(12 * var(--u));
}

.name {
	overflow: hidden;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
	font-size: var(--fs-mono);
	color: var(--stone-900);
	text-overflow: ellipsis;
	white-space: nowrap;
}

.x {
	flex: none;
	border-radius: 4px;
	color: var(--stone-500);
}

.x:hover {
	color: var(--stone-900);
}

.x svg,
.ok svg,
.copy svg {
	width: calc(16 * var(--u));
	height: calc(16 * var(--u));
}

/* v3/dot-progress.svelte: one row of dots lighting up orange from the left.
   The cell is square and the gap is padding inside it, so dots keep their shape. */
.dots {
	display: grid;
	grid-template-columns: repeat(var(--cols, 40), minmax(0, 1fr));
	margin-top: calc(10 * var(--u));
}

.dots span {
	aspect-ratio: 1;
	padding: 16%;
}

.dots i {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	background: var(--stone-300);
	transition: background-color 300ms var(--ease);
}

.dots i.is-lit {
	background: var(--primary-500);
}

.pct {
	margin-top: calc(6 * var(--u));
	font-size: var(--fs-xs);
	line-height: calc(16 / 12);
	color: var(--stone-500);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.ok {
	display: flex;
	align-items: center;
	gap: calc(4 * var(--u));
	margin-top: calc(4 * var(--u));
	font-size: var(--fs-sm);
	line-height: calc(20 / 14);
	color: #00a63e;
	white-space: nowrap;
}

/* ── The link (step 4) ─────────────────────────────────────────────────────── */

.link {
	display: flex;
	align-items: center;
	gap: calc(8 * var(--u));
	width: 100%;
	height: calc(56 * var(--u));
	padding: 0 calc(8 * var(--u)) 0 calc(20 * var(--u));
	border: 1px solid var(--stone-200);
	border-radius: 9999px;
	background: var(--card);
	animation: rise 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
	from {
		opacity: 0;
		transform: translateY(calc(8 * var(--u)));
	}
}

.link-url {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
	font-size: var(--fs-sm);
	line-height: calc(20 / 14);
	color: var(--stone-700);
	text-overflow: ellipsis;
	white-space: nowrap;
}

.copy {
	display: flex;
	flex: none;
	align-items: center;
	gap: calc(6 * var(--u));
	height: calc(40 * var(--u));
	padding: 0 calc(12 * var(--u));
	border-radius: 9999px;
	font-size: var(--fs-sm);
	line-height: calc(20 / 14);
	color: var(--stone-600);
}

.copy:hover,
.copy.is-pressed {
	background: var(--stone-100);
}

.copy .i-check,
.copy.is-copied .i-copy {
	display: none;
}

.copy.is-copied .i-check {
	display: block;
}

/* ── Error box ─────────────────────────────────────────────────────────────── */

.error {
	display: flex;
	align-items: center;
	gap: calc(8 * var(--u));
	margin-bottom: calc(12 * var(--u));
	padding: calc(16 * var(--u));
	border-radius: calc(16 * var(--u));
	background: #ffeceb;
	color: #fd0d00;
	font-size: var(--fs-base);
	line-height: 1.5;
}

.error svg {
	width: calc(24 * var(--u));
	height: calc(24 * var(--u));
}

/* ── Reduced motion: one still state, no pulsing, no travel ────────────────── */

@media (prefers-reduced-motion: reduce) {
	.panel.is-ready,
	.content,
	.zone,
	.dots i {
		transition: none;
	}

	.link,
	.tile.is-pulse .O {
		animation: none;
	}
}
