/**
 * FateGems Tarot Draw — front-end styles.
 *
 * Design language matches the existing Elementor hero: deep indigo-violet
 * ground, antique gold line work, and the same champagne accent gradient.
 */

.td-wrap {
	--td-ink: #f5efe2;
	--td-ink-dim: rgba(245, 239, 226, 0.66);
	--td-ink-faint: rgba(245, 239, 226, 0.4);
	--td-gold: #d4af37;
	--td-gold-soft: #f3e8d3;
	--td-gold-deep: #a9842a;
	--td-deep: #0c0814;
	--td-violet: #1b1030;
	--td-panel: rgba(27, 16, 48, 0.72);
	--td-line: rgba(212, 175, 55, 0.26);
	--td-radius: 20px;
	--td-shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.85);

	position: relative;
	width: 100%;
	color: var(--td-ink);
	font-family: inherit;
	isolation: isolate;
}

/*
 * Elementor's container for this widget is a flex column with align-items:center,
 * which shrink-wraps block children to their intrinsic width. Pin the wrapper to
 * the full column width so the grid can actually spread out.
 */
.elementor-widget-html > .fategems-tarot-draw,
.elementor-widget-html > .td-wrap,
.fategems-tarot-draw {
	width: 100%;
	max-width: 100%;
	flex: 1 1 auto;
	min-width: 0;
}

/* ------------------------------------------------------------------ stage */

.td-stage {
	position: relative;
	max-width: 1120px;
	margin: 0 auto;
	padding: 8px 20px 12px;
}

.td-head {
	text-align: center;
	margin-bottom: 30px;
}

.td-eyebrow {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.32em;
	text-transform: uppercase;
	color: var(--td-gold);
	margin-bottom: 12px;
}

.td-title {
	margin: 0 0 12px;
	font-size: clamp(30px, 4.6vw, 46px);
	font-weight: 500;
	line-height: 1.14;
	background-image: linear-gradient(120deg, var(--td-gold-soft) 0%, var(--td-gold) 100%);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	color: transparent;
}

.td-sub {
	margin: 0 auto;
	max-width: 520px;
	font-size: 15px;
	line-height: 1.7;
	color: var(--td-ink-dim);
}

/* ------------------------------------------------------------------- grid */

.td-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 16px;
	max-width: 780px;
	margin: 0 auto;
	perspective: 1600px;
}

.td-card {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 3 / 4.4;
	padding: 0;
	margin: 0;
	border: 0;
	background: none;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: transform 0.45s cubic-bezier(0.22, 0.8, 0.3, 1), opacity 0.4s ease, filter 0.4s ease;
}

.td-card-inner {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	transform-style: preserve-3d;
	transition: transform 0.9s cubic-bezier(0.4, 0.15, 0.2, 1);
}

.td-card:hover:not(.is-locked) .td-card-inner {
	transform: translateY(-8px) rotateY(0deg);
}

.td-card:focus-visible {
	outline: 2px solid var(--td-gold);
	outline-offset: 4px;
	border-radius: 12px;
}

.td-face {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 12px;
	overflow: hidden;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
}

/* Back of card ------------------------------------------------------- */

.td-back {
	background: radial-gradient(120% 90% at 50% 0%, #241640 0%, #150c28 55%, #0c0814 100%);
	border: 1px solid var(--td-line);
	box-shadow: var(--td-shadow), inset 0 0 40px rgba(212, 175, 55, 0.09);
}

.td-back::after {
	content: "";
	position: absolute;
	inset: 0;
	background: radial-gradient(60% 40% at 50% 108%, rgba(212, 175, 55, 0.16), transparent 70%);
	pointer-events: none;
}

.td-back svg {
	width: 100%;
	height: 100%;
}

.td-svg-bg {
	fill: transparent;
}

.td-svg-frame {
	fill: none;
	stroke: rgba(212, 175, 55, 0.45);
	stroke-width: 1;
}

.td-svg-line {
	fill: none;
	stroke: rgba(212, 175, 55, 0.72);
	stroke-width: 1.4;
	stroke-linejoin: round;
	stroke-linecap: round;
}

.td-svg-dot {
	fill: rgba(243, 232, 211, 0.9);
}

/* Front of card ------------------------------------------------------ */

.td-front {
	flex-direction: column;
	gap: 8px;
	padding: 10px 6px;
	transform: rotateY(180deg);
	background: linear-gradient(168deg, #fdf8ee 0%, #f1e6d2 52%, #e6d6ba 100%);
	border: 1px solid rgba(169, 132, 42, 0.55);
	box-shadow: var(--td-shadow), inset 0 0 28px rgba(169, 132, 42, 0.14);
}

.td-front-numeral {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.24em;
	color: var(--td-gold-deep);
	opacity: 0.85;
}

.td-front-art {
	display: block;
	width: 74%;
	max-width: 86px;
}

.td-front-art svg {
	display: block;
	width: 100%;
	height: auto;
}

.td-svg-art {
	fill: none;
	stroke: #6a4f14;
	stroke-width: 2.4;
	stroke-linejoin: round;
	stroke-linecap: round;
}

.td-front-name {
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	text-align: center;
	color: #5b4512;
	line-height: 1.3;
	padding: 0 4px;
}

/* Flipped / locked states -------------------------------------------- */

.td-card.is-flipped .td-card-inner {
	transform: rotateY(180deg);
}

.td-card.is-locked {
	cursor: default;
}

/*
 * Once the spread resolves the grid stays put — reflowing the columns here
 * would fight the flip transform and make the revealed card jump. The unpicked
 * cards dim away, and only after the flip has played (the class is applied on a
 * timer) do they leave the flow so the drawn card is not left floating in a
 * half-empty row.
 */
.td-grid.is-resolved .td-card:not(.is-picked) {
	opacity: 0;
	filter: blur(3px);
	pointer-events: none;
	position: absolute;
	visibility: hidden;
}

.td-grid.is-resolved {
	position: relative;
	min-height: 0;
}

.td-card.is-picked {
	pointer-events: none;
}

.td-card.is-picked .td-back {
	box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.5), 0 0 46px -4px rgba(212, 175, 55, 0.5), var(--td-shadow);
}

.td-card.is-picked .td-front {
	box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.7), 0 0 70px -8px rgba(212, 175, 55, 0.6), var(--td-shadow);
}

/* ------------------------------------------------------------------- hint */

.td-hint {
	margin: 22px 0 0;
	text-align: center;
	font-size: 12px;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--td-ink-faint);
	transition: opacity 0.3s ease;
}

.td-hint.is-hidden {
	opacity: 0;
	pointer-events: none;
}

/* ----------------------------------------------------------------- result */

.td-result-host {
	margin-top: 0;
}

.td-result {
	opacity: 0;
	transform: translateY(24px);
	transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 0.8, 0.3, 1);
}

.td-result.is-in {
	opacity: 1;
	transform: translateY(0);
}

.td-result-inner {
	margin-top: 34px;
	padding: 30px;
	border-radius: var(--td-radius);
	background: var(--td-panel);
	border: 1px solid var(--td-line);
	box-shadow: var(--td-shadow);
	backdrop-filter: blur(14px);
	-webkit-backdrop-filter: blur(14px);
}

.td-reveal-head {
	text-align: center;
	margin-bottom: 26px;
}

.td-reveal-name {
	margin: 0 0 8px;
	font-size: clamp(24px, 3.4vw, 34px);
	font-weight: 500;
	background-image: linear-gradient(120deg, var(--td-gold-soft) 0%, var(--td-gold) 100%);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	color: transparent;
}

.td-reveal-keywords {
	margin: 0 0 14px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--td-gold);
	opacity: 0.9;
}

.td-reveal-headline {
	margin: 0 auto;
	max-width: 620px;
	font-size: 17px;
	font-style: italic;
	line-height: 1.65;
	color: var(--td-ink);
	opacity: 0.92;
}

.td-columns {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
	gap: 30px;
	align-items: start;
}

.td-block + .td-block {
	margin-top: 24px;
}

.td-block-title {
	margin: 0 0 12px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.24em;
	text-transform: uppercase;
	color: var(--td-gold);
}

.td-block p {
	margin: 0 0 12px;
	font-size: 14.5px;
	line-height: 1.78;
	color: var(--td-ink-dim);
}

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

/* Product card ------------------------------------------------------- */

.td-product {
	display: grid;
	grid-template-columns: 116px minmax(0, 1fr);
	gap: 16px;
	padding: 14px;
	border-radius: 14px;
	background: rgba(12, 8, 20, 0.5);
	border: 1px solid rgba(212, 175, 55, 0.2);
}

.td-product-media {
	position: relative;
	display: block;
	aspect-ratio: 1;
	border-radius: 10px;
	overflow: hidden;
	background: rgba(255, 255, 255, 0.04);
}

.td-product-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.td-product-body {
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-width: 0;
}

.td-product-crystal {
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--td-gold);
}

.td-product-name {
	margin: 0;
	font-size: 17px;
	font-weight: 500;
	line-height: 1.35;
	color: var(--td-ink);
}

.td-product-name a {
	color: inherit;
	text-decoration: none;
}

.td-product-name a:hover {
	color: var(--td-gold-soft);
}

.td-product-price {
	font-size: 18px;
	font-weight: 600;
	color: var(--td-gold-soft);
}

.td-product-price del {
	opacity: 0.5;
	font-weight: 400;
	font-size: 14px;
	margin-right: 6px;
}

.td-product-price ins {
	text-decoration: none;
}

.td-product-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
	margin-top: auto;
	padding-top: 4px;
}

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

.td-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px 22px;
	border-radius: 999px;
	border: 1px solid transparent;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	text-decoration: none;
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.25s ease, background 0.25s ease, color 0.25s ease;
}

.td-btn-primary {
	background: linear-gradient(120deg, #f3e8d3 0%, #d4af37 100%);
	color: #241640;
	box-shadow: 0 10px 26px -12px rgba(212, 175, 55, 0.9);
}

.td-btn-primary:hover {
	transform: translateY(-2px);
	box-shadow: 0 16px 34px -12px rgba(212, 175, 55, 0.95);
}

.td-btn-ghost {
	background: transparent;
	border-color: rgba(212, 175, 55, 0.45);
	color: var(--td-ink);
}

.td-btn-ghost:hover {
	background: rgba(212, 175, 55, 0.12);
	color: var(--td-gold-soft);
}

.td-btn[disabled] {
	opacity: 0.55;
	cursor: progress;
	transform: none;
}

.td-btn-wide {
	width: 100%;
}

/* Reading meta ------------------------------------------------------- */

.td-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 18px;
}

.td-meta span {
	padding: 5px 12px;
	border-radius: 999px;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--td-ink-dim);
	border: 1px solid rgba(212, 175, 55, 0.28);
}

.td-meta span b {
	color: var(--td-gold);
	font-weight: 600;
}

/* Luck stars --------------------------------------------------------- */

.td-luck {
	display: grid;
	gap: 10px;
}

.td-luck-row {
	display: grid;
	grid-template-columns: 88px minmax(0, 1fr);
	gap: 12px;
	align-items: center;
}

.td-luck-label {
	font-size: 12px;
	letter-spacing: 0.06em;
	color: var(--td-ink-dim);
}

.td-luck-bar {
	display: flex;
	gap: 4px;
}

.td-luck-pip {
	width: 100%;
	height: 7px;
	border-radius: 999px;
	background: rgba(245, 239, 226, 0.12);
	overflow: hidden;
}

.td-luck-pip i {
	display: block;
	height: 100%;
	width: 0;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--td-gold-deep), var(--td-gold), var(--td-gold-soft));
	transition: width 0.7s cubic-bezier(0.22, 0.8, 0.3, 1);
}

.td-result.is-in .td-luck-pip i {
	width: var(--td-fill, 0%);
}

/* Benefits ----------------------------------------------------------- */

.td-benefits {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 10px;
}

.td-benefits li {
	position: relative;
	padding-left: 22px;
	font-size: 14px;
	line-height: 1.7;
	color: var(--td-ink-dim);
}

.td-benefits li::before {
	content: "";
	position: absolute;
	left: 2px;
	top: 9px;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--td-gold);
	box-shadow: 0 0 10px rgba(212, 175, 55, 0.8);
}

/* Restart + toast ---------------------------------------------------- */

.td-restart {
	display: flex;
	justify-content: center;
	margin-top: 30px;
}

.td-toast {
	position: fixed;
	left: 50%;
	bottom: 32px;
	z-index: 99999;
	transform: translate(-50%, 20px);
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 20px;
	border-radius: 999px;
	background: rgba(12, 8, 20, 0.95);
	border: 1px solid rgba(212, 175, 55, 0.4);
	box-shadow: 0 20px 44px -20px rgba(0, 0, 0, 0.9);
	color: var(--td-ink);
	font-size: 13.5px;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease, transform 0.3s ease;
}

.td-toast.is-in {
	opacity: 1;
	transform: translate(-50%, 0);
}

.td-toast a {
	color: var(--td-gold);
	text-decoration: underline;
	white-space: nowrap;
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 900px) {
	.td-columns {
		grid-template-columns: minmax(0, 1fr);
		gap: 26px;
	}

	.td-grid {
		max-width: 560px;
	}
}

@media (max-width: 640px) {
	.td-stage {
		padding: 4px 14px 10px;
	}

	/*
	 * Four columns at phone width leaves ~60px cards, which is under a
	 * comfortable tap target. Two columns of four rows keeps them ~150px.
	 */
	.td-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 12px;
		max-width: 420px;
	}

	.td-front {
		gap: 6px;
		padding: 10px 6px;
	}

	.td-front-numeral {
		font-size: 9px;
		letter-spacing: 0.18em;
	}

	.td-front-name {
		font-size: 9px;
		letter-spacing: 0.08em;
	}

	.td-front-art {
		width: 64%;
	}

	.td-result-inner {
		padding: 20px 16px;
		border-radius: 16px;
	}

	.td-product {
		grid-template-columns: 92px minmax(0, 1fr);
		gap: 12px;
		padding: 12px;
	}

	.td-product-name {
		font-size: 15px;
	}

	.td-luck-row {
		grid-template-columns: 74px minmax(0, 1fr);
		gap: 8px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.td-card,
	.td-card-inner,
	.td-result,
	.td-luck-pip i,
	.td-toast {
		transition-duration: 0.01ms !important;
	}

	.td-card:hover:not(.is-locked) .td-card-inner {
		transform: none;
	}
}
