/**
 * Crypto Traffic Engine — frontend.
 *
 * Layout model: sections stretch the full width of whatever the theme gives them,
 * and .cte-container holds the content to --cte-content-width (1200px by default,
 * configurable in Settings → Visual experience).
 *
 * Colours are inherited from the theme wherever possible. Only accents, surfaces and
 * depth are defined here, so tool pages sit inside the site rather than on top of it.
 */

.cte-scope {
	--cte-content-width: 1200px;
	--cte-gutter: clamp(16px, 4vw, 32px);
	--cte-radius: 14px;
	--cte-radius-sm: 10px;
	--cte-gap: clamp(16px, 2.5vw, 28px);

	--cte-accent: #f26b21;
	--cte-accent-soft: rgba(242, 107, 33, 0.12);
	--cte-blue: #2f6bff;
	--cte-cyan: #00b6dd;
	--cte-green: #12a06a;
	--cte-red: #d93a4b;
	--cte-amber: #b7791f;

	--cte-ink: currentColor;
	--cte-muted: color-mix(in srgb, currentColor 62%, transparent);
	--cte-line: color-mix(in srgb, currentColor 14%, transparent);
	--cte-line-strong: color-mix(in srgb, currentColor 24%, transparent);
	--cte-surface: color-mix(in srgb, currentColor 4%, transparent);
	--cte-surface-2: color-mix(in srgb, currentColor 7%, transparent);

	--cte-shadow: none;
	--cte-lift: 0;
	--cte-tilt: 0deg;
	--cte-speed: 0.2s;

	width: 100%;
	box-sizing: border-box;
}

/* Older browsers without color-mix still get a usable, if flatter, palette. */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
	.cte-scope {
		--cte-muted: #6b7280;
		--cte-line: rgba(128, 128, 128, 0.22);
		--cte-line-strong: rgba(128, 128, 128, 0.38);
		--cte-surface: rgba(128, 128, 128, 0.06);
		--cte-surface-2: rgba(128, 128, 128, 0.1);
	}
}

.cte-scope *,
.cte-scope *::before,
.cte-scope *::after {
	box-sizing: inherit;
}

/* ---------------------------------------------------------------------------
 * Layout
 * ------------------------------------------------------------------------ */

.cte-container {
	width: 100%;
	max-width: var(--cte-content-width);
	margin-inline: auto;
	padding-inline: var(--cte-gutter);
	padding-block: clamp(24px, 5vw, 48px);
}

.cte-section {
	margin-block-start: clamp(28px, 4vw, 44px);
}

.cte-tool-form > .cte-panel-title {
	margin-block-end: 18px;
	padding-block-end: 14px;
	border-bottom: 1px solid var(--cte-line);
}

/* A section that should break out of the rail and run edge to edge. */
.cte-section-full {
	width: 100vw;
	max-width: 100vw;
	margin-inline: calc(50% - 50vw);
	padding-inline: var(--cte-gutter);
}

.cte-section-full > * {
	max-width: var(--cte-content-width);
	margin-inline: auto;
}

.cte-tool-layout,
.cte-index-layout {
	display: block;
}

/* ---------------------------------------------------------------------------
 * Typography — sizes only. Families come from the theme.
 * ------------------------------------------------------------------------ */

.cte-eyebrow {
	margin: 0 0 8px;
	font-size: 0.78rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--cte-accent);
}

.cte-page-title {
	margin: 0 0 12px;
	font-size: clamp(1.9rem, 1.2rem + 2.4vw, 2.9rem);
	line-height: 1.15;
}

.cte-page-intro {
	margin: 0;
	max-width: 68ch;
	font-size: clamp(1rem, 0.96rem + 0.25vw, 1.12rem);
	color: var(--cte-muted);
}

.cte-panel-title {
	margin: 0 0 14px;
	font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.55rem);
	line-height: 1.25;
}

.cte-muted {
	color: var(--cte-muted);
}

.cte-help,
.cte-note {
	margin: 5px 0 0;
	font-size: 0.86rem;
	color: var(--cte-muted);
}

.cte-mono,
.cte-formula {
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
 * Breadcrumbs
 * ------------------------------------------------------------------------ */

.cte-breadcrumbs {
	margin: 0 0 20px;
	font-size: 0.86rem;
	color: var(--cte-muted);
}

.cte-breadcrumbs ol {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.cte-breadcrumbs li + li::before {
	content: "/";
	margin-right: 8px;
	opacity: 0.5;
}

/* ---------------------------------------------------------------------------
 * The tool itself
 * ------------------------------------------------------------------------ */

.cte-tool-app {
	display: grid;
	grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
	gap: var(--cte-gap);
	align-items: start;
	margin-block-start: clamp(20px, 3vw, 32px);
}

@media (max-width: 860px) {
	.cte-tool-app {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* The results panel follows the form down the page rather than leaving a tall
   empty column beside a long form. */
@media (min-width: 861px) {
	.cte-tool-results {
		position: sticky;
		top: 24px;
	}
}

.cte-tool-form,
.cte-result-panel {
	padding: clamp(20px, 3vw, 30px);
	border: 1px solid var(--cte-line);
	border-radius: var(--cte-radius);
	background: var(--cte-surface);
	box-shadow: var(--cte-shadow);
	transition: transform var(--cte-speed) ease, box-shadow var(--cte-speed) ease;
}

/* Short numeric fields sit two-up on wider screens; anything that needs room
   spans the full width. This is what removes the tall stack of half-empty rows. */
.cte-field-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	gap: 14px 18px;
	margin-block-end: 20px;
}

.cte-field {
	margin-block-end: 0;
	min-width: 0;
}

.cte-field-wide {
	grid-column: 1 / -1;
}

.cte-label {
	line-height: 1.3;
}

.cte-label {
	display: block;
	margin-block-end: 6px;
	font-size: 0.9rem;
	font-weight: 600;
}

.cte-input-wrap {
	position: relative;
	display: flex;
	align-items: center;
}

.cte-input {
	width: 100%;
	padding: 12px 14px;
	font-size: 1rem;
	font-variant-numeric: tabular-nums;
	color: inherit;
	background: var(--cte-surface-2);
	border: 1px solid var(--cte-line-strong);
	border-radius: var(--cte-radius-sm);
	transition: border-color var(--cte-speed) ease, box-shadow var(--cte-speed) ease;
}

.cte-input:focus-visible {
	outline: none;
	border-color: var(--cte-accent);
	box-shadow: 0 0 0 3px var(--cte-accent-soft);
}

.cte-input-wrap.has-prefix .cte-input {
	padding-inline-start: 36px;
}

.cte-input-prefix {
	position: absolute;
	inset-inline-start: 14px;
	font-size: 0.95rem;
	color: var(--cte-muted);
	pointer-events: none;
}

select.cte-input {
	appearance: none;
	background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: calc(100% - 20px) calc(50% + 2px), calc(100% - 15px) calc(50% + 2px);
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	padding-inline-end: 38px;
}

.cte-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px 22px;
	font-size: 0.98rem;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	border: 1px solid transparent;
	border-radius: var(--cte-radius-sm);
	transition: transform var(--cte-speed) ease, filter var(--cte-speed) ease;
}

.cte-button-primary {
	color: #fff;
	background: var(--cte-accent);
}

.cte-button-secondary {
	color: inherit;
	background: transparent;
	border-color: var(--cte-line-strong);
}

.cte-button:hover {
	filter: brightness(1.05);
	transform: translateY(calc(var(--cte-lift) * -1px));
}

.cte-button:focus-visible {
	outline: 2px solid var(--cte-accent);
	outline-offset: 2px;
}

/* Results */

.cte-result-label {
	margin: 0 0 6px;
	font-size: 0.82rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--cte-muted);
}

.cte-result-value {
	margin: 0 0 20px;
	font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem);
	font-weight: 700;
	line-height: 1.05;
	font-variant-numeric: tabular-nums;
	word-break: break-word;
}

.cte-result-rows {
	display: grid;
	gap: 2px;
	margin: 0;
	border-top: 1px solid var(--cte-line);
}

.cte-result-row {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 0;
	border-bottom: 1px solid var(--cte-line);
}

.cte-result-row dt {
	font-size: 0.92rem;
	color: var(--cte-muted);
}

.cte-result-row dd {
	margin: 0;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.cte-result-notes {
	margin-block-start: 16px;
}

.cte-tone-positive {
	color: var(--cte-green);
}

.cte-tone-negative {
	color: var(--cte-red);
}

.cte-tone-neutral {
	color: inherit;
}

/* Alerts — used for "market data unavailable" and similar honest states. */

.cte-alert {
	margin: 0 0 18px;
	padding: 14px 16px;
	font-size: 0.92rem;
	border: 1px solid var(--cte-line-strong);
	border-inline-start-width: 3px;
	border-radius: var(--cte-radius-sm);
	background: var(--cte-surface);
}

.cte-alert-info {
	border-inline-start-color: var(--cte-blue);
}

.cte-alert-warning {
	border-inline-start-color: var(--cte-amber);
}

.cte-alert-error {
	border-inline-start-color: var(--cte-red);
}

.cte-notices:empty {
	display: none;
}

/* ---------------------------------------------------------------------------
 * Supporting content, FAQ, related
 * ------------------------------------------------------------------------ */

.cte-tool-section {
	margin-block-end: 24px;
}

.cte-tool-section > h2,
.cte-tool-section > h3 {
	margin-block-end: 10px;
}

.cte-tool-section > p {
	margin-block: 0 10px;
}

.cte-formula {
	display: block;
	padding: 14px 16px;
	overflow-x: auto;
	font-size: 0.92rem;
	border: 1px solid var(--cte-line);
	border-radius: var(--cte-radius-sm);
	background: var(--cte-surface-2);
}

.cte-faq-list {
	display: grid;
	gap: 12px;
}

.cte-faq-item {
	padding: 16px 18px;
	border: 1px solid var(--cte-line);
	border-radius: var(--cte-radius-sm);
	background: var(--cte-surface);
}

.cte-faq-item > summary {
	font-weight: 600;
	cursor: pointer;
	list-style: none;
}

.cte-faq-item > summary::-webkit-details-marker {
	display: none;
}

.cte-faq-item > summary::after {
	content: "+";
	float: inline-end;
	font-weight: 400;
	color: var(--cte-muted);
}

.cte-faq-item[open] > summary::after {
	content: "–";
}

.cte-faq-answer {
	margin-block-start: 10px;
	color: var(--cte-muted);
}

.cte-card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: var(--cte-gap);
}

.cte-card {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 20px;
	text-decoration: none;
	color: inherit;
	border: 1px solid var(--cte-line);
	border-radius: var(--cte-radius);
	background: var(--cte-surface);
	box-shadow: var(--cte-shadow);
	transition: transform var(--cte-speed) ease, box-shadow var(--cte-speed) ease, border-color var(--cte-speed) ease;
}

.cte-card:hover {
	border-color: var(--cte-accent);
	transform: translateY(calc(var(--cte-lift) * -1px));
}

.cte-card-badge {
	align-self: flex-start;
	padding: 3px 9px;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--cte-accent);
	background: var(--cte-accent-soft);
	border-radius: 999px;
}

.cte-card-title {
	font-size: 1.06rem;
	font-weight: 700;
	line-height: 1.3;
}

.cte-card-text {
	font-size: 0.9rem;
	color: var(--cte-muted);
}

.cte-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.94rem;
}

.cte-table th,
.cte-table td {
	padding: 10px 12px;
	text-align: start;
	border-bottom: 1px solid var(--cte-line);
}

.cte-table th {
	font-size: 0.82rem;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--cte-muted);
}

/* ---------------------------------------------------------------------------
 * Index page
 * ------------------------------------------------------------------------ */

.cte-index-controls {
	display: grid;
	gap: 12px;
	margin-block: clamp(24px, 4vw, 36px);
}

.cte-filter-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.cte-chip {
	padding: 7px 14px;
	font-size: 0.86rem;
	font-weight: 500;
	color: inherit;
	cursor: pointer;
	background: transparent;
	border: 1px solid var(--cte-line-strong);
	border-radius: 999px;
	transition: background var(--cte-speed) ease, border-color var(--cte-speed) ease;
}

.cte-chip.is-active,
.cte-chip[aria-pressed="true"] {
	color: var(--cte-accent);
	border-color: var(--cte-accent);
	background: var(--cte-accent-soft);
}

.cte-index-empty {
	padding: 32px;
	text-align: center;
	color: var(--cte-muted);
	border: 1px dashed var(--cte-line-strong);
	border-radius: var(--cte-radius);
}

/* ---------------------------------------------------------------------------
 * In-article module
 * ------------------------------------------------------------------------ */

.cte-inline-module {
	margin-block-start: clamp(28px, 4vw, 44px);
	padding-block-start: 20px;
	border-top: 2px solid var(--cte-line-strong);
}

.cte-module-title {
	margin: 0 0 16px;
	font-size: 1.15rem;
}

.cte-module-more {
	margin: 14px 0 0;
	font-size: 0.9rem;
}

.cte-module-more a {
	color: var(--cte-accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

.cte-inline-link {
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

.cte-slot:empty {
	display: none;
}

.cte-slot {
	margin-block: 20px;
}

.cte-cta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-block-start: 28px;
	padding: 20px 24px;
	border-radius: var(--cte-radius);
	background: var(--cte-surface-2);
}

/* ---------------------------------------------------------------------------
 * Visual experience levels
 *
 * Depth here is built from four cues, not one, because a single cue only works
 * on one kind of background:
 *
 *   surface   a panel slightly lighter than the page, which reads as raised on
 *             dark themes where a drop shadow is invisible
 *   rim       a hairline highlight along the top edge, the strongest depth cue
 *             on a near-black background
 *   shadow    ambient occlusion, which does the work on light themes
 *   glow      a soft accent halo, which does the work on dark themes
 *
 * Everything is CSS. No WebGL, no canvas, no animation library.
 * ------------------------------------------------------------------------ */

.cte-scope {
	--cte-rim: none;
	--cte-glow: none;
	--cte-surface-raised: var(--cte-surface);
	--cte-border-strength: var(--cte-line);
}

/* Panels that participate in the depth system. */
.cte-tool-form,
.cte-result-panel,
.cte-card,
.cte-faq-item,
.cte-index-empty {
	position: relative;
	background: var(--cte-surface-raised);
	border-color: var(--cte-border-strength);
	box-shadow: var(--cte-shadow), var(--cte-rim), var(--cte-glow);
}

/* --- 2D: deliberately flat. ------------------------------------------- */

.cte-style-2d {
	--cte-shadow: none;
	--cte-rim: none;
	--cte-glow: none;
	--cte-lift: 0;
	--cte-speed: 0.15s;
	--cte-surface-raised: var(--cte-surface);
}

/* --- 3D: a single raised plane. --------------------------------------- */

.cte-style-3d {
	--cte-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 6px 16px rgba(0, 0, 0, 0.16);
	--cte-rim: inset 0 1px 0 color-mix(in srgb, currentColor 12%, transparent);
	--cte-glow: none;
	--cte-lift: 2;
	--cte-speed: 0.2s;
	--cte-surface-raised: var(--cte-surface-2);
	--cte-border-strength: var(--cte-line-strong);
}

/* --- 5D: raised, lit and tinted. -------------------------------------- */

.cte-style-5d {
	--cte-shadow: 0 2px 6px rgba(0, 0, 0, 0.22), 0 14px 34px rgba(0, 0, 0, 0.24);
	--cte-rim: inset 0 1px 0 color-mix(in srgb, currentColor 18%, transparent);
	--cte-glow: 0 0 0 1px color-mix(in srgb, var(--cte-accent) 10%, transparent);
	--cte-lift: 4;
	--cte-speed: 0.26s;
	--cte-border-strength: var(--cte-line-strong);
}

.cte-style-5d .cte-tool-form,
.cte-style-5d .cte-result-panel,
.cte-style-5d .cte-card {
	background:
		linear-gradient(
			180deg,
			color-mix(in srgb, currentColor 9%, transparent),
			color-mix(in srgb, currentColor 3%, transparent)
		);
}

/* The result panel is the focal point, so it gets an accent edge. */
.cte-style-5d .cte-result-panel {
	border-top: 2px solid var(--cte-accent);
}

/* --- 7D: floating, with atmosphere. ----------------------------------- */

.cte-style-7d {
	--cte-shadow: 0 2px 8px rgba(0, 0, 0, 0.26), 0 18px 44px rgba(0, 0, 0, 0.3), 0 40px 80px rgba(0, 0, 0, 0.18);
	--cte-rim: inset 0 1px 0 color-mix(in srgb, currentColor 24%, transparent);
	--cte-glow: 0 0 34px -10px color-mix(in srgb, var(--cte-accent) 55%, transparent);
	--cte-lift: 6;
	--cte-tilt: 1.1deg;
	--cte-speed: 0.32s;
	--cte-border-strength: color-mix(in srgb, var(--cte-accent) 26%, var(--cte-line-strong));

	perspective: 1600px;
}

.cte-style-7d .cte-tool-form,
.cte-style-7d .cte-result-panel,
.cte-style-7d .cte-card {
	background:
		linear-gradient(
			180deg,
			color-mix(in srgb, currentColor 12%, transparent),
			color-mix(in srgb, currentColor 4%, transparent)
		);
	transform-style: preserve-3d;
}

.cte-style-7d .cte-result-panel {
	transform: rotateX(var(--cte-tilt));
	border-top: 2px solid var(--cte-accent);
}

/* A soft halo behind the result panel. Purely decorative, so it is hidden
   from assistive technology and never intercepts a click. */
.cte-style-7d .cte-result-panel::before {
	content: "";
	position: absolute;
	inset: -30% -10% auto -10%;
	height: 70%;
	pointer-events: none;
	background: radial-gradient(
		60% 100% at 50% 0%,
		color-mix(in srgb, var(--cte-accent) 24%, transparent),
		transparent 70%
	);
	filter: blur(26px);
	z-index: -1;
}

.cte-style-7d .cte-card:hover,
.cte-style-7d .cte-result-panel:hover {
	transform: translateY(-6px) rotateX(0deg);
}

/* The headline figure gets a slow gradient sweep, but only when its tone is
   neutral — see the tone override below. */
.cte-style-7d .cte-result-value {
	background: linear-gradient(
		100deg,
		var(--cte-accent) 0%,
		var(--cte-cyan) 40%,
		var(--cte-accent) 80%
	);
	background-size: 250% 100%;
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	animation: cte-sweep 9s ease-in-out infinite;
}

@keyframes cte-sweep {
	0%, 100% { background-position: 0% 50%; }
	50% { background-position: 100% 50%; }
}

/* Gradient text must never swallow a colour that carries meaning. A green gain
   and a red loss stay green and red at every depth level. */
.cte-style-7d .cte-result-value.cte-tone-positive,
.cte-style-7d .cte-result-value.cte-tone-negative {
	background: none;
	-webkit-text-fill-color: currentColor;
	animation: none;
}

.cte-style-7d .cte-result-value.cte-tone-positive { color: var(--cte-green); }
.cte-style-7d .cte-result-value.cte-tone-negative { color: var(--cte-red); }

/* Inputs pick up the depth too, or the form looks pasted onto the panel. */
.cte-style-5d .cte-input,
.cte-style-7d .cte-input {
	box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.cte-style-5d .cte-button-primary,
.cte-style-7d .cte-button-primary {
	box-shadow:
		0 2px 6px color-mix(in srgb, var(--cte-accent) 30%, transparent),
		0 10px 24px -8px color-mix(in srgb, var(--cte-accent) 45%, transparent);
}

/* Fallback for browsers without color-mix: keep the shadow tiers, drop the
   tinting, so depth still reads rather than disappearing. */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
	.cte-style-3d { --cte-rim: inset 0 1px 0 rgba(255, 255, 255, 0.08); }
	.cte-style-5d { --cte-rim: inset 0 1px 0 rgba(255, 255, 255, 0.12); --cte-glow: none; }
	.cte-style-7d { --cte-rim: inset 0 1px 0 rgba(255, 255, 255, 0.16); --cte-glow: 0 0 30px -12px rgba(242, 107, 33, 0.5); }
}

/* Small screens step down one level when that option is on. */
@media (max-width: 640px) {
	.cte-lighten-mobile.cte-style-7d,
	.cte-lighten-mobile.cte-style-5d {
		--cte-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 6px 14px rgba(0, 0, 0, 0.18);
		--cte-glow: none;
		--cte-lift: 2;
		--cte-tilt: 0deg;
		perspective: none;
	}

	.cte-lighten-mobile.cte-style-7d .cte-result-panel {
		transform: none;
	}

	.cte-lighten-mobile.cte-style-7d .cte-result-panel::before {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cte-scope * {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}

	.cte-scope {
		--cte-lift: 0;
		--cte-tilt: 0deg;
	}

	.cte-style-7d .cte-result-value {
		animation: none;
	}

	.cte-style-7d .cte-result-panel {
		transform: none;
	}

	.cte-card:hover,
	.cte-button:hover,
	.cte-result-panel:hover {
		transform: none;
	}
}

@media print {
	.cte-tool-form,
	.cte-index-controls,
	.cte-slot,
	.cte-cta {
		display: none;
	}

	.cte-result-panel {
		border: 1px solid #999;
		box-shadow: none;
	}
}

/* Utility rules — the hidden attribute must win over any display value above. */
.cte-scope [hidden],
[hidden].cte-index-empty {
	display: none !important;
}
