/*
 * موهبة components. Every value comes from tokens.css; class names are registered
 * as Bricks Global Classes by tools/build-tokens.mjs. Logical properties only (RTL).
 */

/* ---------- Base ---------- */
/* The hidden attribute must win over component display rules (wizard steps, panels, alerts). */
[hidden] { display: none !important; }
html { direction: rtl; }
body {
	background: var(--t-bg);
	color: var(--t-text);
	font-family: var(--t-font);
	font-size: var(--t-fs-body);
	line-height: var(--t-lh-body);
	font-variant-numeric: lining-nums;
	-webkit-font-smoothing: antialiased;
}
:where(h1, h2, h3, h4) { color: var(--t-text); font-family: var(--t-font); margin: 0; }
:where(a) { color: var(--t-secondary); }
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
	outline: none;
	box-shadow: var(--t-glow);
	border-radius: var(--t-r-sm);
}
::selection { background: var(--t-primary); color: var(--t-bg); }

/* ---------- Layout ---------- */
.t-container {
	inline-size: 100%;
	max-inline-size: var(--t-max);
	margin-inline: auto;
	padding-inline: var(--t-gutter);
	box-sizing: border-box;
}
.t-section { padding-block: var(--t-section); }
.t-section__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--t-s-4);
	margin-block-end: var(--t-s-5);
}
.t-stack { display: flex; flex-direction: column; gap: var(--t-s-4); }
:where(.t-stack, .t-card__body) > :where(.t-badge, .t-btn, .t-chip, .t-tip, .t-vote, .t-toast--inline, .t-ribbon) { align-self: flex-start; }
.t-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--t-s-3); }
.t-grid {
	display: grid;
	gap: var(--t-grid-gap);
	grid-template-columns: 1fr;
}
@media (min-width: 600px) { .t-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 992px) { .t-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .t-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.t-masonry { columns: 1; column-gap: var(--t-grid-gap); }
.t-masonry > * { break-inside: avoid; margin-block-end: var(--t-grid-gap); }
@media (min-width: 600px) { .t-masonry { columns: 2; } }
@media (min-width: 992px) { .t-masonry { columns: 3; } }
@media (min-width: 1200px) { .t-masonry { columns: 4; } }
.t-rail {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: minmax(240px, 280px);
	gap: var(--t-s-4);
	overflow-x: auto;
	scroll-snap-type: inline mandatory;
	padding-block-end: var(--t-s-2);
	scrollbar-width: thin;
}
.t-rail > * { scroll-snap-align: start; }

/* ---------- Typography helpers ---------- */
.t-display { font-size: var(--t-fs-display); line-height: var(--t-lh-display); font-weight: var(--t-fw-display); }
.t-h1 { font-size: var(--t-fs-h1); line-height: var(--t-lh-h1); font-weight: var(--t-fw-h1); }
.t-h2 { font-size: var(--t-fs-h2); line-height: var(--t-lh-h2); font-weight: var(--t-fw-h2); }
.t-h3 { font-size: var(--t-fs-h3); line-height: var(--t-lh-h3); font-weight: var(--t-fw-h3); }
.t-small { font-size: var(--t-fs-small); line-height: var(--t-lh-small); }
.t-label { font-size: var(--t-fs-label); line-height: var(--t-lh-label); font-weight: var(--t-fw-label); }
.t-muted { color: var(--t-text-muted); }
.t-num { font-variant-numeric: tabular-nums; }
.t-ugc { unicode-bidi: plaintext; white-space: pre-line; overflow-wrap: anywhere; }
.t-ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.t-sr-only {
	position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden;
	clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Buttons ---------- */
.t-btn {
	--_bg: var(--t-surface-2);
	--_fg: var(--t-text);
	--_bd: var(--t-border);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--t-s-2);
	min-block-size: 44px;
	padding-block: var(--t-s-2);
	padding-inline: var(--t-s-5);
	border: 1px solid var(--_bd);
	border-radius: var(--t-r-pill);
	background: var(--_bg);
	color: var(--_fg);
	font: inherit;
	font-weight: var(--t-fw-bold);
	font-size: var(--t-fs-body);
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition: background var(--t-dur-fast) var(--t-ease), border-color var(--t-dur-fast) var(--t-ease), transform var(--t-dur-fast) var(--t-ease);
}
.t-btn:hover { border-color: var(--t-text-muted); }
.t-btn:active { transform: translateY(1px); }
.t-btn--primary { --_bg: var(--t-primary); --_fg: var(--t-bg); --_bd: var(--t-primary); }
.t-btn--primary:hover { --_bg: var(--t-primary-hover); --_bd: var(--t-primary-hover); }
.t-btn--secondary { --_bg: transparent; --_fg: var(--t-secondary); --_bd: var(--t-secondary); }
.t-btn--ghost { --_bg: transparent; --_fg: var(--t-text); --_bd: var(--t-border); }
.t-btn--danger { --_bg: transparent; --_fg: var(--t-danger); --_bd: var(--t-danger); }
.t-btn--gold { --_bg: transparent; --_fg: var(--t-gold); --_bd: var(--t-gold); }
.t-btn--sm { min-block-size: 36px; padding-inline: var(--t-s-4); font-size: var(--t-fs-small); }
.t-btn--md { min-block-size: 44px; }
.t-btn--lg { min-block-size: 52px; padding-inline: var(--t-s-6); font-size: var(--t-fs-h3); }
.t-btn--block { inline-size: 100%; }
.t-btn--icon { padding-inline: 0; inline-size: 44px; }
.t-btn[disabled], .t-btn.is-disabled { opacity: .4; pointer-events: none; }
.t-btn.is-loading { color: transparent; position: relative; pointer-events: none; }
.t-btn.is-loading::after {
	content: "";
	position: absolute;
	inline-size: 18px;
	block-size: 18px;
	border: 2px solid var(--_fg);
	border-block-start-color: transparent;
	border-radius: 50%;
	animation: t-spin .8s linear infinite;
}
@keyframes t-spin { to { transform: rotate(360deg); } }

/* ---------- Icons ---------- */
.t-icon { inline-size: 20px; block-size: 20px; flex: none; stroke: currentColor; stroke-width: 1.75; fill: none; }
.t-icon--24 { inline-size: 24px; block-size: 24px; }
html[dir="rtl"] .t-icon--dir { transform: scaleX(-1); }

/* ---------- Cards ---------- */
.t-card {
	position: relative;
	display: flex;
	flex-direction: column;
	background: var(--t-surface);
	border: 1px solid var(--t-border);
	border-radius: var(--t-r-md);
	box-shadow: var(--t-shadow-1);
	overflow: hidden;
	transition: transform var(--t-dur-base) var(--t-ease), box-shadow var(--t-dur-base) var(--t-ease);
}
.t-card:where(a, .is-link):hover { transform: translateY(-2px); box-shadow: var(--t-shadow-2); }
.t-card__media { position: relative; aspect-ratio: 16 / 9; background: var(--t-surface-2); overflow: hidden; }
.t-card__media--art { aspect-ratio: 4 / 5; }
.t-card__media img, .t-card__media video { inline-size: 100%; block-size: 100%; object-fit: cover; display: block; }
.t-card__body { display: flex; flex-direction: column; gap: var(--t-s-2); padding: var(--t-s-4); }
.t-card__title { font-size: var(--t-fs-h3); line-height: var(--t-lh-h3); font-weight: var(--t-fw-h3); color: var(--t-text); text-decoration: none; }
.t-card__meta { display: flex; align-items: center; justify-content: space-between; gap: var(--t-s-2); color: var(--t-text-muted); font-size: var(--t-fs-small); }
.t-card__overlay-badges { position: absolute; inset-block-start: var(--t-s-3); inset-inline-start: var(--t-s-3); display: flex; gap: var(--t-s-2); }
.t-card--post .t-card__title { font-size: var(--t-fs-body); font-weight: var(--t-fw-bold); }
.t-card--talent { align-items: center; text-align: center; padding: var(--t-s-5) var(--t-s-4); gap: var(--t-s-3); }
.t-card--contest .t-card__prize { color: var(--t-gold); font-weight: var(--t-fw-black); font-variant-numeric: tabular-nums; }
.t-card--stat { padding: var(--t-s-4) var(--t-s-5); gap: var(--t-s-1); }
.t-card--stat .t-stat__value { font-size: var(--t-fs-stat); line-height: var(--t-lh-stat); font-weight: var(--t-fw-stat); font-variant-numeric: tabular-nums; }
.t-card--stat .t-stat__label { color: var(--t-text-muted); font-size: var(--t-fs-small); }

/* ---------- Badges & chips ---------- */
.t-badge {
	--_c: var(--t-text-muted);
	display: inline-flex;
	align-items: center;
	gap: var(--t-s-1);
	padding-block: 2px;
	padding-inline: var(--t-s-3);
	border-radius: var(--t-r-pill);
	border: 1px solid color-mix(in srgb, var(--_c) 45%, transparent);
	background: color-mix(in srgb, var(--_c) 14%, transparent);
	color: var(--_c);
	font-size: var(--t-fs-label);
	line-height: var(--t-lh-label);
	font-weight: var(--t-fw-label);
	white-space: nowrap;
}
.t-badge--sports { --_c: var(--t-secondary); }
.t-badge--art { --_c: var(--t-art); }
.t-badge--success { --_c: var(--t-success); }
.t-badge--warning { --_c: var(--t-warning); }
.t-badge--danger { --_c: var(--t-danger); }
.t-badge--premium { --_c: var(--t-gold); }
.t-badge--winner-1 { --_c: var(--t-gold); }
.t-badge--winner-2 { --_c: var(--t-silver); }
.t-badge--winner-3 { --_c: var(--t-bronze); }
.t-badge--discovered { --_c: var(--t-success); }
.t-chip {
	display: inline-flex;
	align-items: center;
	gap: var(--t-s-2);
	min-block-size: 36px;
	padding-inline: var(--t-s-4);
	border-radius: var(--t-r-pill);
	border: 1px solid var(--t-border);
	background: var(--t-surface);
	color: var(--t-text);
	font: inherit;
	font-size: var(--t-fs-small);
	cursor: pointer;
	text-decoration: none;
}
.t-chip.is-active, .t-chip[aria-pressed="true"] { background: var(--t-primary); border-color: var(--t-primary); color: var(--t-bg); font-weight: var(--t-fw-bold); }

/* ---------- Avatar ---------- */
.t-avatar {
	--_size: 48px;
	inline-size: var(--_size);
	block-size: var(--_size);
	border-radius: 50%;
	object-fit: cover;
	background: var(--t-surface-2);
	border: 2px solid var(--t-border);
	flex: none;
	display: inline-grid;
	place-items: center;
	color: var(--t-text-muted);
	font-weight: var(--t-fw-bold);
	overflow: hidden;
}
.t-avatar--32 { --_size: 32px; }
.t-avatar--48 { --_size: 48px; }
.t-avatar--72 { --_size: 72px; }
.t-avatar--120 { --_size: 120px; border-width: 3px; }
.t-avatar--premium { border-color: var(--t-gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--t-gold) 25%, transparent); }

/* ---------- Vote ---------- */
.t-vote {
	display: inline-flex;
	align-items: center;
	gap: var(--t-s-2);
	min-block-size: 44px;
	padding-inline: var(--t-s-4);
	border-radius: var(--t-r-pill);
	border: 1px solid var(--t-border);
	background: transparent;
	color: var(--t-text);
	font: inherit;
	font-weight: var(--t-fw-bold);
	cursor: pointer;
	position: relative;
}
.t-vote__count { font-variant-numeric: tabular-nums; display: inline-block; }
.t-vote.is-active { background: var(--t-primary); border-color: var(--t-primary); color: var(--t-bg); }
.t-vote.is-active .t-icon { fill: currentColor; }
.t-vote.is-bumped .t-vote__count { animation: t-bump var(--t-dur-slow) var(--t-ease); }
@keyframes t-bump { 40% { transform: scale(1.15); } 100% { transform: scale(1); } }
.t-vote__burst { position: absolute; inset: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .t-vote__burst { display: none; } }

/* ---------- Rating ---------- */
.t-rating { display: inline-flex; align-items: center; gap: var(--t-s-2); }
.t-rating__stars { display: inline-flex; flex-direction: row-reverse; border: 0; padding: 0; margin: 0; }
.t-rating__stars input { position: absolute; opacity: 0; inline-size: 1px; block-size: 1px; }
.t-rating__stars label { cursor: pointer; color: var(--t-border); padding: 2px; line-height: 0; }
.t-rating__stars label .t-icon { fill: currentColor; stroke: none; }
.t-rating__stars label:hover,
.t-rating__stars label:hover ~ label,
.t-rating__stars input:checked ~ label { color: var(--t-gold); }
.t-rating__stars input:focus-visible + label { box-shadow: var(--t-glow); border-radius: var(--t-r-sm); }
.t-rating__caption { color: var(--t-text-muted); font-size: var(--t-fs-small); font-variant-numeric: tabular-nums; }

/* ---------- Tip ---------- */
.t-tip {
	display: inline-flex; align-items: center; justify-content: center; gap: var(--t-s-2);
	min-block-size: 44px; padding-inline: var(--t-s-5);
	border-radius: var(--t-r-pill); border: 1px solid var(--t-gold);
	background: transparent; color: var(--t-gold);
	font: inherit; font-weight: var(--t-fw-bold); cursor: pointer;
}
.t-tip:hover { background: color-mix(in srgb, var(--t-gold) 12%, transparent); }
.t-tip__amounts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--t-s-2); }

/* ---------- Media ---------- */
.t-player {
	position: relative;
	aspect-ratio: 16 / 9;
	background: var(--t-surface-2);
	border-radius: var(--t-r-md);
	overflow: hidden;
}
.t-player iframe, .t-player video, .t-player img { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; border: 0; object-fit: cover; }
.t-player__play {
	position: absolute; inset: 0; margin: auto;
	inline-size: 72px; block-size: 72px; border-radius: 50%;
	display: grid; place-items: center;
	background: var(--t-primary); color: var(--t-bg); border: 0; cursor: pointer;
	box-shadow: var(--t-shadow-2);
}
.t-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--t-s-2); }
.t-gallery img { inline-size: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--t-r-sm); display: block; cursor: zoom-in; }
.t-placeholder {
	display: grid; place-items: center;
	inline-size: 100%; block-size: 100%;
	background: linear-gradient(135deg, var(--t-surface-2), var(--t-surface));
	color: var(--t-text-muted);
}

/* ---------- Navigation ---------- */
.t-topbar {
	position: sticky; inset-block-start: 0; z-index: 50;
	block-size: var(--t-header-h);
	background: color-mix(in srgb, var(--t-surface) 90%, transparent);
	backdrop-filter: blur(12px);
	border-block-end: 1px solid var(--t-border);
}
.t-topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--t-s-4); block-size: 100%; }
.t-nav { display: flex; gap: var(--t-s-5); }
.t-nav a { color: var(--t-text-muted); text-decoration: none; font-weight: var(--t-fw-semibold); }
.t-nav a:hover, .t-nav a[aria-current="page"] { color: var(--t-text); }
.t-tabbar {
	position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 50;
	block-size: var(--t-tabbar-h);
	display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
	background: color-mix(in srgb, var(--t-surface) 96%, transparent);
	backdrop-filter: blur(12px);
	border-block-start: 1px solid var(--t-border);
	padding-block-end: env(safe-area-inset-bottom);
}
.t-tabbar a { display: grid; justify-items: center; gap: 2px; color: var(--t-text-muted); text-decoration: none; font-size: var(--t-fs-label); }
.t-tabbar a[aria-current="page"] { color: var(--t-primary); }
.t-tabbar__add {
	inline-size: 52px; block-size: 52px; border-radius: 50%;
	display: grid; place-items: center; margin-block-start: calc(var(--t-s-5) * -1);
	background: var(--t-primary); color: var(--t-bg); box-shadow: var(--t-shadow-2);
}
@media (min-width: 992px) { .t-tabbar { display: none; } }
@media (max-width: 991px) { .t-nav { display: none; } }

/* ---------- Feedback ---------- */
.t-alert {
	--_c: var(--t-secondary);
	display: flex; gap: var(--t-s-3); align-items: flex-start;
	padding: var(--t-s-3) var(--t-s-4);
	border-radius: var(--t-r-md);
	border: 1px solid color-mix(in srgb, var(--_c) 40%, transparent);
	background: color-mix(in srgb, var(--_c) 10%, var(--t-surface));
	color: var(--t-text);
}
.t-alert > .t-icon { color: var(--_c); margin-block-start: 3px; }
.t-alert--success { --_c: var(--t-success); }
.t-alert--warning { --_c: var(--t-warning); }
.t-alert--danger { --_c: var(--t-danger); }
.t-toast {
	position: fixed; inset-inline: 0; inset-block-end: calc(var(--t-tabbar-h) + var(--t-s-4));
	margin-inline: auto; inline-size: max-content; max-inline-size: calc(100% - 2 * var(--t-gutter));
	z-index: 100;
	padding: var(--t-s-3) var(--t-s-5);
	border-radius: var(--t-r-pill);
	background: var(--t-text); color: var(--t-bg); font-weight: var(--t-fw-semibold);
	box-shadow: var(--t-shadow-2);
	animation: t-toast-in var(--t-dur-base) var(--t-ease);
}
.t-toast--inline { position: static; inset: auto; margin: 0; animation: none; }
@media (min-width: 992px) { .t-toast { inset-block-end: var(--t-s-6); } }
@keyframes t-toast-in { from { opacity: 0; transform: translateY(8px); } }
.t-empty {
	display: grid; justify-items: center; gap: var(--t-s-3);
	padding: var(--t-s-7) var(--t-s-4);
	text-align: center; color: var(--t-text-muted);
	border: 1px dashed var(--t-border); border-radius: var(--t-r-lg);
}
.t-empty__art { inline-size: 120px; block-size: 120px; }
.t-skeleton {
	background: linear-gradient(90deg, var(--t-surface) 25%, var(--t-surface-2) 50%, var(--t-surface) 75%);
	background-size: 200% 100%;
	border-radius: var(--t-r-sm);
	animation: t-shimmer 1.4s linear infinite;
	min-block-size: 1em;
}
@keyframes t-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .t-skeleton { animation: none; } }

/* ---------- Leaderboard ---------- */
.t-board { display: flex; flex-direction: column; gap: var(--t-s-2); list-style: none; margin: 0; padding: 0; }
.t-board__row {
	display: grid; grid-template-columns: 32px auto 1fr auto; align-items: center; gap: var(--t-s-3);
	padding: var(--t-s-2) var(--t-s-3);
	border-radius: var(--t-r-sm);
	background: var(--t-surface);
}
.t-board__rank { font-weight: var(--t-fw-black); color: var(--t-text-muted); text-align: center; font-variant-numeric: tabular-nums; }
.t-board__who { display: grid; gap: var(--t-s-1); min-inline-size: 0; }
.t-board__name { color: var(--t-text); text-decoration: none; font-weight: var(--t-fw-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-board__bar { block-size: 4px; border-radius: var(--t-r-pill); background: linear-gradient(to left, var(--t-primary), var(--t-primary-hover)); }
.t-board__votes { font-variant-numeric: tabular-nums; font-weight: var(--t-fw-bold); }

/* ---------- Modal / drawer ---------- */
.t-modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: var(--t-gutter); }
.t-modal[hidden] { display: none; }
.t-modal__overlay { position: absolute; inset: 0; background: var(--t-overlay); }
.t-modal__panel {
	position: relative;
	inline-size: min(520px, 100%);
	max-block-size: calc(100dvh - 2 * var(--t-gutter));
	overflow: auto;
	padding: var(--t-s-5);
	background: var(--t-surface);
	border: 1px solid var(--t-border);
	border-radius: var(--t-r-lg);
	box-shadow: var(--t-shadow-2);
}
.t-modal__close { position: absolute; inset-block-start: var(--t-s-3); inset-inline-end: var(--t-s-3); }
@media (max-width: 767px) {
	.t-modal { place-items: end stretch; padding: 0; }
	.t-modal__panel { inline-size: 100%; border-end-start-radius: 0; border-end-end-radius: 0; }
}

/* ---------- Tabs (dashboard) ---------- */
.t-tabs { display: flex; gap: var(--t-s-1); overflow-x: auto; }
.t-tabs a, .t-tabs button {
	padding: var(--t-s-2) var(--t-s-4); border-radius: var(--t-r-sm);
	color: var(--t-text-muted); text-decoration: none; white-space: nowrap;
	background: none; border: 0; font: inherit; cursor: pointer;
}
.t-tabs [aria-selected="true"], .t-tabs [aria-current="page"] { background: var(--t-surface-2); color: var(--t-text); font-weight: var(--t-fw-bold); }
@media (min-width: 992px) { .t-tabs--vertical { flex-direction: column; inline-size: 240px; flex: none; } }

/* ---------- Profile scope ---------- */
.t-profile { --t-primary-hover: color-mix(in srgb, var(--t-primary) 80%, white); }
.t-ribbon {
	display: flex; align-items: center; justify-content: center; gap: var(--t-s-2);
	padding: var(--t-s-2) var(--t-s-4);
	background: color-mix(in srgb, var(--t-success) 16%, var(--t-surface));
	color: var(--t-success); font-weight: var(--t-fw-bold);
	border-radius: var(--t-r-md);
}
.t-countdown { display: inline-flex; gap: var(--t-s-3); font-variant-numeric: tabular-nums; }
.t-countdown__unit { display: grid; justify-items: center; }
.t-countdown__num { font-size: var(--t-fs-stat); font-weight: var(--t-fw-stat); line-height: 1; }
.t-countdown__label { font-size: var(--t-fs-label); color: var(--t-text-muted); }

/* ---------- Design-system page ---------- */
.t-ds-swatch { display: grid; gap: var(--t-s-1); font-size: var(--t-fs-small); }
.t-ds-swatch__chip { block-size: 64px; border-radius: var(--t-r-md); border: 1px solid var(--t-border); }
