/*
Theme Name: Häkelnest
Theme URI: https://haekelnest.com/
Author: Häkelnest
Description: Editorial Block-Theme für kostenlose Häkelanleitungen. Lokale Schriften, keine externen Anfragen.
Version: 2.1.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: haekelnest
*/

/* ---------- Base ---------- */
:where(.wp-site-blocks) a { text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
:where(h1, h2, h3, .wp-block-post-title) { overflow-wrap: break-word; hyphens: auto; }
:focus-visible { outline: 2px solid var(--wp--preset--color--primary); outline-offset: 3px; }
::selection { background: var(--wp--preset--color--rose); }

/* Small uppercase label ("eyebrow") */
.hn-eyebrow {
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--wp--preset--color--primary);
}
.hn-eyebrow a { color: inherit; text-decoration: none; }
.hn-eyebrow a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.hn-topbar { border-bottom: 1px solid var(--wp--preset--color--border); }
.hn-header { border-bottom: 1px solid var(--wp--preset--color--border); }
.hn-brand { gap: 0.55rem; }
.hn-brand .wp-block-site-title a { text-decoration: none; }
.hn-logo img { display: block; }
.hn-header .wp-block-navigation-item__content { padding-block: 0.4rem; }
.hn-header .wp-block-navigation-item__content:hover { text-decoration: none; box-shadow: inset 0 -1px 0 currentColor; }

/* ---------- Category bar ---------- */
.hn-catbar { gap: 0.5rem 0.6rem; }
.hn-catbar a {
	display: inline-block;
	padding: 0.55rem 1.05rem;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 999px;
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	transition: border-color .15s ease, background-color .15s ease;
}
.hn-catbar a:hover { border-color: var(--wp--preset--color--contrast); background: var(--wp--preset--color--surface); }

/* ---------- Editorial post cards ---------- */
.hn-post { position: relative; }
.hn-post .wp-block-post-featured-image { margin: 0; overflow: hidden; background: var(--wp--preset--color--surface); }
.hn-post .wp-block-post-featured-image img { transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.hn-post:hover .wp-block-post-featured-image img { transform: scale(1.035); }
.hn-post .wp-block-post-title a { text-decoration: none; }
.hn-post .wp-block-post-title a::after { content: ""; position: absolute; inset: 0; }
.hn-post .wp-block-post-terms a { position: relative; z-index: 1; }
.hn-post .wp-block-post-terms,
.hn-meta-cat {
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}
.hn-post .wp-block-post-terms a, .hn-meta-cat a { color: var(--wp--preset--color--primary); text-decoration: none; }

/* Featured (lead) story */
.hn-lead .wp-block-post-title { font-size: var(--wp--preset--font-size--xx-large); }

/* ---------- Section headings ---------- */
.hn-section-head { border-bottom: 1px solid var(--wp--preset--color--contrast); padding-bottom: 0.75rem; }
.hn-section-head a { font-size: var(--wp--preset--font-size--x-small); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; text-decoration: none; }

/* ---------- Search ---------- */
.hn-search .wp-block-search__inside-wrapper { border: 1px solid var(--wp--preset--color--border); border-radius: 999px; padding: 4px; background: #fff; }
.hn-search .wp-block-search__input { border: 0; padding-left: 1.1rem; font-size: var(--wp--preset--font-size--medium); background: transparent; }
.hn-search .wp-block-search__button { border-radius: 999px; margin-left: 0; }

/* ---------- Post content ---------- */
.wp-block-post-content :where(h2, h3) { scroll-margin-top: 1.5rem; }
.wp-block-post-content > p:first-child { font-size: var(--wp--preset--font-size--large); }
.wp-block-post-content .wp-block-preformatted {
	background: var(--wp--preset--color--surface);
	border-left: 2px solid var(--wp--preset--color--primary);
	padding: 1rem 1.25rem;
	white-space: pre-wrap;
	font-family: var(--wp--preset--font-family--body);
	font-weight: 600;
}
.wp-block-table table { border-collapse: collapse; width: 100%; font-size: var(--wp--preset--font-size--small); }
.wp-block-table thead { border-bottom: 1px solid var(--wp--preset--color--contrast); }
.wp-block-table th { text-align: left; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: var(--wp--preset--font-size--x-small); }
.wp-block-table td, .wp-block-table th { border: 0; border-bottom: 1px solid var(--wp--preset--color--border); padding: .7rem .8rem; }
.wp-block-table.is-style-stripes tbody tr:nth-child(odd) { background: var(--wp--preset--color--surface); }
.wp-block-table.is-style-stripes { border-bottom: none; }

/* Info box for pattern posts */
.is-style-hn-infobox {
	background: var(--wp--preset--color--surface);
	padding: 1.5rem 1.75rem;
	border-top: 2px solid var(--wp--preset--color--primary);
}

/* ---------- Footer ---------- */
.hn-footer a { color: inherit; text-decoration: none; opacity: .85; }
.hn-footer a:hover { opacity: 1; text-decoration: underline; }
.hn-footer .wp-block-site-title a { opacity: 1; }
.hn-footer ul { list-style: none; padding-left: 0; }
.hn-footer li { margin-bottom: .35rem; }

/* =========================================================
   Motion & decoration layer (v2.1)
   ========================================================= */

/* Sticky header with shadow after scrolling */
.wp-site-blocks > header:first-child,
.wp-site-blocks > .wp-block-template-part:first-child { position: sticky; top: 0; z-index: 50; }
.admin-bar .wp-site-blocks > .wp-block-template-part:first-child { top: 32px; }
.hn-header { transition: box-shadow .25s ease, background-color .25s ease; }
.hn-scrolled .hn-header { box-shadow: 0 8px 24px -18px rgba(30, 26, 23, .45); background: rgba(255,255,255,.96) !important; backdrop-filter: saturate(1.4) blur(8px); }

/* Nav underline grows from left */
.hn-header .wp-block-navigation-item__content { position: relative; }
.hn-header .wp-block-navigation-item__content::after {
	content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
	background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .3s ease;
}
.hn-header .wp-block-navigation-item__content:hover { box-shadow: none; }
.hn-header .wp-block-navigation-item__content:hover::after { transform: scaleX(1); }

/* Logo spins a little on hover */
.hn-logo img { transition: transform .6s cubic-bezier(.2,.8,.2,1); }
.hn-brand:hover .hn-logo img { transform: rotate(-25deg); }

/* Scroll reveal (only when JS is available) */
.hn-js .hn-reveal { opacity: 0; transform: translateY(22px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); transition-delay: calc(var(--i, 0) * 70ms); }
.hn-js .hn-reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Hero ---------- */
.hn-hero { overflow: hidden; position: relative; }
.hn-hero::before {
	content: ""; position: absolute; inset: auto -10% -40% auto; width: 46vw; height: 46vw; max-width: 640px; max-height: 640px;
	background: radial-gradient(closest-side, rgba(201,139,94,.16), transparent 70%); pointer-events: none;
}
.hn-hero h1 { margin-top: .4rem; }
.hn-hl { font-style: italic; color: var(--wp--preset--color--primary); font-weight: 400; position: relative; white-space: nowrap; }
.hn-hl::after {
	content: ""; position: absolute; left: 0; right: 0; bottom: .02em; height: .12em;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 10' preserveAspectRatio='none'%3E%3Cpath d='M0 6 Q 12 0 25 5 T 50 5 T 75 5 T 100 4' fill='none' stroke='%23C98B5E' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") center/100% 100% no-repeat;
	transform: scaleX(0); transform-origin: left; animation: hn-underline 1s .9s cubic-bezier(.2,.8,.2,1) forwards;
}
@keyframes hn-underline { to { transform: scaleX(1); } }

.hn-eyebrow-line { display: inline-flex; align-items: center; gap: .6rem; margin: 0; }
.hn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--wp--preset--color--primary); box-shadow: 0 0 0 0 rgba(156,61,43,.5); animation: hn-pulse 2.2s infinite; }
@keyframes hn-pulse { 0% { box-shadow: 0 0 0 0 rgba(156,61,43,.45); } 70% { box-shadow: 0 0 0 10px rgba(156,61,43,0); } 100% { box-shadow: 0 0 0 0 rgba(156,61,43,0); } }

.hn-hero-text > * { animation: hn-rise .8s cubic-bezier(.2,.7,.2,1) both; }
.hn-hero-text > *:nth-child(2) { animation-delay: .08s; }
.hn-hero-text > *:nth-child(3) { animation-delay: .16s; }
.hn-hero-text > *:nth-child(4) { animation-delay: .24s; }
.hn-hero-text > *:nth-child(5) { animation-delay: .32s; }
@keyframes hn-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.hn-popular { font-size: var(--wp--preset--font-size--small); color: var(--wp--preset--color--muted); display: flex; flex-wrap: wrap; gap: .35rem .9rem; margin-top: 1rem; }
.hn-popular span { font-weight: 600; color: var(--wp--preset--color--contrast); }
.hn-popular a { color: var(--wp--preset--color--muted); text-decoration: none; border-bottom: 1px dashed var(--wp--preset--color--border); }
.hn-popular a:hover { color: var(--wp--preset--color--primary); border-bottom-color: currentColor; }

.hn-hero-art { position: relative; aspect-ratio: 1; max-width: 480px; margin-inline: auto; }
.hn-hero-disc { position: absolute; inset: 6%; border-radius: 50%; background: var(--wp--preset--color--surface); }
.hn-hero-disc::after { content: ""; position: absolute; inset: -14px; border-radius: 50%; border: 1.5px dashed var(--wp--preset--color--border); animation: hn-spin 60s linear infinite; }
@keyframes hn-spin { to { transform: rotate(360deg); } }
.hn-yarn { position: relative; width: 100%; height: auto; }
.hn-draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: hn-draw 1.6s cubic-bezier(.6,.1,.2,1) forwards; animation-delay: var(--d, 0s); }
@keyframes hn-draw { to { stroke-dashoffset: 0; } }
.hn-hook { transform-origin: 258px 120px; animation: hn-hook-in 1s 1.1s cubic-bezier(.2,.8,.2,1) both, hn-hook-wiggle 5s 2.2s ease-in-out infinite; }
@keyframes hn-hook-in { from { opacity: 0; transform: translate(40px, -40px); } to { opacity: 1; transform: none; } }
@keyframes hn-hook-wiggle { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-4deg); } }

.hn-badge {
	position: absolute; display: inline-flex; align-items: center; gap: .5rem;
	background: #fff; color: var(--wp--preset--color--contrast);
	padding: .6rem 1rem .6rem .75rem; border-radius: 999px;
	font-size: var(--wp--preset--font-size--small); font-weight: 600; white-space: nowrap;
	box-shadow: 0 14px 30px -16px rgba(30,26,23,.35), 0 0 0 1px var(--wp--preset--color--border);
	animation: hn-pop .6s cubic-bezier(.2,.9,.3,1.3) both, hn-float 6s ease-in-out infinite;
}
.hn-badge .hn-icon { color: var(--wp--preset--color--primary); }
.hn-badge-1 { top: 10%; left: -4%; animation-delay: 1.3s, 2s; }
.hn-badge-2 { top: 52%; right: -6%; animation-delay: 1.5s, 2.6s; }
.hn-badge-3 { bottom: 6%; left: 6%; animation-delay: 1.7s, 3.2s; }
@keyframes hn-pop { from { opacity: 0; transform: scale(.6) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes hn-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }

/* ---------- Marquee ---------- */
.hn-marquee { background: var(--wp--preset--color--contrast); color: #F3ECE6; overflow: hidden; padding: 1rem 0; margin-top: 0 !important; }
.hn-marquee-track { display: flex; width: max-content; animation: hn-marquee 38s linear infinite; }
.hn-marquee:hover .hn-marquee-track { animation-play-state: paused; }
.hn-marquee-group { display: flex; align-items: center; gap: 1.6rem; padding-right: 1.6rem; }
.hn-marquee-group span { font-family: var(--wp--preset--font-family--heading); font-size: 1.35rem; font-style: italic; white-space: nowrap; }
.hn-marquee .hn-icon { color: var(--wp--preset--color--accent); flex: none; }
@keyframes hn-marquee { to { transform: translateX(-50%); } }

/* ---------- Category cards with icons ---------- */
.hn-cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-top: var(--wp--preset--spacing--40); }
.hn-cat-card {
	position: relative; display: flex; flex-direction: column; gap: .2rem;
	padding: 1.5rem 1.4rem 1.3rem; border: 1px solid var(--wp--preset--color--border); border-radius: 6px;
	color: var(--wp--preset--color--contrast); text-decoration: none; background: #fff; overflow: hidden;
	transition: border-color .25s ease, transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s ease;
}
.hn-cat-card::before {
	content: ""; position: absolute; inset: 0; background: var(--wp--preset--color--surface);
	transform: translateY(101%); transition: transform .45s cubic-bezier(.2,.8,.2,1); z-index: 0;
}
.hn-cat-card > * { position: relative; z-index: 1; }
.hn-cat-card:hover { border-color: var(--wp--preset--color--contrast); transform: translateY(-4px); box-shadow: 0 18px 36px -24px rgba(30,26,23,.5); }
.hn-cat-card:hover::before { transform: none; }
.hn-cat-icon { color: var(--wp--preset--color--primary); margin-bottom: .6rem; display: inline-block; transition: transform .5s cubic-bezier(.2,.9,.3,1.4); }
.hn-cat-card:hover .hn-cat-icon { transform: rotate(-8deg) scale(1.12); }
.hn-cat-name { font-family: var(--wp--preset--font-family--heading); font-size: 1.3rem; font-weight: 500; line-height: 1.2; }
.hn-cat-sub { font-size: var(--wp--preset--font-size--small); color: var(--wp--preset--color--muted); }
.hn-cat-arrow { position: absolute !important; top: 1.3rem; right: 1.2rem; color: var(--wp--preset--color--primary); opacity: 0; transform: translateX(-8px); transition: opacity .3s ease, transform .3s ease; }
.hn-cat-card:hover .hn-cat-arrow { opacity: 1; transform: none; }

/* ---------- Features ---------- */
.hn-features { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2rem; padding: var(--wp--preset--spacing--50) 0; border-top: 1px solid var(--wp--preset--color--border); border-bottom: 1px solid var(--wp--preset--color--border); }
.hn-feature-icon { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--wp--preset--color--rose); color: var(--wp--preset--color--primary); transition: transform .5s cubic-bezier(.2,.9,.3,1.4), background-color .3s ease; }
.hn-feature:hover .hn-feature-icon { transform: translateY(-4px) rotate(-6deg); background: var(--wp--preset--color--honey); }
.hn-feature-title { font-size: 1.2rem; margin: .9rem 0 .35rem; }
.hn-feature-text { font-size: var(--wp--preset--font-size--small); color: var(--wp--preset--color--muted); margin: 0; line-height: 1.6; }

/* ---------- Crochet stitch divider ---------- */
.hn-stitch-top { position: relative; }
.hn-stitch-top::before {
	content: ""; position: absolute; top: -9px; left: 0; right: 0; height: 18px;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='18' viewBox='0 0 28 18'%3E%3Cpath d='M4 4l10 10 10-10' fill='none' stroke='%23C98B5E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") repeat-x center/28px 18px;
}
.hn-section-head { position: relative; }

/* ---------- Buttons: arrow nudge ---------- */
.wp-element-button { transition: background-color .25s ease, transform .2s ease; }
.wp-element-button:hover { transform: translateY(-2px); }
.wp-block-button .wp-element-button::after { content: "→"; display: inline-block; margin-left: .55em; transition: transform .25s ease; }
.wp-block-button .wp-element-button:hover::after { transform: translateX(4px); }

/* Card image zoom already exists; add a soft overlay tag on hover */
.hn-post .wp-block-post-featured-image { position: relative; }
.hn-post .wp-block-post-featured-image::after {
	content: "Zur Anleitung →"; position: absolute; left: 1rem; bottom: 1rem; padding: .45rem .8rem; background: #fff;
	font-size: var(--wp--preset--font-size--x-small); font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
	opacity: 0; transform: translateY(8px); transition: opacity .3s ease, transform .3s ease;
}
.hn-post:hover .wp-block-post-featured-image::after { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
	.hn-cats, .hn-features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 781px) {
	.hn-hero-art { max-width: 360px; margin-top: 1rem; }
	.hn-badge { font-size: var(--wp--preset--font-size--x-small); padding: .45rem .8rem .45rem .6rem; }
	.hn-badge-1 { left: 0; }
	.hn-badge-2 { right: 0; }
	.hn-hl { white-space: normal; }
}
@media (max-width: 480px) {
	.hn-cats { gap: .7rem; }
	.hn-cat-card { padding: 1.1rem 1rem; }
	.hn-features { grid-template-columns: 1fr; gap: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
	.hn-draw { stroke-dashoffset: 0; }
	.hn-hl::after { transform: none; }
	.hn-js .hn-reveal { opacity: 1; transform: none; }
}
