/**
 * Berim Blog — base, RTL, header & footer.
 * Phase 1: visual/structural foundation only (no post/archive templates yet).
 * RTL-first: use CSS logical properties (margin-inline, inset-inline-start,
 * text-align: start) — never physical left/right.
 */

/* -------------------------------------------------------------------------- */
/* Base                                                                       */
/* -------------------------------------------------------------------------- */

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	font-family: var(--font-sans);
	font-size: 100%;
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
}

body {
	margin: 0;
	background-color: var(--surface-warm);
	color: var(--content-dark);
	font-family: var(--font-sans);
	font-size: var(--font-size-base);
	line-height: var(--line-height-body);
	font-feature-settings: 'ss02';
	direction: rtl;
	text-align: start;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
optgroup,
textarea {
	font-family: var(--font-sans);
}

h1, h2, h3, h4, h5, h6 {
	line-height: var(--line-height-heading);
	font-weight: var(--font-weight-bold);
	color: var(--content-dark);
	margin-block: 0 var(--space-4);
	letter-spacing: -0.01em;
	text-wrap: balance;
}

h1, h2 { font-weight: var(--font-weight-extrabold); }

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

p {
	margin-block: 0 var(--space-4);
}

a {
	color: var(--brand-ink);
	text-decoration: none;
	transition: color 0.15s ease;
}

a:hover,
a:focus {
	color: var(--brand-strong);
}

img {
	max-width: 100%;
	height: auto;
}

:focus-visible {
	outline: 2px solid var(--brand);
	outline-offset: 2px;
	border-radius: var(--radius-md);
}

/* Branded text selection. */
::selection {
	background: color-mix(in srgb, var(--brand) 22%, transparent);
	color: var(--content-dark);
}

/* Slim, on-brand scrollbar (matches the product app). */
* {
	scrollbar-width: thin;
	scrollbar-color: var(--border-2) transparent;
}

::-webkit-scrollbar {
	width: 10px;
	height: 10px;
}

::-webkit-scrollbar-thumb {
	background: var(--border-2);
	border-radius: var(--radius-full);
	border: 3px solid var(--surface-warm);
}

::-webkit-scrollbar-thumb:hover {
	background: var(--brand);
}

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

.skip-link.screen-reader-text:focus {
	background-color: var(--background-surface-0);
	clip: auto !important;
	clip-path: none;
	color: var(--content-primary);
	display: block;
	inset-block-start: var(--space-2);
	inset-inline-start: var(--space-2);
	height: auto;
	width: auto;
	padding: var(--space-2) var(--space-4);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-md);
	z-index: 100000;
}

.site {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

/* Shared inner container */
.site-header__inner,
.site-footer__inner {
	width: 100%;
	max-width: var(--content-max-width);
	margin-inline: auto;
	padding-inline: var(--space-4);
}

/* Reusable button — primary brand action. */
.berim-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-2);
	padding: var(--space-3) var(--space-5);
	border-radius: var(--radius-full);
	background: var(--brand-ink);
	color: #fff;
	font-weight: var(--font-weight-bold);
	font-size: var(--font-size-sm);
	line-height: 1.4;
	border: 0;
	cursor: pointer;
	box-shadow: var(--shadow-sm);
	transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.berim-btn::before {
	content: '';
	width: 1.05em;
	height: 1.05em;
	background: currentColor;
	/* A left-pointing arrow drawn natively (no scaleX flip, which renders
	 * inconsistently on some mobile browsers). Left = "forward" in RTL. */
	-webkit-mask: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5'/%3E%3Cpath d='M12 19l-7-7 7-7'/%3E%3C/svg%3E");
	mask: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5'/%3E%3Cpath d='M12 19l-7-7 7-7'/%3E%3C/svg%3E");
	flex-shrink: 0;
	opacity: 0.9;
}

.berim-btn:hover,
.berim-btn:focus {
	color: #fff;
	transform: translateY(-1px);
	box-shadow: var(--shadow-md);
	background: color-mix(in srgb, var(--brand-ink) 88%, #000);
}

/* The header CTA uses a real inline SVG arrow (see header.php) instead of the
 * pseudo-element icon — guaranteed left-pointing on every browser. */
.site-header__cta .berim-btn::before {
	display: none;
}

.berim-btn__icon {
	width: 1.05em;
	height: 1.05em;
	flex-shrink: 0;
	opacity: 0.9;
}

.berim-btn:active {
	transform: translateY(0);
}

/* Quiet/secondary button. */
.berim-btn--ghost {
	background: var(--background-surface-0);
	color: var(--brand-strong);
	border: 1px solid var(--border-2);
	box-shadow: var(--shadow-xs);
}

.berim-btn--ghost::before { display: none; }

.berim-btn--ghost:hover,
.berim-btn--ghost:focus {
	color: var(--brand-strong);
	background: var(--brand-soft);
	box-shadow: var(--shadow-sm);
}

/* -------------------------------------------------------------------------- */
/* Header                                                                     */
/* -------------------------------------------------------------------------- */

.site-header {
	position: sticky;
	inset-block-start: 0;
	z-index: 1000;
	background: var(--background-surface-0);
	background: color-mix(in srgb, var(--background-surface-0) 82%, transparent);
	-webkit-backdrop-filter: saturate(1.4) blur(12px);
	backdrop-filter: saturate(1.4) blur(12px);
	border-block-end: 1px solid transparent;
	transition: box-shadow 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.site-header.is-scrolled {
	background: color-mix(in srgb, var(--background-surface-0) 92%, transparent);
	border-block-end-color: var(--border-1);
	box-shadow: var(--shadow-sm);
}

.site-header__inner {
	display: flex;
	align-items: center;
	gap: var(--space-4);
	min-height: var(--header-height);
}

.site-branding {
	display: flex;
	align-items: center;
	flex-shrink: 0;
}

.site-branding__logo {
	display: inline-flex;
	align-items: center;
	color: var(--content-dark);
}

.site-branding__logo svg {
	width: auto;
	height: 30px;
	display: block;
	color: var(--brand-strong);
	transition: transform 0.2s ease;
}

.site-branding__logo:hover svg {
	transform: scale(1.04);
}

.site-branding .site-title,
.site-branding .site-description {
	margin: 0;
}

.site-branding .site-title {
	font-size: var(--font-size-base);
	font-weight: var(--font-weight-bold);
}

/* Primary navigation */
.main-navigation {
	margin-inline-start: auto;
	display: flex;
	align-items: center;
}

.main-navigation .menu-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	background: transparent;
	border: 1px solid var(--border-2);
	border-radius: var(--radius-lg);
	color: var(--content-dark);
	cursor: pointer;
}

.main-navigation .menu-toggle .menu-toggle__bar,
.main-navigation .menu-toggle .menu-toggle__bar::before,
.main-navigation .menu-toggle .menu-toggle__bar::after {
	display: block;
	width: 1.125rem;
	height: 2px;
	background: currentColor;
	border-radius: var(--radius-full);
	position: relative;
}

.main-navigation .menu-toggle .menu-toggle__bar::before,
.main-navigation .menu-toggle .menu-toggle__bar::after {
	content: '';
	position: absolute;
	inset-inline-start: 0;
}

.main-navigation .menu-toggle .menu-toggle__bar::before { inset-block-start: -6px; }
.main-navigation .menu-toggle .menu-toggle__bar::after { inset-block-start: 6px; }

.main-navigation ul {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	list-style: none;
	margin: 0;
	padding: 0;
}

.main-navigation li {
	position: relative;
}

.main-navigation a {
	position: relative;
	display: block;
	padding: var(--space-2) var(--space-3);
	color: var(--content-neutral);
	font-size: var(--font-size-sm);
	font-weight: var(--font-weight-semibold);
	border-radius: var(--radius-lg);
	transition: color 0.15s ease, background 0.15s ease;
}

.main-navigation a:hover,
.main-navigation a:focus,
.main-navigation .current-menu-item > a {
	color: var(--brand-strong);
	background: var(--brand-soft);
}

/* Accent underline on the active item (desktop). */
@media (min-width: 769px) {
	.main-navigation .current-menu-item > a::after {
		content: '';
		position: absolute;
		inset-block-end: -2px;
		inset-inline: var(--space-3);
		height: 2px;
		border-radius: var(--radius-full);
		background: var(--accent);
	}
}

/* Header CTA sits after the nav */
.site-header__cta {
	flex-shrink: 0;
}

/* Compact / full CTA labels (full on desktop, short on phones). */
.berim-btn__label-short { display: none; }

/* Mobile header — single compact row: logo · CTA · menu toggle. */
@media (max-width: 768px) {
	.berim-btn__label-full { display: none; }
	.berim-btn__label-short { display: inline; }

	.site-header__inner {
		flex-wrap: nowrap;
		gap: var(--space-2);
	}

	.site-header__cta {
		margin-inline-start: auto;
		order: 2;
	}

	.main-navigation {
		margin-inline-start: 0;
		order: 3;
	}

	.main-navigation .menu-toggle {
		display: inline-flex;
	}

	.main-navigation .menu {
		display: none;
		position: absolute;
		inset-block-start: var(--header-height);
		inset-inline: 0;
		flex-direction: column;
		align-items: stretch;
		gap: var(--space-1);
		padding: var(--space-3);
		background: var(--background-surface-0);
		border-block-end: 1px solid var(--border-1);
		box-shadow: var(--shadow-md);
	}

	.main-navigation.toggled .menu {
		display: flex;
	}

	.main-navigation .menu a {
		padding: var(--space-3);
		font-size: var(--font-size-base);
	}
}

/* Keep the CTA compact on phones so the row never overflows. */
@media (max-width: 768px) {
	.site-header__cta .berim-btn { padding: var(--space-2) var(--space-4); }
}

/* Only the very smallest screens drop to an icon-only CTA. */
@media (max-width: 344px) {
	.berim-btn__label-short { display: none; }
	.site-header__cta .berim-btn { padding-inline: var(--space-3); }
	.site-header__cta .berim-btn::before { margin: 0; }
}

/* -------------------------------------------------------------------------- */
/* Footer                                                                      */
/* -------------------------------------------------------------------------- */

.site-footer {
	margin-block-start: var(--space-16);
	background: var(--background-neutral);
	border-block-start: 3px solid var(--brand);
	color: var(--content-neutral);
}

/* The shared width wrapper (above) is reused as a vertical stack here. */
.site-footer__inner {
	display: flex;
	flex-direction: column;
	gap: var(--space-6);
	padding-block: var(--space-10);
}

/* Top bar: logo + important links */
.site-footer__top {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--space-4);
}

@media (min-width: 1024px) {
	.site-footer__top {
		flex-direction: row;
		align-items: center;
	}
}

.site-footer__brand-logo {
	display: inline-flex;
	color: var(--content-dark);
}

.site-footer__brand-logo svg {
	height: 28px;
	width: auto;
	color: var(--brand-strong);
}

.site-footer__top-links {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-6);
}

.site-footer__top-links a {
	font-size: var(--font-size-sm);
	font-weight: var(--font-weight-semibold);
	color: var(--content-dark);
}

.site-footer__top-links a:hover,
.site-footer__top-links a:focus {
	color: var(--brand-strong);
}

.site-footer__divider {
	width: 100%;
	margin: 0;
	border: 0;
	border-block-start: 1px solid var(--border-1);
}

/* Three columns: contact · social · certificates */
.site-footer__grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--space-8);
}

@media (min-width: 768px) {
	.site-footer__grid {
		grid-template-columns: 1.4fr 1fr 1.2fr;
		gap: var(--space-10);
	}
}

.site-footer__col-title {
	font-size: var(--font-size-base);
	font-weight: var(--font-weight-bold);
	color: var(--content-dark);
	margin: 0 0 var(--space-4);
}

/* Contact ways */
.site-footer__contact-lead {
	margin: 0 0 var(--space-4);
	color: var(--content-neutral);
	line-height: var(--line-height-body);
}

.site-footer__contact-row {
	display: flex;
	gap: var(--space-2);
	margin-block-end: var(--space-4);
}

.site-footer__contact-ic {
	flex: none;
	width: 1.5rem;
	height: 1.5rem;
	margin-block-start: 2px;
	color: var(--brand-strong);
}

.site-footer__contact-body {
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
	font-size: var(--font-size-sm);
	line-height: var(--line-height-body);
}

.site-footer__contact-label {
	font-weight: var(--font-weight-semibold);
	color: var(--content-dark);
}

.site-footer__contact-body a {
	color: var(--content-neutral);
	width: fit-content;
}

.site-footer__contact-body a:hover,
.site-footer__contact-body a:focus {
	color: var(--brand-strong);
}

/* Social media */
.site-footer__social {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-3);
}

.site-footer__social a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	border-radius: var(--radius-full);
	background: var(--background-surface-0);
	color: var(--content-neutral);
	border: 1px solid var(--border-1);
	transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.site-footer__social a:hover,
.site-footer__social a:focus {
	color: #fff;
	background: var(--brand-ink);
	border-color: var(--brand-ink);
	box-shadow: var(--shadow-sm);
	transform: translateY(-2px);
}

.site-footer__social svg {
	width: 1.25rem;
	height: 1.25rem;
}

/* Certificates / trust seals */
.site-footer__certs-grid {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-3);
}

.site-footer__cert {
	display: block;
	width: 4.5rem;
	height: 4.5rem;
	padding: var(--space-2);
	border-radius: var(--radius-lg);
	background: #fff;
	border: 1px solid var(--border-1);
	transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.site-footer__cert:hover,
.site-footer__cert:focus {
	box-shadow: var(--shadow-sm);
	transform: translateY(-2px);
}

.site-footer__cert img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.site-footer__copyright {
	margin: 0;
	text-align: center;
	font-size: var(--font-size-sm);
	color: var(--content-lowemphasis);
	line-height: var(--line-height-body);
}
