/*
Theme Name: Olimp
Description: Block theme for olimp-ubezpieczenia.pl.
Author: genius-dev
Version: 1.1.0
Requires at least: 7.1
Requires PHP: 8.4
Text Domain: olimp
License: GNU General Public License v2 or later
*/

/*
 * Structure
 *   1. Settings        5. Cards & grids          9. Steps, photo tiles
 *   2. Base            6. Header & navigation   10. Page header, split layout
 *   3. Layout          7. Hero & trust bar      11. Ubezpieczenia page
 *   4. Buttons, text   8. Offer (bento)         12. Footer
 * Generic rules (cards, grids) come before the components that adjust them.
 *
 * Layout model: section (full width, optional background) > .olimp-container (max 1200px) > content.
 * Templates and patterns use WordPress's "default" layout, so WP adds no centring or grid CSS of its own.
 *
 * Breakpoints (max-width, used everywhere):
 *   phone          600px
 *   small desktop 1100px  (smaller menu text)
 *   hamburger      960px  (menu switches to the hamburger)
 *   tablet         900px
 *
 * Colours, fonts and font sizes come from theme.json (--wp--preset--*).
 */

/* ---------- 1. Settings ---------- */

:root {
	--olimp-container: 1200px;
	--olimp-gutter: clamp(1rem, 4vw, 1.5rem);
	--olimp-measure: 40rem; /* ≈ 75 characters per line at the 17px body size (measured). */
	--olimp-radius: 12px;
	--olimp-gap: var(--wp--preset--spacing--30);
	--olimp-section: var(--wp--preset--spacing--60);
	--olimp-topbar-h: 2.375rem;
	--olimp-muted-on-dark: #c9d6e6;
	--olimp-shadow: 0 16px 40px rgba(29, 74, 122, 0.12), 0 2px 6px rgba(29, 74, 122, 0.06);
}

/* ---------- 2. Base ---------- */

.wp-site-blocks > * + * {
	margin-block-start: 0; /* Header, main and footer sit flush; sections bring their own spacing. */
}

:where([id]) {
	scroll-margin-top: 6rem; /* Anchors land below the sticky header. */
}

/* ---------- 3. Layout ---------- */

.olimp-container {
	box-sizing: border-box;
	margin-inline: auto;
	max-width: calc(var(--olimp-container) + 2 * var(--olimp-gutter));
	padding-inline: var(--olimp-gutter);
	width: 100%;
}

.wp-block-group.olimp-section {
	margin-block: 0; /* Sections touch; spacing comes from their padding only. */
	padding-block: var(--olimp-section);
}

.wp-block-group.olimp-section--loose {
	padding-block: var(--wp--preset--spacing--70);
}

.wp-block-group.olimp-section--flush-top {
	padding-top: 0;
}

/* The section right after a title band needs less room above it. */
.olimp-page-header + .wp-block-group.olimp-section {
	padding-top: var(--wp--preset--spacing--50);
}

.olimp-sections > .olimp-trust {
	margin-block: -3.5rem 0; /* Overlaps the hero above. */
}

/* Readable line length for running text; left-aligned inside the container. */
.olimp-prose > :is(p, ul, ol, h2, h3, h4, h5, h6, blockquote, .wp-block-quote, .wp-block-image),
.is-root-container > :is(p, ul, ol, h2, h3, h4) {
	max-width: var(--olimp-measure);
}

.olimp-prose > * + .olimp-grid { /* Space between text and a card grid; none when the grid comes first. */
	margin-top: var(--wp--preset--spacing--50);
}

/* ---------- 4. Buttons, text helpers ---------- */

.wp-block-button__link {
	white-space: nowrap;
}

.olimp-eyebrow {
	color: var(--wp--preset--color--action);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.olimp-lead {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--large);
	max-width: 40em;
}

.olimp-small {
	font-size: var(--wp--preset--font-size--small);
}

.olimp-icon {
	margin: 0 0 var(--wp--preset--spacing--30);
}

.olimp-section-head {
	margin-bottom: var(--wp--preset--spacing--30);
}

.olimp-section-head h2,
.olimp-section-head p {
	margin: 0;
}

.olimp-section-head a {
	font-weight: 700;
	text-decoration: none;
}

/* ---------- 5. Cards & grids ---------- */

.olimp-grid {
	--olimp-cols: 3;
	display: grid;
	gap: var(--olimp-gap);
	grid-template-columns: repeat(var(--olimp-cols), minmax(0, 1fr));
	list-style: none;
	padding: 0;
}

.olimp-grid > * {
	margin: 0;
}

.olimp-grid--2 { --olimp-cols: 2; }
.olimp-grid--3 { --olimp-cols: 3; }
.olimp-grid--4 { --olimp-cols: 4; }

/* Exactly five cards: 3 + 2, both rows full width. */
.olimp-grid--5 {
	--olimp-cols: 6;
}

.olimp-grid--5 > * {
	grid-column: span 2;
}

.olimp-grid--5 > :nth-child(n + 4) {
	grid-column: span 3;
}

.olimp-card {
	background: var(--wp--preset--color--white);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--olimp-radius);
	box-sizing: border-box;
	height: 100%;
	padding: var(--wp--preset--spacing--40);
	position: relative;
	transition: border-color 0.15s ease, transform 0.15s ease;
}

.olimp-card:hover {
	border-color: var(--wp--preset--color--logo-blue);
	transform: translateY(-2px);
}

.olimp-card p {
	color: var(--wp--preset--color--muted);
}

.olimp-card :is(h3 a, .wp-block-post-title a) {
	color: inherit;
	text-decoration: none;
}

.olimp-card :is(h3 a, .wp-block-post-title a)::after {
	color: var(--wp--preset--color--logo-blue);
	content: "\00a0→"; /* No-break space: the arrow never wraps alone. */
}

/* Whole card clickable: the heading link stays the only real link (SEO, screen readers). */
.olimp-card :is(h3 a, .wp-block-post-title a)::before {
	content: "";
	inset: 0;
	position: absolute;
	z-index: 1;
}

.olimp-card:has(:is(h3 a, .wp-block-post-title a):focus-visible) {
	outline: 2px solid var(--wp--preset--color--logo-blue);
	outline-offset: 3px;
}

.olimp-card :is(h3 a, .wp-block-post-title a):focus-visible {
	outline: none;
}

/* Card with a photo on top (hub pages). */
.olimp-card .olimp-card__image {
	margin: calc(-1 * var(--wp--preset--spacing--40)) calc(-1 * var(--wp--preset--spacing--40)) var(--wp--preset--spacing--30);
}

.olimp-card .olimp-card__image img {
	aspect-ratio: 16 / 9;
	border-radius: var(--olimp-radius) var(--olimp-radius) 0 0;
	object-fit: cover;
	width: 100%;
}

/* ---------- 6. Header & navigation ---------- */

.wp-site-blocks > header.wp-block-template-part {
	background: var(--wp--preset--color--white);
	position: sticky;
	top: calc(var(--wp-admin--admin-bar--height, 0px) - var(--olimp-topbar-h)); /* Top bar scrolls away, menu stays. */
	z-index: 100;
}

.olimp-topbar {
	align-items: center;
	display: flex;
	font-size: 0.875rem;
	height: var(--olimp-topbar-h);
}

.olimp-topbar p {
	margin: 0;
}

.olimp-topbar a {
	color: inherit;
	text-decoration: none;
}

.olimp-topbar a:hover {
	text-decoration: underline;
}

.olimp-header {
	border-bottom: 1px solid var(--wp--preset--color--line);
}

.olimp-header__row {
	padding-block: var(--wp--preset--spacing--30);
}

/* Desktop dropdowns: wide enough for "Branża elektrotechniczna" on one line. */
.olimp-header .wp-block-navigation__submenu-container {
	min-width: 16rem !important; /* Core sets 200px. */
}

/* Label-only parent ("Kredyty i finanse") links nowhere. */
.olimp-header .wp-block-navigation-submenu > a:not([href]) {
	cursor: default;
}

/* Kontakt: a button on desktop, a menu item only inside the opened mobile menu. */
.olimp-header .olimp-nav-mobile,
.olimp-header .olimp-btn-mobile {
	display: none;
}

.olimp-header .is-menu-open .olimp-nav-mobile {
	display: flex;
}

/* Opened mobile menu: left-aligned, sub-items indented and lighter. */
.olimp-header .wp-block-navigation__responsive-container.is-menu-open {
	--navigation-layout-justification-setting: flex-start;
	--navigation-layout-justify: flex-start;
	--navigation-layout-align: flex-start;
	padding: var(--wp--preset--spacing--40);
}

.olimp-header .is-menu-open :is(.wp-block-navigation__responsive-container-content, .wp-block-navigation__container, .wp-block-navigation-item) {
	align-items: flex-start !important; /* Core sets this from the menu's own justification. */
	text-align: left;
}

.olimp-header .is-menu-open .wp-block-navigation__container {
	font-size: var(--wp--preset--font-size--large);
	gap: var(--wp--preset--spacing--30);
}

.olimp-header .is-menu-open .wp-block-navigation__submenu-container {
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 400;
	gap: var(--wp--preset--spacing--20);
	padding: var(--wp--preset--spacing--20) 0 0 var(--wp--preset--spacing--40) !important; /* Core inline padding. */
}

.olimp-header .is-menu-open .wp-block-navigation__submenu-container a {
	color: var(--wp--preset--color--muted);
}

/* ---------- 7. Hero & trust bar ---------- */

.wp-block-group.olimp-hero {
	padding-bottom: calc(var(--olimp-section) + 3.5rem); /* Room for the trust card that overlaps it. */
}

.olimp-hero__grid {
	align-items: center;
	display: grid;
	gap: var(--wp--preset--spacing--60);
	grid-template-columns: 11fr 9fr;
}

.olimp-hero__image {
	margin: 0;
}

.olimp-hero__image img {
	aspect-ratio: 4 / 3;
	border-radius: 16px;
	object-fit: cover;
	width: 100%;
}

.olimp-trust {
	margin-top: -3.5rem;
	position: relative;
	z-index: 2;
}

.olimp-trust__card {
	background: var(--wp--preset--color--white);
	border-radius: 16px;
	box-shadow: var(--olimp-shadow);
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	padding: var(--wp--preset--spacing--40) var(--wp--preset--spacing--30);
}

.olimp-trust__item {
	align-items: center;
	display: flex;
	gap: var(--wp--preset--spacing--30);
	justify-content: center;
	padding: var(--wp--preset--spacing--20) var(--wp--preset--spacing--40);
}

.olimp-trust__item > * {
	margin: 0;
}

.olimp-trust__item + .olimp-trust__item {
	border-left: 1px solid var(--wp--preset--color--line);
}

.olimp-trust__item .olimp-icon {
	flex-shrink: 0;
}

.olimp-trust__item p {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.45;
}

.olimp-trust__item strong {
	color: var(--wp--preset--color--charcoal);
	font-size: var(--wp--preset--font-size--medium);
}

/* ---------- 8. Offer (bento) ---------- */

.olimp-bento {
	display: grid;
	gap: var(--olimp-gap);
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.olimp-bento > * {
	margin: 0;
}

.olimp-bento > .olimp-card--featured {
	grid-row: span 2;
}

.olimp-card--featured {
	background: var(--wp--preset--color--navy);
	border-color: var(--wp--preset--color--navy);
	color: var(--wp--preset--color--white);
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	padding: var(--wp--preset--spacing--50);
}

.olimp-card--featured .olimp-icon img {
	filter: brightness(0) invert(1);
	width: 56px !important; /* Overrides the image block's inline width. */
}

.olimp-card--featured h3 {
	color: var(--wp--preset--color--white);
	font-size: var(--wp--preset--font-size--x-large);
}

.olimp-card--featured h3 a::after,
.olimp-tiles .olimp-card h3 a::after {
	color: var(--wp--preset--color--sky);
}

.olimp-card.olimp-card--featured p {
	color: var(--olimp-muted-on-dark);
	font-size: var(--wp--preset--font-size--large);
}

/* ---------- 9. Steps, photo tiles ---------- */

.olimp-how,
.olimp-how :is(h2, h3) {
	color: var(--wp--preset--color--white);
}

.olimp-how .olimp-eyebrow {
	color: var(--wp--preset--color--logo-blue);
}

.olimp-how p {
	color: var(--olimp-muted-on-dark);
}

.olimp-steps {
	counter-reset: olimp-step;
	display: grid;
	gap: 2rem;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	margin-top: var(--wp--preset--spacing--50);
}

.olimp-steps > * {
	margin: 0;
}

.olimp-step {
	counter-increment: olimp-step;
	position: relative;
}

.olimp-step::before {
	align-items: center;
	background: var(--wp--preset--color--logo-blue);
	border-radius: 50%;
	box-shadow: 0 0 0 8px var(--wp--preset--color--navy), 0 0 0 9px rgba(255, 255, 255, 0.18);
	color: var(--wp--preset--color--white);
	content: counter(olimp-step);
	display: flex;
	font-size: 1.5rem;
	font-weight: 800;
	height: 4rem;
	justify-content: center;
	margin: 0 auto var(--wp--preset--spacing--40);
	position: relative;
	width: 4rem;
	z-index: 1;
}

.olimp-step:not(:last-child)::after { /* Connector to the next circle. */
	background: rgba(255, 255, 255, 0.25);
	content: "";
	height: 2px;
	left: calc(50% + 2.5rem);
	position: absolute;
	top: 2rem;
	width: calc(100% - 3rem);
}

.olimp-step h3 {
	margin-bottom: 0.5rem;
}

.olimp-step p {
	margin-inline: auto;
	max-width: 18rem;
}

/* Photo tiles: image fills the card, text on a navy gradient. */
.olimp-tiles .olimp-card {
	border: 0;
	display: flex;
	flex-direction: column;
	isolation: isolate;
	justify-content: flex-end;
	min-height: 24rem;
	overflow: hidden;
}

.olimp-tiles .olimp-card__image {
	inset: 0;
	margin: 0;
	position: absolute;
	z-index: -1;
}

.olimp-tiles .olimp-card__image::after {
	background: linear-gradient(to top, rgba(29, 74, 122, 0.95) 0%, rgba(29, 74, 122, 0.7) 40%, rgba(29, 74, 122, 0) 75%);
	content: "";
	inset: 0;
	position: absolute;
}

.olimp-tiles .olimp-card__image img {
	aspect-ratio: auto;
	border-radius: 0;
	height: 100%;
	transition: transform 0.4s ease;
}

.olimp-tiles .olimp-card:hover {
	transform: none;
}

.olimp-tiles .olimp-card:hover .olimp-card__image img {
	transform: scale(1.05);
}

.olimp-tiles .olimp-card :is(h3, h3 a) {
	color: var(--wp--preset--color--white);
}

.olimp-tiles .olimp-card p {
	color: #e3eaf3;
	font-size: var(--wp--preset--font-size--small);
}

/* ---------- 10. Page header, split layout ---------- */

.wp-block-group.olimp-page-header {
	padding-bottom: var(--wp--preset--spacing--50);
}

.olimp-page-header .wp-block-post-title {
	margin-block: 0.25rem;
}

.olimp-breadcrumb {
	font-size: var(--wp--preset--font-size--small);
	margin-bottom: 0;
}

.olimp-subtitle {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.55;
	max-width: 46rem;
}

.olimp-subtitle p {
	margin: 0;
}

.olimp-featured {
	max-width: var(--olimp-measure);
}

.olimp-featured img {
	border-radius: var(--olimp-radius);
}

.olimp-split {
	align-items: start;
	display: grid;
	gap: var(--wp--preset--spacing--50);
	grid-template-columns: minmax(0, 1fr) 22rem;
}

.olimp-split > * {
	margin: 0;
}

.olimp-split .olimp-featured {
	max-width: none;
}

.olimp-split__aside {
	position: sticky;
	top: calc(var(--wp-admin--admin-bar--height, 0px) + 6.5rem);
}

.olimp-contact-card {
	background: var(--wp--preset--color--sky);
	border-color: transparent;
}

.olimp-contact-card:hover {
	border-color: transparent;
	transform: none;
}

.olimp-contact-card .wp-block-buttons {
	align-items: stretch;
	flex-direction: column;
}

.olimp-contact-card .wp-block-button__link {
	text-align: center;
	width: 100%;
}

/* ---------- 11. Ubezpieczenia page ---------- */

.olimp-entry {
	border: 0;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	min-height: 13rem;
	padding: var(--wp--preset--spacing--50);
}

.olimp-entry--private {
	background: var(--wp--preset--color--action);
}

.olimp-entry--business {
	background: var(--wp--preset--color--navy);
}

.olimp-entry :is(h3, h3 a) {
	color: var(--wp--preset--color--white);
	font-size: var(--wp--preset--font-size--x-large);
}

.olimp-card.olimp-entry h3 a::after {
	color: var(--wp--preset--color--sky);
	content: "\00a0↓";
}

.olimp-card.olimp-entry p {
	color: #dfe8f3;
	font-size: var(--wp--preset--font-size--large);
	margin-bottom: 0;
}

.olimp-entry .olimp-icon img {
	filter: brightness(0) invert(1);
}

.olimp-entry:hover {
	box-shadow: 0 12px 28px rgba(29, 74, 122, 0.25);
}

.olimp-segment {
	margin-top: var(--wp--preset--spacing--60);
}

.olimp-panel {
	background: var(--wp--preset--color--sky);
	border-radius: 16px;
	padding: var(--wp--preset--spacing--50);
}

/* ---------- 12. Footer ---------- */

.olimp-footer,
.olimp-footer a,
.olimp-footer :is(h1, h2, h3, h4) {
	color: var(--wp--preset--color--white);
}

.olimp-footer a:hover {
	color: var(--wp--preset--color--sky);
}

.olimp-footer .olimp-muted {
	color: var(--olimp-muted-on-dark);
}

.olimp-footer__grid {
	display: grid;
	gap: var(--wp--preset--spacing--50);
	grid-template-columns: 2fr 1fr 1fr;
}

.olimp-footer__grid > * {
	margin: 0;
}

.olimp-footer__title {
	font-size: var(--wp--preset--font-size--medium);
}

.olimp-footer__bottom {
	margin-top: var(--wp--preset--spacing--50);
}

/* ---------- Breakpoint: small desktop (≤ 1100px) ---------- */

@media (max-width: 1100px) {
	/* Keep the 5-item menu on one line down to the 900px hamburger switch. */
	.olimp-header .wp-block-navigation {
		font-size: 0.9375rem;
	}

	.olimp-header .wp-block-navigation__container {
		gap: 0.75rem !important; /* Core inline gap from the block's blockGap. */
	}
}

/* ---------- Breakpoint: hamburger menu (≤ 960px) ---------- */

@media (max-width: 960px) {
	/* The 5-item menu needs ~950px; below that use the hamburger (core switches only at 600px). */
	.olimp-header .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}

	.olimp-header .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
		display: none;
	}

	/* On phones and tablets the header button calls instead of opening the contact page. */
	.olimp-header .olimp-btn-desktop {
		display: none;
	}

	.olimp-header .olimp-btn-mobile {
		display: block;
	}
}

/* ---------- Breakpoint: tablet (≤ 900px) ---------- */

@media (max-width: 900px) {
	.olimp-topbar {
		display: none;
	}

	.wp-site-blocks > header.wp-block-template-part {
		top: var(--wp-admin--admin-bar--height, 0px);
	}

	.olimp-hero__grid,
	.olimp-split,
	.olimp-steps,
	.olimp-trust__card {
		grid-template-columns: minmax(0, 1fr);
	}

	.olimp-split__aside {
		position: static;
	}

	.olimp-grid--3,
	.olimp-grid--4 {
		--olimp-cols: 2;
	}

	.olimp-grid--5 > *,
	.olimp-grid--5 > :nth-child(n + 4) {
		grid-column: span 3; /* 2 per row… */
	}

	.olimp-grid--5 > :first-child {
		grid-column: span 6; /* …with the first one full width: 1 + 2 + 2. */
	}

	.olimp-bento {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.olimp-bento > .olimp-card--featured {
		grid-column: span 2;
		grid-row: auto;
	}

	.olimp-trust__item {
		justify-content: flex-start;
	}

	.olimp-trust__item + .olimp-trust__item {
		border-left: 0;
		border-top: 1px solid var(--wp--preset--color--line);
	}

	.olimp-step:not(:last-child)::after {
		bottom: -2rem;
		height: 2rem;
		left: 50%;
		top: auto;
		width: 2px;
	}

	.olimp-footer__grid {
		grid-template-columns: 1fr 1fr;
	}

	.olimp-footer__grid > :first-child {
		grid-column: span 2;
	}
}

/* ---------- Breakpoint: phone (≤ 600px) ---------- */

@media (max-width: 600px) {
	.wp-site-blocks > header.wp-block-template-part {
		top: 0; /* The admin bar is not fixed on small screens. */
	}

	.olimp-grid {
		--olimp-cols: 1;
	}

	.olimp-grid--5 > *,
	.olimp-grid--5 > :nth-child(n + 4),
	.olimp-grid--5 > :first-child {
		grid-column: auto;
	}

	.olimp-bento,
	.olimp-footer__grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.olimp-bento > .olimp-card--featured,
	.olimp-footer__grid > :first-child {
		grid-column: auto;
	}

	.olimp-panel {
		padding: var(--wp--preset--spacing--40);
	}
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.olimp-card,
	.olimp-tiles .olimp-card__image img {
		transition: none;
	}
}
