/**
 * EDATA Portal Pro — shared layer (front end + editor).
 * Uses logical properties (inline/block) so layouts mirror correctly in RTL.
 */

/* ---------- 1. Text wrapping: long Hindi/English headlines, URLs, mixed scripts ---------- */

h1, h2, h3, h4, h5, h6,
.wp-block-post-title,
.wp-block-query-title,
.wp-block-site-title {
	overflow-wrap: break-word;
	word-break: normal;
	hyphens: manual;
	text-wrap: balance;
	min-width: 0;
}

p, li, dd, blockquote, figcaption, td, th {
	overflow-wrap: break-word;
	text-wrap: pretty;
}

/* Long unbroken strings (URLs, codes) must never push the layout sideways. */
.wp-block-post-content a,
.wp-block-comment-content a {
	overflow-wrap: anywhere;
}

/* Flex/grid children default to min-width:auto, which lets long words overflow. */
.wp-block-columns > .wp-block-column,
.wp-block-group.is-layout-flex > *,
.wp-block-post-template > li {
	min-width: 0;
}

/* ---------- 2. Devanagari rhythm ---------- */
/* Matras and conjuncts sit above/below the line; give them room. */

:lang(hi), :lang(mr), :lang(ne), :lang(sa) {
	--wp--custom--line-height--heading: 1.42;
	--wp--custom--line-height--snug: 1.6;
	--wp--custom--line-height--body: 1.85;
	letter-spacing: 0;
}

:lang(hi) :is(h1, h2, h3, h4, h5, h6, .wp-block-post-title),
:lang(mr) :is(h1, h2, h3, h4, h5, h6, .wp-block-post-title) {
	letter-spacing: 0;
	text-transform: none;
}

/* Uppercase has no meaning in Devanagari; keep tracking neutral for labels. */
:lang(hi) .wp-block-post-terms,
:lang(hi) .is-style-edata-kicker,
:lang(hi) .is-style-edata-label {
	letter-spacing: 0;
}

/* ---------- 3. Accessibility ---------- */

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: var(--wp--custom--focus--width, 3px) solid var(--wp--custom--focus--color, #0b3c8c);
	outline-offset: var(--wp--custom--focus--offset, 2px);
	border-radius: 2px;
}

/* Keep focus visible on dark/accent sections. */
:where(.is-style-edata-section-dark, .is-style-edata-section-accent) :where(a, button, input, summary):focus-visible {
	outline-color: var(--wp--preset--color--accent-3);
}

.screen-reader-text {
	border: 0;
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute !important;
	width: 1px;
	word-wrap: normal !important;
}

.screen-reader-text:focus {
	background-color: var(--wp--preset--color--base);
	clip-path: none;
	color: var(--wp--preset--color--contrast);
	display: block;
	font-size: 1rem;
	height: auto;
	inset-inline-start: 6px;
	padding: 1rem 1.25rem;
	top: 6px;
	width: auto;
	z-index: 100000;
}

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

/* ---------- 4. Media and layout stability ---------- */

img, video, iframe {
	max-width: 100%;
}

img {
	height: auto;
}

.wp-block-post-featured-image img {
	display: block;
}

/* Sticky groups (Group block → Position → Sticky) need a solid background and stacking. */
.is-position-sticky {
	z-index: 50;
}

.is-position-sticky:not(.has-background) {
	background-color: var(--wp--preset--color--base);
}

/* ---------- 5. RTL corrections for physical properties produced by theme.json ---------- */

[dir="rtl"] .wp-block-quote {
	border-left: 0;
	border-right: 4px solid var(--wp--preset--color--accent);
	padding-left: 0;
	padding-right: var(--wp--preset--spacing--40);
}

/* ---------- 6. Block styles (registered in inc/block-styles.php) ---------- */

/* Group: Card */
.wp-block-group.is-style-edata-card {
	background-color: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--medium);
	overflow: hidden;
}

/* Group: Newspaper rule (top) */
.wp-block-group.is-style-edata-rule-top {
	border-top: 3px solid var(--wp--preset--color--contrast);
	padding-top: var(--wp--preset--spacing--30);
}

/* Group: Image overlay card — Featured Image as background, text at the bottom. */
.wp-block-group.is-style-edata-overlay {
	position: relative;
	isolation: isolate;
	overflow: hidden;
	border-radius: var(--wp--custom--radius--medium);
	color: #fff;
}

.wp-block-group.is-style-edata-overlay > .wp-block-post-featured-image {
	position: absolute;
	inset: 0;
	z-index: -1;
	margin: 0;
	height: 100% !important;
}

.wp-block-group.is-style-edata-overlay > .wp-block-post-featured-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.wp-block-group.is-style-edata-overlay::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: linear-gradient(180deg, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0.85) 100%);
	pointer-events: none;
}

.wp-block-group.is-style-edata-overlay :is(.wp-block-post-title a, .wp-block-post-terms a, .wp-block-post-date, .wp-block-post-date a, .wp-block-post-author-name a, .wp-block-post-excerpt) {
	color: #fff;
}

/* Columns: Newspaper column rules */
.wp-block-columns.is-style-edata-ruled > .wp-block-column + .wp-block-column {
	border-inline-start: 1px solid var(--wp--preset--color--border);
	padding-inline-start: var(--wp--preset--spacing--40);
}

@media (max-width: 781px) {
	.wp-block-columns.is-style-edata-ruled > .wp-block-column + .wp-block-column {
		border-inline-start: 0;
		padding-inline-start: 0;
		border-top: 1px solid var(--wp--preset--color--border);
		padding-top: var(--wp--preset--spacing--40);
	}
}

/* Heading: Section title (accent bar) */
.wp-block-heading.is-style-edata-section-title {
	border-inline-start: 4px solid var(--wp--preset--color--accent);
	padding-inline-start: 0.6em;
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.3;
}

/* Heading: Section title (ruled line) */
.wp-block-heading.is-style-edata-ruled {
	display: flex;
	align-items: center;
	gap: 0.75em;
	font-size: var(--wp--preset--font-size--medium);
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.wp-block-heading.is-style-edata-ruled::after {
	content: "";
	flex: 1 1 auto;
	height: 1px;
	background-color: currentColor;
	opacity: 0.25;
}

.wp-block-heading.is-style-edata-ruled.has-text-align-center::before {
	content: "";
	flex: 1 1 auto;
	height: 1px;
	background-color: currentColor;
	opacity: 0.25;
}

/* Heading: Label (filled) */
.wp-block-heading.is-style-edata-label {
	display: inline-block;
	background-color: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--on-accent);
	font-size: var(--wp--preset--font-size--small);
	padding: 0.35em 0.75em;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	line-height: 1.3;
}

/* Paragraph: Kicker and Lead */
p.is-style-edata-kicker {
	color: var(--wp--preset--color--accent);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

p.is-style-edata-lead {
	color: var(--wp--preset--color--contrast-2);
	font-size: var(--wp--preset--font-size--large);
	line-height: var(--wp--custom--line-height--snug);
}

/* Post Template: Divided list */
.wp-block-post-template.is-style-edata-divided > li + li {
	border-top: 1px solid var(--wp--preset--color--border);
	padding-top: var(--wp--style--block-gap, 1.25rem);
}

.wp-block-post-template.is-style-edata-divided.is-layout-grid > li + li {
	border-top: 0;
	padding-top: 0;
}

/* Post Template: Numbered list */
.wp-block-post-template.is-style-edata-numbered {
	counter-reset: edata-rank;
}

.wp-block-post-template.is-style-edata-numbered > li {
	counter-increment: edata-rank;
	display: grid;
	grid-template-columns: 2.25em minmax(0, 1fr);
	column-gap: 0.75em;
	align-items: start;
}

.wp-block-post-template.is-style-edata-numbered > li::before {
	content: counter(edata-rank);
	color: var(--wp--preset--color--accent);
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 800;
	line-height: 1;
}

.wp-block-post-template.is-style-edata-numbered > li > * {
	grid-column: 2;
}

/* Post Terms: Pill */
.wp-block-post-terms.is-style-edata-pill a {
	display: inline-block;
	background-color: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--on-accent);
	border-radius: var(--wp--custom--radius--small);
	padding: 0.25em 0.6em;
	line-height: 1.3;
}

.wp-block-post-terms.is-style-edata-pill .wp-block-post-terms__separator {
	display: inline-block;
	width: 0.25em;
	overflow: hidden;
	color: transparent;
}

/* Post Title: Limit to 3 lines (visual only; full title stays in the HTML). */
.wp-block-post-title.is-style-edata-clamp-3 {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
}

/* Images: Rounded */
.is-style-edata-rounded img,
.wp-block-post-featured-image.is-style-edata-rounded {
	border-radius: var(--wp--custom--radius--large);
	overflow: hidden;
}

/* List: Plain and Inline */
ul.is-style-edata-plain,
ol.is-style-edata-plain {
	list-style: none;
	padding-inline-start: 0;
}

ul.is-style-edata-plain > li + li {
	margin-top: 0.5em;
}

ul.is-style-edata-inline {
	list-style: none;
	padding-inline-start: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.4em 1.25em;
}

/* Separator: Thick */
.wp-block-separator.is-style-edata-thick {
	border-top-width: 4px !important;
	border-bottom: 0;
	opacity: 1;
}

/* ---------- 7. Theme components ---------- */

/* Meta rows: author · date · reading time */
.edata-meta {
	color: var(--wp--preset--color--contrast-3);
	font-size: var(--wp--preset--font-size--x-small);
}

.edata-meta > * {
	margin: 0;
}

.edata-meta > * + *:not(.wp-block-avatar)::before {
	content: "·";
	margin-inline-end: 0.5rem;
	color: var(--wp--preset--color--contrast-3);
}

.edata-meta > .wp-block-avatar + *::before {
	content: none;
}

.edata-meta .wp-block-avatar img {
	display: block;
}

.edata-modified__label {
	font-weight: 600;
}

/* Latest-headlines strip (fallback when the breaking-news block is not available) */
.edata-latest-strip > p {
	flex-shrink: 0;
	margin: 0;
}

.edata-latest-strip .wp-block-post-template {
	margin: 0;
	gap: 0.4rem 1.5rem;
}

.edata-latest-strip .edata-strip-title {
	margin: 0;
	font-weight: 600;
}

/* Category lists */
.wp-block-categories.is-style-edata-plain {
	list-style: none;
	padding-inline-start: 0;
}

.wp-block-categories.is-style-edata-plain li + li {
	margin-top: 0.4em;
}

.wp-block-categories.edata-category-columns {
	columns: 2 9rem;
	column-gap: var(--wp--preset--spacing--40);
}

.wp-block-categories.edata-chips {
	list-style: none;
	padding-inline-start: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.wp-block-categories.edata-chips li a {
	display: inline-block;
	padding: 0.45em 1em;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--pill);
	text-decoration: none;
	color: var(--wp--preset--color--contrast);
}

.wp-block-categories.edata-chips li a:hover {
	border-color: var(--wp--preset--color--contrast);
}

/* Article */
.edata-article-content {
	margin-top: var(--wp--preset--spacing--50);
}

.edata-post-nav > * {
	max-width: 48%;
}

.edata-tags a {
	text-transform: none;
	letter-spacing: 0;
}

/* Archive newspaper grid: thin column rules */
.edata-newspaper-grid > li {
	border-top: 1px solid var(--wp--preset--color--border);
	padding-top: var(--wp--preset--spacing--30);
}

/* Footer helpers */
.edata-back-to-top a,
.edata-credit {
	text-decoration: none;
}

/* Sidebar becomes full width under the main column on small screens (Columns stack natively). */
.edata-sidebar {
	min-width: 0;
}

/* Cover-based heroes: titles stay readable on any image */
.wp-block-cover .wp-block-post-title,
.wp-block-cover .wp-block-post-title a {
	color: #fff;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* ---------- 8. Full-width + responsive safeguards ---------- */

/* Unbroken strings (URLs, codes, very long words) in titles must not widen grids or columns:
   "anywhere" lowers the min-content width, so layouts can shrink; normal words still wrap at spaces. */
.wp-block-post-title,
.wp-block-post-title a,
.wp-block-heading,
.wp-block-query-title,
.wp-block-post-navigation-link,
.post-navigation-link__title,
.wp-block-post-excerpt,
.wp-block-breadcrumbs,
.edata-related__title,
.edata-most-discussed__list a,
.edata-breaking__item,
.edata-toc a {
	overflow-wrap: anywhere;
}

/* Media never wider than its container. */
.wp-block-post-content :is(img, video, iframe, embed, object, table, pre) {
	max-width: 100%;
}

.wp-block-post-content pre,
.wp-block-post-content .wp-block-table {
	overflow-x: auto;
}

/* Header rows: on small phones let the right-hand group (menu button, search, CTA) drop below the logo
   instead of pushing past the screen edge. */
@media (max-width: 599px) {
	header .wp-block-group.is-nowrap {
		flex-wrap: wrap;
	}

	header .wp-block-site-title {
		font-size: clamp(1.25rem, 6vw, 1.875rem);
	}
}

/* Sidebar items (search form, ads, lists) may never be wider than the sidebar column. */
.edata-sidebar > * {
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

.wp-block-search__inside-wrapper,
.wp-block-search__input {
	min-width: 0;
	max-width: 100%;
}

/* News header on phones: the top-bar menu repeats the main menu (which is still available
   through the menu button), so it is hidden to keep the header compact. */
@media (max-width: 781px) {
	.edata-topbar-nav {
		display: none !important;
	}
}
