/* ============================================================
   cv.css — หน้า CV บุคลากรรายบุคคล (person.php)
   ใช้ร่วมกับ style.css (theme variables ต้องโหลดก่อน)
   ============================================================ */

.cv-wrap {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.25rem 3rem;
}

.cv-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    color: var(--theme, #64748b);
    text-decoration: none;
    margin-bottom: 1.25rem;
    opacity: 0.85;
    transition: opacity 0.18s;
}
.cv-back-link:hover { opacity: 1; }
.cv-back-link svg {
    width: 16px; height: 16px;
    stroke: currentColor; fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.cv-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.cv-sidebar {
    position: sticky;
    top: 5rem;
    background: linear-gradient(160deg,
        var(--theme-dark, #475569) 0%,
        var(--theme, #64748b) 100%);
    border-radius: 1.25rem;
    padding: 2rem 1.5rem 1.75rem;
    color: #fff;
    box-shadow: 0 8px 32px var(--theme-glow, rgba(100,116,139,0.35));
    overflow: hidden;
}
.cv-sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--theme-soft, rgba(100,116,139,0.15));
    pointer-events: none;
}

.cv-sidebar-photo {
    width: 140px; height: 140px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.55);
    object-fit: cover;
    display: block;
    margin: 0 auto 1.25rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.cv-sidebar-name {
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.cv-sidebar-role {
    font-size: 0.8rem;
    text-align: center;
    opacity: 0.85;
    line-height: 1.5;
    margin-bottom: 0.2rem;
}
.cv-sidebar-role + .cv-sidebar-role {
    opacity: 0.72;
    font-size: 0.78rem;
}

.cv-sidebar-dept {
    font-size: 0.78rem;
    text-align: center;
    opacity: 0.7;
    margin-top: 0.4rem;
    padding: 0.3rem 0.75rem;
    background: rgba(255,255,255,0.12);
    border-radius: 2rem;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
}

.cv-sidebar-divider {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.22);
    margin: 1.25rem 0 1rem;
}

.cv-contact-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.6;
    margin-bottom: 0.6rem;
}

.cv-contact-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
    opacity: 0.88;
}
.cv-contact-item svg {
    width: 15px; height: 15px;
    flex-shrink: 0;
    margin-top: 0.15rem;
    stroke: currentColor; fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.cv-contact-item a {
    color: #fff;
    text-decoration: none;
    word-break: break-all;
}
.cv-contact-item a:hover { text-decoration: underline; }

/* ── Content area ─────────────────────────────────────────── */
.cv-content {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.cv-section {
    background: rgba(255,255,255,0.72);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--theme-border-40, rgba(100,116,139,0.25));
    border-radius: 1rem;
    padding: 1.5rem 1.75rem;
    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
}

.cv-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--theme, #64748b);
    border-left: 3px solid var(--theme, #64748b);
    padding-left: 0.65rem;
    margin: 0 0 1rem;
    line-height: 1.4;
}

.cv-edu-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 0.75rem;
}
.cv-edu-item {
    display: grid;
    grid-template-columns: 4.5rem 1fr;
    gap: 0 0.75rem;
    align-items: start;
}
.cv-edu-year {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--theme, #64748b);
    background: var(--theme-soft, rgba(100,116,139,0.1));
    border-radius: 0.4rem;
    padding: 0.15rem 0.4rem;
    text-align: center;
    line-height: 1.6;
    white-space: nowrap;
}
.cv-edu-degree {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.4;
}
.cv-edu-detail {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.1rem;
    line-height: 1.4;
}

.cv-subjects-level { margin-bottom: 0.85rem; }
.cv-subjects-level:last-child { margin-bottom: 0; }
.cv-level-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.65rem;
    border-radius: 1rem;
    background: var(--theme-soft, rgba(100,116,139,0.12));
    color: var(--theme-dark, #475569);
    margin-bottom: 0.45rem;
}
.cv-subject-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 0.3rem;
}
.cv-subject-item {
    font-size: 0.84rem;
    color: #334155;
    padding-left: 0.85rem;
    position: relative;
    line-height: 1.5;
}
.cv-subject-item::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--theme, #64748b);
    font-weight: 700;
}

.cv-bullet-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 0.4rem;
}
.cv-bullet-item {
    font-size: 0.875rem;
    color: #334155;
    padding-left: 1.1rem;
    position: relative;
    line-height: 1.55;
}
.cv-bullet-item::before {
    content: '';
    position: absolute;
    left: 0.1rem;
    top: 0.6em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--theme, #64748b);
    opacity: 0.7;
}

/* ── Research / Publications (full-width below) ──────────── */
.cv-research-wrap {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.cv-pub-section {
    background: rgba(255,255,255,0.72);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--theme-border-40, rgba(100,116,139,0.25));
    border-radius: 1rem;
    padding: 1.5rem 1.75rem;
    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
}

.cv-pub-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--theme, #64748b);
    border-left: 3px solid var(--theme, #64748b);
    padding-left: 0.65rem;
    margin: 0 0 1rem;
}

.cv-pub-sublabel {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--theme-dark, #475569);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0.85rem 0 0.45rem;
    border-bottom: 1px dashed var(--theme-border-40, rgba(100,116,139,0.3));
    padding-bottom: 0.3rem;
}
.cv-pub-sublabel:first-child { margin-top: 0; }

.cv-pub-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 0.6rem;
}
.cv-pub-item {
    font-size: 0.84rem;
    color: #334155;
    line-height: 1.6;
    padding-left: 1.25rem;
    position: relative;
    text-indent: -1.25rem;
    margin-left: 1.25rem;
}

@media (max-width: 860px) {
    .cv-layout { grid-template-columns: 1fr; }
    .cv-sidebar {
        position: static;
        display: grid;
        grid-template-columns: 160px 1fr;
        gap: 0 1.25rem;
        align-items: start;
    }
    .cv-sidebar-photo { width: 120px; height: 120px; margin: 0 auto 0.75rem; }
    .cv-sidebar-name, .cv-sidebar-role, .cv-sidebar-dept { text-align: left; }
}
@media (max-width: 560px) {
    .cv-sidebar { grid-template-columns: 1fr; }
    .cv-sidebar-photo { width: 100px; height: 100px; }
    .cv-edu-item { grid-template-columns: 1fr; }
    .cv-edu-year { width: fit-content; margin-bottom: 0.25rem; }
}

/* ============================================================
   Motion & Animation — CV page
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {

    @keyframes cvSlideInLeft {
        from { opacity: 0; transform: translate3d(-24px, 0, 0); }
        to   { opacity: 1; transform: translate3d(0, 0, 0); }
    }
    @keyframes cvSlideInRight {
        from { opacity: 0; transform: translate3d(20px, 0, 0); }
        to   { opacity: 1; transform: translate3d(0, 0, 0); }
    }
    @keyframes cvFadeUp {
        from { opacity: 0; transform: translate3d(0, 16px, 0); }
        to   { opacity: 1; transform: translate3d(0, 0, 0); }
    }
    @keyframes cvPhotoIn {
        from { opacity: 0; transform: scale(0.7) rotate(-4deg); }
        to   { opacity: 1; transform: scale(1) rotate(0); }
    }
    @keyframes cvPopIn {
        0%   { opacity: 0; transform: scale(0.6); }
        70%  { opacity: 1; transform: scale(1.06); }
        100% { transform: scale(1); }
    }
    @keyframes cvBulletGrow {
        from { opacity: 0; width: 0; }
        to   { opacity: 0.7; width: 6px; }
    }

    /* ── Page entrance ─────────────────────────────────── */
    .cv-back-link { animation: cvSlideInLeft 0.45s ease-out 0.05s both; }

    .cv-sidebar {
        animation: cvSlideInLeft 0.7s cubic-bezier(0.2, 0.85, 0.2, 1) 0.10s both;
    }
    .cv-sidebar-photo {
        animation: cvPhotoIn 0.85s cubic-bezier(0.2, 1.4, 0.4, 1) 0.30s both;
    }
    .cv-sidebar-name        { animation: cvFadeUp 0.5s ease-out 0.45s both; }
    .cv-sidebar-role        { animation: cvFadeUp 0.5s ease-out 0.55s both; }
    .cv-sidebar-role + .cv-sidebar-role { animation-delay: 0.62s; }
    .cv-sidebar-dept        { animation: cvFadeUp 0.5s ease-out 0.70s both; }
    .cv-sidebar-divider     { animation: cvFadeUp 0.4s ease-out 0.78s both; }
    .cv-contact-label       { animation: cvFadeUp 0.4s ease-out 0.82s both; }
    .cv-contact-item        { animation: cvFadeUp 0.5s ease-out both; }
    .cv-contact-item:nth-of-type(1) { animation-delay: 0.86s; }
    .cv-contact-item:nth-of-type(2) { animation-delay: 0.94s; }
    .cv-contact-item:nth-of-type(3) { animation-delay: 1.02s; }

    /* ── Content sections stagger from right ─────────── */
    .cv-content > .cv-section {
        animation: cvSlideInRight 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    }
    .cv-content > .cv-section:nth-child(1) { animation-delay: 0.20s; }
    .cv-content > .cv-section:nth-child(2) { animation-delay: 0.32s; }
    .cv-content > .cv-section:nth-child(3) { animation-delay: 0.44s; }
    .cv-content > .cv-section:nth-child(4) { animation-delay: 0.56s; }
    .cv-content > .cv-section:nth-child(5) { animation-delay: 0.68s; }

    /* Section title underline grow */
    .cv-section-title {
        position: relative;
        overflow: hidden;
    }
    .cv-section-title::after {
        content: '';
        position: absolute;
        left: 0;
        bottom: -3px;
        width: 100%;
        height: 2px;
        background: linear-gradient(to right, var(--theme, #64748b), transparent);
        transform: scaleX(0);
        transform-origin: left;
        transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    }
    .cv-section:hover .cv-section-title::after { transform: scaleX(1); }

    /* Section hover lift */
    .cv-section,
    .cv-pub-section {
        transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
                    box-shadow 0.3s ease,
                    border-color 0.3s ease;
    }
    .cv-section:hover,
    .cv-pub-section:hover {
        transform: translateY(-2px);
        border-color: var(--theme-border-50, rgba(100,116,139,0.45));
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
    }

    /* Education items stagger */
    .cv-edu-list .cv-edu-item {
        animation: cvFadeUp 0.45s ease-out both;
    }
    .cv-edu-list .cv-edu-item:nth-child(1) { animation-delay: 0.40s; }
    .cv-edu-list .cv-edu-item:nth-child(2) { animation-delay: 0.48s; }
    .cv-edu-list .cv-edu-item:nth-child(3) { animation-delay: 0.56s; }
    .cv-edu-list .cv-edu-item:nth-child(4) { animation-delay: 0.64s; }
    .cv-edu-list .cv-edu-item:nth-child(n+5) { animation-delay: 0.72s; }

    .cv-edu-year {
        animation: cvPopIn 0.5s cubic-bezier(0.4, 1.6, 0.5, 1) both;
        animation-delay: inherit;
        transition: transform 0.2s ease;
    }
    .cv-edu-item:hover .cv-edu-year {
        transform: scale(1.08);
    }

    /* Subject badges + bullet animations */
    .cv-level-badge {
        animation: cvPopIn 0.45s cubic-bezier(0.4, 1.4, 0.5, 1) 0.55s both;
        transition: transform 0.2s ease;
    }
    .cv-subjects-level:hover .cv-level-badge {
        transform: translateX(3px);
    }

    .cv-subject-item,
    .cv-bullet-item {
        transition: transform 0.2s ease, color 0.2s ease;
    }
    .cv-subject-item:hover,
    .cv-bullet-item:hover {
        transform: translateX(4px);
        color: var(--theme-dark, #475569);
    }
    .cv-bullet-item::before {
        transition: transform 0.25s ease, opacity 0.25s ease;
    }
    .cv-bullet-item:hover::before {
        transform: scale(1.6);
        opacity: 1;
    }
    .cv-subject-item::before {
        transition: transform 0.2s ease;
    }
    .cv-subject-item:hover::before {
        transform: translateX(2px);
    }

    /* Publications below: fade-up sequence */
    .cv-research-wrap > .cv-pub-section {
        animation: cvFadeUp 0.65s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    }
    .cv-research-wrap > .cv-pub-section:nth-child(1) { animation-delay: 0.55s; }
    .cv-research-wrap > .cv-pub-section:nth-child(2) { animation-delay: 0.70s; }
    .cv-research-wrap > .cv-pub-section:nth-child(3) { animation-delay: 0.85s; }
    .cv-research-wrap > .cv-pub-section:nth-child(4) { animation-delay: 1.00s; }

    /* Pub item left-border grow on hover */
    .cv-pub-item {
        transition: padding-left 0.25s ease, color 0.25s ease;
    }
    .cv-pub-item:hover {
        color: #1e293b;
    }

    /* Smooth scroll for back-link */
    html { scroll-behavior: smooth; }

    /* Sidebar photo subtle hover */
    .cv-sidebar-photo {
        transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
                    box-shadow 0.4s ease;
    }
    .cv-sidebar-photo:hover {
        transform: scale(1.05) rotate(-2deg);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    }

    /* Email/phone icons hover */
    .cv-contact-item svg {
        transition: transform 0.25s ease;
    }
    .cv-contact-item:hover svg {
        transform: translateX(2px) scale(1.1);
    }

    /* Back link arrow slide */
    .cv-back-link svg {
        transition: transform 0.25s ease;
    }
    .cv-back-link:hover svg {
        transform: translateX(-3px);
    }
}

