/*
 * Sangeet Jagat — base presentation layer (M2 Step 1)
 * Presentation only: no business logic. Values come from theme.json presets.
 * Loaded after GeneratePress (dependency: generate-style) so these rules win
 * over GeneratePress Customizer defaults at equal specificity.
 */

/* ---------- 1. Token aliases (short names for templates in later steps) ---------- */
:root {
	--sj-primary: var(--wp--preset--color--primary);
	--sj-primary-dark: var(--wp--preset--color--primary-dark);
	--sj-secondary: var(--wp--preset--color--secondary);
	--sj-accent: var(--wp--preset--color--accent);           /* decorative only */
	--sj-accent-safe: var(--wp--preset--color--accent-safe); /* gold for text/icons */
	--sj-bg: var(--wp--preset--color--background);
	--sj-surface: var(--wp--preset--color--surface);
	--sj-text: var(--wp--preset--color--text);
	--sj-text-2: var(--wp--preset--color--text-secondary);
	--sj-border: var(--wp--preset--color--border);
	--sj-border-strong: var(--wp--preset--color--border-strong);
	--sj-danger: var(--wp--preset--color--danger);

	--sj-font-ui: var(--wp--preset--font-family--ui);
	--sj-font-content: var(--wp--preset--font-family--content);
	--sj-font-content-heading: var(--wp--preset--font-family--content-heading);
	--sj-font-editorial-en: var(--wp--preset--font-family--editorial-en);

	--sj-radius-sm: var(--wp--custom--radius--sm);
	--sj-radius-card: var(--wp--custom--radius--card);
	--sj-radius-lg: var(--wp--custom--radius--lg);
	--sj-radius-pill: var(--wp--custom--radius--pill);

	--sj-touch: var(--wp--custom--control--touch);

	--sj-focus-ring: var(--wp--custom--focus--ring);
	--sj-focus-width: var(--wp--custom--focus--width);
	--sj-focus-offset: var(--wp--custom--focus--offset);
}

/* ---------- 2. Page base (overrides GeneratePress Customizer defaults) ---------- */
body {
	background-color: var(--sj-bg);
	color: var(--sj-text);
	font-family: var(--sj-font-ui);
	font-size: var(--wp--preset--font-size--body);
	line-height: var(--wp--custom--line-height--ui);
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

button, input, select, textarea {
	font-family: inherit;
}

h1, h2, h3, h4, h5, h6 {
	font-family: var(--sj-font-ui);
	color: var(--sj-text);
	line-height: var(--wp--custom--line-height--ui-heading);
}
h1 { font-size: var(--wp--preset--font-size--h-1); font-weight: 700; }
h2 { font-size: var(--wp--preset--font-size--h-2); font-weight: 600; }
h3 { font-size: var(--wp--preset--font-size--h-3); font-weight: 600; }
h4 { font-size: var(--wp--preset--font-size--h-4); font-weight: 600; }

a { color: var(--sj-primary); }
a:hover { color: var(--sj-primary-dark); }

/* ---------- 3. Marathi (Devanagari) content typography ---------- */
/*
 * Content areas use Mukta (body) and Tiro Devanagari Marathi (headings).
 * The UI stack already falls back to Mukta for Devanagari glyphs, so UI labels
 * such as category names render correctly without a lang switch.
 */
.entry-content,
.sj-content {
	font-family: var(--sj-font-content);
	font-size: var(--wp--preset--font-size--body-lg);
	line-height: var(--wp--custom--line-height--content-body);
	/* Mukta has no italic and Tiro has one weight: never let the browser fake them */
	font-synthesis: none;
}

.entry-content p,
.sj-content p {
	text-align: start; /* never justify Devanagari */
}

.entry-title,
.sj-content-title,
.entry-content :is(h1, h2, h3, h4),
.sj-content :is(h1, h2, h3, h4) {
	font-family: var(--sj-font-content-heading);
	font-weight: 400; /* Tiro Devanagari Marathi ships a single weight */
	font-synthesis: none;
	line-height: var(--wp--custom--line-height--content-heading);
	letter-spacing: 0;
	text-transform: none;
}

/*
 * M3.5 — Hindi articles use Tiro Devanagari Hindi for headings (the Marathi cut draws ल and श in
 * Marathi style). Any element marked lang="hi" (article title, body, cards) switches the variable;
 * Marathi headings are unchanged.
 */
[lang="hi"] {
	--sj-font-content-heading: var(--wp--preset--font-family--content-heading-hi);
}

/* Emphasis in Marathi: no fake italic; use a real weight instead */
/* Content is Marathi unless the content element itself says lang="en" */
:is(.entry-content, .sj-content):not([lang="en"]) :is(em, i) {
	font-style: normal;
	font-weight: 600;
}

/* Underlines clear the matras and descenders */
.entry-content a,
.sj-content a {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.3em;
	text-decoration-skip-ink: auto;
}

/*
 * Future English articles: Inter body, Lora headings.
 * Opt-in only — the content element itself must carry lang="en".
 * (Inherited :lang(en) is NOT used: the site's <html lang> is English UI,
 *  so :lang(en) would wrongly match every Marathi article. Fixed in v0.2.2.)
 */
.entry-content[lang="en"],
.sj-content[lang="en"] {
	font-family: var(--sj-font-ui);
	line-height: 1.7;
}
.entry-content[lang="en"] :is(h1, h2, h3, h4),
.sj-content[lang="en"] :is(h1, h2, h3, h4),
.entry-title[lang="en"],
.sj-content-title[lang="en"] {
	font-family: var(--sj-font-editorial-en);
	font-weight: 600;
	font-synthesis: weight;
}

/* ---------- 4. Focus (visible on every surface) ---------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible,
.wp-element-button:focus-visible {
	outline: var(--sj-focus-width) solid var(--sj-focus-ring);
	outline-offset: var(--sj-focus-offset);
}

/* Dark surfaces: switch the ring to cream so it stays visible.
   (.site-footer joins this list in Step 2, when the dark footer is applied.) */
.sj-on-dark,
.has-primary-background-color,
.has-primary-dark-background-color,
.has-secondary-background-color,
.has-footer-background-color {
	--sj-focus-ring: var(--wp--custom--focus--ring-on-dark);
}

/* ---------- 5. Buttons (non-block buttons; block buttons are styled in theme.json) ---------- */
.sj-btn,
.button,
input[type="submit"],
input[type="button"] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: var(--wp--custom--control--md);
	padding: 0 20px;
	border: 1.5px solid var(--sj-primary);
	border-radius: var(--sj-radius-sm);
	background-color: var(--sj-primary);
	color: var(--sj-surface);
	font-family: var(--sj-font-ui);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
}
.sj-btn:hover,
.button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
	background-color: var(--sj-primary-dark);
	border-color: var(--sj-primary-dark);
	color: var(--sj-surface);
}

.sj-btn--secondary {
	background-color: transparent;
	color: var(--sj-primary);
}
.sj-btn--secondary:hover {
	background-color: var(--wp--preset--color--tint-primary);
	border-color: var(--sj-primary-dark);
	color: var(--sj-primary-dark);
}

.sj-btn--ghost {
	background-color: transparent;
	border-color: transparent;
	color: var(--sj-primary);
	padding: 0 8px;
}
.sj-btn--ghost:hover {
	background-color: transparent;
	border-color: transparent;
	color: var(--sj-primary-dark);
	text-decoration: underline;
	text-decoration-color: var(--sj-accent); /* decorative gold, per M0 */
	text-decoration-thickness: 2px;
	text-underline-offset: 0.3em;
}

.sj-btn--sm { min-height: var(--wp--custom--control--sm); padding: 0 12px; font-size: 14px; }
.sj-btn--lg { min-height: var(--wp--custom--control--lg); padding: 0 24px; }

/* Disabled: muted colours, readable text, no opacity trick (M0) */
.sj-btn:disabled,
.sj-btn[aria-disabled="true"],
.button:disabled,
input[type="submit"]:disabled,
.wp-element-button[aria-disabled="true"] {
	background-color: var(--sj-border);
	border-color: var(--sj-border);
	color: var(--sj-text-2);
	cursor: not-allowed;
}

/* Touch devices: every button reaches the 48px target */
@media (pointer: coarse) {
	.sj-btn,
	.button,
	.wp-element-button,
	input[type="submit"],
	input[type="button"] {
		min-height: var(--sj-touch);
	}
}

/* ---------- 6. Form controls ---------- */
label {
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	color: var(--sj-text-2);
}

:where(input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="range"], [type="color"]), select, textarea) {
	min-height: var(--sj-touch);
	padding: 10px 14px;
	border: 1px solid var(--sj-border-strong); /* 3:1+ against surface and background */
	border-radius: var(--sj-radius-sm);
	background-color: var(--sj-surface);
	color: var(--sj-text);
	font-size: var(--wp--preset--font-size--body); /* 16px: stops iOS zoom on focus */
	box-sizing: border-box;
}
:where(input, select, textarea):focus-visible {
	border-color: var(--sj-primary);
}
:where(input, select, textarea)[aria-invalid="true"] {
	border-color: var(--sj-danger);
}
::placeholder {
	color: var(--sj-text-2);
	opacity: 1;
}

input[type="checkbox"],
input[type="radio"] {
	accent-color: var(--sj-primary);
	width: 20px;
	height: 20px;
}

/* ---------- 7. Motion ---------- */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/* ---------- M3.5: profile photos inside avatar circles (0.11.1: always a circle) ---------- */
:is(.sj-byline__avatar, .sj-authorcard__avatar, .sj-dircard__avatar, .sj-person__avatar, .sj-writer__avatar, .sj-profile__avatar, .sj-profile__avatar > span) {
	overflow: hidden;
}
.sj-profile__avatar > span {
	min-width: 0;
	min-height: 0;
}
img.sj-avatar-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	object-position: center top;
	border-radius: 50%;
}
/* M3.5: topic icons in tiles */
.sj-tile__icon--topic svg,
.sj-topictile__glyph svg,
.sj-topic__glyph svg {
	display: block;
}
.sj-profile__creds {
	margin: 4px 0 0;
	color: var(--sj-text-secondary, #6B6355);
	font-size: var(--wp--preset--font-size--small, 14px);
}

/* ---------- M7 (0.13.0): ad places. Space is reserved before the ad loads (no layout shift). ---------- */
.sj-ad {
	display: flex;
	flex-direction: column;
	gap: 6px;
	clear: both;
	margin: 24px 0;
	font-family: var(--sj-font-ui);
}
.sj-ad__label {
	font-size: 11px;
	letter-spacing: 0.6px;
	text-transform: uppercase;
	color: var(--sj-text-2);
}
.sj-ad__box {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 280px;
	overflow: hidden;
	border-radius: 8px;
	background-color: var(--wp--preset--color--ad-background);
}
.sj-ad--preview .sj-ad__box {
	padding: 16px;
	border: 1px dashed var(--wp--preset--color--ad-border);
	font-size: 13px;
	line-height: 1.5;
	text-align: center;
	color: var(--sj-text-2);
}
.sj-ad--adsense .sj-ad__box > ins { width: 100%; }
.sj-ad--direct .sj-ad__box { min-height: 0; background: none; }
.sj-ad__link { display: block; width: 100%; }
.sj-ad__link img { display: block; width: 100%; height: auto; border-radius: 8px; }
.sj-ad__link:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.sj-ad:has(ins[data-ad-status="unfilled"]) { display: none; }
.sj-listad { list-style: none; }
.sj-listad .sj-ad { margin: 8px 0; }
.sj-home__ad { padding: 0 16px; }
.sj-home__ad .sj-ad { margin: 0; }
@media (min-width: 1024px) {
	.sj-home__ad { padding: 0; }
	.sj-ad--home .sj-ad__box { min-height: 100px; }
	.sj-ad--home.sj-ad--direct .sj-ad__box { min-height: 0; }
}

/* ---------- M8.2.1 install card (theme 0.14.1) — non-modal, fixed, no layout shift ---------- */
.sj-install {
	position: fixed;
	z-index: 105; /* above page + bottom bar (100), below header menus (110) */
	left: 12px;
	right: 12px;
	bottom: calc(var(--wp--custom--chrome--bottom-nav, 72px) + env(safe-area-inset-bottom, 0px) + 8px);
	max-width: 440px;
	margin: 0 auto;
	display: flex;
	gap: 12px;
	align-items: flex-start;
	padding: 14px 40px 14px 14px;
	background: var(--sj-surface);
	color: var(--sj-text);
	border: 1px solid var(--sj-border-strong);
	border-radius: var(--sj-radius-card);
	box-shadow: 0 8px 28px rgba(42, 33, 25, .18);
	font-family: var(--sj-font-ui);
	font-size: .9rem;
	line-height: 1.45;
	opacity: 0;
	transform: translateY(12px);
	transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
	visibility: hidden;
}
.sj-install.is-in { opacity: 1; transform: none; visibility: visible; transition: opacity .2s ease, transform .2s ease; }
.sj-install.is-in.is-away { opacity: 0; visibility: hidden; pointer-events: none; transform: none; }
@media (min-width: 1024px) {
	.sj-install { left: auto; right: 24px; bottom: 24px; margin: 0; width: 400px; }
}
@media (prefers-reduced-motion: reduce) {
	.sj-install, .sj-install.is-in { transition: none; transform: none; }
}
.sj-install__icon { flex: 0 0 48px; width: 48px; height: 48px; border-radius: 12px; }
.sj-install__text { min-width: 0; }
.sj-install__title { margin: 0 0 4px; font-weight: 700; font-size: 1rem; color: var(--sj-primary); }
.sj-install__title span { display: block; }
.sj-install__title .sj-install__en { font-size: .85rem; font-weight: 600; color: var(--sj-text-2); }
.sj-install p { margin: 0 0 4px; }
.sj-install p.sj-install__en { color: var(--sj-text-2); font-size: .82rem; }
.sj-install__ios { margin-top: 6px !important; }
.sj-install__ios span { display: block; }
.sj-install__ios svg { vertical-align: -3px; }
.sj-install__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sj-install__add, .sj-install__later {
	min-height: var(--sj-touch, 44px);
	padding: 8px 14px;
	border-radius: var(--sj-radius-pill);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
.sj-install__add { background: var(--sj-primary); color: #fff; border: 0; }
.sj-install__add:hover { background: var(--sj-primary-dark); }
.sj-install__later { background: transparent; color: var(--sj-text); border: 1px solid var(--sj-border-strong); }
.sj-install__close {
	position: absolute;
	top: 2px;
	right: 2px;
	width: var(--sj-touch, 44px);
	height: var(--sj-touch, 44px);
	border: 0;
	background: transparent;
	color: var(--sj-text-2);
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
}
.sj-install button:focus-visible { outline: var(--sj-focus-width, 3px) solid var(--sj-focus-ring); outline-offset: 2px; }
@media print { .sj-install { display: none !important; } }

/* ---------- M8.4: Support page parts (Core shortcodes) + language links on forms ---------- */
.sj-give { display: grid; gap: 16px; margin: 12px 0 24px; }
.sj-give__online, .sj-give__bank { padding: 18px; border: 1px solid var(--sj-border); border-radius: var(--sj-radius-lg); background: var(--sj-surface); }
.sj-give__btn {
	display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 28px;
	border-radius: var(--sj-radius-pill); background: var(--sj-primary); color: var(--sj-surface) !important; font-weight: 700; font-size: 17px; text-decoration: none;
}
.sj-give__btn:hover { background: var(--sj-primary-dark); }
.sj-give__btn:focus-visible { outline: 3px solid var(--sj-accent-safe); outline-offset: 3px; }
.sj-give__bank h3 { margin: 0 0 10px; font-size: 18px; }
.sj-give__bank dl { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.sj-give__bank dt { color: var(--sj-text-2); font-size: 14px; }
.sj-give__bank dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; user-select: all; }
.sj-give__note { margin: 10px 0 0; font-size: 14px; color: var(--sj-text-2); line-height: 1.55; }
.sj-give__warn { margin: 10px 0 0; padding: 10px 12px; border-left: 4px solid var(--sj-danger); font-size: 14px; line-height: 1.55; }
.sj-donors__list { display: grid; gap: 0; margin: 12px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--sj-border); }
.sj-donors__item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--sj-border); }
.sj-donors__who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sj-donors__name { font-weight: 600; font-size: 17px; overflow-wrap: anywhere; }
.sj-donors__meta { color: var(--sj-text-2); font-size: 14px; }
.sj-donors__amt { flex: none; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--sj-primary); }
@media (min-width: 768px) { .sj-donors__list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; } }
.sj-support-en { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--sj-border); }
.sj-langs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; font-size: 14px; }
.sj-langs a, .sj-langs span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid var(--sj-border); border-radius: var(--sj-radius-pill); color: var(--sj-text); }
.sj-langs span[aria-current] { border-color: var(--sj-primary); color: var(--sj-primary); font-weight: 600; }
