/*
Theme Name: MA Theme
Theme URI: https://managementacademy.it
Author: Management Academy
Description: High-performance block theme for MA PBN network. SEO-first, mobile-first, zero JS.
Version: 1.1.0
Requires at least: 6.4
Tested up to: 6.7
Requires PHP: 7.4
License: Proprietary
Text Domain: ma-theme
*/

/* ==========================================================================
   Design System — reads palette from theme.json CSS vars
   ========================================================================== */

:root {
    --ma-text-muted: #64748b;
    --ma-border: #e2e8f0;
    --ma-radius: 16px;
    --ma-radius-sm: 10px;
    --ma-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --ma-shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --ma-shadow-lg: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
    --ma-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Global Reset & Base
   ========================================================================== */

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

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a { text-decoration: none; transition: color var(--ma-transition); }
img { max-width: 100%; height: auto; display: block; }

/* ==========================================================================
   Typography — fluid, bold, magazine-style
   ========================================================================== */

h1 {
    font-family: var(--wp--preset--font-family--heading);
    font-size: clamp(2.25rem, 5vw, 3.5rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--wp--preset--color--text);
}

h2 {
    font-family: var(--wp--preset--font-family--heading);
    font-size: clamp(1.5rem, 3.5vw, 2.25rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h3 {
    font-family: var(--wp--preset--font-family--heading);
    font-size: clamp(1.125rem, 2.5vw, 1.375rem);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

p {
    line-height: 1.7;
    color: var(--wp--preset--color--text);
}

/* ==========================================================================
   Hero Section — gradient background, large centered text
   ========================================================================== */

.ma-hero {
    position: relative;
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 6rem 2rem;
    background: linear-gradient(
        135deg,
        var(--wp--preset--color--primary) 0%,
        var(--wp--preset--color--secondary, var(--wp--preset--color--primary)) 50%,
        color-mix(in srgb, var(--wp--preset--color--primary) 70%, #000) 100%
    );
    overflow: hidden;
}

.ma-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(255,255,255,0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255,255,255,0.06) 0%, transparent 50%);
    pointer-events: none;
}

.ma-hero__inner {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
}

.ma-hero h1 {
    color: #fff;
    margin-bottom: 1.25rem;
    font-size: clamp(2.5rem, 6vw, 4rem);
    text-shadow: 0 2px 20px rgba(0,0,0,0.15);
}

.ma-hero__tagline {
    font-size: clamp(1.125rem, 2.5vw, 1.375rem);
    color: rgba(255,255,255,0.85);
    line-height: 1.6;
    margin-bottom: 2.5rem;
    font-weight: 400;
}

.ma-hero__cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2.5rem;
    background: #fff;
    color: var(--wp--preset--color--primary);
    font-weight: 700;
    font-size: 1.0625rem;
    border-radius: 100px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transition: transform var(--ma-transition), box-shadow var(--ma-transition);
}

.ma-hero__cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    color: var(--wp--preset--color--primary);
}

.ma-hero__cta svg {
    width: 20px;
    height: 20px;
    transition: transform var(--ma-transition);
}

.ma-hero__cta:hover svg {
    transform: translateX(4px);
}

/* ==========================================================================
   Section Containers
   ========================================================================== */

.ma-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 5rem 2rem;
}

.ma-section__label {
    display: inline-block;
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--wp--preset--color--primary);
    margin-bottom: 0.75rem;
}

.ma-section h2 {
    margin-bottom: 0.75rem;
}

.ma-section__subtitle {
    font-size: 1.125rem;
    color: var(--ma-text-muted);
    max-width: 600px;
    line-height: 1.6;
    margin-bottom: 3rem;
}

/* ==========================================================================
   Featured Posts Grid — card-based with image, hover lift
   ========================================================================== */

.ma-featured-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
}

.ma-featured-card {
    background: #fff;
    border-radius: var(--ma-radius);
    overflow: hidden;
    box-shadow: var(--ma-shadow);
    transition: transform var(--ma-transition), box-shadow var(--ma-transition);
}

.ma-featured-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--ma-shadow-lg);
}

.ma-featured-card__image {
    display: block;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--wp--preset--color--surface);
}

.ma-featured-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.ma-featured-card:hover .ma-featured-card__image img {
    transform: scale(1.05);
}

.ma-featured-card__content {
    padding: 1.5rem 1.75rem 1.75rem;
}

.ma-featured-card__content h3 {
    margin: 0 0 0.5rem;
}

.ma-featured-card__content h3 a {
    color: var(--wp--preset--color--text);
}

.ma-featured-card__content h3 a:hover {
    color: var(--wp--preset--color--primary);
}

.ma-featured-card__content p {
    font-size: 0.9375rem;
    color: var(--ma-text-muted);
    line-height: 1.6;
    margin: 0;
}

.ma-featured-card .ma-post-meta {
    margin-bottom: 0.75rem;
}

/* First card = featured large */
.ma-featured-grid .ma-featured-card:first-child {
    grid-column: 1 / -1;
}

.ma-featured-grid .ma-featured-card:first-child .ma-featured-card__image {
    aspect-ratio: 21/9;
}

/* ==========================================================================
   Category Cards — colorful, pill-shaped with count badge
   ========================================================================== */

.ma-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}

.ma-category-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: #fff;
    border-radius: var(--ma-radius-sm);
    box-shadow: var(--ma-shadow);
    transition: transform var(--ma-transition), box-shadow var(--ma-transition);
    text-decoration: none;
    border-left: 4px solid var(--wp--preset--color--primary);
}

.ma-category-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ma-shadow-md);
}

.ma-category-card h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--wp--preset--color--text);
}

.ma-category-card__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    background: var(--wp--preset--color--surface);
    color: var(--wp--preset--color--primary);
    font-size: 0.8125rem;
    font-weight: 700;
    border-radius: 100px;
}

/* Alternate border colors for visual variety */
.ma-category-card:nth-child(2) { border-left-color: var(--wp--preset--color--accent, #f59e0b); }
.ma-category-card:nth-child(3) { border-left-color: var(--wp--preset--color--secondary, #3b82f6); }
.ma-category-card:nth-child(4) { border-left-color: #10b981; }
.ma-category-card:nth-child(5) { border-left-color: #8b5cf6; }
.ma-category-card:nth-child(6) { border-left-color: #ec4899; }

/* ==========================================================================
   About Section — centered, elegant
   ========================================================================== */

.ma-about {
    text-align: center;
    max-width: 680px;
    margin: 0 auto;
    padding: 5rem 2rem;
}

.ma-about p {
    font-size: 1.1875rem;
    line-height: 1.8;
    color: var(--ma-text-muted);
    margin-bottom: 2rem;
}

.ma-about__cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: var(--wp--preset--color--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.9375rem;
    border-radius: 100px;
    transition: transform var(--ma-transition), box-shadow var(--ma-transition);
}

.ma-about__cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    color: #fff;
}

/* ==========================================================================
   Newsletter — modern CTA bar
   ========================================================================== */

.ma-newsletter {
    background: linear-gradient(
        135deg,
        var(--wp--preset--color--surface) 0%,
        color-mix(in srgb, var(--wp--preset--color--primary) 5%, #fff) 100%
    );
    padding: 4rem 2rem;
    text-align: center;
    border-radius: var(--ma-radius);
    border: 1px solid var(--ma-border);
}

.ma-newsletter h2 {
    margin-bottom: 0.5rem;
}

.ma-newsletter p {
    color: var(--ma-text-muted);
    margin-bottom: 2rem;
}

.ma-newsletter__form {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 480px;
    margin: 0 auto;
}

.ma-newsletter input[type="email"] {
    flex: 1;
    min-width: 240px;
    padding: 0.875rem 1.25rem;
    border: 2px solid var(--ma-border);
    border-radius: 100px;
    font-size: 0.9375rem;
    font-family: var(--wp--preset--font-family--body);
    transition: border-color var(--ma-transition);
    outline: none;
}

.ma-newsletter input[type="email"]:focus {
    border-color: var(--wp--preset--color--primary);
}

.ma-newsletter button {
    padding: 0.875rem 2rem;
    background: var(--wp--preset--color--primary);
    color: #fff;
    border: none;
    border-radius: 100px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: var(--wp--preset--font-family--body);
    cursor: pointer;
    transition: transform var(--ma-transition), box-shadow var(--ma-transition);
}

.ma-newsletter button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ==========================================================================
   Post Meta
   ========================================================================== */

.ma-post-meta {
    font-size: 0.8125rem;
    color: var(--ma-text-muted);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-weight: 500;
}

.ma-post-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.625rem;
    background: var(--wp--preset--color--surface);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--wp--preset--color--primary);
}

/* ==========================================================================
   Table of Contents — sidebar-style
   ========================================================================== */

.ma-toc {
    border-left: 3px solid var(--wp--preset--color--primary);
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    background: var(--wp--preset--color--surface);
    border-radius: 0 var(--ma-radius-sm) var(--ma-radius-sm) 0;
}

.ma-toc__title {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    color: var(--wp--preset--color--text);
}

.ma-toc ol { list-style-type: decimal; padding-left: 1.25rem; margin: 0; }
.ma-toc li { margin-bottom: 0.375rem; font-size: 0.9375rem; }
.ma-toc a { color: var(--wp--preset--color--primary); }
.ma-toc a:hover { text-decoration: underline; }
.ma-toc__sub { padding-left: 1rem; font-size: 0.875rem; }

/* ==========================================================================
   Utilities
   ========================================================================== */

.ma-reading-time {
    font-size: 0.8125rem;
    color: var(--ma-text-muted);
    font-weight: 500;
}

.ma-breadcrumb {
    font-size: 0.8125rem;
    color: var(--ma-text-muted);
    margin-bottom: 1.5rem;
}

.ma-breadcrumb a { color: var(--ma-text-muted); }
.ma-breadcrumb a:hover { color: var(--wp--preset--color--primary); }

.ma-related-posts {
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 1px solid var(--ma-border);
}

.ma-related-posts__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.ma-cta-block {
    background: linear-gradient(135deg, var(--wp--preset--color--surface), #fff);
    padding: 2.5rem;
    border-radius: var(--ma-radius);
    text-align: center;
    margin: 2.5rem 0;
    border: 1px solid var(--ma-border);
}

.ma-cta-block a {
    color: var(--wp--preset--color--primary);
    font-weight: 700;
}

/* ==========================================================================
   Buttons — global override for WP buttons
   ========================================================================== */

.wp-block-button__link,
.wp-element-button {
    border-radius: 100px !important;
    font-weight: 600 !important;
    transition: transform var(--ma-transition), box-shadow var(--ma-transition) !important;
}

.wp-block-button__link:hover,
.wp-element-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ==========================================================================
   Mobile Navigation
   ========================================================================== */

.ma-nav-toggle-input { display: none; }
.ma-nav-toggle-label { display: none; cursor: pointer; font-size: 1.5rem; }

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

@media (max-width: 767px) {
    .ma-hero { min-height: 60vh; padding: 4rem 1.5rem; }
    .ma-hero h1 { font-size: clamp(2rem, 8vw, 2.75rem); }
    .ma-section { padding: 3rem 1.25rem; }
    .ma-featured-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .ma-featured-grid .ma-featured-card:first-child { grid-column: auto; }
    .ma-featured-grid .ma-featured-card:first-child .ma-featured-card__image { aspect-ratio: 16/9; }
    .ma-categories-grid { grid-template-columns: 1fr; }
    .ma-related-posts__grid { grid-template-columns: 1fr; }
    .ma-toc { position: static; }
    .ma-nav-toggle-label { display: block; }
    .ma-nav-menu { display: none; }
    .ma-nav-toggle-input:checked ~ .ma-nav-menu { display: block; }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .ma-featured-grid { grid-template-columns: repeat(2, 1fr); }
    .ma-related-posts__grid { grid-template-columns: repeat(2, 1fr); }
    .ma-categories-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .ma-toc { position: sticky; top: 2rem; }
    .ma-content-with-sidebar {
        display: grid;
        grid-template-columns: 1fr 300px;
        gap: 2rem;
    }
}

/* ==========================================================================
   Brand Kit Dynamic Sections
   ========================================================================== */

/* Features / Benefits / Testimonials grid */
.ma-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.ma-feature-card {
    background: #fff;
    padding: 2rem;
    border-radius: var(--ma-radius);
    box-shadow: var(--ma-shadow);
    transition: transform var(--ma-transition), box-shadow var(--ma-transition);
}

.ma-feature-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ma-shadow-md);
}

.ma-feature-card h3 {
    margin: 0 0 0.75rem;
    font-size: 1.125rem;
    color: var(--wp--preset--color--text);
}

.ma-feature-card p {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--ma-text-muted);
    line-height: 1.6;
}

/* Steps grid: numbered cards */
.ma-steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    counter-reset: step-counter;
}

.ma-step-card {
    background: #fff;
    padding: 2rem;
    border-radius: var(--ma-radius);
    box-shadow: var(--ma-shadow);
    position: relative;
    padding-top: 3.5rem;
}

.ma-step-card__number {
    position: absolute;
    top: 1.25rem;
    left: 1.5rem;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--wp--preset--color--primary);
    color: #fff;
    font-weight: 800;
    font-size: 0.875rem;
    border-radius: 50%;
}

.ma-step-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1.0625rem;
}

.ma-step-card p {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--ma-text-muted);
    line-height: 1.6;
}

/* Stats grid: big numbers */
.ma-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    text-align: center;
}

.ma-stat-card {
    padding: 2rem 1.5rem;
}

.ma-stat-card__value {
    font-family: var(--wp--preset--font-family--heading);
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    color: var(--wp--preset--color--primary);
    line-height: 1.1;
    margin-bottom: 0.5rem;
}

.ma-stat-card p {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--ma-text-muted);
}

/* FAQ list */
.ma-faq-list {
    max-width: 800px;
}

.ma-faq-item {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--ma-border);
}

.ma-faq-item:first-child {
    padding-top: 0;
}

.ma-faq-item__question {
    margin: 0 0 0.5rem;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--wp--preset--color--text);
}

.ma-faq-item__answer {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--ma-text-muted);
    line-height: 1.7;
}

/* CTA section */
.ma-cta-section {
    text-align: center;
    max-width: 640px;
    margin: 0 auto;
    padding: 2rem 0;
}

@media (max-width: 767px) {
    .ma-features-grid,
    .ma-steps-grid,
    .ma-stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Print
   ========================================================================== */

@media print {
    .ma-toc, .ma-cta-block, .ma-newsletter, .ma-related-posts,
    .ma-nav-toggle-label, .ma-nav-menu, header, footer { display: none; }
    .ma-content-with-sidebar { display: block; }
    body { font-size: 12pt; line-height: 1.5; color: #000; background: #fff; }
    a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
}
