/* The candle you carry. Uses the theme's colors when it has them. */
:root {
	--cc-bg: var(--wp--preset--color--base, #1A1714);
	--cc-surface: var(--wp--preset--color--surface, #24201B);
	--cc-rule: var(--wp--preset--color--border, #3A332B);
	--cc-rule-strong: #4A4238;
	--cc-text: var(--wp--preset--color--contrast, #EDE3D1);
	--cc-text-2: var(--wp--preset--color--contrast-2, #D8CDB9);
	--cc-muted: var(--wp--preset--color--muted, #B8AC97);
	--cc-ember: var(--wp--preset--color--accent, #D9925B);
	--cc-ember-glow: var(--wp--preset--color--accent-2, #E8B088);
	--cc-display: var(--wp--preset--font-family--display, Georgia, serif);
}

.cc-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.cc-has-companion .wp-site-blocks { padding-bottom: 120px; }

/* Candle drawing */
.cc-candle-svg { display: block; overflow: visible; }
.cc-candle-svg .flame { transform-origin: 50% 100%; transform-box: fill-box; opacity: 0; transform: scale(0.2, 0.1); transition: opacity 0.5s ease, transform 0.6s cubic-bezier(.2, 1.4, .4, 1); }
.is-burning .cc-candle-svg .flame { opacity: 1; transform: none; }
.cc-candle-svg .smoke { opacity: 0; }
.is-out .cc-candle-svg .smoke { animation: cc-smoke 2.6s ease-out both; }
@keyframes cc-smoke { 0% { opacity: 0; transform: translateY(0); } 20% { opacity: 0.6; } 100% { opacity: 0; transform: translateY(-40px); } }
@keyframes cc-flicker { 0%, 100% { transform: scale(1, 1) rotate(0deg); } 30% { transform: scale(0.95, 1.06) rotate(-2deg); } 60% { transform: scale(1.04, 0.97) rotate(1.5deg); } }

/* The dark entrance */
.cc-gate {
	position: fixed;
	inset: 0;
	z-index: 2147483001;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 22px;
	padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
	background: radial-gradient(circle at 50% 46%, rgba(217, 146, 91, 0.10) 0, rgba(0, 0, 0, 0) 160px), #0B0A09;
	color: #8F8472;
	text-align: center;
	transition: opacity 1.4s ease 0.6s;
}
.cc-gate.is-lit { opacity: 0; pointer-events: none; }
.cc-gate__brand { margin: 0; font-family: var(--cc-display); font-style: italic; font-size: 1.25rem; color: #7A7064; }
.cc-gate__candle { width: 120px; height: 220px; padding: 0; border: 0; border-radius: 16px; background: transparent; cursor: pointer; }
.cc-gate__candle:focus-visible { outline: 2px solid var(--cc-ember); outline-offset: 6px; }
.cc-gate__hint { margin: 0; font-style: italic; font-size: 1.0625rem; color: #9A8F80; }
.cc-gate__glow {
	position: fixed;
	left: 50%;
	top: 50%;
	width: 40px;
	height: 40px;
	margin: -20px 0 0 -20px;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(255, 220, 170, 0.55) 0%, rgba(217, 146, 91, 0.25) 35%, rgba(217, 146, 91, 0) 70%);
	transform: scale(0);
	pointer-events: none;
	z-index: 2147483000;
}
.cc-gate.is-lit + .cc-gate__glow { animation: cc-bloom 2.2s ease-out forwards; }
@keyframes cc-bloom { 0% { transform: scale(0); opacity: 1; } 60% { opacity: 0.9; } 100% { transform: scale(90); opacity: 0; } }

/* Room light: the far corner dims as the candle burns down */
.cc-roomlight {
	position: fixed;
	inset: 0;
	z-index: 99990;
	pointer-events: none;
	background: radial-gradient(ellipse 130% 110% at calc(100% - 60px) calc(100% - 80px), rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 45%, rgba(8, 6, 5, var(--cc-dark, 0.12)) 100%);
}

/* The candle in the corner */
.cc-companion {
	position: fixed;
	right: calc(16px + env(safe-area-inset-right, 0px));
	bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	z-index: 99995;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 10px;
	font-size: 0.9375rem;
	line-height: 1.5;
}
.cc-companion__btn { position: relative; width: 64px; height: 104px; padding: 0; border: 0; border-radius: 12px; background: transparent; cursor: pointer; }
.cc-companion__btn::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 4px;
	width: 120px;
	height: 120px;
	margin-left: -60px;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(232, 176, 136, var(--cc-glow, 0.35)) 0%, rgba(217, 146, 91, 0) 65%);
	pointer-events: none;
}
.cc-companion__btn:focus-visible { outline: 2px solid var(--cc-ember); outline-offset: 2px; }
.cc-panel {
	width: min(300px, calc(100vw - 32px));
	padding: 18px 18px 16px;
	border-radius: 10px;
	border: 1px solid var(--cc-rule-strong);
	background: #221E19;
	color: var(--cc-text);
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.cc-panel[hidden] { display: none; }
.cc-panel h2 { margin: 0; font-family: var(--cc-display); font-weight: 400; font-size: 1.25rem; color: var(--cc-text); }
.cc-meter { height: 8px; border-radius: 4px; background: var(--cc-rule); overflow: hidden; }
.cc-meter i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--cc-ember), var(--cc-ember-glow)); }
.cc-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0; color: var(--cc-text-2); }
.cc-row select { font: inherit; color: var(--cc-text); background: var(--cc-surface); border: 1px solid var(--cc-rule-strong); border-radius: 4px; padding: 6px 8px; }
.cc-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--cc-ember); }
.cc-wax { display: inline-flex; align-items: center; gap: 4px; color: var(--cc-muted); }
.cc-ghost { min-height: 40px; padding: 0 14px; border: 1px solid var(--cc-rule-strong); border-radius: 6px; background: none; color: var(--cc-text-2); font: inherit; cursor: pointer; }
.cc-ghost:hover { border-color: var(--cc-muted); }
.cc-ghost:focus-visible, .cc-primary:focus-visible { outline: 2px solid var(--cc-ember); outline-offset: 3px; }
.cc-primary { min-height: 48px; padding: 0 22px; border: 0; border-radius: 6px; background: var(--cc-ember); color: #1A1714; font: inherit; font-weight: 600; cursor: pointer; }
.cc-primary:hover { background: var(--cc-ember-glow); }

.cc-toast {
	position: fixed;
	left: 50%;
	bottom: calc(24px + env(safe-area-inset-bottom, 0px));
	z-index: 99996;
	transform: translateX(-50%);
	max-width: min(440px, calc(100vw - 120px));
	margin: 0;
	padding: 12px 18px;
	border-radius: 8px;
	border: 1px solid rgba(217, 146, 91, 0.5);
	background: #2A231C;
	color: var(--cc-text);
	font-size: 1rem;
	line-height: 1.5;
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
.cc-toast[hidden] { display: none; }

/* Burned out: the room goes dark again */
.cc-out {
	position: fixed;
	inset: 0;
	z-index: 2147483002;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
	background: rgba(8, 6, 5, 0.94);
	color: var(--cc-text);
	text-align: center;
}
.cc-out[hidden] { display: none; }
.cc-out__box { max-width: 30rem; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.cc-out__box h2 { margin: 0; font-family: var(--cc-display); font-weight: 400; font-size: clamp(1.75rem, 1rem + 2.5vw, 2.5rem); line-height: 1.15; color: var(--cc-text); }
.cc-out__box p { margin: 0; color: var(--cc-text-2); }
.cc-out__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 8px; }
.cc-breath { width: 120px; height: 120px; border-radius: 50%; border: 1px solid var(--cc-rule-strong); display: grid; place-items: center; position: relative; }
.cc-breath[hidden] { display: none; }
.cc-breath::before { content: ""; position: absolute; inset: 18px; border-radius: 50%; background: radial-gradient(circle, rgba(232, 176, 136, 0.45), rgba(217, 146, 91, 0.05)); }
.cc-breath span { position: relative; font-size: 1.125rem; font-variant-numeric: tabular-nums; }

/* Lessons the reader has learned, in any lesson list */
.cc-lessons .wp-block-post.is-learned .wp-block-post-title::after {
	content: " ✦";
	color: var(--cc-ember-glow);
	font-size: 0.75em;
}

@media (prefers-reduced-motion: no-preference) {
	.is-burning .cc-candle-svg .flame-inner { animation: cc-flicker 2.4s ease-in-out infinite; transform-origin: 50% 100%; transform-box: fill-box; }
	.cc-gate__candle:hover .flame-inner, .cc-gate__candle:focus-visible .flame-inner { animation: cc-flicker 0.8s ease-in-out infinite; }
	.cc-roomlight { animation: cc-room 5s ease-in-out infinite; }
	.cc-breath.is-on::before { animation: cc-breathe 10s ease-in-out infinite; }
}
@keyframes cc-room { 0%, 100% { opacity: 1; } 45% { opacity: 0.93; } 70% { opacity: 0.98; } }
@keyframes cc-breathe { 0%, 100% { transform: scale(0.55); } 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) {
	.cc-gate { transition: opacity 0.3s ease; }
	.cc-gate.is-lit + .cc-gate__glow { animation: none; }
	.cc-candle-svg .flame { transition: none; }
}
@media print {
	.cc-companion, .cc-roomlight, .cc-toast, .cc-gate, .cc-gate__glow, .cc-out { display: none !important; }
}
