* { box-sizing: border-box; }

:root {
    --bg: #ffffff;
    --text: #222222;
    --text-muted: #555555;
    --text-faint: #999999;
    --link: #1772d0;
    --link-hover: #f09228;
    --rule: #e5e5e5;
    --rule-soft: #f0f0f0;
    --featured: #fff7dc;
    --award: #c0392b;
    --thumb-bg: #f4f4f4;
    --logo-bg: transparent;
}

/* 테마는 index.html <head>의 스크립트가 <html data-theme>로 지정 (저장된 선택 > 시스템 설정) */
:root[data-theme="dark"] {
    --bg: #16181c;
    --text: #e4e4e4;
    --text-muted: #a8a8a8;
    --text-faint: #777777;
    --link: #5aa9f0;
    --link-hover: #f5a54a;
    --rule: #2e3137;
    --rule-soft: #25282d;
    --featured: #2c2717;
    --award: #ff7b6b;
    --thumb-bg: #22252a;
    --logo-bg: #f4f4f4;
    color-scheme: dark;
}

body {
    font-family: 'Lato', Verdana, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    font-size: clamp(15px, 0.35vw + 10px, 17px);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--link); text-decoration: none; }
a:hover, a:focus { color: var(--link-hover); }

.page {
    max-width: clamp(760px, 75vw, 1200px);
    margin: 0 auto;
    padding: 48px 20px 60px;
}

/* ---------- Profile header ---------- */
.profile {
    display: flex;
    flex-wrap: wrap-reverse;
    align-items: stretch;
    justify-content: center;
    gap: 28px;
    text-align: center;
}

.profile-photo { flex: 0 0 auto; }

.profile-photo img {
    width: clamp(150px, 13vw, 200px);
    height: auto;
    border-radius: 12px;
    display: block;
}

.profile-text { flex: 1 1 380px; }

.profile-text h1 {
    font-size: 2.2em;
    margin: 0 0 6px;
}

.position {
    margin: 0 0 14px;
    color: var(--text-muted);
}

.profile-links {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 18px;
}

.profile-links a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.link-icon { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- Bio ---------- */
.bio { margin-top: 32px; }
.bio p { margin: 0 0 1em; }

/* ---------- Sections ---------- */
section.block {
    margin-top: 36px;
    padding-top: 28px;
    border-top: 1px solid var(--rule);
}

section.block h2 {
    font-size: 1.4em;
    margin: 0 0 14px;
}

.subnote {
    margin: -8px 0 14px;
    font-size: 0.85em;
    color: var(--text-muted);
}

/* ---------- News ---------- */
#news-list { margin: 0; padding-left: 1.25em; }
#news-list li { margin-bottom: 8px; }
#news-list .date { text-decoration: underline; }

#news-toggle,
.more-toggle {
    margin-top: 6px;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 0.95em;
    color: var(--link);
    cursor: pointer;
}

#news-toggle:hover,
.more-toggle:hover { color: var(--link-hover); text-decoration: underline; }

.more-toggle { display: block; margin: 0; }
.more-toggle[hidden] { display: none; }

/* 잘린 설명의 마지막 줄을 흐리게 */
.item-desc.clamped {
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.6em), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 1.6em), transparent);
}

/* ---------- Publications / Projects ---------- */
.item {
    display: flex;
    gap: 20px;
    padding: 16px 0;
    border-bottom: 1px solid var(--rule-soft);
}

.item:last-child { border-bottom: none; }

.item-thumb {
    flex: 0 0 clamp(240px, 30%, 360px);
    max-width: 360px;
}

.item-thumb img,
.item-thumb video {
    width: 100%;
    height: auto;
    border-radius: 6px;
    display: block;
    background: var(--thumb-bg);
}

.item-thumb img { cursor: zoom-in; }

.item-thumb.crop img,
.item-thumb.crop video { aspect-ratio: 16 / 9; object-fit: cover; }

.item-text { flex: 1 1 auto; min-width: 0; }

.item-text.featured {
    background-color: var(--featured);
    border-radius: 6px;
    padding: 10px 12px;
    margin: -10px -12px;
}

/* 썸네일과 글 상자를 같은 높이로 맞추고, 링크는 아랫단에 붙임 */
.item { align-items: stretch; }

.item-text {
    display: flex;
    flex-direction: column;
}

.item-text > .item-links { margin-top: auto; margin-bottom: 0; padding-top: 4px; }
.item-text > .more-toggle { align-self: flex-start; }

/* 논문: 제목·저자는 위, 학회·링크는 아래. 글이 길면 썸네일을 글 높이에 맞춰 늘림(가장자리만 잘림) */
.pub-item .item-text { justify-content: space-between; gap: 8px; }

.pub-item .item-thumb img,
.pub-item .item-thumb video { height: 100%; object-fit: cover; object-position: left center; }

.pub-item .item-text.featured { margin: 0; }
.pub-item .item-text > div > p:last-child { margin-bottom: 0; }

.item-text p { margin: 0 0 4px; }
.item-title { font-weight: 700; margin-bottom: 6px !important; }
.item-note { font-size: 0.85em; color: var(--text-muted); }
.item-award { color: var(--award); font-weight: 700; }
.item-period { color: var(--text-muted); font-size: 0.92em; }
.self { font-weight: 700; text-decoration: underline; }

@media (max-width: 560px) {
    .item { flex-direction: column; }
    .item-thumb { flex-basis: auto; max-width: 100%; width: 100%; }
    .pub-item .item-thumb img,
    .pub-item .item-thumb video { height: auto; }
    .item-text.featured { margin: 0; }
}

/* ---------- Education ---------- */
.edu-item {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px 0;
}

.edu-item + .edu-item { border-top: 1px solid var(--rule-soft); }

.edu-logo { flex: 0 0 56px; }

.edu-logo img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    display: block;
    padding: 4px;
    border-radius: 8px;
    background: var(--logo-bg);   /* 다크 모드에서 어두운 로고가 묻히지 않도록 */
}

.edu-degree { font-weight: 700; }
.edu-period { color: var(--text-muted); font-size: 0.92em; }
.edu-detail { color: var(--text-muted); font-size: 0.95em; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 5;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--rule);
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
}

.theme-toggle:hover { color: var(--link-hover); border-color: var(--link-hover); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Heart (giscus) ---------- */
.heart {
    position: fixed;
    top: 62px;          /* 테마 버튼(14px + 38px) 바로 아래 */
    right: 14px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

/* 하트 버튼 아래 이모지별 개수 */
.reaction-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.8em;
    color: var(--text-muted);
}

.reaction-list li { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.reaction-list .emoji { font-size: 1.05em; }
.reaction-list li.mine { color: var(--text); font-weight: 700; }

.heart-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--rule);
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
}

.heart-button:hover { color: #e0245e; border-color: #e0245e; }
.heart-button svg { width: 18px; height: 18px; }
.heart.reacted .heart-button { color: #e0245e; }
.heart.reacted .heart-button svg { fill: currentColor; }

/* 팝업: giscus가 미리 로드되어 개수를 보내도록 display:none 대신 visibility로 숨김 */
.heart-panel {
    position: absolute;
    top: 46px;
    right: 0;
    width: 280px;
    padding: 10px 12px 4px;
    border: 1px solid var(--rule);
    border-radius: 10px;
    background: var(--bg);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s;
}

.heart.open .heart-panel { visibility: visible; opacity: 1; }
.heart-panel-note { margin: 0 0 4px; font-size: 0.85em; color: var(--text-muted); }

/* ---------- Image modal ---------- */
.modal {
    display: none;
    position: fixed;
    z-index: 10;
    inset: 0;
    padding: 80px 16px 16px;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    cursor: zoom-out;
}

.modal.open { display: block; }

.modal-content {
    display: block;
    margin: auto;
    width: 100%;
    max-width: 1100px;
    height: auto;
}

.modal-close {
    position: fixed;
    top: 16px;
    right: 28px;
    color: #aaa;
    font-size: 36px;
    font-weight: bold;
    cursor: pointer;
}

.modal-close:hover { color: #fff; }

footer {
    text-align: center;
    padding: 20px;
    color: var(--text-faint);
    font-size: 0.8em;
}
