/*
Theme Name: Alla fackförbund
Theme URI: https://www.allafackforbund.se/
Author: Enkla Media
Description: Ett modernt blocktema för allafackforbund.se – tydlig läsbarhet, marinblått och fackgrönt, registerlistor för förbund och numrerade topplistor.
Version: 1.0.0
Requires at least: 6.6
Tested up to: 6.9
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: allafackforbund
*/

/* ---------- Base ---------- */
html { scroll-behavior: smooth; scroll-padding-top: 5.5rem; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::selection { background: var(--wp--preset--color--green); color: var(--wp--preset--color--ink); }
:where(a, button, .wp-block-button__link, summary):focus-visible {
	outline: 3px solid var(--wp--preset--color--green);
	outline-offset: 3px;
	border-radius: 4px;
}
h1, h2, h3, h4 { text-wrap: balance; }
p, li { text-wrap: pretty; }

/* ---------- Header ---------- */
header.wp-block-template-part {
	position: sticky;
	top: 0;
	z-index: 50;
	background: rgba(255, 255, 255, 0.92);
	backdrop-filter: saturate(1.4) blur(10px);
	border-bottom: 1px solid var(--wp--preset--color--line);
}
.admin-bar header.wp-block-template-part { top: var(--wp-admin--admin-bar--height, 0px); }
.aff-header { background: transparent !important; }

.aff-brand .wp-block-site-title a {
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	text-decoration: none;
}
/* The mark: two overlapping rounds, one for each side of the table. */
.aff-brand .wp-block-site-title a::before {
	content: "";
	flex: none;
	width: 1.9rem;
	height: 1.25rem;
	background:
		radial-gradient(circle at 0.625rem 50%, var(--wp--preset--color--ink) 0 0.6rem, transparent 0.625rem),
		radial-gradient(circle at 1.275rem 50%, var(--wp--preset--color--green) 0 0.6rem, transparent 0.625rem);
}
.aff-footer .aff-brand .wp-block-site-title a::before {
	background:
		radial-gradient(circle at 0.625rem 50%, var(--wp--preset--color--base) 0 0.6rem, transparent 0.625rem),
		radial-gradient(circle at 1.275rem 50%, var(--wp--preset--color--green) 0 0.6rem, transparent 0.625rem);
}

.aff-header .wp-block-navigation .wp-block-navigation-item__content {
	padding: 0.45rem 0.8rem;
	border-radius: 999px;
	transition: background-color 0.15s ease;
}
.aff-header .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content:hover,
.aff-header .wp-block-navigation .current-menu-item > .wp-block-navigation-item__content,
.aff-header .wp-block-navigation .wp-block-navigation-item__content:hover {
	background: var(--wp--preset--color--tint);
}
.aff-header .wp-block-navigation__container, .aff-header .wp-block-page-list { gap: 0.25rem; }
.wp-block-navigation__responsive-container.is-menu-open { padding: 1.5rem; }
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.6rem;
	font-weight: 650;
}

/* ---------- Buttons ---------- */
.wp-block-button__link { transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease; }
.wp-block-button__link:active { transform: translateY(1px); }
.wp-block-button.is-style-outline > .wp-block-button__link {
	border: 2px solid currentColor;
	padding: calc(0.85rem - 2px) calc(1.5rem - 2px);
}
.wp-block-button.is-style-outline > .wp-block-button__link:hover {
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--ink);
	border-color: var(--wp--preset--color--base);
}
.has-ink-background-color .wp-block-button:not(.is-style-outline) > .wp-block-button__link:hover {
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--ink);
}

/* ---------- Hero (front page) ---------- */
.aff-hero { position: relative; overflow: hidden; }
.aff-hero .wp-block-post-title { max-width: 11ch; }
.aff-hero__lead { max-width: 34rem; color: #C9D0EE; }

.aff-register {
	border-radius: 20px;
	background: var(--wp--preset--color--ink-raised);
	overflow: hidden;
}
.aff-register__head {
	padding: 0.9rem 1.5rem;
	color: #AEB7E0;
	border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.aff-register__row {
	padding: 1.15rem 1.5rem;
	border-bottom: 1px solid rgba(255, 255, 255, 0.12);
	align-items: baseline;
}
.aff-register__row:last-child { border-bottom: 0; }
.aff-register__row > p { margin: 0; }
.aff-register__name {
	font-family: var(--wp--preset--font-family--display);
	font-weight: 700;
	font-size: clamp(1.75rem, 3vw, 2.4rem);
	line-height: 1;
	letter-spacing: -0.02em;
	min-width: 4.2ch;
}
.aff-register__who { color: #C9D0EE; flex: 1; }
.aff-register__count {
	color: var(--wp--preset--color--ink);
	background: var(--wp--preset--color--green);
	border-radius: 999px;
	padding: 0.2rem 0.75rem;
	font-weight: 600;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

/* ---------- Page title band ---------- */
.aff-titleband .wp-block-post-title { max-width: 18ch; }

/* ---------- Article content ---------- */
.entry-content > h2.wp-block-heading { margin-top: var(--wp--preset--spacing--60); }
.entry-content > h3.wp-block-heading { margin-top: var(--wp--preset--spacing--50); }
.entry-content > p:first-child { font-size: var(--wp--preset--font-size--large); line-height: 1.55; }

.entry-content a:not(.wp-block-button__link):not(.wp-element-button) {
	text-decoration-color: var(--wp--preset--color--green);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.18em;
}
.entry-content a:not(.wp-block-button__link):hover { text-decoration-thickness: 3px; }

/* Bulleted lists: square green markers */
.entry-content ul.wp-block-list { list-style: none; padding-left: 0; }
.entry-content ul.wp-block-list > li {
	position: relative;
	padding-left: 1.5rem;
	margin-block: 0.45rem;
}
.entry-content ul.wp-block-list > li::before {
	content: "";
	position: absolute;
	left: 0.1rem;
	top: 0.62em;
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 2px;
	background: var(--wp--preset--color--green);
}

/* Lists placed alone in a column (and the "Register" list style) read as a directory. */
.entry-content .wp-block-column > ul.wp-block-list:only-child,
.entry-content ul.wp-block-list.is-style-register {
	margin: 0;
	border-top: 2px solid var(--wp--preset--color--ink);
}
.entry-content .wp-block-column > ul.wp-block-list:only-child > li,
.entry-content ul.wp-block-list.is-style-register > li {
	margin: 0;
	padding: 0.6rem 0;
	border-bottom: 1px solid var(--wp--preset--color--line);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.35;
	overflow-wrap: anywhere;
	hyphens: auto;
}
.entry-content .wp-block-column > ul.wp-block-list:only-child > li::before,
.entry-content ul.wp-block-list.is-style-register > li::before { content: none; }
.entry-content .wp-block-column > ul.wp-block-list:only-child strong,
.entry-content ul.wp-block-list.is-style-register strong { font-weight: 600; }
.entry-content .wp-block-columns .wp-block-columns { gap: 0 1.25rem; margin-top: var(--wp--preset--spacing--30); }

/* Checklist style */
.entry-content ul.wp-block-list.is-style-check > li { padding-left: 2rem; }
.entry-content ul.wp-block-list.is-style-check > li::before {
	top: 0.2em;
	left: 0;
	width: 1.35rem;
	height: 1.35rem;
	border-radius: 50%;
	background: var(--wp--preset--color--mint) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-7' fill='none' stroke='%230B7A47' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}

/* Numbered lists: a ranked list with big numerals */
.entry-content ol.wp-block-list {
	list-style: none;
	padding-left: 0;
	counter-reset: aff;
	border-top: 2px solid var(--wp--preset--color--ink);
}
.entry-content ol.wp-block-list > li {
	counter-increment: aff;
	position: relative;
	padding: 1.1rem 0 1.1rem 4rem;
	border-bottom: 1px solid var(--wp--preset--color--line);
	min-height: 2.4rem;
}
.entry-content ol.wp-block-list > li::before {
	content: counter(aff);
	position: absolute;
	left: 0;
	top: 0.85rem;
	width: 3rem;
	font-family: var(--wp--preset--font-family--display);
	font-weight: 700;
	font-size: 2.1rem;
	line-height: 1;
	letter-spacing: -0.03em;
	color: var(--wp--preset--color--green-dark);
	font-variant-numeric: tabular-nums;
}

/* Images */
.entry-content .wp-block-image img { border-radius: 14px; }
.entry-content .wp-block-image a { display: inline-block; }
/* Tables */
.entry-content .wp-block-table table { border-collapse: collapse; width: 100%; }
.entry-content .wp-block-table th,
.entry-content .wp-block-table td {
	border: 0;
	border-bottom: 1px solid var(--wp--preset--color--line);
	padding: 0.75rem 0.9rem;
	text-align: left;
}
.entry-content .wp-block-table thead th {
	border-bottom: 2px solid var(--wp--preset--color--ink);
	font-weight: 600;
}
.entry-content .wp-block-table tbody tr:nth-child(even) { background: var(--wp--preset--color--paper); }
.entry-content .wp-block-table { overflow-x: auto; }

/* Details / FAQ */
.wp-block-details {
	border-bottom: 1px solid var(--wp--preset--color--line);
	padding: 1rem 0;
	margin: 0;
}
.wp-block-details summary {
	cursor: pointer;
	font-weight: 600;
	font-size: var(--wp--preset--font-size--large);
	list-style: none;
	display: flex;
	justify-content: space-between;
	gap: 1rem;
}
.wp-block-details summary::-webkit-details-marker { display: none; }
.wp-block-details summary::after {
	content: "+";
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.5rem;
	line-height: 1;
	color: var(--wp--preset--color--green-dark);
	transition: transform 0.2s ease;
}
.wp-block-details[open] summary::after { transform: rotate(45deg); }

/* ---------- Block styles: cards ---------- */
.wp-block-group.is-style-card {
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 20px;
	padding: var(--wp--preset--spacing--40);
}
.wp-block-group.is-style-tinted {
	background: var(--wp--preset--color--mint);
	border-radius: 20px;
	padding: var(--wp--preset--spacing--40);
}
.aff-orgcard { height: 100%; box-sizing: border-box; border-top: 6px solid var(--wp--preset--color--ink) !important; }
.aff-orgcard .aff-register__count { display: inline-block; }

/* ---------- CTA band ---------- */
.aff-cta { border-radius: 28px; }
.aff-cta h2 { max-width: 16ch; }

/* ---------- Post cards (blog/search) ---------- */
.aff-postcard { border-bottom: 1px solid var(--wp--preset--color--line); padding-bottom: var(--wp--preset--spacing--40); }
.aff-postcard .wp-block-post-title a { text-decoration: none; }
.aff-postcard .wp-block-post-title a:hover { color: var(--wp--preset--color--green-dark); }

/* ---------- Footer ---------- */
.aff-footer a { color: inherit; }
.aff-footer .wp-block-navigation .wp-block-navigation-item__content { padding: 0.2rem 0; }
.aff-footer .wp-block-navigation .wp-block-navigation-item__content:hover { text-decoration: underline; text-decoration-color: var(--wp--preset--color--green); text-underline-offset: 0.2em; }
.aff-footer__meta { color: #AEB7E0; border-top: 1px solid rgba(255, 255, 255, 0.14); }

.entry-content .wp-block-columns:has(> .wp-block-column > ul.wp-block-list:only-child) { column-gap: 1.25rem; }
.entry-content > .wp-block-columns.alignwide { margin-block: var(--wp--preset--spacing--50); }
.aff-register__who { min-width: 0; overflow-wrap: normal; word-break: normal; }

@media (max-width: 781px) {
	.entry-content .wp-block-columns:has(> .wp-block-column > ul.wp-block-list:only-child) { gap: 0; }
	.entry-content .wp-block-column + .wp-block-column > ul.wp-block-list:only-child { border-top: 0; }
	.entry-content ol.wp-block-list > li { padding-left: 3.1rem; }
	.aff-cta { border-radius: 20px; }
}
@media (max-width: 480px) {
	.aff-register__head, .aff-register__row { padding-inline: 1.1rem; }
	.aff-register__row { gap: 0.75rem; }
	.aff-register__name { min-width: 3.6ch; }
	.aff-register__who { font-size: var(--wp--preset--font-size--small); }
}
@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	* { transition: none !important; }
}

/* Search field */
.wp-block-search__input {
	border: 2px solid var(--wp--preset--color--ink);
	border-radius: 999px;
	padding: 0.75rem 1.2rem;
	font: inherit;
}
.wp-block-search__button { margin-left: 0.5rem; }
