/* =====================================================
  YOON's WORK LIBRARY — style.css
  · CSS Nesting 사용 / 모든 표현은 이 파일에서만 정의 (HTML 에 인라인 style 없음)
===================================================== */
:root {
  /* color */
  --line: #e5e5e5;
  --ink: #111;
  --ink-muted: #767676;
  --text: #1a1c1c;
  --secondary: #5e5e60;
  --on-variant: #444748;
  --bg: #f9f9f9;
  --white: #fff;
  --surface-low: #f3f3f3;
  --surface-high: #e8e8e8;

  /* 어두운 배경(--ink) 위에서 쓰는 색 */
  --on-ink-1: rgb(255 255 255 / 0.9);
  --on-ink-2: rgb(255 255 255 / 0.8);
  --on-ink-line: rgb(255 255 255 / 0.2);
  --ink-line: rgb(68 71 72 / 0.35);

  /* spacing */
  --sp-xs: 0.25rem;
  --sp-sm: 0.5rem;
  --sp-md: 1rem;
  --sp-lg: 1.5rem;
  --sp-xl: 2.5rem;
  --pad-x: 1.25rem;
  --bar-h: 64px; /* 상단 고정 바 높이 */

  /* font */
  --font-sans:
    'Hanken Grotesk', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  @media (min-width: 768px) {
    --pad-x: 2.5rem;
  }
  @media (min-width: 1024px) {
    --pad-x: 4rem;
  }
}

/* =====================================================
  베이스
===================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  scrollbar-width: none; /* 페이지 자체 스크롤바만 숨김 */
  &::-webkit-scrollbar {
    display: none;
  }
}
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/22px var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
h1,
h2,
h3,
p,
ul,
ol,
dl,
dd {
  margin: 0;
  padding: 0;
}
ul,
ol {
  list-style: none;
}
a {
  color: inherit;
  text-decoration: none;
}
main {
  flex: 1;
  width: 100%;
  background: var(--bg);
}
/* 앵커로 이동했을 때 고정 바에 제목이 가려지지 않게 */
main section {
  scroll-margin-top: var(--bar-h);
}

/* 가로 스크롤 영역 (책장 / 실적 표) 공용 스크롤바 */
.shelf,
.ledger {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ink) var(--surface-low);
  &::-webkit-scrollbar {
    height: 8px;
  }
  &::-webkit-scrollbar-track {
    background: var(--surface-low);
  }
  &::-webkit-scrollbar-thumb {
    background: var(--ink);
  }
}

/* =====================================================
  Helpers
===================================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.mono {
  font: 400 11px/14px var(--font-mono);
  letter-spacing: 0.08em;
  padding-left: 0.175rem;
}
.caps {
  font: 600 11px/14px var(--font-sans);
  letter-spacing: 0.06em;
}
.muted {
  color: var(--ink-muted);
}
.small {
  font-size: 12px;
  line-height: 18px;
  letter-spacing: 0.01em;
}
.h-lg {
  font: 500 32px/40px var(--font-sans);
  letter-spacing: -0.02em;
  color: var(--ink);
}
.h-md {
  font: 500 20px/28px var(--font-sans);
  letter-spacing: -0.01em;
  color: var(--ink);
}
.icon {
  font: 14px/1 'Material Symbols Outlined';
  font-feature-settings: 'liga';
  transition: transform 0.2s;
}

.container {
  width: 100%;
  padding: var(--sp-xl) var(--pad-x);
}
.section {
  border-bottom: 1px solid var(--line);
}
.section-head {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  margin-bottom: var(--sp-lg);
  padding-bottom: var(--sp-sm);
  border-bottom: 1px solid var(--line);
  &.section-head--strong {
    border-bottom-color: var(--ink);
  }
  @media (min-width: 768px) {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

/* =====================================================
  Header (페이지 상단: 고정 바 + 소개 카드)
===================================================== */
.page-header {
  padding-top: var(--bar-h); /* 고정 바 높이만큼 소개 카드를 내림 */
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--line);

  & .site-header__inner {
    height: var(--bar-h);
    padding: 0 var(--pad-x);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-md);
  }
  & .site-header__right {
    display: flex;
    align-items: center;
    gap: var(--sp-lg);
  }
  & .brand {
    white-space: nowrap;
    font: 700 20px/28px var(--font-sans);
    letter-spacing: -0.01em;
    color: var(--ink);
  }
  & .nav {
    display: none; /* 좁은 화면: 로고 + GitHub 만 */
    align-items: center;
    gap: var(--sp-lg);
    @media (min-width: 720px) {
      display: flex;
    }
    & a {
      padding: var(--sp-xs) 0;
      color: var(--on-variant);
      transition: color 0.2s;
      &:hover {
        color: var(--ink);
      }
    }
  }
  & .divider {
    display: none;
    width: 1px;
    height: 16px;
    background: var(--line);
    @media (min-width: 720px) {
      display: block;
    }
  }
  & .github-link {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    color: var(--ink);
    transition: opacity 0.2s;
    &:hover {
      opacity: 0.7;
    }
    &:focus-visible {
      outline: 2px solid var(--ink);
      outline-offset: 2px;
    }
    & svg {
      width: 32px;
      height: 32px;
      fill: currentColor;
    }
  }
}

/* =====================================================
  Intro
===================================================== */
.intro {
  display: grid;
  gap: var(--sp-xl);
  @media (min-width: 1024px) {
    grid-template-columns: 5fr 7fr;
    align-items: stretch;
  }
}
.id-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 320px;
  padding: var(--sp-lg);
  background: var(--ink);
  color: var(--white);
  border: 1px solid var(--ink);
  @media (min-width: 1024px) {
    padding: var(--sp-xl);
  }

  & .id-card__bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--sp-lg);
    padding-bottom: var(--sp-sm);
    border-bottom: 1px solid var(--ink-line);
    & .caps {
      letter-spacing: 0.1em;
      color: var(--on-ink-2);
    }
  }
  & .id-card__title {
    margin-bottom: var(--sp-sm);
    font: 500 40px/44px var(--font-sans);
    letter-spacing: -0.05em;
    text-transform: uppercase;
    @media (min-width: 1024px) {
      font-size: 56px;
      line-height: 64px;
    }
  }
  & .id-card__affil {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    margin-bottom: var(--sp-lg);
    color: var(--on-ink-2);
    letter-spacing: 0.05em;
    &::before {
      content: '';
      width: 6px;
      height: 6px;
      background: var(--white);
    }
  }
  & .id-card__lead {
    max-width: 26rem;
    font: 300 16px/26px var(--font-sans);
    word-break: keep-all;
    color: var(--on-ink-1);
  }
  & .id-card__foot {
    padding-top: var(--sp-lg);
    border-top: 1px solid var(--ink-line);
  }
}
.link-ext {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  margin-top: 4px;
  letter-spacing: 0.1em;
  text-underline-offset: 4px;
  &:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    & .icon {
      transform: translate(2px, -2px);
    }
  }
  &.link-ext--down:hover .icon {
    transform: translateY(2px);
  }
  &.link-ext--up:hover .icon {
    transform: translateY(-2px);
  }
}
.overview {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-top: var(--sp-lg);
  border-top: 1px solid var(--line);
  @media (min-width: 1024px) {
    padding: 0 0 0 var(--sp-xl);
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  & .overview__bar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: var(--sp-lg);
    padding-bottom: var(--sp-sm);
    border-bottom: 1px solid var(--line);
    & .caps {
      letter-spacing: 0.1em;
    }
  }
  & .overview__text {
    display: grid;
    gap: var(--sp-md);
    & .h-md {
      font-weight: 400;
    }
    & p:last-child {
      color: var(--secondary);
    }
  }
  & .meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-sm);
    margin-top: var(--sp-lg);
    padding-top: var(--sp-md);
    border-top: 1px solid var(--line);
    & > div {
      display: flex;
      flex-direction: column;
      & + div {
        padding-left: var(--sp-sm);
        border-left: 1px solid var(--line);
      }
    }
    & .caps {
      margin-top: 4px;
      color: var(--ink);
    }
  }
}

/* =====================================================
  [F-03] 실적 대장 (table)
    · 책장과 같은 흰 바탕 + 가는 선, 머리행 아래 검은 굵은 선
    · 좁은 화면에서는 표 자체가 가로 스크롤 (페이지는 스크롤 X)
===================================================== */
.ledger {
  background: var(--white);
  border: 1px solid var(--line);
}
.ledger__table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;

  & th,
  & td {
    padding: var(--sp-md);
    text-align: left;
    vertical-align: top;
  }
  & th {
    padding-block: 0.75rem;
    font: 400 11px/14px var(--font-mono);
    letter-spacing: 0.08em;
    color: var(--ink-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--ink);
  }
  & tbody {
    counter-reset: row; /* NO. 자동 번호 */
  }
  & tbody tr {
    counter-increment: row;
    transition: background 0.2s;
    & + tr {
      border-top: 1px solid var(--line);
    }
    &:hover {
      background: var(--surface-low);
    }
  }
  & .ledger__no {
    width: 4.5rem;
  }
  & td.ledger__no {
    font: 400 11px/22px var(--font-mono);
    letter-spacing: 0.08em;
    color: var(--ink-muted);
    &::before {
      content: counter(row, decimal-leading-zero);
    }
  }
  & .ledger__date {
    width: 7.5rem;
    white-space: nowrap;
  }
  & td.ledger__date {
    font: 500 12px/22px var(--font-mono);
    letter-spacing: 0.04em;
    color: var(--ink);
  }
  & .ledger__type {
    width: 7rem;
    white-space: nowrap;
  }
  & .ledger__role {
    width: 13rem;
  }
  & td.ledger__role {
    color: var(--on-variant);
    word-break: keep-all;
  }
}
.ledger__title {
  font: 500 16px/22px var(--font-sans);
  letter-spacing: -0.01em;
  word-break: keep-all;
  color: var(--ink);
}
.ledger__desc {
  margin-top: 4px;
  word-break: keep-all;
  color: var(--secondary);
}
/* 분류 표기 (수강 과목 배지와 같은 모양) */
.tag {
  display: inline-block;
  margin-top: 2px;
  padding: 2px 6px;
  background: var(--ink);
  color: var(--white);
  font: 500 11px/14px var(--font-sans);
  letter-spacing: 0.04em;
}

/* =====================================================
  [F-04] 강의
===================================================== */
.courses {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-lg);
  padding: var(--sp-md);
  background: var(--white);
  border: 1px solid var(--line);
  @media (min-width: 608px) {
    grid-template-columns: repeat(2, 1fr);
  }
  @media (min-width: 922px) {
    grid-template-columns: repeat(3, 1fr);
  }
  @media (min-width: 1250px) {
    grid-template-columns: repeat(4, 1fr);
  }
  @media (min-width: 1803px) {
    grid-template-columns: repeat(6, 1fr);
  }
  /* 목록 항목 안의 카드가 칸 높이를 꽉 채우도록 */
  & > li {
    display: flex;
    & > .course {
      flex: 1;
    }
  }
}
.course {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 170px;
  padding: var(--sp-md);
  background: var(--bg);
  border: 1px solid var(--line);
  transition:
    background 0.2s,
    color 0.2s;

  & .course__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-sm);
  }
  & .course__badge {
    padding: 2px 6px;
    background: var(--surface-high);
    color: var(--on-variant);
    font: 500 11px/14px var(--font-sans);
    letter-spacing: 0.04em;
  }
  & h3 {
    line-height: 1.375;
    padding-top: 0.5rem;
  }
  & .course__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--sp-md);
    border-top: 1px solid var(--line);
    & .mono:last-child {
      color: var(--secondary);
    }
  }

  /* 링크 카드 */
  &.course--link {
    border-color: var(--ink);
    & .course__badge {
      background: var(--ink);
      color: var(--white);
    }
    & .icon {
      font-size: 16px;
    }
    &:hover,
    &:focus-visible {
      background: var(--ink);
      color: var(--white);
      & h3 {
        color: var(--white);
      }
      & .muted {
        color: var(--white);
        opacity: 0.7;
      }
      & .course__badge {
        background: var(--white);
        color: var(--ink);
      }
      & .course__foot {
        border-color: var(--on-ink-line);
      }
      & .icon {
        transform: translateY(2px);
      }
    }
  }
}

/* =====================================================
  [A-01] 스킬 — 이름 + 한 줄 설명 (분류명·번호 없음)
===================================================== */
.skills {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-md);
  @media (min-width: 640px) {
    grid-template-columns: repeat(2, 1fr);
  }
  @media (min-width: 768px) {
    grid-template-columns: repeat(3, 1fr);
  }
}
.skill {
  padding: var(--sp-lg);
  background: var(--white);
  border: 1px solid var(--line);
  transition: border-color 0.2s;
  &:hover {
    border-color: var(--ink);
  }
  & p {
    margin-top: 4px;
    color: var(--secondary);
  }
}

/* =====================================================
  [F-05] 15주 책장
    · 15칸 책장, 세로 책등, 호버 시 옆으로 펼쳐지는 안내 패널
    · 모든 주차는 같은 마크업(li > a.spine). 상태는 a 의 href 유무로 자동 결정
        a[href]      : 완료 → --on: 1 (진한 글자, 클릭, 펼쳐짐)
        a(href 없음) : 예정/휴강/OT → --on: 0 (흐린 글자, 클릭·호버 반응 없음)
    · 아래 항목은 CSS 가 자동 생성 (HTML 에는 쓰지 않음)
        책등 번호 01~15 · href 없는 주차의 "NN주" · 펼침 패널의 큰 번호, "WEEK NN", "과제 페이지 보기 →"
    · 칸 수를 바꾸려면 --slots 만 수정 (과제 요구는 15주)
    · 주차를 마치는 방법은 index.html 의 [F-05] 주석 참고
===================================================== */

/* 제목 옆에 범례가 다 들어가지 않으면 범례가 통째로 제목 아래로 내려감 */
#web-programming .section-head {
  flex-wrap: wrap;
  row-gap: var(--sp-sm);
}

/* ----- 범례 ----- */
.legend {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--sp-md);
  white-space: nowrap;
  color: var(--ink);
}
.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.legend__swatch {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  background: var(--ink);
}
.legend__item--todo {
  color: var(--ink-muted);
  & .legend__swatch {
    background: var(--ink-muted);
  }
}

/* ----- 책장 ----- */
.shelf {
  background: var(--white);
  border-block: 1px solid var(--line);
}
.shelf__grid {
  --slots: 15; /* 한 줄에 꽂히는 칸 수 */
  --grow: 9; /* 호버한 책이 평소 칸보다 몇 배 넓어지는지 */
  /* 책장 폭 = 화면 폭 - 좌우 여백 (최소 960px) */
  --shelf-w: max(960px, 100vw - 2 * var(--pad-x));

  counter-reset: week;
  display: flex;
  min-width: 960px;
  height: 460px;
  border-inline: 1px solid var(--line);

  & > li {
    --spine-w: calc(var(--shelf-w) / var(--slots)); /* 책등(=접힌 칸) 폭 */

    position: relative;
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    counter-increment: week;
    transition: flex-grow 0.42s cubic-bezier(0.2, 0.7, 0.2, 1);
    pointer-events: none; /* 링크 없는 칸은 호버에 반응하지 않음 (아래 a[href] 만 반응) */

    & + li {
      border-left: 1px solid var(--line);
    }
    /* 호버/키보드 포커스 시 옆으로 펼쳐짐 (a[href] 만 호버되므로 완료 주차만 해당) */
    &:is(:hover, :focus-within) {
      flex-grow: var(--grow);
    }
  }
}

/* ----- 책등 (a.spine) : 상태는 href 유무로 결정 ----- */
.spine {
  --on: 0; /* 1 = 완료(href 있음), 0 = 링크 없음 */
  --off: calc(1 - var(--on));
  --tone: var(--ink-muted);

  z-index: 1;
  flex: 0 0 min(var(--spine-w), 100%); /* 펼쳐져도 책등 폭 유지, 눌린 이웃은 칸 폭만큼 */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  height: 100%;
  padding: 0.75rem 0.125rem;
  overflow: hidden;
  text-align: center;
  background: rgb(243 243 243 / calc(var(--off) * 0.4));
  transition: background 0.22s ease;

  &[href] {
    --on: 1;
    --tone: var(--ink);
    pointer-events: auto;
  }
  &:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
  }

  /* 링크 없는 주차는 전체가 살짝 흐려짐 */
  & :is(.spine__no, .spine__title span, .spine__state) {
    opacity: calc(1 - var(--off) * 0.3);
  }

  & .spine__no {
    color: var(--ink-muted);
    &::before {
      content: counter(week, decimal-leading-zero);
    }
  }
  & .spine__title {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: var(--sp-sm) 0;
    & span {
      /* 아래 → 위로 읽는 세로 제목 (긴 제목은 옆 줄로 자동 줄바꿈) */
      writing-mode: vertical-rl;
      text-orientation: sideways;
      transform: rotate(180deg);
      max-height: 300px;
      white-space: normal;
      word-break: keep-all;
      user-select: none;
      color: var(--tone);
      font:
        500 12px/14px var(--font-mono),
        var(--font-sans);
      letter-spacing: 0.1em;
      font-weight: calc(400 + var(--on) * 100); /* 링크 없음 400 → 완료 500 */
    }
  }
  & .spine__status {
    padding-top: var(--sp-sm);
    border-top: 1px solid var(--line);
  }
  & .spine__state {
    display: block;
    font: 400 10px/14px var(--font-mono);
    font-weight: calc(400 + var(--on) * 300); /* 링크 없음 400 → 완료 700 */
    white-space: nowrap;
    color: var(--tone);
  }
}

/* 링크 없는 주차: 상태 글자 앞에 "NN주 " 자동 */
.spine:not([href]) .spine__state::before {
  content: counter(week, decimal-leading-zero) '주 ';
}

/* 호버/포커스 중인 책등: 연한 회색 + 오른쪽 구분선 (펼쳐진 패널과 경계) */
.shelf__grid > li:is(:hover, :focus-within) .spine {
  background: var(--surface-low);
  box-shadow: inset -1px 0 0 var(--line);
}

/* ----- 펼침 패널: 책등 오른쪽에 나타남 (a.spine 의 가상 요소라서 패널 어디를 눌러도 링크) ----- */
.spine::before,
.spine::after {
  position: absolute;
  inset: 0 0 0 var(--spine-w); /* 책등 폭만큼 띄우고 칸 나머지를 채움 */
  display: flex;
  opacity: 0;
  transform: scale(0.985);
  transition:
    opacity 0.26s ease,
    transform 0.42s cubic-bezier(0.2, 0.7, 0.2, 1);
}
/* 바탕 + 큰 번호 */
.spine::before {
  content: counter(week, decimal-leading-zero);
  justify-content: flex-end;
  padding: var(--sp-md) var(--sp-lg);
  background: var(--ink);
  font: 500 clamp(64px, 9vw, 120px) / 1 var(--font-sans);
  letter-spacing: -0.06em;
  color: rgb(255 255 255 / 0.1);
}
/* 하단 안내 문구 */
.spine::after {
  content: 'WEEK ' counter(week, decimal-leading-zero) '\A 과제 페이지 보기 →';
  white-space: pre-line;
  text-align: left;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--sp-lg);
  font: 500 clamp(18px, 2vw, 26px) / 1.4 var(--font-sans);
  letter-spacing: -0.02em;
  color: var(--white);
}
.shelf__grid > li:is(:hover, :focus-within) .spine::before,
.shelf__grid > li:is(:hover, :focus-within) .spine::after {
  opacity: 1;
  transform: scale(1);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .shelf__grid > li,
  .spine::before,
  .spine::after {
    transition: none;
  }
}

/* 화면 폭이 좁아지면(768px 이하) 가로 행으로 층층이 쌓임 (펼침 패널 없음) */
@media (max-width: 768px) {
  .shelf {
    overflow-x: visible;
  }
  .shelf__grid {
    display: block;
    min-width: 0;
    height: auto;
    border-inline: 0;
    & > li {
      display: block;
      overflow: visible;
      & + li {
        border-left: 0;
        border-top: 1px solid var(--line);
      }
    }
  }
  .spine {
    display: grid;
    grid-template-columns: 3rem 1fr 4.5rem;
    align-items: center;
    height: auto;
    min-height: 72px;
    padding: var(--sp-md) var(--sp-sm);
    text-align: left;
    &::before,
    &::after {
      display: none;
    }
    & .spine__title {
      margin: 0;
      & span {
        writing-mode: horizontal-tb;
        transform: none;
        max-height: none;
        text-align: center;
        font-size: 14px;
        line-height: 20px;
        letter-spacing: 0.02em;
      }
    }
    & .spine__status {
      padding: 2px 0 2px var(--sp-sm);
      border: 0;
      border-left: 1px solid var(--line);
      text-align: center;
    }
  }
}

/* =====================================================
  [F-06] Footer
===================================================== */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg);

  & .site-footer__inner {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-lg);
    @media (min-width: 768px) {
      flex-direction: row;
      align-items: center;
    }
  }
  & .site-footer__col {
    display: flex;
    flex-direction: column;
    gap: 4px;
    &.site-footer__col--right {
      @media (min-width: 768px) {
        align-items: flex-end;
      }
    }
  }
  & .contact {
    color: var(--ink);
  }
  & .date {
    color: var(--ink);
    font-weight: 500;
  }
}
