/* ============================================
   MyPodDesign — Main Stylesheet / Design Tokens
   ============================================ */

/* ---------- Google Fonts ---------- */
/* Fonts are enqueued via wp_enqueue_style() in inc/setup.php for performance. */

/* ---------- Base Reset ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--mypod-font-base, 16px);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Smooth scrolling — disabled for users who prefer reduced motion */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

body {
    font-family: var(--mypod-font-family, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    background-color: var(--mypod-color-bg);
    color: var(--mypod-color-text);
    line-height: 1.5;
    transition: background-color 0.2s ease, color 0.2s ease;
    /* BUG-043 fix: prefer `overflow-x: clip` so we don't create a new
       block-formatting-context that breaks `position: sticky` on descendants
       (e.g. the mobile header). `hidden` is kept as the legacy fallback;
       browsers that understand `clip` will use the second declaration and
       discard the first per CSS cascade rules. */
    overflow-x: hidden;
    overflow-x: clip;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Global Focus State */
:focus-visible {
    outline: 2px solid var(--mypod-color-accent);
    outline-offset: 2px;
}

/* Skip Link */
/* BUG-018 fix: Use the modern clip/clip-path hide technique instead of
   `top: -1000px` so the link does not cause scroll jumps in some browsers
   nor flash visibly during page transitions. */
.mypod-skip-link {
    position: absolute;
    top: var(--mypod-space-md);
    left: var(--mypod-space-md);
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    background: var(--mypod-color-accent);
    color: #fff;
    padding: var(--mypod-space-sm) var(--mypod-space-md);
    z-index: 99999;
    border-radius: var(--mypod-radius-md);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}

.mypod-skip-link:focus {
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    clip-path: none;
}

/* Screen Reader Text — WordPress accessibility pattern */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

.screen-reader-text:focus {
    background-color: var(--mypod-color-bgSecondary, #f1f1f1);
    clip: auto !important;
    clip-path: none;
    color: var(--mypod-color-text, #21759b);
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    height: auto;
    left: 5px;
    line-height: normal;
    padding: 15px 23px 14px;
    text-decoration: none;
    top: 5px;
    width: auto;
    z-index: 100000;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

ul,
ol {
    list-style: none;
}

/* ---------- Layout ---------- */
.mypod-wrapper {
    display: flex;
    min-height: 100vh;
    /* dynamic header height (grows with AI textarea) + category bar */
    padding-top: calc(var(--mypod-header-height, 64px) + var(--mypod-catbar-height, 72px));
    transition: padding-top 0.2s ease;
}

@media (max-width: 768px) {
    .mypod-wrapper {
        /* Reset padding since header & catbar are in document flow (sticky/relative) on mobile */
        padding-top: 0;
    }
}

.mypod-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--mypod-sidebar-expanded);
    padding: var(--mypod-space-lg) var(--mypod-space-xl);
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.mypod-sidebar-collapsed .mypod-main {
    margin-left: var(--mypod-sidebar-collapsed);
}

/* Hidden/Drawer mode (acts like mobile on desktop) */
body.mypod-sidebar-hidden .mypod-main {
    margin-left: 0;
}

/* Push sidebar mode: starts at collapsed sidebar width */
body.push-sidebar-enabled .mypod-main {
    margin-left: var(--mypod-sidebar-collapsed);
    transition: margin-left 0.3s cubic-bezier(0.2, 0, 0, 1);
    will-change: margin-left;
    /* Prevent inner cards/buttons from reflowing during slide */
    overflow-x: hidden;
}

/* Push sidebar expanded: shift to full sidebar width */
body.push-sidebar-enabled.sidebar-expanded .mypod-main {
    margin-left: var(--mypod-sidebar-expanded);
}

/* Push + Hidden (desktop only): starts at 0, expands to full width */
@media (min-width: 1025px) {
    body.push-sidebar-enabled.mypod-sidebar-hidden .mypod-main {
        margin-left: 0;
    }

    body.push-sidebar-enabled.mypod-sidebar-hidden.sidebar-expanded .mypod-main {
        margin-left: var(--mypod-sidebar-expanded);
    }
}

/* Mobile */
@media (max-width: 1024px) {
    .mypod-main {
        margin-left: 0 !important;
        padding: var(--mypod-space-md);
        transition: none !important;
        will-change: auto;
    }
}

/* ---------- Typography Scale ---------- */
.mypod-h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.mypod-h2 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
}

.mypod-h3 {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.35;
}

.mypod-h4 {
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4;
}

.mypod-body {
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
}

.mypod-caption {
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    color: var(--mypod-color-textSecondary);
}

/* ---------- Utility ---------- */
.mypod-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mypod-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ---------- 404 Page ---------- */
.mypod-404 {
    text-align: center;
    padding: 80px 20px;
}

.mypod-404__title {
    font-size: 4rem;
    margin-bottom: 16px;
}

.mypod-404__text {
    color: var(--mypod-color-textSecondary);
    margin-bottom: 24px;
}

/* ---------- Page & Single Post ---------- */
.mypod-page {
    padding: var(--mypod-space-xl) 0;
    max-width: 900px;
}

.mypod-single {
    padding: var(--mypod-space-xl) 0;
    max-width: 800px;
}

.mypod-article__thumb img {
    width: 100%;
    height: auto;
    border-radius: var(--mypod-radius-lg);
    margin-bottom: var(--mypod-space-lg);
}

.mypod-article__footer {
    margin-top: var(--mypod-space-xl);
    padding-top: var(--mypod-space-md);
    border-top: 1px solid var(--mypod-color-border);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--mypod-color-border);
    border-radius: var(--mypod-radius-pill, 9999px);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--mypod-color-textSecondary);
}

/* ---------- Transitions ---------- */
.mypod-fade-in {
    animation: mypodFadeIn 0.3s ease-out;
}

@keyframes mypodFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Overlay ---------- */
.mypod-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    /* Fade-out: matches sidebar close (0.2s ease-in) */
    transition: opacity 0.2s cubic-bezier(0.4, 0, 1, 1);
}

.mypod-overlay.active {
    opacity: 1;
    pointer-events: auto;
    /* Fade-in: matches sidebar open (0.25s ease-out) */
    transition: opacity 0.25s cubic-bezier(0, 0, 0.2, 1);
}

/* ---------- Badge ---------- */
.mypod-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--mypod-radius-pill, 9999px);
    background: var(--mypod-color-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

/* ---------- Buttons ---------- */
.mypod-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--mypod-space-sm);
    padding: var(--mypod-space-sm) var(--mypod-space-md);
    border-radius: var(--mypod-radius-lg);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
}

.mypod-btn-primary {
    background: var(--mypod-color-accent);
    color: #fff;
}

.mypod-btn-primary:hover {
    background: var(--mypod-color-accentHover);
}

.mypod-btn-secondary {
    background: var(--mypod-color-bgTertiary);
    color: var(--mypod-color-text);
}

.mypod-btn-secondary:hover {
    background: var(--mypod-color-border);
}

.mypod-btn-ghost {
    background: transparent;
    color: var(--mypod-color-text);
}

.mypod-btn-ghost:hover {
    background: var(--mypod-color-surfaceHover);
}

/* ---------- Icon sizing ---------- */
.mypod-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.mypod-icon-sm {
    width: 20px;
    height: 20px;
}

.mypod-icon-lg {
    width: 28px;
    height: 28px;
}