/* ============================================================
   JS Design Studio — mobile-first front end
   Palette: Heritage Gold #C47B00 · Kente Red #A52A2A
            Emerald #1B7A4B · Royal Indigo #2E3A8C
            Ivory #FAF5E6 · Charcoal #1A1A1A
   ============================================================ */

.jsds {
	--gold: #C47B00;
	--gold-lift: #E09A1F;
	--red: #A52A2A;
	--green: #1B7A4B;
	--indigo: #2E3A8C;
	--ivory: #FAF5E6;
	--char: #1A1A1A;
	--ink: #141210;
	--panel: #221F1B;
	--panel-2: #2B2722;
	--line: rgba(250, 245, 230, 0.14);
	--muted: rgba(250, 245, 230, 0.58);

	box-sizing: border-box;
	max-width: 720px;
	margin: 0 auto;
	padding: 0 16px calc(104px + env(safe-area-inset-bottom, 0px));
	background: var(--ink);
	color: var(--ivory);
	font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	-webkit-tap-highlight-color: transparent;
	-webkit-font-smoothing: antialiased;
}

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

.jsds img { max-width: 100%; display: block; }

/* ── Header ───────────────────────────────────────────────── */

.jsds-top {
	display: flex;
	align-items: center;
	padding: 18px 0 14px;
}

.jsds-brand { display: flex; align-items: center; gap: 12px; }

.jsds-brand-mark {
	width: 40px;
	height: 40px;
	flex: 0 0 40px;
	border-radius: 50%;
	background:
		radial-gradient(circle at 50% 42%, #FFF 0 22%, transparent 23%),
		conic-gradient(var(--gold) 0 25%, var(--red) 0 50%, var(--green) 0 75%, var(--indigo) 0 100%);
	border: 2px solid rgba(250, 245, 230, 0.25);
}

.jsds-brand-text { display: flex; flex-direction: column; line-height: 1.2; }

.jsds-brand-text strong {
	font-size: 17px;
	font-weight: 700;
	letter-spacing: -0.2px;
}

.jsds-brand-text em {
	font-style: normal;
	font-size: 11px;
	letter-spacing: 1.4px;
	text-transform: uppercase;
	color: var(--gold);
	margin-top: 2px;
}

/* Kente rule */
.jsds-kente { display: flex; height: 4px; border-radius: 2px; overflow: hidden; }
.jsds-kente i { flex: 1; }
.jsds-kente i:nth-child(1) { background: var(--gold); }
.jsds-kente i:nth-child(2) { background: var(--red); }
.jsds-kente i:nth-child(3) { background: var(--green); }
.jsds-kente i:nth-child(4) { background: var(--indigo); }

/* ── Steps ────────────────────────────────────────────────── */

.jsds-step { padding: 22px 0 6px; scroll-margin-top: 96px; }

.jsds-step-title {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 6px;
	font-size: 16px;
	font-weight: 700;
	color: var(--ivory);
	letter-spacing: -0.2px;
}

.jsds-step-title-plain { font-size: 13px; text-transform: uppercase; letter-spacing: 1.6px; color: var(--muted); }

.jsds-num {
	width: 22px;
	height: 22px;
	flex: 0 0 22px;
	border-radius: 50%;
	background: var(--gold);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
}

.jsds-hint {
	margin: 0 0 14px;
	font-size: 13px;
	line-height: 1.55;
	color: var(--muted);
}

/* ── Photo slots ──────────────────────────────────────────── */

.jsds-slots {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
	gap: 10px;
}

.jsds-slot {
	position: relative;
	aspect-ratio: 1 / 1;
	border-radius: 12px;
	overflow: hidden;
	background: var(--panel);
	border: 1px solid var(--line);
}

.jsds-slot img { width: 100%; height: 100%; object-fit: cover; }

.jsds-slot-badge {
	position: absolute;
	left: 6px;
	top: 6px;
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 1px;
	text-transform: uppercase;
	padding: 3px 7px;
	border-radius: 4px;
	background: var(--gold);
	color: #fff;
}

.jsds-slot-badge.is-ref { background: var(--indigo); }

.jsds-slot-remove {
	position: absolute;
	right: 5px;
	top: 5px;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	border: 0;
	background: rgba(10, 8, 6, 0.72);
	color: #fff;
	font-size: 19px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.jsds-add {
	aspect-ratio: 1 / 1;
	border-radius: 12px;
	border: 1.5px dashed rgba(196, 123, 0, 0.55);
	background: rgba(196, 123, 0, 0.07);
	color: var(--gold);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 5px;
	cursor: pointer;
	font-family: inherit;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.3px;
	padding: 6px;
	text-align: center;
}

.jsds-add:active { background: rgba(196, 123, 0, 0.16); }
.jsds-add span.plus { font-size: 26px; line-height: 1; font-weight: 300; }

/* ── Prompt ───────────────────────────────────────────────── */

.jsds-prompt {
	width: 100%;
	min-height: 92px;
	padding: 14px;
	border-radius: 12px;
	border: 1px solid var(--line);
	background: var(--panel);
	color: var(--ivory);
	/* 16px keeps iOS Safari from zooming the viewport on focus. */
	font-size: 16px;
	line-height: 1.5;
	font-family: 'Merriweather', Georgia, serif;
	resize: vertical;
	-webkit-appearance: none;
}

.jsds-prompt::placeholder { color: rgba(250, 245, 230, 0.36); }
.jsds-prompt:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }

/* Wraps rather than scrolls. A hidden-scrollbar row clips the last chip
   mid-word, which reads as broken layout instead of a scroll affordance. */
.jsds-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 12px;
}

.jsds-chip {
	flex: 0 1 auto;
	max-width: 100%;
	padding: 9px 14px;
	border-radius: 999px;
	border: 1px solid var(--line);
	background: var(--panel);
	color: var(--ivory);
	font-family: inherit;
	font-size: 12.5px;
	font-weight: 500;
	/* Short labels still sit on one line; only a long or translated label
	   wraps, instead of clipping or pushing the page sideways. */
	white-space: normal;
	text-align: center;
	line-height: 1.3;
	cursor: pointer;
	min-height: 38px;
}

.jsds-chip:active { background: var(--gold); border-color: var(--gold); color: #fff; }

/* ── Options ──────────────────────────────────────────────── */

.jsds-disclosure {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 0;
	background: none;
	border: 0;
	border-top: 1px solid var(--line);
	color: var(--ivory);
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	min-height: 48px;
}

.jsds-summary { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--muted); }

.jsds-caret {
	width: 8px;
	height: 8px;
	border-right: 2px solid var(--muted);
	border-bottom: 2px solid var(--muted);
	transform: rotate(45deg);
	transition: transform 0.18s ease;
	flex: 0 0 8px;
}

.jsds-disclosure[aria-expanded="true"] .jsds-caret { transform: rotate(-135deg); }

.jsds-options { display: grid; gap: 14px; padding: 4px 0 14px; }

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

.jsds-field label {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 1.3px;
	text-transform: uppercase;
	color: var(--gold);
}

.jsds-field select {
	width: 100%;
	padding: 12px 14px;
	border-radius: 10px;
	border: 1px solid var(--line);
	background: var(--panel);
	color: var(--ivory);
	font-family: inherit;
	font-size: 16px;
	min-height: 46px;
	-webkit-appearance: none;
	appearance: none;
	background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
	background-position: calc(100% - 19px) calc(50% + 2px), calc(100% - 14px) calc(50% + 2px);
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
}

/* ── Stage: working / error / result ──────────────────────── */

.jsds-stage { padding: 8px 0 0; scroll-margin-top: 96px; }

.jsds-working {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	padding: 44px 20px;
	border-radius: 14px;
	background: var(--panel);
	border: 1px solid var(--line);
	text-align: center;
}

.jsds-spinner {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: 3px solid rgba(250, 245, 230, 0.14);
	border-top-color: var(--gold);
	animation: jsds-spin 0.9s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.jsds-spinner { animation-duration: 2.4s; }
}

.jsds-working-text { margin: 0; font-size: 15px; font-weight: 600; }
.jsds-working-sub { margin: 0; font-size: 12.5px; color: var(--muted); }

.jsds-error {
	padding: 16px;
	border-radius: 12px;
	background: rgba(165, 42, 42, 0.16);
	border: 1px solid rgba(165, 42, 42, 0.55);
}

.jsds-error p { margin: 0 0 12px; font-size: 14px; line-height: 1.55; }

.jsds-result { margin: 0; scroll-margin-top: 96px; }

.jsds-result img {
	width: 100%;
	border-radius: 14px;
	border: 1px solid var(--line);
	background: var(--panel);
}

.jsds-result figcaption {
	margin-top: 10px;
	font-size: 12.5px;
	line-height: 1.5;
	color: var(--muted);
	font-family: 'Merriweather', Georgia, serif;
}

.jsds-result-actions {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	margin-top: 14px;
}

.jsds-result-actions .jsds-btn-ghost { grid-column: 1 / -1; }

/* ── History ──────────────────────────────────────────────── */

.jsds-history-wrap {
	border-top: 1px solid var(--line);
	margin-top: 18px;
	position: relative;
}

/* Fade at the right edge signals there is more to swipe to. */
.jsds-history-wrap::after {
	content: '';
	position: absolute;
	right: 0;
	bottom: 6px;
	width: 40px;
	height: 92px;
	background: linear-gradient(to right, rgba(20, 18, 16, 0), var(--ink));
	pointer-events: none;
}

.jsds-history {
	display: flex;
	gap: 10px;
	overflow-x: auto;
	padding-bottom: 6px;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.jsds-history::-webkit-scrollbar { display: none; }

.jsds-history-item {
	position: relative;
	flex: 0 0 92px;
	width: 92px;
	height: 92px;
	border-radius: 10px;
	overflow: hidden;
	border: 1px solid var(--line);
	background: var(--panel);
	padding: 0;
	cursor: pointer;
}

.jsds-history-item img { width: 100%; height: 100%; object-fit: cover; }

/* ── Buttons ──────────────────────────────────────────────── */

.jsds-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 46px;
	padding: 12px 20px;
	border-radius: 999px;
	border: 1px solid transparent;
	font-family: inherit;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.2px;
	cursor: pointer;
	text-decoration: none;
	transition: transform 0.1s ease, opacity 0.15s ease;
}

.jsds-btn:active { transform: scale(0.985); }
.jsds-btn[disabled] { opacity: 0.5; cursor: default; }

.jsds-btn-gold { background: var(--gold); color: #fff; }
.jsds-btn-gold:active { background: var(--gold-lift); }

.jsds-btn-outline { background: transparent; border-color: var(--gold); color: var(--gold); }

.jsds-btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }

.jsds-btn-big { width: 100%; min-height: 54px; font-size: 16px; }

/* ── Sticky action bar ────────────────────────────────────── */

.jsds-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 40;
	background: linear-gradient(to bottom, rgba(20, 18, 16, 0) 0%, rgba(20, 18, 16, 0.94) 26%, var(--ink) 60%);
	padding: 22px 16px calc(16px + env(safe-area-inset-bottom, 0px));
	pointer-events: none;
}

.jsds-bar-inner {
	max-width: 688px;
	margin: 0 auto;
	pointer-events: auto;
}

.jsds-chain {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 10px;
	padding: 8px 8px 8px 14px;
	border-radius: 999px;
	background: rgba(46, 58, 140, 0.28);
	border: 1px solid rgba(46, 58, 140, 0.7);
	font-size: 12px;
	color: var(--ivory);
	width: fit-content;
}

.jsds-chain button {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	border: 0;
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
}

/* ── Gate (logged out / no access) ────────────────────────── */

.jsds-gate { padding-bottom: 32px; }

.jsds-gate-card {
	margin-top: 28px;
	padding: 34px 24px;
	border-radius: 16px;
	background: var(--panel);
	border: 1px solid var(--line);
	text-align: center;
}

.jsds-gate-card .jsds-brand-mark { margin: 0 auto 16px; }
.jsds-gate-card h2 { margin: 0 0 8px; font-size: 19px; font-weight: 700; }
.jsds-gate-card p { margin: 0 0 20px; font-size: 14px; line-height: 1.6; color: var(--muted); }

/* ── Larger screens ───────────────────────────────────────── */

@media (max-width: 400px) {
	.jsds-chip { font-size: 12px; padding: 8px 12px; }
}

@media (min-width: 700px) {
	.jsds { padding-bottom: 120px; }
	.jsds-slots { grid-template-columns: repeat(4, 1fr); }
	.jsds-result-actions { grid-template-columns: repeat(3, 1fr); }
	.jsds-result-actions .jsds-btn-ghost { grid-column: auto; }
}
