/* WiseMoe Picker Wheel — front-end styles */

.wmpw {
	--wm-ink: #111211;
	--wm-gold: #FAC630;
	--wm-violet: #6E4F9A;
	--wm-green: #6C8F34;
	--wm-red: #DE433D;
	--wm-cream: #FEFAF3;
	--wm-panel: #ffffff;
	--wm-border: #ece5d8;
	--wm-muted: #7a746b;
	--wm-radius: 16px;
	--wm-shadow: 0 10px 30px rgba(17, 18, 17, 0.10);

	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: var(--wm-ink);
	max-width: 960px;
	margin: 0 auto;
}
.wmpw *, .wmpw *::before, .wmpw *::after { box-sizing: border-box; }

.wmpw-main {
	display: flex;
	flex-wrap: wrap;
	gap: 26px;
	align-items: flex-start;
	justify-content: center;
}

.wmpw-left {
	flex: 1 1 440px;
	min-width: 300px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 18px;
}

.wmpw-title {
	margin: 0;
	font-size: clamp(1.2rem, 2.6vw, 1.7rem);
	font-weight: 800;
	text-align: center;
	letter-spacing: -0.01em;
}

/* ---- Stage: wheel ---- */
.wmpw-stage {
	position: relative;
	width: 100%;
	max-width: 520px;
	display: flex;
	justify-content: center;
	align-items: flex-end;
	min-height: 40px;
}

.wmpw-wheelbox {
	position: relative;
	width: 100%;
	max-width: 430px;
	aspect-ratio: 1 / 1;
	z-index: 2;
}

.wmpw-canvas {
	width: 100%;
	height: 100%;
	display: block;
	transform-origin: 50% 50%;
	filter: drop-shadow(0 6px 14px rgba(17, 18, 17, 0.16));
}

.wmpw-pointer {
	position: absolute;
	top: -4px;
	left: 50%;
	transform: translateX(-50%);
	width: 0; height: 0;
	border-left: 17px solid transparent;
	border-right: 17px solid transparent;
	border-top: 28px solid var(--wm-ink);
	z-index: 6;
	filter: drop-shadow(0 2px 2px rgba(0,0,0,0.25));
}

.wmpw-spin {
	position: absolute;
	top: 50%; left: 50%;
	transform: translate(-50%, -50%);
	width: 22%;
	aspect-ratio: 1 / 1;
	min-width: 66px;
	border-radius: 50%;
	border: 4px solid #fff;
	background: var(--wm-ink);
	color: #fff;
	font-weight: 800;
	font-size: clamp(0.85rem, 2.2vw, 1.1rem);
	letter-spacing: 0.05em;
	cursor: pointer;
	z-index: 5;
	box-shadow: 0 4px 12px rgba(0,0,0,0.35);
	transition: transform 0.12s ease;
}
.wmpw-spin:hover { transform: translate(-50%, -50%) scale(1.05); }
.wmpw-spin:active { transform: translate(-50%, -50%) scale(0.96); }
.wmpw-spin.is-disabled, .wmpw-spin:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Controls ---- */
.wmpw-controls { display: flex; gap: 12px; }
.wmpw-ctrl {
	width: 46px; height: 46px;
	border-radius: 50%;
	border: 1px solid var(--wm-border);
	background: var(--wm-panel);
	display: inline-flex; align-items: center; justify-content: center;
	cursor: pointer;
	box-shadow: 0 2px 6px rgba(17,18,17,0.06);
	transition: background 0.15s ease, transform 0.12s ease;
}
.wmpw-ctrl:hover { background: var(--wm-cream); transform: translateY(-1px); }
.wmpw-ctrl svg { width: 22px; height: 22px; fill: #55504a; }
.wmpw-ctrl.is-off svg { fill: var(--wm-red); }

/* ---- Right column / panels ---- */
.wmpw-right {
	flex: 1 1 320px;
	min-width: 280px;
	max-width: 380px;
	background: var(--wm-panel);
	border: 1px solid var(--wm-border);
	border-radius: var(--wm-radius);
	box-shadow: var(--wm-shadow);
	overflow: hidden;
	align-self: stretch;
}

.wmpw-tabbar { display: flex; border-bottom: 1px solid var(--wm-border); background: var(--wm-cream); }
.wmpw-tab {
	flex: 1;
	border: none;
	background: transparent;
	padding: 14px 8px;
	font-weight: 700;
	font-size: 0.82rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--wm-muted);
	cursor: pointer;
	border-bottom: 3px solid transparent;
}
.wmpw-tab.is-active { color: var(--wm-ink); border-bottom-color: var(--wm-gold); background: var(--wm-panel); }

.wmpw-panel { display: none; padding: 18px; }
.wmpw-panel.is-active { display: block; }

.wmpw-add-row { display: flex; gap: 10px; margin-bottom: 14px; }
.wmpw-add-input {
	flex: 1;
	border: 1px solid var(--wm-border);
	border-radius: 10px;
	padding: 11px 12px;
	font-size: 0.95rem;
	background: #fff;
	color: var(--wm-ink);
}
.wmpw-add-input:focus { outline: none; border-color: var(--wm-gold); box-shadow: 0 0 0 3px rgba(250,198,48,0.25); }
.wmpw-add-btn {
	width: 46px; border: none; border-radius: 10px;
	background: var(--wm-gold); color: var(--wm-ink);
	font-size: 1.5rem; font-weight: 700; cursor: pointer;
	line-height: 1;
}
.wmpw-add-btn:hover { filter: brightness(0.96); }

.wmpw-item-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.wmpw-item {
	display: flex; align-items: center; gap: 8px;
	padding: 8px 4px;
	border-bottom: 1px solid #f3efe7;
	flex-wrap: wrap;
}
.wmpw-item:last-child { border-bottom: none; }
.wmpw-swatch-wrap { position: relative; width: 26px; height: 26px; flex: 0 0 auto; }
.wmpw-swatch {
	width: 26px; height: 26px; border-radius: 8px;
	border: 2px solid #fff; box-shadow: 0 0 0 1px var(--wm-border);
	cursor: pointer; padding: 0;
}
.wmpw-color-input {
	position: absolute; inset: 0; opacity: 0; width: 26px; height: 26px;
	border: none; padding: 0; cursor: pointer; pointer-events: none;
}
.wmpw-item-label {
	flex: 1 1 90px; min-width: 90px;
	border: 1px solid transparent;
	border-radius: 8px; padding: 7px 8px;
	font-size: 0.92rem; background: transparent; color: var(--wm-ink);
}
.wmpw-item-label:focus { outline: none; background: #fff; border-color: var(--wm-border); }
.wmpw-item-weight {
	width: 52px; border: 1px solid var(--wm-border); border-radius: 8px;
	padding: 6px 4px; text-align: center; font-size: 0.82rem;
}
.wmpw-iconbtn {
	width: 32px; height: 32px; border-radius: 8px;
	border: 1px solid var(--wm-border); background: #fff; cursor: pointer;
	display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.wmpw-iconbtn svg { width: 16px; height: 16px; fill: #7a746b; }
.wmpw-iconbtn:hover { background: var(--wm-cream); }
.wmpw-iconbtn.has-image { background: var(--wm-gold); border-color: var(--wm-gold); }
.wmpw-iconbtn.has-image svg { fill: var(--wm-ink); }
.wmpw-remove:hover { background: #fdecec; border-color: #f5b7b5; }
.wmpw-remove:hover svg { fill: var(--wm-red); }

.wmpw-imgchooser {
	flex: 1 1 100%;
	display: flex; gap: 6px; margin-top: 6px;
}
.wmpw-imgurl { flex: 1; border: 1px solid var(--wm-border); border-radius: 8px; padding: 6px 8px; font-size: 0.82rem; }
.wmpw-mini {
	border: 1px solid var(--wm-border); background: #fff; border-radius: 8px;
	width: 34px; cursor: pointer; font-size: 0.9rem;
}
.wmpw-mini-ok { background: var(--wm-green); color: #fff; border-color: var(--wm-green); }

/* ---- Results ---- */
.wmpw-results-list { display: flex; flex-direction: column; gap: 12px; min-height: 60px; }
.wmpw-result-top { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 5px; }
.wmpw-result-label { font-weight: 700; }
.wmpw-result-count { color: var(--wm-muted); font-variant-numeric: tabular-nums; }
.wmpw-bar { height: 9px; background: #f1ece2; border-radius: 6px; overflow: hidden; }
.wmpw-bar-fill { height: 100%; background: linear-gradient(90deg, var(--wm-gold), var(--wm-green)); border-radius: 6px; transition: width 0.4s ease; }

/* ---- History ---- */
.wmpw-history-list { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow-y: auto; }
.wmpw-history-item { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid #f3efe7; font-size: 0.9rem; }
.wmpw-history-item:last-child { border-bottom: none; }
.wmpw-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.wmpw-history-label { flex: 1; font-weight: 600; }
.wmpw-history-time { color: var(--wm-muted); font-size: 0.8rem; }

.wmpw-empty { color: var(--wm-muted); text-align: center; padding: 20px 0; margin: 0; }
.wmpw-panel-foot { margin-top: 14px; text-align: right; }
.wmpw-textbtn {
	border: none; background: transparent; color: var(--wm-red);
	font-weight: 700; font-size: 0.85rem; cursor: pointer; padding: 6px 4px;
}
.wmpw-textbtn:hover { text-decoration: underline; }

/* ---- Modal (winner + share) ---- */
.wmpw-modal {
	position: fixed; inset: 0;
	background: rgba(17, 18, 17, 0.55);
	display: flex; align-items: center; justify-content: center;
	z-index: 100000;
	opacity: 0; visibility: hidden;
	transition: opacity 0.25s ease, visibility 0.25s ease;
	padding: 20px;
}
.wmpw-modal.is-visible { opacity: 1; visibility: visible; }

.wmpw-winner-inner {
	position: relative;
	display: flex; align-items: center; justify-content: center;
	transform: scale(0.9); transition: transform 0.3s cubic-bezier(.2,.9,.3,1.2);
}
.wmpw-modal.is-visible .wmpw-winner-inner { transform: scale(1); }

.wmpw-embed-textarea {
	width: 100%; resize: vertical; min-height: 90px;
	font-family: monospace; font-size: 0.8rem; line-height: 1.5;
}

.wmpw-winner-card {
	position: relative; z-index: 1;
	background: #fff; border-radius: 20px;
	padding: 30px 34px 26px 34px;
	min-width: 240px; max-width: 380px;
	box-shadow: 0 20px 50px rgba(0,0,0,0.3);
	text-align: center;
}
.wmpw-winner-sub { color: var(--wm-muted); font-size: 0.9rem; margin-bottom: 4px; }
.wmpw-winner-value { font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 800; line-height: 1.1; margin-bottom: 4px; word-break: break-word; }
.wmpw-winner-heading { color: var(--wm-ink); font-weight: 700; font-size: 0.95rem; margin-bottom: 18px; }
.wmpw-winner-actions { display: flex; flex-direction: column; gap: 8px; }

.wmpw-btn {
	border: none; border-radius: 10px; padding: 11px 16px;
	font-weight: 700; font-size: 0.9rem; cursor: pointer;
}
.wmpw-btn-primary { background: var(--wm-gold); color: var(--wm-ink); }
.wmpw-btn-primary:hover { filter: brightness(0.96); }
.wmpw-btn-ghost { background: transparent; color: var(--wm-muted); border: 1px solid var(--wm-border); }
.wmpw-btn-ghost:hover { background: var(--wm-cream); color: var(--wm-ink); }

.wmpw-winner-close {
	position: absolute; top: -14px; right: -14px;
	width: 36px; height: 36px; border-radius: 50%;
	border: none; background: #fff; cursor: pointer; z-index: 3;
	box-shadow: 0 4px 10px rgba(0,0,0,0.2);
	display: inline-flex; align-items: center; justify-content: center;
}
.wmpw-winner-close svg { width: 20px; height: 20px; fill: #55504a; }

.wmpw-confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 99999; }

/* ---- Share modal ---- */
.wmpw-share-box {
	position: relative; background: #fff; border-radius: 18px;
	padding: 26px; width: min(460px, 92vw);
	box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.wmpw-share-title { font-weight: 800; font-size: 1.05rem; margin-bottom: 14px; }
.wmpw-share-row { display: flex; gap: 8px; }
.wmpw-share-url { flex: 1; border: 1px solid var(--wm-border); border-radius: 10px; padding: 10px 12px; font-size: 0.85rem; background: var(--wm-cream); }
.wmpw-share-note { margin-top: 10px; font-size: 0.8rem; color: var(--wm-muted); }

/* ---- Fullscreen ---- */
.wmpw.is-fullscreen {
	max-width: none; width: 100%; height: 100%;
	background: var(--wm-cream);
	display: flex; align-items: center; justify-content: center;
	overflow: auto; padding: 24px;
}
.wmpw.is-fullscreen .wmpw-main { width: 100%; max-width: 1100px; align-items: center; }
.wmpw.is-fullscreen .wmpw-wheelbox { max-width: 520px; }

/* ---- Responsive ---- */
@media (max-width: 760px) {
	.wmpw-right { max-width: 100%; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
	.wmpw-canvas { transition: none !important; }
}

/* ---- RTL ---- */
[dir="rtl"] .wmpw-winner-close { right: auto; left: -14px; }

/* ---- RTL ---- */
[dir="rtl"] .wmpw-stage { padding-left: 0; padding-right: 90px; }
[dir="rtl"] .wmpw-char-idle {
	left: auto; right: 0;
	transform: translateX(-6%) scaleX(-1);
}
[dir="rtl"] .wmpw-winner-char { margin-right: 0; margin-left: -46px; transform: scaleX(-1); }
[dir="rtl"] .wmpw-winner-card { padding: 30px 60px 26px 34px; }
[dir="rtl"] .wmpw-winner-close { right: auto; left: -14px; }
@media (max-width: 760px) {
	[dir="rtl"] .wmpw-stage { padding-right: 0; }
	[dir="rtl"] .wmpw-char-idle { align-self: flex-end; }
}
@media (max-width: 480px) {
	[dir="rtl"] .wmpw-winner-char { margin-left: -34px; }
	[dir="rtl"] .wmpw-winner-card { padding: 24px 46px 22px 22px; }
}
