/* ==========================================================================
   TOP CNC — Base design system (RTL, Persian)
   Tokens, reset, typography, layout primitives, buttons, cards, badges.
   Loaded on every page. Feature styles build on top of these tokens.
   ========================================================================== */

/* --- Fonts ------------------------------------------------------------- */
@font-face {
	font-family: "Vazirmatn";
	src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
	font-weight: 400;
	font-display: swap;
}
@font-face {
	font-family: "Vazirmatn";
	src: url("../fonts/Vazirmatn-Medium.woff2") format("woff2");
	font-weight: 500;
	font-display: swap;
}
@font-face {
	font-family: "Vazirmatn";
	src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2");
	font-weight: 700;
	font-display: swap;
}

/* --- Tokens ------------------------------------------------------------ */
:root {
	/* Brand: deep industrial navy + machine-amber accent */
	--tc-primary: #0f3d5e;
	--tc-primary-700: #0b2e47;
	--tc-primary-100: #e3eef6;
	--tc-accent: #f59e0b;
	--tc-accent-600: #d97706;
	--tc-accent-100: #fef3c7;

	/* Neutrals */
	--tc-bg: #ffffff;
	--tc-bg-muted: #f5f7fa;
	--tc-bg-dark: #0b1b2b;
	--tc-surface: #ffffff;
	--tc-border: #e2e8f0;
	--tc-text: #0f172a;
	--tc-text-muted: #55657a;
	--tc-text-on-dark: #e6edf5;
	--tc-text-on-dark-muted: #9fb0c3;

	/* Semantic */
	--tc-success: #15803d;
	--tc-success-100: #dcfce7;
	--tc-danger: #b91c1c;
	--tc-danger-100: #fee2e2;
	--tc-warning: #b45309;
	--tc-warning-100: #fef3c7;

	/* Typography */
	--tc-font: "Vazirmatn", "Segoe UI", Tahoma, system-ui, sans-serif;
	--tc-font-mono: "JetBrains Mono", Consolas, "Courier New", monospace;
	--tc-fs-xs: 0.78rem;
	--tc-fs-sm: 0.9rem;
	--tc-fs-md: 1rem;
	--tc-fs-lg: 1.15rem;
	--tc-fs-xl: 1.4rem;
	--tc-fs-2xl: 1.85rem;
	--tc-fs-3xl: 2.5rem;
	--tc-lh: 1.8;

	/* Spacing & shape */
	--tc-space-1: 0.25rem;
	--tc-space-2: 0.5rem;
	--tc-space-3: 0.75rem;
	--tc-space-4: 1rem;
	--tc-space-6: 1.5rem;
	--tc-space-8: 2rem;
	--tc-space-12: 3rem;
	--tc-space-16: 4rem;
	--tc-space-24: 6rem;
	--tc-radius: 12px;
	--tc-radius-sm: 8px;
	--tc-radius-lg: 20px;
	--tc-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 24px rgba(15, 23, 42, 0.06);
	--tc-shadow-lg: 0 2px 4px rgba(15, 23, 42, 0.06), 0 24px 60px rgba(15, 23, 42, 0.14);
	--tc-container: 1200px;
	--tc-container-narrow: 780px;
	--tc-header-h: 72px;
}

/* --- Reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
	margin: 0;
	font-family: var(--tc-font);
	font-size: var(--tc-fs-md);
	line-height: var(--tc-lh);
	color: var(--tc-text);
	background: var(--tc-bg);
	direction: rtl;
	text-align: right;
	-webkit-font-smoothing: antialiased;
	/* Sticky footer on short pages */
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}
.topcnc-main { flex: 1 0 auto; display: flex; flex-direction: column; }
.topcnc-main > * { flex: 0 0 auto; }
.topcnc-main > .topcnc-auth { flex: 1 0 auto; }
[hidden] { display: none !important; }
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--tc-primary); text-decoration: none; }
a:hover { color: var(--tc-primary-700); }
h1, h2, h3, h4, h5, h6 { margin: 0 0 var(--tc-space-3); line-height: 1.35; font-weight: 700; color: var(--tc-text); }
h1 { font-size: var(--tc-fs-3xl); }
h2 { font-size: var(--tc-fs-2xl); }
h3 { font-size: var(--tc-fs-xl); }
h4 { font-size: var(--tc-fs-lg); }
p { margin: 0 0 var(--tc-space-4); }
ul, ol { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
code, pre { font-family: var(--tc-font-mono); direction: ltr; unicode-bidi: embed; }
:focus-visible { outline: 3px solid var(--tc-accent); outline-offset: 2px; border-radius: 4px; }

/* Numbers and latin tokens inside Persian text read better as LTR runs */
.topcnc-ltr, [dir="ltr"] { direction: ltr; unicode-bidi: isolate; }

/* --- Layout ------------------------------------------------------------ */
.topcnc-container {
	width: 100%;
	max-width: var(--tc-container);
	margin-inline: auto;
	padding-inline: var(--tc-space-6);
}
.topcnc-container--narrow { max-width: var(--tc-container-narrow); }
.topcnc-section { padding-block: var(--tc-space-16); }
.topcnc-section--muted { background: var(--tc-bg-muted); }
.topcnc-section--dark { background: var(--tc-bg-dark); color: var(--tc-text-on-dark); }
.topcnc-section--dark h1, .topcnc-section--dark h2, .topcnc-section--dark h3 { color: #fff; }
.topcnc-section--dark .topcnc-lead { color: var(--tc-text-on-dark-muted); }
.topcnc-section--center { text-align: center; }
.topcnc-section__head { max-width: 760px; margin-bottom: var(--tc-space-12); }
.topcnc-section__title { font-size: var(--tc-fs-2xl); }

.topcnc-grid { display: grid; gap: var(--tc-space-6); }
.topcnc-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.topcnc-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.topcnc-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1024px) {
	.topcnc-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.topcnc-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
	.topcnc-grid--2, .topcnc-grid--3, .topcnc-grid--4 { grid-template-columns: 1fr; }
	.topcnc-section { padding-block: var(--tc-space-12); }
	h1 { font-size: var(--tc-fs-2xl); }
	h2, .topcnc-section__title { font-size: var(--tc-fs-xl); }
}

/* --- Typography helpers ------------------------------------------------ */
.topcnc-eyebrow {
	display: inline-block;
	font-size: var(--tc-fs-sm);
	font-weight: 700;
	color: var(--tc-accent-600);
	letter-spacing: 0.01em;
	margin-bottom: var(--tc-space-3);
}
.topcnc-lead { font-size: var(--tc-fs-lg); color: var(--tc-text-muted); }
.topcnc-page-title { margin-bottom: var(--tc-space-6); }
.topcnc-meta { font-size: var(--tc-fs-sm); color: var(--tc-text-muted); }
.topcnc-empty { color: var(--tc-text-muted); text-align: center; padding: var(--tc-space-12) 0; }

/* --- Buttons ----------------------------------------------------------- */
.topcnc-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--tc-space-2);
	padding: 0.65rem 1.25rem;
	border-radius: var(--tc-radius-sm);
	font-weight: 700;
	font-size: var(--tc-fs-md);
	line-height: 1.4;
	border: 2px solid transparent;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
	white-space: nowrap;
}
.topcnc-btn:active { transform: translateY(1px); }
.topcnc-btn--sm { padding: 0.45rem 0.95rem; font-size: var(--tc-fs-sm); }
.topcnc-btn--lg { padding: 0.9rem 1.75rem; font-size: var(--tc-fs-lg); }
.topcnc-btn--primary { background: var(--tc-accent); color: #1a1200; border-color: var(--tc-accent); }
.topcnc-btn--primary:hover { background: var(--tc-accent-600); border-color: var(--tc-accent-600); color: #1a1200; }
.topcnc-btn--ghost { background: transparent; color: var(--tc-text); }
.topcnc-btn--ghost:hover { background: var(--tc-primary-100); color: var(--tc-primary-700); }
.topcnc-btn--outline { background: transparent; color: var(--tc-primary); border-color: var(--tc-primary); }
.topcnc-btn--outline:hover { background: var(--tc-primary); color: #fff; }
.topcnc-section--dark .topcnc-btn--ghost, .topcnc-section--dark .topcnc-btn--outline { color: #fff; border-color: rgba(255,255,255,0.4); }
.topcnc-section--dark .topcnc-btn--ghost:hover, .topcnc-section--dark .topcnc-btn--outline:hover { background: rgba(255,255,255,0.1); }

/* --- Cards & badges ---------------------------------------------------- */
.topcnc-card {
	display: block;
	background: var(--tc-surface);
	border: 1px solid var(--tc-border);
	border-radius: var(--tc-radius);
	padding: var(--tc-space-6);
	box-shadow: var(--tc-shadow);
	color: inherit;
}
.topcnc-badge {
	display: inline-block;
	padding: 0.15rem 0.6rem;
	border-radius: 999px;
	font-size: var(--tc-fs-xs);
	font-weight: 700;
	background: var(--tc-primary-100);
	color: var(--tc-primary-700);
}
.topcnc-badge--ok { background: var(--tc-success-100); color: var(--tc-success); }
.topcnc-badge--warn { background: var(--tc-warning-100); color: var(--tc-warning); }
.topcnc-badge--danger { background: var(--tc-danger-100); color: var(--tc-danger); }

/* --- Forms & alerts (shared by landing, auth and panel) ---------------- */
.topcnc-form { display: grid; gap: var(--tc-space-4); }
.topcnc-form__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--tc-space-4); }
@media (max-width: 560px) { .topcnc-form__row { grid-template-columns: 1fr; } }
.topcnc-form__hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; }
.topcnc-form__hint { font-size: var(--tc-fs-xs); color: var(--tc-text-muted); margin: 0; }
.topcnc-form__between { display: flex; justify-content: space-between; align-items: center; gap: var(--tc-space-3); flex-wrap: wrap; font-size: var(--tc-fs-sm); }

.topcnc-field { display: grid; gap: 6px; font-size: var(--tc-fs-sm); font-weight: 500; border: 0; padding: 0; margin: 0; min-width: 0; }
.topcnc-field legend { padding: 0; margin-bottom: 6px; font-weight: 500; }
.topcnc-field em { color: var(--tc-danger); font-style: normal; }
.topcnc-field input:not([type="checkbox"]):not([type="radio"]), .topcnc-field textarea, .topcnc-field select {
	width: 100%; padding: 0.7rem 0.9rem; border: 1px solid var(--tc-border); border-radius: var(--tc-radius-sm);
	background: #fff; font-weight: 400; transition: border-color 0.15s, box-shadow 0.15s; font-family: inherit;
}
.topcnc-field input[type="checkbox"], .topcnc-field input[type="radio"] { width: 16px; height: 16px; flex: 0 0 auto; margin: 4px 0 0; }
.topcnc-field input:focus, .topcnc-field textarea:focus, .topcnc-field select:focus { outline: none; border-color: var(--tc-primary); box-shadow: 0 0 0 3px var(--tc-primary-100); }
.topcnc-field textarea { resize: vertical; }
.topcnc-field small { font-weight: 400; color: var(--tc-danger); }
.topcnc-field small.is-hint { color: var(--tc-text-muted); }
.topcnc-field.has-error input, .topcnc-field.has-error select, .topcnc-field.has-error textarea { border-color: var(--tc-danger); }
.topcnc-field__error { color: var(--tc-danger); font-size: var(--tc-fs-xs); }
.topcnc-field__password { position: relative; display: block; }
.topcnc-field__password input { padding-inline-end: 2.8rem; }
.topcnc-field__eye { position: absolute; inset-inline-end: 0.6rem; top: 50%; transform: translateY(-50%); font-size: 1rem; opacity: 0.6; line-height: 1; }
.topcnc-field__eye:hover { opacity: 1; }

.topcnc-check { display: inline-flex; align-items: flex-start; gap: 8px; font-size: var(--tc-fs-sm); font-weight: 400; cursor: pointer; }
.topcnc-check input { margin-top: 4px; accent-color: var(--tc-primary); }
.topcnc-check-group { display: flex; flex-wrap: wrap; gap: var(--tc-space-3) var(--tc-space-6); }
.topcnc-check-group--stack { flex-direction: column; gap: var(--tc-space-2); }
.topcnc-check-group--stack .topcnc-check { display: flex; }
.topcnc-check-group--stack .topcnc-check span { flex: 1; }

.topcnc-alert { padding: var(--tc-space-3) var(--tc-space-4); border-radius: var(--tc-radius-sm); margin-bottom: var(--tc-space-4); font-weight: 500; }
.topcnc-alert--success { background: var(--tc-success-100); color: var(--tc-success); }
.topcnc-alert--error { background: var(--tc-danger-100); color: var(--tc-danger); }
.topcnc-alert a { color: inherit; text-decoration: underline; }

.topcnc-btn--block { width: 100%; }
.topcnc-btn--danger { background: transparent; color: var(--tc-danger); border-color: transparent; }
.topcnc-btn--danger:hover { background: var(--tc-danger-100); color: var(--tc-danger); }
.topcnc-btn--google { width: 100%; background: #fff; color: var(--tc-text); border-color: var(--tc-border); }
.topcnc-btn--google:hover { background: var(--tc-bg-muted); color: var(--tc-text); }

/* --- Plan cards & period toggle (pricing page and panel billing) ------- */
.topcnc-toggle {
	display: inline-flex; gap: 4px; padding: 4px;
	background: #fff; border: 1px solid var(--tc-border); border-radius: 999px;
}
.topcnc-toggle__btn {
	display: inline-flex; align-items: center; gap: var(--tc-space-2);
	padding: 0.5rem 1.1rem; border-radius: 999px; font-weight: 700; color: var(--tc-text-muted);
}
.topcnc-toggle__btn.is-active { background: var(--tc-primary); color: #fff; }
.topcnc-toggle__btn.is-active .topcnc-badge { background: var(--tc-accent); color: #1a1200; }

.topcnc-plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--tc-space-6); align-items: stretch; }
@media (max-width: 900px) { .topcnc-plans { grid-template-columns: 1fr; max-width: 460px; margin-inline: auto; } }

.topcnc-plan {
	position: relative; display: flex; flex-direction: column;
	background: #fff; border: 1px solid var(--tc-border); border-radius: var(--tc-radius-lg);
	padding: var(--tc-space-8) var(--tc-space-6); box-shadow: var(--tc-shadow);
}
.topcnc-plan--featured { border-color: var(--tc-primary); box-shadow: var(--tc-shadow-lg); }
.topcnc-plan__ribbon {
	position: absolute; top: -14px; inset-inline-start: var(--tc-space-6);
	background: var(--tc-accent); color: #1a1200; font-weight: 700; font-size: var(--tc-fs-xs);
	padding: 4px 12px; border-radius: 999px;
}
.topcnc-plan__name { font-size: var(--tc-fs-xl); margin-bottom: var(--tc-space-1); }
.topcnc-plan--bronze .topcnc-plan__name { color: #92400e; }
.topcnc-plan--silver .topcnc-plan__name { color: #475569; }
.topcnc-plan--gold .topcnc-plan__name { color: #b45309; }
.topcnc-plan__desc { color: var(--tc-text-muted); font-size: var(--tc-fs-sm); min-height: 3.2em; }
.topcnc-plan__price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-top: var(--tc-space-2); }
.topcnc-plan__amount { font-size: 2.1rem; font-weight: 700; color: var(--tc-primary); line-height: 1; }
.topcnc-plan__currency { font-weight: 700; }
.topcnc-plan__period { color: var(--tc-text-muted); font-size: var(--tc-fs-sm); }
.topcnc-plan__note { min-height: 1.6em; font-size: var(--tc-fs-xs); color: var(--tc-success); margin: var(--tc-space-1) 0 var(--tc-space-4); }
.topcnc-plan__limits { list-style: none; display: grid; gap: var(--tc-space-2); margin-bottom: var(--tc-space-6); border-top: 1px solid var(--tc-border); padding-top: var(--tc-space-4); font-size: var(--tc-fs-sm); }
.topcnc-plan__limits strong { color: var(--tc-text); }
.topcnc-plan__cta { margin-top: auto; width: 100%; }

/* --- Header ------------------------------------------------------------ */
.topcnc-skip-link {
	position: absolute; inset-inline-start: 0; top: -100px;
	background: var(--tc-accent); color: #000; padding: 0.5rem 1rem; z-index: 1000;
}
.topcnc-skip-link:focus { top: 0; }

.topcnc-header {
	position: sticky; top: 0; z-index: 100;
	background: rgba(255,255,255,0.88);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--tc-border);
}
.topcnc-header__inner {
	display: flex; align-items: center; justify-content: space-between; gap: var(--tc-space-6);
	min-height: var(--tc-header-h);
}
.topcnc-logo { display: inline-flex; align-items: center; gap: var(--tc-space-2); color: var(--tc-primary); }
.topcnc-logo__mark { display: inline-flex; color: var(--tc-primary); }
.topcnc-logo__text { font-weight: 700; font-size: var(--tc-fs-xl); letter-spacing: 0.02em; direction: ltr; unicode-bidi: isolate; }
.topcnc-logo__text span { color: var(--tc-accent-600); }

.topcnc-nav__list { display: flex; gap: var(--tc-space-6); list-style: none; }
.topcnc-nav__list a { color: var(--tc-text); font-weight: 500; padding: 0.4rem 0; border-bottom: 2px solid transparent; }
.topcnc-nav__list a:hover, .topcnc-nav__list .current-menu-item > a { color: var(--tc-primary); border-color: var(--tc-accent); }

.topcnc-header__actions { display: flex; align-items: center; gap: var(--tc-space-2); }

.topcnc-burger { display: none; width: 40px; height: 40px; flex-direction: column; justify-content: center; gap: 5px; align-items: center; }
.topcnc-burger span { display: block; width: 22px; height: 2px; background: var(--tc-text); border-radius: 2px; transition: transform 0.2s, opacity 0.2s; }
.topcnc-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.topcnc-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.topcnc-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 900px) {
	.topcnc-burger { display: inline-flex; }
	.topcnc-nav {
		position: absolute; inset-inline: 0; top: 100%;
		background: #fff; border-bottom: 1px solid var(--tc-border);
		padding: var(--tc-space-4) var(--tc-space-6);
		display: none;
	}
	.topcnc-nav.is-open { display: block; }
	.topcnc-nav__list { flex-direction: column; gap: var(--tc-space-3); }
	.topcnc-header__actions .topcnc-btn--ghost { display: none; }
}

/* --- Footer ------------------------------------------------------------ */
.topcnc-footer { background: var(--tc-bg-dark); color: var(--tc-text-on-dark-muted); padding-block: var(--tc-space-16) var(--tc-space-8); margin-top: auto; }
.topcnc-footer__grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: var(--tc-space-8); }
.topcnc-footer h4 { color: #fff; font-size: var(--tc-fs-md); margin-bottom: var(--tc-space-4); }
.topcnc-footer ul { list-style: none; display: grid; gap: var(--tc-space-2); }
.topcnc-footer a { color: var(--tc-text-on-dark-muted); }
.topcnc-footer a:hover { color: #fff; }
.topcnc-footer__brand .topcnc-logo__text { color: #fff; display: inline-block; margin-bottom: var(--tc-space-3); }
.topcnc-footer__brand p { max-width: 36ch; }
.topcnc-footer__bottom {
	display: flex; justify-content: space-between; gap: var(--tc-space-4); flex-wrap: wrap;
	margin-top: var(--tc-space-12); padding-top: var(--tc-space-6);
	border-top: 1px solid rgba(255,255,255,0.1); font-size: var(--tc-fs-sm);
}
@media (max-width: 900px) { .topcnc-footer__grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .topcnc-footer__grid { grid-template-columns: 1fr; } }

/* --- Prose (pages, posts) --------------------------------------------- */
.topcnc-prose { font-size: var(--tc-fs-lg); }
.topcnc-prose p { margin-bottom: var(--tc-space-6); }
.topcnc-prose h2, .topcnc-prose h3 { margin-top: var(--tc-space-8); }
.topcnc-prose ul, .topcnc-prose ol { padding-inline-start: 1.5rem; margin-bottom: var(--tc-space-6); }
.topcnc-prose img { border-radius: var(--tc-radius); }
.topcnc-prose__hero { margin: 0 0 var(--tc-space-8); }

.topcnc-post-list { display: grid; gap: var(--tc-space-6); }
.topcnc-post-card { padding: 0; overflow: hidden; display: grid; grid-template-columns: 260px 1fr; }
.topcnc-post-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.topcnc-post-card__body { padding: var(--tc-space-6); }
.topcnc-post-card__body time { font-size: var(--tc-fs-sm); color: var(--tc-text-muted); }
.topcnc-post-card__body h2 { font-size: var(--tc-fs-xl); margin-top: var(--tc-space-2); }
@media (max-width: 640px) { .topcnc-post-card { grid-template-columns: 1fr; } }

.topcnc-pagination { margin-top: var(--tc-space-8); }
.topcnc-pagination .nav-links { display: flex; gap: var(--tc-space-2); justify-content: center; }
.topcnc-pagination .page-numbers { padding: 0.4rem 0.8rem; border: 1px solid var(--tc-border); border-radius: var(--tc-radius-sm); }
.topcnc-pagination .page-numbers.current { background: var(--tc-primary); color: #fff; border-color: var(--tc-primary); }
