/**
 * PageWize Frontend CSS
 * Shared foundation styles for the section-based page builder.
 * Individual section templates provide their own scoped styles;
 * this file supplies reset, container, spacing, typography,
 * buttons, utilities, responsive breakpoints, animations, and print.
 *
 * Expected wrapper:
 *   <div class="pw-page" data-post-id="123">
 *     <style> CSS custom properties </style>
 *     <section class="pw-section pw-{category} pw-{id}"> ... </section>
 *   </div>
 *
 * CSS custom properties consumed here:
 *   --pw-primary, --pw-secondary, --pw-accent,
 *   --pw-text, --pw-text-light, --pw-bg-alt,
 *   --pw-font-heading, --pw-font-body, --pw-radius
 */

/* ==========================================================================
   1. Reset / Base
   ========================================================================== */

.pw-page,
.pw-page *,
.pw-page *::before,
.pw-page *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.pw-page {
    font-family: var(--pw-font-body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
    font-size: 16px;
    line-height: 1.6;
    color: var(--pw-text, #1a1a1a);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

.pw-page img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   2. Container
   ========================================================================== */

.pw-container {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
}

/* ==========================================================================
   3. Section Spacing
   ========================================================================== */

.pw-section {
    padding-top: 80px;
    padding-bottom: 80px;
    position: relative;
    overflow: hidden;
}

.pw-section:nth-child(even) {
    background-color: var(--pw-bg-alt, #f8f9fa);
}

/* ==========================================================================
   4. Typography
   ========================================================================== */

.pw-page h1,
.pw-page h2,
.pw-page h3,
.pw-page h4,
.pw-page h5,
.pw-page h6 {
    font-family: var(--pw-font-heading, var(--pw-font-body, system-ui, sans-serif));
    color: var(--pw-text, #1a1a1a);
    line-height: 1.25;
    font-weight: 700;
}

.pw-page h1 { font-size: clamp(2rem, 4vw, 3rem); }
.pw-page h2 { font-size: clamp(1.625rem, 3.2vw, 2.25rem); }
.pw-page h3 { font-size: clamp(1.375rem, 2.6vw, 1.75rem); }
.pw-page h4 { font-size: clamp(1.125rem, 2vw, 1.375rem); }
.pw-page h5 { font-size: 1.125rem; }
.pw-page h6 { font-size: 1rem; }

.pw-page p,
.pw-page li,
.pw-page span {
    font-family: var(--pw-font-body, system-ui, sans-serif);
    color: var(--pw-text, #1a1a1a);
}

.pw-page .pw-text-light,
.pw-page .pw-text-light p {
    color: var(--pw-text-light, #555);
}

/* ==========================================================================
   5. Buttons
   ========================================================================== */

.pw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    border: 2px solid transparent;
    border-radius: var(--pw-radius, 6px);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    white-space: nowrap;
}

.pw-btn:focus-visible {
    outline: 2px solid var(--pw-primary, #2271b1);
    outline-offset: 2px;
}

.pw-btn:active {
    transform: scale(0.97);
}

/* Primary */
.pw-btn-primary {
    background-color: var(--pw-primary, #2271b1);
    color: #fff;
    border-color: var(--pw-primary, #2271b1);
}

.pw-btn-primary:hover {
    background-color: var(--pw-secondary, #135e96);
    border-color: var(--pw-secondary, #135e96);
    color: #fff;
}

/* Secondary (outline) */
.pw-btn-secondary {
    background-color: transparent;
    color: var(--pw-primary, #2271b1);
    border-color: var(--pw-primary, #2271b1);
}

.pw-btn-secondary:hover {
    background-color: var(--pw-primary, #2271b1);
    color: #fff;
}

/* Accent */
.pw-btn-accent {
    background-color: var(--pw-accent, #e65100);
    color: #fff;
    border-color: var(--pw-accent, #e65100);
}

.pw-btn-accent:hover {
    filter: brightness(0.9);
    color: #fff;
}

/* ==========================================================================
   6. Links
   ========================================================================== */

.pw-page a {
    color: var(--pw-primary, #2271b1);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
}

.pw-page a:hover {
    color: var(--pw-secondary, #135e96);
}

/* Buttons and nav links should not get underline */
.pw-page a.pw-btn,
.pw-page nav a {
    text-decoration: none;
}

/* ==========================================================================
   7. Image Utilities
   ========================================================================== */

.pw-img-responsive {
    max-width: 100%;
    height: auto;
    display: block;
}

.pw-img-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================================================
   8. Responsive Breakpoints
   ========================================================================== */

/* Tablet - 1024px */
@media (max-width: 1024px) {
    .pw-section {
        padding-top: 64px;
        padding-bottom: 64px;
    }

    .pw-container {
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* Mobile - 768px */
@media (max-width: 768px) {
    .pw-page {
        font-size: 15px;
    }

    .pw-section {
        padding-top: 48px;
        padding-bottom: 48px;
    }

    .pw-btn {
        padding: 10px 22px;
        font-size: 0.9375rem;
        width: 100%;
    }
}

/* Small mobile - 480px */
@media (max-width: 480px) {
    .pw-container {
        padding-left: 16px;
        padding-right: 16px;
    }

    .pw-section {
        padding-top: 40px;
        padding-bottom: 40px;
    }
}

/* ==========================================================================
   9. Animation Helpers
   ========================================================================== */

@keyframes pwFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pw-fade-in {
    animation: pwFadeIn 0.5s ease-out both;
}

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
    .pw-page,
    .pw-page * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   10. Print Styles
   ========================================================================== */

@media print {
    .pw-section {
        padding-top: 24px;
        padding-bottom: 24px;
        break-inside: avoid;
    }

    .pw-container {
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
    }

    .pw-btn,
    .pw-page nav,
    .pw-page video,
    .pw-page iframe,
    .pw-page audio {
        display: none !important;
    }

    .pw-page a {
        color: #000;
        text-decoration: underline;
    }

    .pw-page a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        color: #555;
    }
}
