/**
 * Puns R Fun - Main Stylesheet
 *
 * This stylesheet uses CSS custom properties (variables) defined in site.php
 * for easy theming. To create a new theme, just change the config values.
 *
 * Structure:
 * 1. Reset & Base
 * 2. Typography
 * 3. Layout & Container
 * 4. Header & Navigation
 * 5. Cards & Content
 * 6. Single Post
 * 7. Affiliate Section
 * 8. Sidebar
 * 9. Footer
 * 10. Forms
 * 11. Buttons
 * 12. Utilities
 * 13. Animations
 * 14. Responsive
 */

/* ============================================
   1. RESET & BASE
   ============================================ */

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

* {
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-background);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

input, button, textarea, select {
    font: inherit;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-primary-dark);
}

ul, ol {
    list-style: none;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    padding: 8px 16px;
    z-index: 1000;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
}


/* ============================================
   2. TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 400; /* Fredoka One is already bold */
    line-height: 1.2;
    color: var(--color-text);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
    margin-bottom: 1rem;
}

p:last-child {
    margin-bottom: 0;
}

.text-muted {
    color: var(--color-text-light);
}

.text-center {
    text-align: center;
}

/* Fun gradient text for headings */
.gradient-text {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}


/* ============================================
   3. LAYOUT & CONTAINER
   ============================================ */

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1rem;
}

.container-narrow {
    max-width: var(--content-width);
}

.site-main {
    flex: 1;
    padding: 2rem 0;
}

/* Grid layouts */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Content with sidebar */
.content-sidebar {
    display: grid;
    grid-template-columns: 1fr var(--sidebar-width);
    gap: 2rem;
    align-items: start;
}


/* ============================================
   4. HEADER & NAVIGATION
   ============================================ */

.site-header {
    background: var(--color-surface);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    gap: 1rem;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.site-logo img {
    height: 48px;
    width: auto;
}

.site-name {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    color: var(--color-primary);
    transition: transform 0.2s ease;
}

.site-logo:hover .site-name {
    transform: scale(1.05);
}

.site-tagline {
    color: var(--color-text-light);
    font-size: 0.9rem;
    display: none; /* Show on larger screens */
}

.main-nav {
    display: flex;
}

.nav-list {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    color: var(--color-text);
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: var(--color-primary);
    color: var(--color-text-inverse);
    transform: translateY(-2px);
}

.nav-icon {
    font-size: 1.1rem;
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.hamburger {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-text);
    position: relative;
    transition: background 0.2s ease;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--color-text);
    left: 0;
    transition: transform 0.2s ease;
}

.hamburger::before { top: -7px; }
.hamburger::after { bottom: -7px; }

/* Mobile nav open state */
.mobile-menu-toggle[aria-expanded="true"] .hamburger {
    background: transparent;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger::before {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger::after {
    transform: rotate(-45deg) translate(5px, -5px);
}


/* ============================================
   5. CARDS & CONTENT
   ============================================ */

.card {
    background: var(--color-surface);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.card-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.card-title a {
    color: var(--color-text);
}

.card-title a:hover {
    color: var(--color-primary);
}

.card-excerpt {
    color: var(--color-text-light);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.card-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--color-accent);
    color: var(--color-text);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Pun-specific card styling */
.pun-card {
    text-align: center;
    padding: 2rem 1.5rem;
}

.pun-card .card-body {
    padding: 0;
}

.pun-emoji {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.pun-content {
    font-size: 1.25rem;
    line-height: 1.5;
    color: var(--color-text);
    margin-bottom: 1rem;
}

.pun-punchline {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--color-primary);
    margin-top: 0.5rem;
}

/* Posts grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}


/* ============================================
   6. SINGLE POST
   ============================================ */

.single-post {
    max-width: var(--content-width);
    margin: 0 auto;
}

.post-header {
    text-align: center;
    margin-bottom: 2rem;
}

.post-category {
    display: inline-block;
    padding: 0.35rem 1rem;
    background: var(--color-accent);
    color: var(--color-text);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.post-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.post-meta {
    color: var(--color-text-light);
    font-size: 0.9rem;
}

.post-featured-image {
    width: 100%;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
}

.post-content {
    background: var(--color-surface);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    box-shadow: var(--card-shadow);
}

/* Pun-specific single view */
.pun-single {
    text-align: center;
    padding: 3rem 2rem;
}

.pun-single .pun-emoji {
    font-size: 5rem;
    margin-bottom: 1.5rem;
    animation: bounce 2s ease-in-out infinite;
}

.pun-single .pun-content {
    font-size: 1.75rem;
    max-width: 600px;
    margin: 0 auto 1.5rem;
}

.pun-single .pun-punchline {
    font-size: 2.25rem;
}

/* Share buttons */
.share-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
    text-align: center;
}

.share-title {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--color-text-light);
}

.share-buttons {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.share-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.25rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.share-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.share-facebook { background: #1877F2; color: white; }
.share-twitter { background: #1DA1F2; color: white; }
.share-pinterest { background: #E60023; color: white; }
.share-copy { background: var(--color-text-light); color: white; }


/* ============================================
   7. AFFILIATE SECTION
   ============================================ */

.affiliate-section {
    margin-top: 2.5rem;
    padding: 2rem;
    background: linear-gradient(135deg, #FFF9E6 0%, #FFF0F0 100%);
    border-radius: var(--border-radius);
    border: 2px dashed var(--color-accent);
}

.affiliate-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    text-align: center;
}

.affiliate-products {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.affiliate-product {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--color-surface);
    border-radius: calc(var(--border-radius) / 2);
    text-align: center;
    transition: transform 0.2s ease;
}

.affiliate-product:hover {
    transform: translateY(-4px);
}

.affiliate-product-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin-bottom: 0.75rem;
}

.affiliate-product-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.affiliate-product-price {
    color: var(--color-primary);
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.affiliate-cta {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s ease;
}

.affiliate-cta:hover {
    background: var(--color-primary-dark);
    color: var(--color-text-inverse);
}

.affiliate-disclosure-inline {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--color-text-light);
    text-align: center;
}


/* ============================================
   8. SIDEBAR
   ============================================ */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-widget {
    background: var(--color-surface);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
}

.widget-title {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--color-accent);
}

/* Categories widget */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-link {
    color: var(--color-text);
    transition: color 0.2s ease, padding-left 0.2s ease;
}

.category-link:hover {
    color: var(--color-primary);
    padding-left: 0.5rem;
}

.category-count {
    background: var(--color-background);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--color-text-light);
}


/* ============================================
   9. FOOTER
   ============================================ */

.site-footer {
    background: var(--color-text);
    color: var(--color-text-inverse);
    padding: 3rem 0 2rem;
    margin-top: auto;
}

.site-footer a {
    color: var(--color-accent);
}

.site-footer a:hover {
    color: var(--color-secondary);
}

.newsletter-section {
    text-align: center;
    max-width: 500px;
    margin: 0 auto 2rem;
}

.newsletter-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.newsletter-description {
    margin-bottom: 1rem;
    opacity: 0.9;
}

.newsletter-form .form-group {
    display: flex;
    gap: 0.5rem;
}

.newsletter-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
}

.newsletter-button {
    padding: 0.75rem 1.5rem;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.newsletter-button:hover {
    background: var(--color-primary-dark);
}

.social-section {
    text-align: center;
    margin-bottom: 2rem;
}

.social-title {
    margin-bottom: 1rem;
    font-size: 1rem;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    font-size: 1.25rem;
    transition: background 0.2s ease, transform 0.2s ease;
}

.social-link:hover {
    background: var(--color-primary);
    transform: scale(1.1);
}

.footer-nav {
    text-align: center;
    margin-bottom: 1.5rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.copyright {
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.affiliate-disclosure {
    text-align: center;
    opacity: 0.6;
    max-width: 600px;
    margin: 0 auto;
}


/* ============================================
   10. FORMS
   ============================================ */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: calc(var(--border-radius) / 2);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.2);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}


/* ============================================
   11. BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text-inverse);
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    color: var(--color-text-inverse);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--color-secondary);
    color: var(--color-text-inverse);
}

.btn-secondary:hover {
    background: var(--color-secondary-dark);
    color: var(--color-text-inverse);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
}

.btn-outline:hover {
    background: var(--color-primary);
    color: var(--color-text-inverse);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Fun random button */
.btn-random {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: var(--color-text-inverse);
    animation: gradient-shift 3s ease infinite;
    background-size: 200% 200%;
}


/* ============================================
   12. UTILITIES
   ============================================ */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.py-2 { padding-top: 1rem; padding-bottom: 1rem; }
.py-4 { padding-top: 2rem; padding-bottom: 2rem; }

/* Section styling */
.section-header {
    text-align: center;
    margin-bottom: 2rem;
}

.section-title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.section-subtitle {
    color: var(--color-text-light);
    font-size: 1.1rem;
}

/* Hero section */
.hero {
    text-align: center;
    padding: 3rem 1rem;
    background: linear-gradient(135deg, var(--color-background) 0%, #FFF0E6 100%);
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
}

.hero-title {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--color-text-light);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

/* Loading spinner */
.loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 0.75rem;
    background: var(--color-surface);
    border-radius: calc(var(--border-radius) / 2);
    color: var(--color-text);
    font-weight: 600;
    transition: all 0.2s ease;
}

.pagination-link:hover,
.pagination-link.active {
    background: var(--color-primary);
    color: var(--color-text-inverse);
}


/* ============================================
   13. ANIMATIONS
   ============================================ */

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fade-in 0.3s ease forwards;
}


/* ============================================
   14. RESPONSIVE
   ============================================ */

/* Large tablets and small desktops */
@media (max-width: 1024px) {
    .content-sidebar {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .site-tagline {
        display: none;
    }
}

/* Tablets */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }

    .hero-title {
        font-size: 2.25rem;
    }

    .grid-3, .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .sidebar {
        grid-template-columns: 1fr;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .main-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: var(--color-surface);
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
        padding: 5rem 1.5rem 2rem;
        transition: right 0.3s ease;
        z-index: 99;
    }

    .main-nav.is-open {
        right: 0;
    }

    .nav-list {
        flex-direction: column;
        gap: 0.25rem;
    }

    .nav-link {
        padding: 1rem;
        font-size: 1.1rem;
    }

    .mobile-nav-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 98;
    }

    .mobile-nav-overlay.is-visible {
        opacity: 1;
        visibility: visible;
    }

    .newsletter-form .form-group {
        flex-direction: column;
    }

    .footer-links {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }

    h1 { font-size: 1.75rem; }

    .hero {
        padding: 2rem 1rem;
    }

    .hero-title {
        font-size: 1.75rem;
    }

    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }

    .post-content {
        padding: 1.5rem;
    }

    .pun-single .pun-emoji {
        font-size: 3.5rem;
    }

    .pun-single .pun-content {
        font-size: 1.35rem;
    }

    .pun-single .pun-punchline {
        font-size: 1.75rem;
    }

    .affiliate-products {
        grid-template-columns: 1fr;
    }

    .share-buttons {
        flex-wrap: wrap;
    }
}

/* Print styles */
@media print {
    .site-header,
    .site-footer,
    .share-section,
    .affiliate-section,
    .sidebar {
        display: none;
    }

    .site-main {
        padding: 0;
    }

    .post-content {
        box-shadow: none;
        padding: 0;
    }
}
