/* --- RELATED POSTS INJECTION --- */
.custom-related-posts { padding: 16px 0; }
.custom-related-posts h4 { margin: 0; font-weight: 600; font-size: var(--wp--preset--font-size--medium); }
.custom-related-posts ul { list-style-type: none; background-color: var(--wp--preset--color--base-2); border: 1px solid var(--wp--preset--color--contrast-3); padding: 20px; margin: 16px 0; border-radius: 12px; }
.custom-related-posts ul li { margin-bottom: 8px; padding-bottom: 8px; }
.custom-related-posts ul li:last-child { border: none; margin: 0; padding: 0; }
.custom-related-posts a { text-decoration: none; font-weight: 500; }

/* --- OLD POST ALERT --- */
.old-post-alert {
  background-color: var(--wp--preset--color--info-bg-neutral);
  color: var(--wp--preset--color--contrast);
  padding: 1rem; margin-bottom: 2rem; border-radius: 12px; font-size: var(--wp--preset--font-size--small);
}

/* --- AUTO TABLE OF CONTENTS (TOC) --- */
details.cv-toc {
    background-color: var(--wp--preset--color--base-2);
    border: 1px solid var(--wp--preset--color--contrast-3);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    margin-bottom: 2.5rem;
}

summary.cv-toc-header {
    position: relative;
    padding: 12px 44px 12px 16px;
    cursor: pointer;
    user-select: none;
    outline: none;
    list-style: none;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
}

summary.cv-toc-header::-webkit-details-marker { display: none; }

summary.cv-toc-header:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

summary.cv-toc-header::after {
    content: '';
    position: absolute;
    right: 20px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-right: 1px solid var(--wp--preset--color--contrast-2);
    border-bottom: 1px solid var(--wp--preset--color--contrast-2);
    transform: translateY(calc(-50% - 2px)) rotate(45deg);
    transition: transform 0.3s ease, border-color 0.2s ease;
}

details.cv-toc[open] summary.cv-toc-header::after {
    transform: translateY(calc(-50% + 2px)) rotate(225deg);
    border-color: var(--wp--preset--color--contrast);
}

.cv-toc-content {
    border-top: 1px solid transparent; 
    padding: 0 20px 20px 20px;
}

details.cv-toc[open] .cv-toc-content {
    border-top-color: var(--wp--preset--color--contrast-3);
    padding-top: 16px;
}

.cv-toc-title {
    margin: 0;
    font-weight: 600;
    font-size: var(--wp--preset--font-size--medium);
    color: var(--wp--preset--color--contrast);
}

.cv-toc ol {
    list-style-type: decimal !important;
    margin: 0 0 0 1.25rem !important;
    padding: 0 !important;
}

.cv-toc li {
    margin-bottom: 8px;
    line-height: 1.5;
    padding-left: 4px;
}

.cv-toc a {
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--wp--preset--color--contrast);
    transition: color 0.2s ease;
}

.cv-toc a:hover {
    color: var(--wp--preset--color--accent);
    text-decoration: underline;
}


/* --- HERO CAROUSEL SLIDER --- */
.cv-hero-slider-instance {
    width: 100%;
    margin: 0 0 2rem 0;
    font-family: inherit;
    outline: none !important;
    user-select: none;
    -webkit-user-select: none;
}

.cv-carousel-container {
    position: relative;
    width: 100%;
}

.cv-main-carousel {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 4/3;
    background: var(--wp--preset--color--base-2, #1a1a1a);
    transition: box-shadow 0.3s ease;
}

.cv-carousel-container:hover .cv-main-carousel {
    box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}

@media (min-width: 992px) {
    .cv-main-carousel { max-height: 760px; aspect-ratio: 16/9; }
}

.cv-slide-track {
    position: absolute;
    inset: 0;
    display: flex;
    transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: transform;
}

.cv-slide-main {
    flex: 0 0 100%;
    min-width: 100%;
    position: relative;
    overflow: hidden;
    text-decoration: none !important;
    display: block;
}

.cv-slide-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    display: block;
    pointer-events: none;
}

.cv-slide-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.3) 30%, transparent 60%);
    pointer-events: none;
}

.cv-slider-progress {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 20;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    overflow: hidden;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.cv-progress-pie {
    fill: none;
    stroke: rgba(255, 255, 255, 0.75);
    stroke-width: 14; 
    stroke-dasharray: 43.982;
    stroke-dashoffset: 43.982;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.cv-slide-content {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 3;
    padding: 32px;
    color: #fff !important;
}

.cv-slide-badge {
    display: inline-block;
    background: rgba(255,255,255,0.25);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    padding: 4px 10px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.5px;
    text-transform: uppercase; margin-bottom: 12px; color: #fff;
}

.cv-slide-title {
    font-size: 1.8rem; font-weight: 700; margin: 0 0 10px 0;
    line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden; color: #fff;
    max-width: 75%;
}

.cv-slide-desc {
    font-size: 1rem; opacity: 0.9; margin: 0;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; color: #eee; 
    max-width: 65%;
}

.cv-slide-readmore { font-weight: 700; color: #fff; margin-left: 4px; }

.cv-slider-arrow {
    position: absolute; top: 50%; z-index: 10;
    background: rgba(255,255,255,0.95); color: #111; border: none;
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.15); padding: 0;
    transition: transform 0.2s ease, background 0.2s ease, opacity 0.3s ease;
}

.cv-slider-prev { left: -16px; transform: translateY(-50%) translateX(10px); }
.cv-slider-next { right: -16px; transform: translateY(-50%) translateX(-10px); }

@media (hover: hover) and (pointer: fine) {
    .cv-slider-arrow { opacity: 0; pointer-events: none; }
    .cv-carousel-container:hover .cv-slider-arrow, .cv-slider-arrow:focus-visible { opacity: 1; pointer-events: auto; transform: translateY(-50%) translateX(0); }
    .cv-slider-arrow:hover { background: #fff; transform: translateY(-50%) scale(1.1) !important; }
}

@media (hover: none) and (pointer: coarse) {
    .cv-slider-arrow { 
        opacity: 0; 
        pointer-events: none; 
        width: 32px; height: 32px; 
    }
    .cv-slider-prev { transform: translateY(-50%) translateX(-5px); left: 8px; }
    .cv-slider-next { transform: translateY(-50%) translateX(5px); right: 8px; }

    .cv-carousel-container.show-mobile-arrows .cv-slider-arrow {
        opacity: 0.9;
        pointer-events: auto;
        transform: translateY(-50%) translateX(0);
    }
}

.cv-slider-dots { display: flex; justify-content: center; gap: 6px; margin-top: 14px; }
.cv-slider-dot {
    width: 6px; height: 6px; border-radius: 4px;
    background: var(--wp--preset--color--contrast-3, #ccc);
    cursor: pointer; border: none; padding: 0;
    transition: all 0.3s ease;
}
.cv-slider-dot.active { 
    width: 16px;
    background: var(--wp--preset--color--contrast, #111);
}
html[data-theme="dark"] .cv-slider-dot.active { background: var(--wp--preset--color--accent, #fff); }

@media (max-width: 768px) {
    .cv-slide-title, .cv-slide-desc { max-width: 100%; }
    .cv-slide-desc { display: none !important; }
    .cv-slide-content { padding: 20px; }
    .cv-slide-badge { margin-bottom: 8px; font-size: 0.65rem; }
    .cv-slide-title { font-size: 1.3rem; margin-bottom: 0; }
    .cv-slider-progress { width: 24px; height: 24px; top: 12px; left: 12px; }
}

@media (min-width: 769px) {
  .cv-slide-desc {
    max-height: 0;
    opacity: 0 !important;
    margin-top: 0 !important;
    transform: translateY(10px);
    transition: max-height 0.4s ease, opacity 0.4s ease, transform 0.4s ease, margin-top 0.4s ease;
  }
  
  .cv-carousel-container:hover .cv-slide-desc,
  .cv-carousel-container:focus-within .cv-slide-desc {
    max-height: 80px;
    opacity: 0.9 !important;
    transform: translateY(0);
    margin-top: 8px !important;
  }
}


/* --- EXPANDABLE PAGE MODAL SYSTEM --- */
.custom-modal {
    margin: auto;
    inset: 0;
    position: fixed;
    border: 1px solid var(--wp--preset--color--contrast-3);
    border-radius: 12px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.3);
    padding: 0;
    width: 90%;
    max-width: 800px;
    height: 80vh;
    background: var(--wp--preset--color--base);
    overflow: hidden;
    overscroll-behavior: contain;
    opacity: 0;
    transform: scale(1.1);
}

.custom-modal.is-sidebar {
    inset: 0 auto 0 0;
    width: 340px;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--wp--preset--color--contrast-3);
    box-shadow: none;
    transform: translateX(-100%);
}

.custom-modal[open]:not(.is-sidebar) {
    opacity: 1;
    transform: scale(1);
    animation: zoomOutEntry 0.2s cubic-bezier(0.2, 0, 0.2, 1) forwards;
}

.custom-modal.modal-closing:not(.is-sidebar) {
    animation: zoomInExit 0.2s cubic-bezier(0.2, 0, 0.2, 1) forwards;
}

.custom-modal.is-sidebar[open] {
    opacity: 1;
    animation: slideInLeft 0.3s cubic-bezier(0.2, 0, 0, 1) forwards;
}

.custom-modal.is-sidebar.modal-closing {
    animation: slideOutLeft 0.3s cubic-bezier(0.2, 0, 0, 1) forwards;
}

.custom-modal.is-sidebar::backdrop,
.custom-modal.is-sidebar[open]::backdrop,
.custom-modal.is-sidebar.modal-closing::backdrop {
    background: none;
}

.custom-modal::backdrop {
    background: rgba(0, 0, 0, 0);
    transition: background 0.2s ease;
}

.custom-modal[open]::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

.custom-modal.modal-closing::backdrop {
    background: rgba(0, 0, 0, 0) !important;
}

@media (max-width: 768px) {
    .custom-modal.mobile-fullscreen {
        width: 100%;
        height: 100dvh;
        max-width: none;
        max-height: none;
        border: none;
        border-radius: 0;
        inset: 0;
        transform: scale(1.1);
    }

    .custom-modal.is-sidebar.mobile-fullscreen {
        width: 100%;
        transform: translateY(100%);
        border: none;
    }

    .custom-modal.is-sidebar[open] {
        animation: appSlideUpIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    }

    .custom-modal.is-sidebar.modal-closing {
        animation: appSlideDownOut 0.25s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    }
}

@keyframes zoomOutEntry {
    from { opacity: 0; transform: scale(1.08); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes zoomInExit {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(1.08); }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@keyframes slideOutLeft {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}

@keyframes appSlideUpIn {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes appSlideDownOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(100%); }
}

.modal-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#close-modal {
    position: absolute;
    top: 0.75rem;
    left: 0.9rem;
    z-index: 100;
    background: none;
    color: var(--wp--preset--color--contrast);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
    padding: 0;
}

#close-modal:hover {
    background: var(--wp--preset--color--base-2);
}

#close-modal svg {
    display: block;
}

#modal-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 50;
    position: relative;
}

.spinner-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 60;
    background: var(--wp--preset--color--base);
}

.loading-text {
    margin-top: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--wp--preset--color--contrast);
    opacity: 0.7;
}

.material-spinner {
    width: 50px;
    height: 50px;
    animation: rotate 2s linear infinite;
}

.material-spinner .path {
    stroke: var(--wp--preset--color--accent, #0073aa);
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}
