/*
 * Ketabbin 3.4.0 — unified, fluid Persian typography.
 * This is the final visual layer and intentionally normalizes legacy micro type.
 */

:root {
	--kb-type-micro: clamp(11.5px, .16vw + 11px, 13px);
	--kb-type-caption: clamp(12.5px, .18vw + 12px, 14px);
	--kb-type-ui: clamp(13.5px, .2vw + 13px, 15px);
	--kb-type-body: clamp(15.5px, .24vw + 15px, 17px);
	--kb-type-lead: clamp(16px, .35vw + 15px, 19px);
	--kb-type-h4: clamp(17px, .45vw + 15px, 22px);
	--kb-type-h3: clamp(20px, .8vw + 17px, 28px);
	--kb-type-h2: clamp(25px, 1.5vw + 19px, 40px);
	--kb-type-h1: clamp(34px, 3.1vw + 18px, 62px);
}

html {
	font-size: 100%;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	font-size: var(--kb-type-body);
	line-height: 1.85;
}

input,
select,
textarea {
	font-size: var(--kb-type-ui);
	line-height: 1.65;
}

button { line-height: 1.5; }

:is(.kb-prose, .entry-content, .woocommerce-Tabs-panel, .kb-article-content) :is(p, li, dd) {
	font-size: var(--kb-type-body);
	line-height: 2.05;
}

.kb-button,
.kb-card-action,
.kb-text-link,
.woocommerce a.button,
.woocommerce button.button,
.woocommerce input.button {
	font-size: var(--kb-type-ui);
}

.kb-kicker,
.kb-auth-eyebrow,
.kb-product-kicker,
.kb-store-section-head > div > span,
.kb-member-today > span,
.kb-member-card > header small {
	font-size: var(--kb-type-micro);
}

/* Header and discovery. */
.kb-commerce-notice,
.kb-nav a,
.kb-commerce-location,
.kb-account-link,
.kb-category-toggle,
.kb-commerce-search input,
.kb-commerce-search > button,
.kb-mobile-theme-controls button,
.kb-mobile-theme-controls > span {
	font-size: var(--kb-type-caption);
}

.kb-search-results :is(strong, small, p, a) { font-size: var(--kb-type-caption); }
.kb-story-rail > strong { font-size: var(--kb-type-ui); }
.kb-story small { font-size: var(--kb-type-caption); }

/* Homepage hierarchy. */
.kb-commerce-hero-grid .kb-hero-slide__copy :is(h1, h2),
.kb-hero-slide__copy :is(h1, h2) {
	font-size: clamp(36px, 3.4vw, 58px);
	line-height: 1.42;
}

.kb-hero-slide__copy p,
.kb-epub-commerce p,
.kb-community-commerce__intro p,
.kb-cafe-feature p {
	font-size: var(--kb-type-lead);
	line-height: 1.9;
}

.kb-quick-links strong { font-size: var(--kb-type-ui); }
.kb-quick-links small { font-size: var(--kb-type-micro); }
.kb-store-section-head h2 { font-size: var(--kb-type-h2); }
.kb-store-section-head > a { font-size: var(--kb-type-caption); }

.kb-store-card__body > small,
.kb-store-card__meta,
.kb-store-card__price del,
.kb-discount-badge,
.kb-format-badge {
	font-size: var(--kb-type-micro);
}

.kb-store-card h3 {
	font-size: var(--kb-type-ui);
	line-height: 1.75;
}

.kb-store-card__price { font-size: var(--kb-type-ui); }
.kb-store-card__buy { font-size: var(--kb-type-caption); }

.kb-service-strip strong,
.kb-community-commerce__events article strong,
.kb-category-grid strong {
	font-size: var(--kb-type-ui);
}

.kb-service-strip small,
.kb-community-commerce__events article small,
.kb-category-grid small,
.kb-community-commerce__events article > a {
	font-size: var(--kb-type-micro);
}

.kb-epub-commerce h2,
.kb-community-commerce__intro h2,
.kb-cafe-feature h2,
.kb-host-strip h2 {
	font-size: var(--kb-type-h2);
}

.kb-article-card small { font-size: var(--kb-type-micro); }
.kb-article-card :is(h2, h3) { font-size: var(--kb-type-h4); }
.kb-article-card p { font-size: var(--kb-type-caption); }

/* Regular pages, events and chat. */
.kb-page-heading h1,
.kb-single__header h1,
.kb-cafe-hero h1,
.kb-empty-state h1 {
	font-size: var(--kb-type-h1);
	line-height: 1.38;
}

.kb-page-heading span,
.kb-section-head small,
.kb-section-head > a,
.kb-field,
.kb-event-row :is(p, small, span),
.kb-chat__rooms :is(small, h3, p),
.kb-chat__conversation header :is(small, a),
.kb-chat__notice,
.kb-message :is(strong, small),
.kb-chat__side :is(p, small, li) {
	font-size: var(--kb-type-caption);
}

.kb-section-head h2,
.kb-chat__conversation h1 { font-size: var(--kb-type-h3); }
.kb-event-row h3 { font-size: var(--kb-type-h4); }

/* Footer must remain compact but readable. */
.kb-footer-main a:not(.kb-footer-logo),
.kb-footer-main p,
.kb-footer-trust small,
.kb-newsletter :is(input, button),
.kb-footer-bottom,
.kb-footer p,
.kb-footer a,
.kb-footer__copy {
	font-size: var(--kb-type-micro);
}

.kb-footer-main > div > strong,
.kb-footer-trust strong { font-size: var(--kb-type-caption); }

/* Customer dashboard. */
.kb-member-dashboard .kb-account-nav nav a,
.kb-member-edit,
.kb-member-today > a,
.kb-member-card > header > a,
.kb-member-card-link,
.kb-member-empty > a,
.kb-member-profile-card > a,
.kb-member-recommendations > header > a {
	font-size: var(--kb-type-caption);
}

.kb-member-dashboard .kb-account-nav__profile strong,
.kb-member-hero__identity small,
.kb-member-today > span,
.kb-member-stats small,
.kb-member-stats article > i,
.kb-member-card > header small,
.kb-member-reading__saved,
.kb-member-order__status,
.kb-member-order__summary small,
.kb-member-order__track i,
.kb-member-event__body span,
.kb-member-invite-list small,
.kb-member-profile-card small,
.kb-member-wallet-card small,
.kb-member-recommendations > header small {
	font-size: var(--kb-type-micro);
}

.kb-member-hero__identity p,
.kb-member-reading__body p,
.kb-member-event__body p,
.kb-member-empty p,
.kb-member-profile-card p,
.kb-member-wallet-card p {
	font-size: var(--kb-type-caption);
	line-height: 1.8;
}

.kb-member-card > header h2,
.kb-member-reading__body h3,
.kb-member-event__body h3,
.kb-member-profile-card h2,
.kb-member-wallet-card strong,
.kb-member-recommendations > header h2 {
	font-size: var(--kb-type-h4);
}

.kb-member-order__summary strong,
.kb-member-invite-list strong,
.kb-member-empty strong { font-size: var(--kb-type-caption); }

/* Authentication. */
.kb-auth-back,
.kb-auth-tabs a,
.kb-auth-message,
.kb-auth-form > label > span,
.kb-auth-check,
.kb-auth-form__meta > a,
.kb-auth-return,
.kb-auth-security,
.kb-auth-admin-link,
.kb-auth-visual__content li,
.kb-auth-quote small,
.kb-auth-footer {
	font-size: var(--kb-type-caption);
}

.kb-auth-panel h1 { font-size: clamp(32px, 3vw, 45px); }
.kb-auth-panel h1 + p,
.kb-auth-visual__content > p,
.kb-auth-quote p { font-size: var(--kb-type-body); }
.kb-auth-form input { font-size: var(--kb-type-ui); }
.kb-auth-submit { font-size: var(--kb-type-ui); }

/* WooCommerce catalogue, cart and checkout. */
.woocommerce .woocommerce-result-count,
.woocommerce .woocommerce-ordering,
.woocommerce .product_meta,
.woocommerce table.shop_table,
.woocommerce form .form-row label,
.woocommerce .woocommerce-message,
.woocommerce .woocommerce-info,
.woocommerce .woocommerce-error,
.woocommerce-checkout-review-order,
.woocommerce-cart-form {
	font-size: var(--kb-type-caption);
}

.woocommerce ul.products li.product .woocommerce-loop-product__title {
	font-size: var(--kb-type-ui) !important;
	line-height: 1.75;
}

.woocommerce ul.products li.product .price { font-size: var(--kb-type-ui); }
.woocommerce ul.products li.product .button { font-size: var(--kb-type-caption); }

/* Book product page. */
.kb-book-byline small,
.kb-format-selector > span,
.kb-format-selector small,
.kb-product-fulfillment small,
.kb-purchase-box > header small,
.kb-purchase-box__footer span,
.kb-product-assurances span,
.kb-book-specs th {
	font-size: var(--kb-type-micro);
}

.kb-book-byline strong,
.kb-format-selector strong,
.kb-product-fulfillment b,
.kb-purchase-box > header span,
.kb-product-core-actions .kb-wishlist-button span,
.kb-book-specs td,
body.single-product .woocommerce div.product .woocommerce-review-link,
body.single-product .woocommerce div.product .woocommerce-tabs ul.tabs li a {
	font-size: var(--kb-type-caption);
}

body.single-product .woocommerce div.product .woocommerce-product-details__short-description,
body.single-product .woocommerce div.product .woocommerce-tabs .panel {
	font-size: var(--kb-type-body);
}

body.single-product .woocommerce div.product .product_title { font-size: clamp(32px, 3vw, 48px); }
.kb-product-sample h3 { font-size: var(--kb-type-h4); }

@media (max-width: 700px) {
	:root {
		--kb-type-micro: 11.5px;
		--kb-type-caption: 12.5px;
		--kb-type-ui: 13.5px;
		--kb-type-body: 16px;
		--kb-type-lead: 16px;
		--kb-type-h4: 18px;
		--kb-type-h3: 22px;
		--kb-type-h2: 27px;
		--kb-type-h1: 36px;
	}

	body { font-size: 16px; }

	/* 16px prevents unwanted automatic zoom on iOS form focus. */
	input,
	select,
	textarea,
	.kb-auth-form input,
	.kbc-phone-auth input {
		font-size: 16px !important;
	}

	.kb-commerce-search input { font-size: 13px !important; }
	.kb-category-toggle span { font-size: 12px !important; }
	.kb-mobile-theme-controls :is(button, b, span) { font-size: 12px !important; }

	.kb-commerce-hero-grid .kb-hero-slide__copy :is(h1, h2),
	.kb-hero-slide__copy :is(h1, h2) {
		font-size: clamp(31px, 9.2vw, 37px) !important;
		line-height: 1.48;
		letter-spacing: -.6px;
	}

	.kb-hero-slide__copy p { font-size: 15px !important; line-height: 1.95; }
	.kb-button--hero { font-size: 14px !important; }
	.kb-story small { font-size: 12px !important; }
	.kb-quick-links strong { font-size: 13.5px; }
	.kb-quick-links small { font-size: 11.5px; }
	.kb-store-card h3 { min-height: 50px; font-size: 13.5px !important; line-height: 1.8; }
	.kb-store-card__body > small,
	.kb-store-card__meta,
	.kb-store-card__price del { font-size: 11.5px; }
	.kb-store-card__price { font-size: 13px; }
	.kb-store-card__buy { min-height: 42px; font-size: 12.5px; }
	.kb-store-section-head h2 { font-size: 24px; }
	.kb-store-section-head > a { font-size: 12px; }
	.kb-category-grid strong { font-size: 13px; }
	.kb-category-grid small { font-size: 11.5px; }
	.kb-service-strip strong { font-size: 13px; }
	.kb-service-strip small { font-size: 11.5px; }

	.kb-mobile-store-nav a { font-size: 12px !important; }
	.kb-mobile-store-nav a span { overflow: visible; text-overflow: clip; }

	.kb-page-heading h1,
	.kb-single__header h1,
	.kb-cafe-hero h1 { font-size: clamp(32px, 9vw, 39px); }

	.kb-member-dashboard .kb-account-nav nav a { font-size: 12px !important; }
	.kb-member-hero__identity h1 { font-size: 24px !important; }
	.kb-member-stats strong { font-size: 20px; }
	.kb-member-stats small { font-size: 11.5px; white-space: normal; }
	.kb-member-reading__body h3,
	.kb-member-event__body h3 { font-size: 17px !important; }
	.kb-member-order__track i span { font-size: 11.5px !important; line-height: 1.45; }
	.kb-member-invite-list strong { font-size: 13px; }
	.kb-member-invite-list small { font-size: 11.5px; }

	.kb-auth-panel h1 { font-size: 32px !important; }
	.kb-auth-panel h1 + p,
	.kb-auth-message,
	.kb-auth-tabs a,
	.kb-auth-check,
	.kb-auth-security,
	.kb-auth-return { font-size: 13px; }
	.kb-auth-submit { font-size: 14px; }

	body.single-product .woocommerce div.product .product_title { font-size: 30px; }
	.kb-product-kicker { font-size: 12px; }
	.kb-book-byline small { font-size: 11.5px; }
	.kb-book-byline strong { font-size: 13px; }
	.kb-format-selector :is(strong, small) { font-size: 12.5px; }
	.kb-product-fulfillment :is(b, small) { font-size: 12px; }
	.kb-purchase-box > header :is(span, small) { font-size: 12px; }
	body.single-product .woocommerce div.product .kb-purchase-box .single_add_to_cart_button { font-size: 14px; }
	.kb-product-assurances span { font-size: 11.5px; }
	.kb-book-specs :is(th, td) { font-size: 12.5px; }
	body.single-product .woocommerce div.product .woocommerce-tabs ul.tabs li a { font-size: 12px; }
	body.single-product .woocommerce div.product .woocommerce-tabs .panel { font-size: 15px; }
}

@media (min-width: 701px) and (max-width: 1100px) {
	:root {
		--kb-type-micro: 12px;
		--kb-type-caption: 13px;
		--kb-type-ui: 14px;
		--kb-type-body: 16px;
	}
}
