/* ===========================================================================
   Phase 1 — 타이포그래피 · 색 토큰 · 다크모드
   styles.css(부트스트랩 번들) 뒤에 로드해서 덮어쓰는 레이어.
   마크업은 건드리지 않고 이 파일만으로 외형을 바꾼다.
   =========================================================================== */

:root {
  /* 타입 스케일 */
  --font-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1.0625rem;
  --text-lg: 1.1875rem;
  --text-h3: 1.1875rem;
  --text-h2: clamp(1.5rem, 1.1rem + 1.4vw, 2rem);
  --text-h1: clamp(2.25rem, 1.5rem + 3vw, 3.5rem);

  --leading-body: 1.62;
  --leading-tight: 1.2;
  --measure: 70ch;

  /* 색 — 라이트 (Coursera 계열 블루 #0056d2) */
  --bg: #eef5ff;
  --surface: #ffffff;
  --rail-bg: #0056d2;
  --rail-fg: #cfe1fb;
  --rail-fg-strong: #ffffff;
  --text: #11223a;
  --text-muted: #55657a;
  --border: #d2e2f9;
  --accent: #0056d2;
  --accent-hover: #00409e;
  --accent-soft: #dfecff;
  --shadow: 0 1px 2px rgba(0, 48, 120, 0.06), 0 8px 24px -12px rgba(0, 48, 120, 0.22);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1526;
    --surface: #12203a;
    --rail-bg: #0b2d63;
    --rail-fg: #a9c3e8;
    --rail-fg-strong: #f1f6ff;
    --text: #e3ebf7;
    --text-muted: #91a4bd;
    --border: #1e3250;
    --accent: #6aa8ff;
    --accent-hover: #8dbdff;
    --accent-soft: #16294a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 8px 24px -12px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  --bg: #0a1526;
  --surface: #12203a;
  --rail-bg: #0b2d63;
  --rail-fg: #a9c3e8;
  --rail-fg-strong: #f1f6ff;
  --text: #e3ebf7;
  --text-muted: #91a4bd;
  --border: #1e3250;
  --accent: #6aa8ff;
  --accent-hover: #8dbdff;
  --accent-soft: #16294a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 8px 24px -12px rgba(0, 0, 0, 0.7);
}

/* --- 기본 ---------------------------------------------------------------- */

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  font-feature-settings: "ss01", "tnum" 0;
  letter-spacing: -0.003em;
}

::selection { background: var(--accent-soft); color: var(--text); }

/* --- 섹션 레이아웃 ------------------------------------------------------- */

section.resume-section {
  display: block;
  min-height: 0;
  max-width: none;
  padding: 3.25rem 1.25rem;
  scroll-margin-top: 4rem;
  border-bottom: 1px solid var(--border);
}

section.resume-section:last-of-type { border-bottom: 0; }

section.resume-section .resume-section-content {
  width: 100%;
  max-width: var(--measure);
}

@media (min-width: 768px) {
  section.resume-section { min-height: 0; }
}

@media (min-width: 992px) {
  section.resume-section { padding: 3.5rem 3.25rem; }
}

/* --- 제목 ---------------------------------------------------------------- */

h1, .h1, h2, .h2, h3, .h3, h4, .h4 {
  font-family: var(--font-sans);
  line-height: var(--leading-tight);
  letter-spacing: -0.022em;
  text-wrap: balance;
  color: var(--text);
}

h1, .h1 {
  font-size: var(--text-h1);
  font-weight: 760;
  letter-spacing: -0.035em;
}

h1 .text-primary { color: var(--accent) !important; }

h2, .h2 {
  font-size: var(--text-h2);
  font-weight: 700;
  margin-bottom: 1.5rem !important;
}

h3, .h3 {
  font-size: var(--text-h3);
  font-weight: 650;
  letter-spacing: -0.015em;
}

h4, .h4, h5, .h5, h6, .h6 { font-size: var(--text-base); font-weight: 600; }

/* 섹션 안의 작은 라벨 — 원래 Saira Extra Condensed 1.5rem 대문자였으나
   폰트가 로드되지 않아 그냥 큰 대문자로 보였다. 라벨답게 줄인다. */
.subheading {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --- 본문 · 리스트 ------------------------------------------------------- */

p, li { text-wrap: pretty; }

p.lead, .lead {
  font-size: var(--text-base);
  font-weight: 400;
  line-height: var(--leading-body);
  color: var(--text);
}

#about .lead:first-of-type { color: var(--text-muted); }

/* 인라인 font-size:1.5em 로 커져 있던 목록들 */
.resume-section-content ol,
.resume-section-content ul {
  font-size: var(--text-base) !important;
}

.resume-section-content ol.fa-ul > li,
.resume-section-content ul.fa-ul > li {
  margin-bottom: 0.55rem;
  line-height: 1.55;
  color: var(--text);
}

.fa-ul .fa-li { color: var(--text-muted); }

/* 이력 항목의 기간 텍스트 — 주황을 걷어내고 수치용 서체로 */
section.resume-section .text-primary {
  color: var(--text-muted) !important;
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  font-weight: 500;
}

section.resume-section h1 .text-primary {
  color: var(--accent) !important;
  font-size: inherit;
  font-weight: inherit;
}

.resume-section-content .text-md-end,
.resume-section-content .text-end {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

/* 세로 여백 압축 — 부트스트랩 기본 간격이 본문에서는 너무 넓다 */
section.resume-section .mb-5 { margin-bottom: 1.75rem !important; }
section.resume-section .mb-4 { margin-bottom: 1.25rem !important; }
section.resume-section .mb-3 { margin-bottom: 0.55rem !important; }
section.resume-section .mt-4 { margin-top: 1.5rem !important; }
section.resume-section p { margin-bottom: 0.85rem; }

/* 빈 <p></p> 가 한 줄씩 자리를 차지하고 있다 */
section.resume-section p:empty,
section.resume-section div:empty:not([class]) { display: none; }

/* 항목 사이 간격 (경력·학력·수상 행) */
section.resume-section .d-flex.flex-column { margin-bottom: 1.5rem !important; }
section.resume-section .d-flex.flex-column:last-child { margin-bottom: 0 !important; }

/* --- 링크 ---------------------------------------------------------------- */

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 0.12s ease, text-decoration-color 0.12s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

/* --- 좌측 레일 ----------------------------------------------------------- */

#sideNav.bg-primary { background-color: var(--rail-bg) !important; }

#sideNav { border-right: 1px solid rgba(255, 255, 255, 0.06); }

#sideNav .navbar-brand { opacity: 1; }

#sideNav .navbar-nav .nav-item .nav-link {
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--rail-fg);
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
}

#sideNav .navbar-nav .nav-item .nav-link:hover,
#sideNav .navbar-nav .nav-item .nav-link:focus-visible {
  color: var(--rail-fg-strong);
  background-color: rgba(255, 255, 255, 0.07);
}

/* 외부로 나가는 링크는 마크업 수정 없이 화살표로 구분 */
#sideNav .nav-link[target="_blank"]::after,
#sideNav .nav-link[href^="http"]::after {
  content: "↗";
  font-size: 0.75em;
  margin-left: 0.35em;
  opacity: 0.55;
}

/* 접근 제한(로그인 필요) 메뉴 표시 */
#sideNav .nav-link .nav-lock {
  font-size: 0.7em;
  margin-left: 0.3em;
  opacity: 0.6;
  vertical-align: 0.1em;
}
#sideNav .nav-link--locked:hover .nav-lock,
#sideNav .nav-link--locked:focus-visible .nav-lock { opacity: 0.9; }

/* 본문 내 접근 제한 링크 뱃지 */
.access-lock {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-size: 0.78em;
  padding: 0.05em 0.5em;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--accent-soft);
  vertical-align: 0.1em;
  white-space: nowrap;
}
.access-lock .fa-lock { font-size: 0.85em; }

/* 하위 페이지(.html)는 살짝 다른 톤 */
#sideNav .nav-link[href$=".html"] { color: color-mix(in srgb, var(--rail-fg) 88%, white); }

@media (min-width: 992px) {
  body { padding-left: 15.5rem; }
  /* 메뉴가 늘어나 화면 높이를 넘으면 레일 안에서만 스크롤 */
  #sideNav { width: 15.5rem; overflow-y: auto; }
  #sideNav .navbar-collapse { padding-bottom: 1rem; }
  #sideNav .navbar-brand .img-profile {
    max-width: 8.5rem;
    max-height: 8.5rem;
    border: 0.35rem solid rgba(255, 255, 255, 0.1);
  }
  #sideNav .navbar-collapse .navbar-nav { padding: 0 0.6rem; }
}

/* --- Teaching: 과목 중심 카드 ------------------------------------------- */

.course-intro { color: var(--text-muted); margin-bottom: 1.5rem; }
.course-area { margin-top: 1.75rem; }
.course-area:first-of-type { margin-top: 0; }

.course-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
}
.course-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
}
.course-title { display: flex; flex-direction: column; min-width: 0; }
.course-name { font-weight: 650; color: var(--text); }
.course-en { font-size: var(--text-xs); color: var(--text-muted); }

.course-terms { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.course-term {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.5;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: transparent;
  white-space: nowrap;
}
.course-term--latest {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* 과목 소개: 한국어와 영어를 각 문단으로 구분한다. */
.course-description { margin-top: 0.75rem; }
.course-description p { margin: 0; line-height: 1.65; }
.course-description p + p { margin-top: 0.5rem; }
.course-description p[lang="en"] { color: var(--text-muted); font-size: 1rem; }

.course-note { font-size: var(--text-xs); color: var(--text-muted); margin: 0.45rem 0 0; }
.course-links { display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; margin-top: 0.5rem; font-size: var(--text-sm); }
.course-link::before { content: "\2197"; font-size: 0.8em; margin-right: 0.3em; opacity: 0.6; }

.course-projects-wrap, .course-tools { margin-top: 0.7rem; padding-top: 0.6rem; border-top: 1px dashed var(--border); }
.course-projects-head {
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.course-projects-item { font-size: var(--text-sm); margin: 0.2rem 0; }
.course-projects-term {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 650;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 0 0.4rem;
  margin-right: 0.3rem;
  vertical-align: 0.1em;
}
.course-projects summary {
  cursor: pointer;
  font-size: var(--text-sm);
  margin: 0.2rem 0;
  list-style: none;
}
.course-projects summary::-webkit-details-marker { display: none; }
.course-projects summary::before {
  content: "\25B8";
  display: inline-block;
  width: 1em;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.course-projects[open] summary::before { transform: rotate(90deg); }
.course-projects-n {
  font-size: 0.7rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 0.4rem;
  margin-left: 0.2rem;
}
.course-projects ol, .course-tools ul {
  margin: 0.35rem 0 0.25rem 1.6rem;
  padding: 0;
  font-size: var(--text-sm);
}
.course-projects ol li, .course-tools ul li { margin: 0.15rem 0; }
/* Workshop 카드 전용 보조 요소 */
.ws-meta { font-size: var(--text-xs); color: var(--text-muted); margin-top: 0.4rem; }
.ws-meta i { margin-right: 0.3em; opacity: 0.75; }
.ws-desc { font-size: var(--text-sm); color: var(--text); margin: 0.55rem 0 0; }
.course-en a { color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 2px; }
.course-en a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.course-footnote { font-size: var(--text-xs); color: var(--text-muted); margin-top: 1.5rem; }
.course-footnote .fas { margin-right: 0.3em; }

@media (max-width: 575.98px) {
  .course-card { padding: 0.75rem 0.8rem; }
  .course-head { flex-direction: column; align-items: flex-start; }
}

/* --- 이미지 확대 보기(라이트박스) --------------------------------------- */

.img-zoomable { cursor: zoom-in; }

.img-lightbox {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
}
.img-lightbox::backdrop { background: rgba(0, 0, 0, 0.82); }
.img-lightbox img {
  display: block;
  max-width: min(96vw, 1400px);
  max-height: 92vh;
  width: auto;
  height: auto;
  margin: 4vh auto;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  cursor: zoom-out;
}
/* 사이드바 원형 프로필은 전체 화면 대신 원래 크기(8.5rem)의 2배 원형으로만 확대 */
.img-lightbox img.is-profile {
  width: 17rem;
  height: 17rem;
  max-width: 90vw;
  max-height: 90vw;
  object-fit: cover;
  border-radius: 50%;
  border: 0.35rem solid rgba(255, 255, 255, 0.25);
  margin: 0;
}
.img-lightbox:has(img.is-profile) {
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
}

.img-lightbox-close {
  position: fixed;
  top: 0.75rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.img-lightbox-close:hover,
.img-lightbox-close:focus-visible { background: rgba(255, 255, 255, 0.3); }

/* --- 아이콘 ------------------------------------------------------------- */

.dev-icons { font-size: 2rem; color: var(--text-muted); }

.social-icons .social-icon {
  height: 2.75rem;
  width: 2.75rem;
  font-size: 1.15rem;
  background-color: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  margin-right: 0.75rem;
}

.social-icons .social-icon:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 공사중 🔧 안내 블록 */
.lead .social-icons .fa-wrench { color: var(--accent); margin-right: 0.5rem; }
.lead .social-icons { display: inline; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  opacity: 1;
  margin: 1.75rem 0;
}

/* --- 테마 토글 ----------------------------------------------------------- */

.theme-toggle {
  position: fixed;
  top: 0.85rem;
  right: 0.85rem;
  z-index: 1100;
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 0.95rem;
}

/* 모바일 상단 바에서 메뉴 버튼 오른쪽에 테마 버튼 전용 공간을 확보한다. */
@media (max-width: 991.98px) {
  #sideNav { padding-right: 4.25rem; }
  .theme-toggle { top: 0.5rem; }
}

.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle .fa-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .fa-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .fa-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .fa-sun { display: inline; }
  :root:not([data-theme="light"]) .theme-toggle .fa-moon { display: none; }
}

/* --- 인쇄(CV 출력) ------------------------------------------------------- */

@media print {
  #sideNav, .theme-toggle { display: none !important; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .container-fluid > div, section.resume-section {
    padding: 0 0 1.25rem !important;
    border: 0;
    page-break-inside: avoid;
  }
  section.resume-section .resume-section-content { max-width: none; }
  a { color: #000; text-decoration: none; }
}
