/**
 * Group Block Styles
 *
 * Card variations for group blocks using semantic tokens.
 *
 * Styles:
 * - Card: Basic card container
 * - Portfolio Card: Project showcase card
 * - Company Card: Company/organization card
 * - Blog Roll Card: Blog link card
 * - Form Container: Styled form wrapper
 *
 * @package Matt_Blocks
 */

/* ==========================================================================
   Card Base Styles (Applied to all card variants)

   Scoped to Matt Blocks' own registered card style names, not a
   [class*="card"] wildcard — a substring match also catches any theme's
   own card-style class (e.g. is-style-valencia-card), silently imposing
   Matt Blocks' margin/shadow/hover-lift on styles it doesn't own. Per
   CLAUDE.md rule #4 (Unique Class Names — Avoid Conflicts), Matt Blocks
   should only ever touch its own explicitly listed style names.
   ========================================================================== */

.wp-block-group.is-style-card,
.wp-block-group.is-style-portfolio-card,
.wp-block-group.is-style-company-card,
.wp-block-group.is-style-blog-roll-card {
	background: var(--wp--preset--color--base, #fff);
	border-radius: 8px;
	border: 1px solid var(--wp--preset--color--contrast-3, var(--wp--preset--color--gray, rgba(0,0,0,0.1)));
	margin: 2rem 0;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	transition: all 0.2s ease;
}

/* Card hover effect */
.wp-block-group.is-style-card:hover,
.wp-block-group.is-style-portfolio-card:hover,
.wp-block-group.is-style-company-card:hover,
.wp-block-group.is-style-blog-roll-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
	border-color: var(--wp--preset--color--contrast, rgba(0,0,0,0.2));
}

/* Remove shadows from nested cards */
.wp-block-group .wp-block-group.is-style-card,
.wp-block-group .wp-block-group.is-style-portfolio-card,
.wp-block-group .wp-block-group.is-style-company-card,
.wp-block-group .wp-block-group.is-style-blog-roll-card {
	box-shadow: none;
}

.wp-block-group .wp-block-group.is-style-card:hover,
.wp-block-group .wp-block-group.is-style-portfolio-card:hover,
.wp-block-group .wp-block-group.is-style-company-card:hover,
.wp-block-group .wp-block-group.is-style-blog-roll-card:hover {
	box-shadow: none;
	transform: none;
}

/* ==========================================================================
   Basic Card
   ========================================================================== */

.wp-block-group.is-style-card {
	padding: 2rem;
}

.wp-block-group.is-style-card > * {
	margin-bottom: 1rem;
}

.wp-block-group.is-style-card > *:last-child {
	margin-bottom: 0;
}

/* ==========================================================================
   Portfolio Card
   ========================================================================== */

.wp-block-group.is-style-portfolio-card {
	padding: 0;
	overflow: hidden;
}

.wp-block-group.is-style-portfolio-card .wp-block-image {
	margin: 0 0 1rem 0;
}

.wp-block-group.is-style-portfolio-card .wp-block-image img {
	border-radius: 0;
	margin: 0;
	width: 100%;
	height: auto;
}

.wp-block-group.is-style-portfolio-card .wp-block-heading {
	margin: 0 0 0.5rem 0;
	padding: 0 2rem;
	font-size: 1.125rem;
	font-weight: 600;
	line-height: 1.3;
}

.wp-block-group.is-style-portfolio-card .wp-block-paragraph,
.wp-block-group.is-style-portfolio-card p {
	margin: 0 0 1rem 0;
	padding: 0 2rem;
	color: var(--wp--preset--color--contrast-3, var(--wp--preset--color--gray, rgba(0,0,0,0.6)));
	font-size: 0.875rem;
	line-height: 1.6;
}

.wp-block-group.is-style-portfolio-card .wp-block-buttons {
	margin: 0;
	padding: 0 2rem 2rem;
}

/* ==========================================================================
   Company Card
   ========================================================================== */

.wp-block-group.is-style-company-card {
	padding: 2rem;
	text-align: center;
}

.wp-block-group.is-style-company-card .wp-block-image {
	margin: 0 auto 1rem;
	width: 80px;
	height: 80px;
}

.wp-block-group.is-style-company-card .wp-block-image img {
	border-radius: 8px;
	width: 80px;
	height: 80px;
	object-fit: cover;
	border: 1px solid var(--wp--preset--color--contrast-3, var(--wp--preset--color--gray, rgba(0,0,0,0.1)));
}

.wp-block-group.is-style-company-card .wp-block-heading {
	margin: 0 0 0.5rem 0;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.3;
	color: var(--wp--preset--color--contrast, #000);
}

.wp-block-group.is-style-company-card .wp-block-paragraph {
	margin: 0 0 1rem 0;
	color: var(--wp--preset--color--contrast-3, var(--wp--preset--color--gray, rgba(0,0,0,0.6)));
	font-size: 0.875rem;
	line-height: 1.6;
}

.wp-block-group.is-style-company-card .wp-block-buttons {
	margin: 0;
}

.wp-block-group.is-style-company-card .wp-block-button .wp-block-button__link {
	font-size: 0.875rem;
	padding: 0.5rem 1rem;
}

/* ==========================================================================
   Blog Roll Card
   ========================================================================== */

.wp-block-group.is-style-blog-roll-card {
	padding: 2rem;
}

.wp-block-group.is-style-blog-roll-card:hover {
	background: var(--wp--preset--color--base, #fff);
}

.wp-block-group.is-style-blog-roll-card .wp-block-heading {
	margin-bottom: 0.5rem;
	font-size: 1.125rem;
	font-weight: 600;
	line-height: 1.3;
}

.wp-block-group.is-style-blog-roll-card .wp-block-heading a {
	color: var(--wp--preset--color--contrast, #000);
	text-decoration: none;
}

.wp-block-group.is-style-blog-roll-card .wp-block-heading a:hover {
	color: var(--wp--preset--color--accent-1, var(--wp--preset--color--accent, var(--wp--preset--color--primary, #0070f3)));
}

.wp-block-group.is-style-blog-roll-card .wp-block-paragraph {
	color: var(--wp--preset--color--contrast-3, var(--wp--preset--color--gray, rgba(0,0,0,0.6)));
	font-size: 0.875rem;
	line-height: 1.6;
	margin: 0;
}

/* ==========================================================================
   Form Container
   ========================================================================== */

.wp-block-group.is-style-form-container {
	background: var(--wp--preset--color--base, #fff);
	border: 1px solid var(--wp--preset--color--contrast-3, var(--wp--preset--color--gray, rgba(0,0,0,0.1)));
	border-radius: 8px;
	padding: 2rem;
	margin: 2rem 0;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.wp-block-group.is-style-form-container .wp-block-heading {
	margin-bottom: 1.5rem;
}

/* Form inputs inside form container */
.wp-block-group.is-style-form-container input[type="text"],
.wp-block-group.is-style-form-container input[type="email"],
.wp-block-group.is-style-form-container textarea {
	width: 100%;
	padding: 0.75rem 1rem;
	border: 1px solid var(--wp--preset--color--gray, rgba(0,0,0,0.2));
	border-radius: 4px;
	font-size: 1rem;
	line-height: 1.5;
	background: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--contrast, #000);
}

.wp-block-group.is-style-form-container input:focus,
.wp-block-group.is-style-form-container textarea:focus {
	outline: 2px solid var(--wp--preset--color--accent-1, var(--wp--preset--color--accent, var(--wp--preset--color--primary, #0070f3)));
	outline-offset: 2px;
	border-color: var(--wp--preset--color--accent-1, var(--wp--preset--color--accent, var(--wp--preset--color--primary, #0070f3)));
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */

@media (max-width: 768px) {
	.wp-block-group.is-style-form-container {
		padding: 1.5rem 1rem;
		margin: 1.5rem 0;
	}

	.wp-block-group.is-style-portfolio-card .wp-block-heading,
	.wp-block-group.is-style-portfolio-card .wp-block-paragraph,
	.wp-block-group.is-style-portfolio-card .wp-block-buttons {
		padding-left: 1.5rem;
		padding-right: 1.5rem;
	}
}

@media (max-width: 480px) {
	.wp-block-group.is-style-form-container {
		padding: 1rem 0.75rem;
	}

	.wp-block-group.is-style-card,
	.wp-block-group.is-style-portfolio-card,
	.wp-block-group.is-style-company-card,
	.wp-block-group.is-style-blog-roll-card {
		margin: 1rem 0;
	}
}

/* ==========================================================================
   Utility: Subtle Border Override
   ========================================================================== */

/* Override card border for patterns that need more subtle styling */
.wp-block-group.is-style-card.has-subtle-border {
	border: 1px solid var(--wp--preset--color--contrast-3, var(--wp--preset--color--gray, rgba(0,0,0,0.15)));
	box-shadow: none;
	overflow: hidden;
}

.wp-block-group.is-style-card.has-subtle-border:hover {
	border-color: var(--wp--preset--color--contrast-2, var(--wp--preset--color--contrast, rgba(0,0,0,0.25)));
	box-shadow: none;
	transform: none;
}

/* Case Study Card: mb-case-card / mb-case-card-accent. Theme-portable colors
 * (base/contrast/accent-1 presets + fallbacks). 6px radius, -6px hover lift. */

.wp-block-group.is-style-mb-case-card,
.wp-block-group.is-style-mb-case-card-accent {
	background: var(--wp--preset--color--base, var(--wp--preset--color--background, #fff));
	border-radius: 6px;
	overflow: hidden;
	box-shadow: var(--wp--preset--shadow--soft, 0 2px 6px rgba(0, 0, 0, 0.06));
	transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.3s ease;
}

.wp-block-group.is-style-mb-case-card:hover,
.wp-block-group.is-style-mb-case-card-accent:hover {
	transform: translateY(-6px);
	box-shadow: var(--wp--preset--shadow--lifted, 0 10px 28px rgba(0, 0, 0, 0.12));
}

.mb-case-stat, .mb-case-stat-label, .mb-case-tag { margin: 0 !important; }

.mb-case-stat {
	font-family: var(--wp--preset--font-family--heading, var(--wp--preset--font-family--display, serif));
	font-weight: 700;
	font-size: 1.4em;
	/* !important: theme content rules (e.g. .valencia-entry-content p at
	 * line-height 1.6) out-rank this selector and inflate the number's box
	 * by ~15px of pure leading — same specificity war as the margin resets,
	 * same sanctioned remedy. */
	line-height: 1 !important;
	color: var(--wp--preset--color--accent-1, var(--wp--preset--color--accent, var(--wp--preset--color--primary, #0070f3)));
}

.mb-case-stat-label {
	font-size: 0.65em;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	opacity: 0.55;
	margin-top: 0.25em !important;
}

.mb-case-cta {
	/* Deliberately quieter than the stat: the number is the hero of the
	 * footer row, the CTA is the secondary action. Smaller size, hairline
	 * underline, muted ink — one focal point per card. */
	font-size: 0.85em;
	font-weight: 600;
	opacity: 0.75;
	text-decoration: none;
	border-bottom: 1px solid var(--wp--preset--color--accent-1, var(--wp--preset--color--accent, var(--wp--preset--color--primary, #0070f3)));
	padding-bottom: 2px;
	white-space: nowrap;
	transition: opacity 0.15s ease;
}

.wp-block-group.is-style-mb-case-card:hover .mb-case-cta,
.wp-block-group.is-style-mb-case-card-accent:hover .mb-case-cta {
	opacity: 1;
}

/* The paragraph's border-bottom IS the underline; theme link styles
 * (text-decoration and border-based underlines alike, e.g. Valencia's
 * accent border on content links) double it on the inner <a>. Doubled-up
 * ancestor (0,2,1) out-ranks theme content-link rules like Valencia's
 * .valencia-entry-content a:where(...) at (0,1,1), which otherwise wins
 * the tie on stylesheet order. */
.wp-block-group .mb-case-cta a,
.wp-block-group .mb-case-cta a:hover {
	text-decoration: none;
	border-bottom: 0;
	color: inherit;
}

.mb-case-tag {
	display: inline-block;
	padding: 5px 12px;
	border-radius: 7px;
	font-size: 0.75em;
	font-weight: 600;
	color: var(--wp--preset--color--accent-1, var(--wp--preset--color--accent, var(--wp--preset--color--primary, #0070f3)));
	background: color-mix(in srgb, var(--wp--preset--color--accent-1, var(--wp--preset--color--accent, var(--wp--preset--color--primary, #0070f3))) 12%, transparent);
}

.wp-block-group.is-style-mb-case-card-accent { background: var(--wp--preset--color--accent-1, var(--wp--preset--color--accent, var(--wp--preset--color--primary, #0070f3))); color: var(--wp--preset--color--base, var(--wp--preset--color--background, #fff)); }

.wp-block-group.is-style-mb-case-card-accent h2, .wp-block-group.is-style-mb-case-card-accent h3, .wp-block-group.is-style-mb-case-card-accent h4 { color: var(--wp--preset--color--base, var(--wp--preset--color--background, #fff)); }

.wp-block-group.is-style-mb-case-card-accent .mb-case-stat,
.wp-block-group.is-style-mb-case-card-accent .mb-case-tag,
.wp-block-group.is-style-mb-case-card-accent .mb-case-cta {
	color: var(--wp--preset--color--base, var(--wp--preset--color--background, #fff));
}

.wp-block-group.is-style-mb-case-card-accent .mb-case-tag {
	background: color-mix(in srgb, var(--wp--preset--color--base, var(--wp--preset--color--background, #fff)) 16%, transparent);
}
.wp-block-group.is-style-mb-case-card-accent .mb-case-cta {
	border-bottom-color: color-mix(in srgb, var(--wp--preset--color--base, var(--wp--preset--color--background, #fff)) 60%, transparent);
}

/* Hover-reveal (scope addition after live use): the description (the <p>
 * directly after the card title) and the tag row collapse at rest and expand
 * on card hover, like the 21st.dev reference. Keyed to classes already in
 * inserted copies — no re-insertion needed. Touch devices have no hover, so
 * below 781px everything stays visible; the reveal is desktop-only. The
 * max-height cap (240px) is the transition ceiling, not a clamp — content
 * taller than the cap still shows fully once expanded (transition just ends
 * early). Reduced-motion users get instant states, no animation. */
@media (min-width: 781px) {
	/* Grid rows stretch items by default, so a collapsed card sits inside a
	 * box pre-sized by the row and the reveal grows text INSIDE a static
	 * card — nothing visibly expands. align-items:start lets each card size
	 * to its own content, so the hovered card genuinely grows. Trade-off:
	 * resting cards in a row may differ slightly in height. Scoped via
	 * :has() to grids that actually contain case cards. */
	.wp-block-group.is-layout-grid:has(> .is-style-mb-case-card),
	.wp-block-group.is-layout-grid:has(> .is-style-mb-case-card-accent) {
		align-items: start;
	}

	.wp-block-group.is-style-mb-case-card h3 + p,
	.wp-block-group.is-style-mb-case-card-accent h3 + p,
	.wp-block-group.is-style-mb-case-card .wp-block-group:has(> .mb-case-tag),
	.wp-block-group.is-style-mb-case-card-accent .wp-block-group:has(> .mb-case-tag) {
		max-height: 0;
		opacity: 0;
		overflow: hidden;
		margin-top: 0 !important;
		margin-bottom: 0 !important;
		transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
	}
	.wp-block-group.is-style-mb-case-card:hover h3 + p,
	.wp-block-group.is-style-mb-case-card-accent:hover h3 + p,
	.wp-block-group.is-style-mb-case-card:hover .wp-block-group:has(> .mb-case-tag),
	.wp-block-group.is-style-mb-case-card-accent:hover .wp-block-group:has(> .mb-case-tag) {
		max-height: 140px;
		opacity: 1;
	}
	.wp-block-group.is-style-mb-case-card:hover h3 + p,
	.wp-block-group.is-style-mb-case-card-accent:hover h3 + p {
		/* Restore breathing room on BOTH sides when revealed — the collapsed
		 * state zeroes margins, and the title has no bottom margin of its
		 * own, so without margin-top the description sits flush under it. */
		margin-top: 0.5em !important;
		margin-bottom: 0.75em !important;
	}
}

/* Spacing pass (live feedback): the body group's blockGap margin + its own
 * top padding stacked to ~42px under the photo (vs a 25px internal rhythm),
 * and the footer's blockGap margin + padding piled ~118px of footer zone.
 * The hairline + padding already separate the footer; the margins were
 * double-counting. Applies at all widths, both variants. */
.wp-block-group.is-style-mb-case-card > figure + .wp-block-group,
.wp-block-group.is-style-mb-case-card-accent > figure + .wp-block-group {
	margin-top: 6px !important;
}
.wp-block-group.is-style-mb-case-card > .wp-block-group:last-child,
.wp-block-group.is-style-mb-case-card-accent > .wp-block-group:last-child {
	margin-top: 8px !important;
	border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent);
}

@media (min-width: 781px) and (prefers-reduced-motion: reduce) {
	.wp-block-group.is-style-mb-case-card h3 + p,
	.wp-block-group.is-style-mb-case-card-accent h3 + p,
	.wp-block-group.is-style-mb-case-card .wp-block-group:has(> .mb-case-tag),
	.wp-block-group.is-style-mb-case-card-accent .wp-block-group:has(> .mb-case-tag) {
		transition: none;
	}
}
