/* ============================================================
   Flash Order — Onboarding
   ============================================================ */

:root {
	--fo-seasalt:        #FAFAFA;
	--fo-soft-black:     #252525;
	--fo-bright-orange:  #E76933;
	--fo-soft-orange:    #F6D9CC;
	--fo-off-white:      #EDEDED;
	--fo-light-gray:     #E1E2E3;
	--fo-cool-gray:      #5B5B5B;
	--fo-dark-gray:      #404040;
	--fo-green:          #629460;
	--fo-red:            #D1462F;

	--fo-font-sans:    "General Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--fo-font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

	--fo-radius-sm: 10px;
	--fo-radius-md: 14px;
	--fo-radius-pill: 999px;

	--fo-shadow-sm: 0 2px 8px rgba(37, 37, 37, 0.06);
	--fo-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
	height: 100%;
	background: var(--fo-seasalt);
	color: var(--fo-soft-black);
	font-family: var(--fo-font-sans);
	font-size: 16px;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
}

#app {
	position: relative;
	width: 100%;
	height: 100%;
	max-width: 480px;
	margin: 0 auto;
	overflow: hidden;
}

/* --- Screens ------------------------------------------------ */

.screen {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	opacity: 0;
	pointer-events: none;
	transform: translateX(40px);
	transition: opacity 0.35s var(--fo-ease-out), transform 0.35s var(--fo-ease-out);
}

.screen.active {
	opacity: 1;
	pointer-events: auto;
	transform: translateX(0);
}

.screen.exit-left {
	opacity: 0;
	transform: translateX(-40px);
}

.screen-content {
	flex: 1;
	display: flex;
	flex-direction: column;
	padding: 24px;
}

.screen-pad {
	padding: 16px 24px 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

/* --- Screen header ------------------------------------------ */

.screen-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 20px 8px;
}

.screen-header .spacer { width: 32px; }

.step-label {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

.back-btn {
	background: none;
	border: none;
	font-size: 18px;
	color: var(--fo-soft-black);
	cursor: pointer;
	padding: 4px 8px;
	width: 32px;
}

/* --- Step dots ---------------------------------------------- */

.step-dots {
	display: flex;
	gap: 5px;
	padding: 0 20px 10px;
}

.step-dots .dot-seg {
	height: 3px;
	flex: 1;
	border-radius: 2px;
	background: var(--fo-light-gray);
	transition: background 0.3s;
}

.step-dots .dot-seg.filled {
	background: var(--fo-soft-black);
}

/* --- Typography --------------------------------------------- */

h1 {
	font-size: 28px;
	font-weight: 700;
	letter-spacing: -0.02em;
	line-height: 1.1;
}

h2 {
	font-size: 22px;
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.15;
}

p.muted {
	font-size: 13px;
	color: var(--fo-cool-gray);
	line-height: 1.5;
}

.eyebrow {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.18em;
	text-transform: uppercase;
}

.eyebrow.accent {
	color: var(--fo-bright-orange);
}

/* --- Buttons ------------------------------------------------ */

.btn-primary {
	display: block;
	width: 100%;
	padding: 14px;
	border: 1.5px solid var(--fo-soft-black);
	border-radius: var(--fo-radius-pill);
	background: var(--fo-soft-black);
	color: var(--fo-seasalt);
	font-family: var(--fo-font-sans);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-align: center;
	cursor: pointer;
	transition: opacity 0.15s;
}

.btn-primary:active { opacity: 0.8; }

.btn-ghost {
	display: block;
	width: 100%;
	padding: 14px;
	border: 1.5px dashed var(--fo-light-gray);
	border-radius: var(--fo-radius-pill);
	background: transparent;
	color: var(--fo-soft-black);
	font-family: var(--fo-font-sans);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-align: center;
	cursor: pointer;
	transition: opacity 0.15s;
}

.btn-ghost:active { opacity: 0.7; }

.btn-secondary {
	display: block;
	width: 100%;
	padding: 14px;
	border: 1.5px solid var(--fo-soft-black);
	border-radius: var(--fo-radius-pill);
	background: transparent;
	color: var(--fo-soft-black);
	font-family: var(--fo-font-sans);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-align: center;
	cursor: pointer;
	transition: opacity 0.15s, background 0.15s;
}

.btn-secondary:active { opacity: 0.7; }

.hidden { display: none !important; }

/* --- Welcome screen ----------------------------------------- */

.welcome-content {
	justify-content: space-between;
	padding: 48px 24px 24px;
}

.welcome-top {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.welcome-bottom {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.welcome-notice {
	margin-top: 4px;
	padding: 10px 14px;
	border-radius: 10px;
	background: #fff4e5;
	border: 1px solid #f0c98a;
	color: #6b3d00;
	font-size: 14px;
	line-height: 1.4;
}

.fo-logo-mark {
	width: 44px;
	height: 44px;
}

.fo-logo-mark img {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 50%;
}

/* --- Square connect screen ---------------------------------- */

.square-content {
	justify-content: space-between;
	padding: 20px 24px 24px;
}

.square-top {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.square-bottom {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.permissions-box {
	border: 1.25px dashed var(--fo-light-gray);
	border-radius: 8px;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.permissions-label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 11px;
	color: var(--fo-cool-gray);
}

.permissions-label .dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--fo-light-gray);
}

.perm-item {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	color: var(--fo-soft-black);
}

.perm-item::before {
	content: "\2713";
	color: var(--fo-green);
	font-weight: 700;
}

.alt-link {
	font-size: 11px;
	color: var(--fo-cool-gray);
	text-align: center;
}

.alt-link a {
	color: var(--fo-soft-black);
	text-decoration: underline;
}

/* --- Sign-in options (returning user) ----------------------- */

.signin-content {
	justify-content: space-between;
	padding: 20px 24px 24px;
}

.signin-top {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.signin-bottom {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.or-divider {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--fo-cool-gray);
	font-size: 10px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	margin: 4px 0;
}

.or-divider::before,
.or-divider::after {
	content: "";
	flex: 1;
	height: 1px;
	background: var(--fo-light-gray);
}

/* --- Code entry --------------------------------------------- */

.code-content {
	justify-content: space-between;
	padding: 20px 24px 24px;
}

.code-top {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.code-bottom {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.code-boxes {
	display: flex;
	gap: 8px;
	margin-top: 8px;
}

.code-box {
	flex: 1;
	min-width: 0;
	aspect-ratio: 1 / 1.2;
	border: 1.25px solid var(--fo-light-gray);
	border-radius: 8px;
	background: transparent;
	font-family: var(--fo-font-mono);
	font-size: 22px;
	font-weight: 700;
	color: var(--fo-soft-black);
	text-align: center;
	-webkit-appearance: none;
	appearance: none;
}

.code-box:focus {
	outline: none;
	border-color: var(--fo-bright-orange);
	border-width: 1.5px;
}

.code-box:not(:placeholder-shown),
.code-box[value]:not([value=""]) {
	border-color: var(--fo-soft-black);
}

/* While the verify request is in flight, dim the boxes and disable interaction. */
.code-boxes.checking .code-box {
	opacity: 0.55;
	pointer-events: none;
	animation: fo-saving-pulse 1.1s ease-in-out infinite;
}

/* Inline error message in the code subtitle (replaces system alerts). */
.muted.error {
	color: var(--fo-red);
}

.code-resend {
	font-size: 12px;
	color: var(--fo-cool-gray);
	text-align: center;
	margin-top: 4px;
}

.code-resend a {
	color: var(--fo-soft-black);
	text-decoration: underline;
}

/* --- Confirm details screen --------------------------------- */

.confirm-content {
	justify-content: space-between;
	padding: 20px 24px 24px;
}

.confirm-top {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.confirm-bottom {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.logo-row {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 4px;
}

.logo-placeholder {
	width: 64px;
	height: 64px;
	border: 1.25px dashed var(--fo-light-gray);
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 10px;
	color: var(--fo-cool-gray);
	background-color: #fff;
	flex-shrink: 0;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
	transition: opacity 0.15s;
}

.logo-placeholder:active { opacity: 0.6; }

/* When the logo image is loaded, layer the actual image on top of a checkerboard
   so transparent regions are visually obvious. JS sets --tile-image. */
.logo-placeholder.has-image {
	color: transparent;
	border-style: solid;
	background-image:
		var(--tile-image, none),
		linear-gradient(45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%),
		linear-gradient(45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%);
	background-size: cover, 8px 8px, 8px 8px;
	background-position: center, 0 0, 4px 4px;
	background-repeat: no-repeat, repeat, repeat;
}

.logo-placeholder.uploading {
	animation: fo-saving-pulse 1.1s ease-in-out infinite;
}

/* --- Action sheet (logo replace) ----------------------------
   Backdrop and card are independently fixed to the viewport rather than
   flex-laid-out inside a 100vh wrapper. iOS Safari's layout viewport
   includes the area behind its URL bar, so flex-end inside `inset:0` puts
   the card off-screen. Anchoring directly to `bottom:0` avoids that.
*/

.action-sheet[hidden] { display: none; }

.action-sheet-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(37, 37, 37, 0.45);
	z-index: 999;
	animation: fo-fade-in 0.2s var(--fo-ease-out);
}

.action-sheet-card {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1000;
	background: var(--fo-seasalt);
	border-top-left-radius: 18px;
	border-top-right-radius: 18px;
	padding: 8px 0 max(env(safe-area-inset-bottom), 12px);
	box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
	animation: fo-slide-up 0.25s var(--fo-ease-out);
	max-width: 480px;
	margin: 0 auto;
}

@keyframes fo-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes fo-slide-up {
	from { transform: translateY(100%); }
	to   { transform: translateY(0); }
}

.action-sheet-title {
	text-align: center;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--fo-cool-gray);
	padding: 14px 16px 10px;
}

/* Larger preview of the current logo, shown at the top of the Replace-logo
   sheet. Same checkerboard layering as the inline placeholder so transparency
   stays visible. */
.action-sheet-preview {
	width: 140px;
	height: 140px;
	margin: 14px auto 4px;
	border-radius: 12px;
	border: 1px solid var(--fo-light-gray);
	background-color: #fff;
	background-image:
		var(--tile-image, none),
		linear-gradient(45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%),
		linear-gradient(45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%);
	background-size: contain, 10px 10px, 10px 10px;
	background-position: center, 0 0, 5px 5px;
	background-repeat: no-repeat, repeat, repeat;
}

.action-sheet-btn {
	display: block;
	width: 100%;
	padding: 16px 20px;
	background: transparent;
	border: none;
	border-top: 1px solid var(--fo-light-gray);
	color: var(--fo-soft-black);
	font-family: var(--fo-font-sans);
	font-size: 15px;
	font-weight: 500;
	text-align: center;
	cursor: pointer;
	transition: background 0.15s;
}

.action-sheet-btn:active { background: var(--fo-light-gray); }

.action-sheet-btn.cancel {
	margin-top: 6px;
	font-weight: 700;
	border-top: 6px solid var(--fo-light-gray);
}

.action-sheet-btn.destructive {
	color: #b3261e;
}

.replace-link {
	flex: 1;
	font-size: 12px;
	text-align: right;
	color: var(--fo-soft-black);
	text-decoration: underline;
}

.field-group {
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin-top: 4px;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.field-label {
	font-size: 10px;
	color: var(--fo-cool-gray);
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.field-input {
	border: 1.25px solid var(--fo-soft-black);
	border-radius: 8px;
	padding: 10px 12px;
	font-family: var(--fo-font-sans);
	font-size: 13px;
	font-weight: 500;
	color: var(--fo-soft-black);
	background: transparent;
	width: 100%;
	-webkit-appearance: none;
	appearance: none;
}

.field-input:focus {
	outline: none;
	border-color: var(--fo-bright-orange);
}

/* Per-field save state cues */
.field-input[data-state="saving"]  { border-color: var(--fo-cool-gray); }
.field-input[data-state="saved"]   { border-color: var(--fo-green); }
.field-input[data-state="error"]   { border-color: var(--fo-red); }
.field-input[data-state="invalid"] { border-color: var(--fo-red); }

.field-status {
	display: inline-block;
	margin-left: 6px;
	font-size: 9px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	opacity: 0;
	transition: opacity 0.2s, color 0.2s;
}

.field-status[data-state="saving"]  { color: var(--fo-cool-gray); opacity: 1; }
.field-status[data-state="saved"]   { color: var(--fo-green); opacity: 1; }
.field-status[data-state="error"]   { color: var(--fo-red); opacity: 1; }
.field-status[data-state="invalid"] { color: var(--fo-red); opacity: 1; }

@keyframes fo-saving-pulse {
	0%, 100% { opacity: 0.55; }
	50%      { opacity: 1; }
}

.field-status[data-state="saving"] {
	animation: fo-saving-pulse 1.1s ease-in-out infinite;
}

/* --- Logo preview (post-capture, choose what to do) --------- */

.preview-content {
	justify-content: space-between;
	padding: 20px 24px 24px;
}

.preview-top {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.preview-bottom {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.preview-image {
	width: 100%;
	max-width: 240px;
	aspect-ratio: 1 / 1;
	margin: 4px auto 0;
	border: 1.25px solid var(--fo-light-gray);
	border-radius: 12px;
	background-color: var(--fo-seasalt);
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
}

/* --- AI logo studio ----------------------------------------- */

.studio-content {
	justify-content: space-between;
	padding: 20px 24px 24px;
}

.studio-top {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.studio-bottom {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

/* style-notes input — rides into the AI prompt on regenerate */
#studio-notes {
	width: 100%;
	box-sizing: border-box;
	padding: 12px 14px;
	font-size: 15px;
	border: 1.25px solid var(--fo-light-gray, #ddd);
	border-radius: 10px;
	background: transparent;
	color: inherit;
}

.studio-loading {
	display: flex;
	justify-content: center;
	padding: 40px 0;
}

.studio-loading .spinner {
	width: 48px;
	height: 48px;
}

.logo-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin-top: 4px;
}

/* When there's only one candidate (cleanup result), let it span both columns
   and shrink its width so the square doesn't fill the whole content area. */
.logo-grid:has(> .logo-grid-tile:only-child) {
	grid-template-columns: 1fr;
	justify-items: center;
}

.logo-grid > .logo-grid-tile:only-child {
	width: 70%;
	max-width: 240px;
}

.logo-grid-tile {
	aspect-ratio: 1 / 1;
	border: 1.25px dashed var(--fo-light-gray);
	border-radius: 10px;
	/* Layered backgrounds: the actual logo (via --tile-image) on top of a
	   checkerboard pattern so transparent regions are visually obvious. */
	background-color: #fff;
	background-image:
		var(--tile-image, none),
		linear-gradient(45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%),
		linear-gradient(45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%);
	background-size: cover, 16px 16px, 16px 16px;
	background-position: center, 0 0, 8px 8px;
	background-repeat: no-repeat, repeat, repeat;
	cursor: pointer;
	transition: border-color 0.15s, transform 0.1s;
	position: relative;
	-webkit-user-select: none;
	user-select: none;
}

.logo-grid-tile:active { transform: scale(0.97); }

.logo-grid-tile.selected {
	border: 2px solid var(--fo-soft-black);
}

.logo-grid-tile.selected::after {
	content: "✓";
	position: absolute;
	top: 6px;
	right: 6px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--fo-soft-black);
	color: var(--fo-seasalt);
	font-size: 13px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
}

.btn-primary[disabled] {
	opacity: 0.4;
	pointer-events: none;
}

/* --- Loading screens ---------------------------------------- */

.loading-content {
	justify-content: center;
	align-items: center;
}

.loading-center {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 18px;
	width: 100%;
	max-width: 280px;
}

.spinner {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	border: 2px dashed var(--fo-soft-black);
	border-top: 2px solid var(--fo-bright-orange);
	animation: spin 1.2s linear infinite;
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

/* --- Checklist (branding screen) ---------------------------- */

.checklist {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 100%;
	margin-top: 12px;
}

.check-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 13px;
	padding: 6px 2px;
	color: var(--fo-cool-gray);
	transition: color 0.3s;
}

.check-item.found {
	color: var(--fo-soft-black);
}

.check-status {
	font-family: var(--fo-font-mono);
	font-size: 11px;
	color: var(--fo-cool-gray);
}

.check-status.done {
	color: var(--fo-bright-orange);
}

/* --- Counter row (menu screen) ------------------------------ */

.counter-row {
	display: flex;
	gap: 24px;
	margin-top: 12px;
}

.counter {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.counter-num {
	font-size: 28px;
	font-weight: 800;
	letter-spacing: -0.02em;
	line-height: 1;
}

.counter-label {
	font-size: 10px;
	color: var(--fo-cool-gray);
	letter-spacing: 0.06em;
	text-transform: uppercase;
	margin-top: 4px;
}

/* --- Screen footer ------------------------------------------ */

.screen-footer {
	padding: 14px 24px 24px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

/* --- Menu pull "done" check (replaces the spinner once import is complete) */

.menu-check {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	border: 2px solid var(--fo-soft-black);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 28px;
	font-weight: 700;
	color: var(--fo-soft-black);
}

