/*
 * Janad Diamond - presentation that theme.json cannot express.
 * Everything here is either a state (hover/scroll), a texture, a language
 * rule, or slider mechanics. Design tokens stay in theme.json.
 *
 * Logical properties only (margin-inline, inset-inline, padding-inline) so
 * Arabic mirrors without a parallel stylesheet.
 */

/* -------------------------------------------------------------------------
 * 1. Arabic typography
 *
 * Arabic reads slightly larger with looser leading, and must never receive
 * uppercase or extra letter-spacing - both break cursive joining.
 * +1px on the root (not a percentage) so rem-based sizes gain exactly 1px at
 * body size rather than scaling up multiplicatively at heading sizes.
 * ---------------------------------------------------------------------- */

html[lang="ar"] {
	font-size: 17px;
}

html[lang="ar"] body {
	font-family: var(--wp--preset--font-family--arabic);
	line-height: 1.9;
}

html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] h3,
html[lang="ar"] h4,
html[lang="ar"] h5,
html[lang="ar"] h6,
html[lang="ar"] .wp-block-navigation,
html[lang="ar"] .wp-block-button__link,
html[lang="ar"] button {
	font-family: var(--wp--preset--font-family--arabic);
}

html[lang="ar"] [style*="text-transform"],
html[lang="ar"] .wp-block-navigation,
html[lang="ar"] .wp-block-button__link,
html[lang="ar"] .jd-uppercase {
	text-transform: none !important;
	letter-spacing: normal !important;
}

/* -------------------------------------------------------------------------
 * 2. Surfaces
 * ---------------------------------------------------------------------- */

/* Subtle navy linen texture over the surface grey, used by the top bar and
   footer. Reads as texture, not a visible pattern. */
.jd-texture {
	background-color: var(--wp--preset--color--brand-surface);
	background-image:
		repeating-linear-gradient(0deg, rgba(2, 76, 115, 0.05) 0px, rgba(2, 76, 115, 0.05) 1px, transparent 1px, transparent 3px),
		repeating-linear-gradient(90deg, rgba(2, 76, 115, 0.05) 0px, rgba(2, 76, 115, 0.05) 1px, transparent 1px, transparent 3px);
}

.jd-uppercase {
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

/* -------------------------------------------------------------------------
 * 3. Header
 *
 * The header floats transparent over the hero photo, then turns solid once
 * the page scrolls. Navy text is unreadable on a busy photo, so the floating
 * state is white; the orange hover passes against both photo and white.
 * ---------------------------------------------------------------------- */

.jd-header {
	position: fixed;
	inset-block-start: 0;
	inset-inline: 0;
	z-index: 40;
	transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.jd-header[data-transparent="true"]:not(.is-scrolled) {
	background-color: transparent;
}

.jd-header[data-transparent="true"]:not(.is-scrolled) .wp-block-navigation a,
.jd-header[data-transparent="true"]:not(.is-scrolled) .jd-lang-switch a {
	color: #fff;
}

.jd-header.is-scrolled,
.jd-header:not([data-transparent="true"]) {
	background-color: var(--wp--preset--color--base);
	box-shadow: var(--wp--preset--shadow--jd);
}

/* Nav underline: grows from the centre on hover/focus. */
.jd-header .wp-block-navigation-item__content {
	position: relative;
	padding-block: 0.5rem;
}

.jd-header .wp-block-navigation-item__content::after {
	content: "";
	position: absolute;
	inset-inline-start: 50%;
	inset-block-end: 0;
	block-size: 2px;
	inline-size: 0;
	background: var(--wp--preset--color--brand-orange);
	transition: inline-size 0.2s ease, inset-inline-start 0.2s ease;
}

.jd-header .wp-block-navigation-item__content:hover::after,
.jd-header .wp-block-navigation-item__content:focus-visible::after,
.jd-header .wp-block-navigation-item[aria-expanded="true"] > .wp-block-navigation-item__content::after {
	inline-size: 100%;
	inset-inline-start: 0;
}

.jd-header .wp-block-navigation-item__content:hover,
.jd-header .wp-block-navigation-item__content:focus-visible {
	color: var(--wp--preset--color--brand-orange-cta);
}

/* The header (top bar + logo row) floats over the first block of every page.
   Every template in this theme opens with a full-width Cover - the hero on
   the front page, a page banner everywhere else - so there is always
   something for it to float over and no spacer is needed.

   If a template is ever added that does NOT open with a Cover, give its
   <main> the .jd-main-offset class so content clears the header. */
.jd-main-offset {
	padding-block-start: 148px;
}

@media (max-width: 1023px) {
	.jd-main-offset {
		padding-block-start: 116px;
	}
}

/* The top bar scrolls away with the header; the logo row shrinks slightly
   once scrolled, matching the original. */
.jd-header.is-scrolled .jd-top-bar {
	display: none;
}

.jd-header .custom-logo-link img,
.jd-header .wp-block-site-logo img {
	block-size: 56px;
	inline-size: auto;
	transition: block-size 0.3s ease;
}

.jd-header.is-scrolled .custom-logo-link img,
.jd-header.is-scrolled .wp-block-site-logo img {
	block-size: 44px;
}

/* -------------------------------------------------------------------------
 * 4. Language switch (Polylang)
 *
 * Polylang outputs a <ul> of links; this makes it read as a single inline
 * control matching the top bar rather than a bullet list.
 * ---------------------------------------------------------------------- */

.jd-lang-switch ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.jd-lang-switch li {
	margin: 0;
}

.jd-lang-switch a {
	font-family: var(--wp--preset--font-family--heading-en);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	text-decoration: none;
	color: var(--wp--preset--color--brand-navy);
}

.jd-lang-switch a:hover,
.jd-lang-switch a:focus-visible {
	color: var(--wp--preset--color--brand-orange-cta);
}

.jd-header .jd-lang-switch .current-lang a {
	opacity: 0.55;
	pointer-events: none;
}

/* -------------------------------------------------------------------------
 * 5. Hero slider
 *
 * Slides are plain Cover blocks. Only one is shown at a time on the front
 * end; in the editor they stay stacked and visible (see §5b) so the editor
 * can add, remove and reorder them.
 * ---------------------------------------------------------------------- */

.jd-slider {
	position: relative;
}

.jd-slider__track > .wp-block-cover {
	display: none;
}

.jd-slider__track > .wp-block-cover.is-active {
	display: flex;
	animation: jd-fade 0.6s ease;
}

@keyframes jd-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

/* Before the script runs, show the first slide so there is no blank gap. */
.jd-slider:not([data-ready]) .jd-slider__track > .wp-block-cover:first-child {
	display: flex;
}

.jd-slider__dots {
	position: absolute;
	inset-block-end: 1.5rem;
	inset-inline-start: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 0.625rem;
	z-index: 2;
	margin: 0;
	padding: 0;
}

.jd-slider__dot {
	inline-size: 12px;
	block-size: 12px;
	border-radius: 50%;
	border: 2px solid #fff;
	background: transparent;
	padding: 0;
	cursor: pointer;
}

.jd-slider__dot[aria-selected="true"] {
	background: var(--wp--preset--color--brand-orange);
	border-color: var(--wp--preset--color--brand-orange);
}

.jd-slider__arrow {
	position: absolute;
	inset-block-start: 50%;
	transform: translateY(-50%);
	z-index: 2;
	inline-size: 44px;
	block-size: 44px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.85);
	color: var(--wp--preset--color--brand-navy);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.jd-slider__arrow:hover,
.jd-slider__arrow:focus-visible {
	background: #fff;
	color: var(--wp--preset--color--brand-orange-cta);
}

.jd-slider__arrow--prev { inset-inline-start: 1rem; }
.jd-slider__arrow--next { inset-inline-end: 1rem; }

/* Arrows point along the reading direction. */
.jd-slider__arrow svg { inline-size: 18px; block-size: 18px; }
[dir="rtl"] .jd-slider__arrow svg { transform: scaleX(-1); }

/* Hide the controls when there is only one slide. */
.jd-slider[data-count="1"] .jd-slider__dots,
.jd-slider[data-count="1"] .jd-slider__arrow {
	display: none;
}

/* 5b. In the editor, never hide slides - the editor must see and reorder all
   of them. The editor canvas never gets [data-ready]. */
.block-editor-block-list__layout .jd-slider__track > .wp-block-cover {
	display: flex !important;
	animation: none !important;
}

.block-editor-block-list__layout .jd-slider__dots,
.block-editor-block-list__layout .jd-slider__arrow {
	display: none !important;
}

/* -------------------------------------------------------------------------
 * 6. Cards and effects
 * ---------------------------------------------------------------------- */

.jd-card {
	transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.jd-card:hover {
	box-shadow: var(--wp--preset--shadow--jd-hover);
}

/* Circular photo badges in the "Why choose us" section. */
.jd-badge img {
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	border-radius: 50%;
}

/* -------------------------------------------------------------------------
 * 7. Per-slot image crops
 *
 * Only for Image blocks, where there is no focal-point control. Anywhere the
 * photo sits in a Cover block, the editor sets the focal point visually
 * instead and no class is needed here.
 * ---------------------------------------------------------------------- */

.jd-crop-about-ceo img      { object-fit: cover; object-position: center 20%; }
.jd-crop-why-petroleum img  { object-fit: cover; object-position: center 50%; }
.jd-crop-why-agriculture img{ object-fit: cover; object-position: center 40%; }
.jd-crop-why-business img   { object-fit: cover; object-position: center 35%; }

/* -------------------------------------------------------------------------
 * 8. Accessibility
 * ---------------------------------------------------------------------- */

:where(a, button, input, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--wp--preset--color--brand-orange-cta);
	outline-offset: 2px;
}

.skip-link:focus {
	inset-block-start: 1rem;
	inset-inline-start: 1rem;
	z-index: 100;
	background: #fff;
	padding: 0.75rem 1.25rem;
}

/* Phone numbers stay on one line and read left-to-right in Arabic. */
.jd-tel {
	direction: ltr;
	unicode-bidi: isolate;
	white-space: nowrap;
}

/* -------------------------------------------------------------------------
 * 9. 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;
	}
}

/* ---------------------------------------------------------------------------
 * Text for screen readers only.
 *
 * Used to name a link's destination where the visible label is deliberately
 * short ("Learn more"), so a screen reader and a search engine both know
 * where it leads without changing what is on the page. Same technique and
 * class name WordPress itself uses.
 * ------------------------------------------------------------------------- */
.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* -------------------------------------------------------------------------
 * Header, slide-in menu and search dialog.
 * ---------------------------------------------------------------------- */

.jd-header {
	position: fixed;
	inset-block-start: 0;
	inset-inline: 0;
	z-index: 40;
	background: var(--wp--preset--color--base);
	box-shadow: var(--wp--preset--shadow--jd);
	transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

body.jd-is-front-page .jd-header:not(.is-scrolled) {
	background: transparent;
	box-shadow: none;
}

.jd-header__row {
	padding-block: 0.75rem;
	transition: padding 0.3s ease;
}

.jd-header.is-scrolled .jd-header__row {
	padding-block: 0.5rem;
}

.jd-header__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	min-block-size: 56px;
}

.jd-header__bar > * {
	margin-block: 0;
}

.jd-header .wp-block-site-logo {
	display: flex;
	align-items: center;
	line-height: 0;
}

.jd-header .custom-logo-link img,
.jd-header .wp-block-site-logo img {
	display: block;
	inline-size: auto;
	block-size: 56px;
	transition: block-size 0.3s ease;
}

.jd-header.is-scrolled .custom-logo-link img,
.jd-header.is-scrolled .wp-block-site-logo img {
	block-size: 44px;
}

.jd-header .jd-top-bar {
	display: block;
}

.jd-top-bar > .wp-block-group {
	justify-content: flex-end;
}

.jd-header.is-scrolled .jd-top-bar {
	display: none;
}

.jd-header__actions {
	display: flex;
	align-items: center;
	gap: 0.25rem;
}

.jd-header__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	inline-size: 44px;
	block-size: 44px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--brand-navy);
	cursor: pointer;
	transition: color 0.2s ease;
}

.jd-header__btn svg {
	display: block;
	inline-size: 22px;
	block-size: 22px;
}

.jd-header__btn--menu svg {
	inline-size: 26px;
	block-size: 26px;
}

.jd-header__btn:hover,
.jd-header__btn:focus-visible {
	color: var(--wp--preset--color--brand-orange-cta);
}

body.jd-is-front-page .jd-header:not(.is-scrolled) .jd-header__btn {
	color: #fff;
}

body.jd-is-front-page .jd-header:not(.is-scrolled) .jd-header__btn:hover,
body.jd-is-front-page .jd-header:not(.is-scrolled) .jd-header__btn:focus-visible {
	color: var(--wp--preset--color--brand-orange);
}

@media (min-width: 1024px) {
	.jd-header .custom-logo-link img,
	.jd-header .wp-block-site-logo img {
		block-size: 80px;
	}
}

.jd-lang-switch .current-lang a {
	color: var(--wp--preset--color--brand-orange-cta);
	opacity: 1;
	pointer-events: none;
}

.jd-header .jd-lang-switch a {
	color: var(--wp--preset--color--brand-navy);
}

.jd-header .jd-lang-switch a:hover,
.jd-header .jd-lang-switch a:focus-visible {
	color: var(--wp--preset--color--brand-orange-cta);
}

.jd-dialog-open,
.jd-dialog-open body {
	overflow: hidden;
}

.jd-offcanvas__backdrop {
	position: fixed;
	inset: 0;
	z-index: 90;
	background: rgba(2, 76, 115, 0.48);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.jd-offcanvas__backdrop.is-open {
	opacity: 1;
}

.jd-offcanvas__backdrop[hidden] {
	display: none;
}

.jd-offcanvas {
	position: fixed;
	inset-block: 0;
	inset-inline-end: 0;
	z-index: 95;
	display: flex;
	flex-direction: column;
	inline-size: min(100vw, 560px);
	max-inline-size: 100vw;
	overflow-x: hidden;
	background: var(--wp--preset--color--base);
	box-shadow: var(--wp--preset--shadow--jd);
	transform: translateX(100%);
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[dir="rtl"] .jd-offcanvas {
	transform: translateX(-100%);
}

.jd-offcanvas.is-open,
[dir="rtl"] .jd-offcanvas.is-open {
	transform: translateX(0);
}

.jd-offcanvas[hidden] {
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	.jd-offcanvas,
	.jd-offcanvas__backdrop,
	.jd-search {
		transition: none;
	}
}

.jd-offcanvas__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex: none;
	block-size: 64px;
	padding-inline: 1rem;
	border-block-end: 1px solid rgba(2, 76, 115, 0.12);
}

.jd-offcanvas__logo {
	display: block;
	inline-size: auto;
	max-inline-size: min(70%, 220px);
	block-size: 36px;
	object-fit: contain;
	object-position: center;
}

.jd-offcanvas__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	inline-size: 40px;
	block-size: 40px;
	flex: none;
	padding: 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--brand-navy);
	cursor: pointer;
}

.jd-offcanvas__close svg {
	inline-size: 22px;
	block-size: 22px;
}

.jd-offcanvas__close:hover,
.jd-offcanvas__close:focus-visible {
	color: var(--wp--preset--color--brand-orange-cta);
}

.jd-offcanvas__nav {
	flex: 1 1 auto;
	min-inline-size: 0;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 0.75rem 0.5rem;
	scrollbar-width: thin;
	scrollbar-color: rgba(2, 76, 115, 0.35) transparent;
}

.jd-offcanvas__nav::-webkit-scrollbar {
	inline-size: 6px;
}

.jd-offcanvas__nav::-webkit-scrollbar-thumb {
	border-radius: 3px;
	background: rgba(2, 76, 115, 0.35);
}

.jd-offcanvas__group {
	min-inline-size: 0;
}

.jd-offcanvas__link {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	inline-size: 100%;
	min-inline-size: 0;
	padding: 0.75rem;
	border: 0;
	background: none;
	color: var(--wp--preset--color--brand-navy);
	font-family: var(--wp--preset--font-family--heading-en);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	letter-spacing: 0.04em;
	text-align: start;
	text-decoration: none;
	text-transform: uppercase;
	overflow-wrap: anywhere;
	cursor: pointer;
}

.jd-offcanvas__link:hover,
.jd-offcanvas__link:focus-visible,
.jd-offcanvas__link.is-current,
.jd-offcanvas__sublink:hover,
.jd-offcanvas__sublink:focus-visible,
.jd-offcanvas__sublink.is-current {
	color: var(--wp--preset--color--brand-orange-cta);
}

.jd-offcanvas__chevron {
	display: inline-flex;
	flex: none;
	line-height: 0;
	transition: transform 0.2s ease;
}

.jd-offcanvas__chevron svg {
	inline-size: 12px;
	block-size: 12px;
}

.jd-offcanvas__group.is-open .jd-offcanvas__chevron {
	transform: rotate(180deg);
}

.jd-offcanvas__sub {
	min-inline-size: 0;
	padding-inline-start: 1.25rem;
	padding-block-end: 0.5rem;
}

.jd-offcanvas__sub[hidden] {
	display: none;
}

.jd-offcanvas__sublink {
	display: block;
	min-inline-size: 0;
	padding: 0.5rem 0.75rem;
	color: var(--wp--preset--color--brand-navy);
	font-size: var(--wp--preset--font-size--small);
	text-decoration: none;
	overflow-wrap: anywhere;
}

.jd-offcanvas__foot {
	display: flex;
	flex: none;
	flex-direction: column;
	gap: 0.75rem;
	min-inline-size: 0;
	padding: 1rem;
	border-block-start: 1px solid rgba(2, 76, 115, 0.12);
	font-size: var(--wp--preset--font-size--small);
}

.jd-offcanvas__contact {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	min-inline-size: 0;
	color: var(--wp--preset--color--brand-navy);
	text-decoration: none;
}

.jd-offcanvas__contact svg {
	inline-size: 15px;
	block-size: 15px;
	flex: none;
}

.jd-offcanvas__contact:hover,
.jd-offcanvas__contact:focus-visible {
	color: var(--wp--preset--color--brand-orange-cta);
}

.jd-offcanvas__social {
	display: flex;
	align-items: center;
	gap: 1rem;
	min-inline-size: 0;
}

.jd-offcanvas__social a {
	display: inline-flex;
	flex: none;
	color: var(--wp--preset--color--brand-navy);
}

.jd-offcanvas__social svg {
	inline-size: 16px;
	block-size: 16px;
}

.jd-offcanvas__social a:hover,
.jd-offcanvas__social a:focus-visible {
	color: var(--wp--preset--color--brand-orange-cta);
}

.jd-offcanvas__lang {
	margin-inline-start: auto;
	color: var(--wp--preset--color--brand-orange-cta);
	font-family: var(--wp--preset--font-family--heading-en);
	font-weight: 700;
	text-decoration: none;
}

html[lang="ar"] .jd-offcanvas__lang,
html[lang="ar"] .jd-offcanvas__link {
	font-family: var(--wp--preset--font-family--arabic);
}

html[lang="ar"] .jd-offcanvas__link {
	letter-spacing: normal;
	text-transform: none;
}

.jd-search {
	position: fixed;
	inset: 0;
	z-index: 100;
	background: rgba(2, 76, 115, 0.96);
	backdrop-filter: blur(4px);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.jd-search.is-open {
	opacity: 1;
}

.jd-search[hidden] {
	display: none;
}

.jd-search__inner {
	max-inline-size: 42rem;
	margin-inline: auto;
	padding: 6rem 1rem 0;
}

.jd-search__field {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	min-inline-size: 0;
	padding-block-end: 0.75rem;
	border-block-end: 2px solid rgba(255, 255, 255, 0.55);
}

.jd-search__icon {
	display: inline-flex;
	flex: none;
	color: #fff;
	line-height: 0;
}

.jd-search__icon svg {
	inline-size: 22px;
	block-size: 22px;
}

.jd-search__field input[type="search"] {
	flex: 1 1 auto;
	min-inline-size: 0;
	border: 0;
	outline: 0;
	background: transparent;
	color: #fff;
	font-size: var(--wp--preset--font-size--large);
}

.jd-search__field input[type="search"]::placeholder {
	color: rgba(255, 255, 255, 0.72);
}

.jd-search__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	inline-size: 40px;
	block-size: 40px;
	flex: none;
	padding: 0;
	border: 0;
	background: none;
	color: #fff;
	cursor: pointer;
}

.jd-search__close svg {
	inline-size: 22px;
	block-size: 22px;
}

.jd-search__hint {
	color: rgba(255, 255, 255, 0.82);
}

html[lang="ar"] .jd-offcanvas__link,
html[lang="ar"] .jd-offcanvas__sublink,
html[lang="ar"] .jd-search__inner {
	font-family: var(--wp--preset--font-family--arabic);
}
