/* 공통 디자인 토큰: 색상과 간격을 한곳에서 관리한다. */
:root {
  --bg: #f7f5ef;
  --surface: #fffdf8;
  --surface-tint: #ecefe8;
  --text: #17211b;
  --muted: #5f6b63;
  --line: #ccd3ca;
  --accent: #ff5a36;
  --accent-strong: #cf351b;
  --accent-soft: #ffd8cc;
  --shadow: 0 18px 50px rgba(26, 37, 30, .12);
  --radius: 1.25rem;
  --space: clamp(1rem, 2vw, 1.5rem);
  --max-width: 72rem;
  --font: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, sans-serif;
}

/* 다크 모드는 같은 변수 이름의 값만 교체한다. */
[data-theme="dark"] {
  --bg: #101713;
  --surface: #18211c;
  --surface-tint: #202c25;
  --text: #eff7f1;
  --muted: #a9b8ae;
  --line: #35443a;
  --accent: #ff7758;
  --accent-strong: #ff9b84;
  --accent-soft: #4a271f;
  --shadow: 0 18px 55px rgba(0, 0, 0, .32);
}

/* 기본 문서 스타일과 재사용 유틸리티 */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  line-height: 1.7;
  transition: color .25s ease, background-color .25s ease;
}
body.menu-open { overflow: hidden; }
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input, textarea { font: inherit; }
button { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.035em; }
h1 { font-size: clamp(2.7rem, 10vw, 6.7rem); margin-bottom: 1.2rem; }
h2 { font-size: clamp(2rem, 6vw, 3.8rem); max-width: 15ch; }
h3 { font-size: 1.25rem; }

.container { width: min(calc(100% - 2rem), var(--max-width)); margin-inline: auto; }
.section { padding: clamp(5rem, 12vw, 9rem) 0; }
.section-tint { background: var(--surface-tint); }
.section-kicker, .eyebrow { color: var(--accent-strong); font-weight: 800; letter-spacing: .13em; font-size: .78rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; left: 1rem; top: -5rem; padding: .7rem 1rem; background: var(--text); color: var(--bg); border-radius: .5rem; }
.skip-link:focus { top: 1rem; }

/* 내비게이션: 모바일에서는 접힌 메뉴, 768px부터 가로 메뉴다. */
.site-header { position: fixed; inset: 0 0 auto; z-index: 20; transition: background-color .25s ease, box-shadow .25s ease; }
.site-header.scrolled { background: color-mix(in srgb, var(--bg) 88%, transparent); box-shadow: 0 1px 0 var(--line); backdrop-filter: blur(14px); }
.nav { min-height: 4.5rem; display: flex; align-items: center; gap: .7rem; }
.logo { margin-right: auto; text-decoration: none; font-size: 1.45rem; font-weight: 900; letter-spacing: -.06em; }
.logo span { color: var(--accent); }
.nav-menu { position: fixed; inset: 4.5rem 1rem auto; display: none; padding: 1rem; margin: 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); }
.nav-menu.active { display: grid; }
.nav-menu a { display: block; padding: .8rem; text-decoration: none; font-weight: 750; border-radius: .6rem; }
.nav-menu a:hover, .nav-menu a:focus-visible { color: var(--accent-strong); background: var(--accent-soft); }
.menu-toggle, .theme-toggle { display: grid; place-items: center; width: 2.8rem; height: 2.8rem; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer; }
.menu-toggle span:not(.sr-only) { width: 1rem; height: 2px; margin: 2px; background: currentColor; transition: transform .2s ease, opacity .2s ease; }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(4) { transform: translateY(-6px) rotate(-45deg); }
.theme-toggle { font-size: 1.4rem; }

/* 첫 화면은 소개 문구와 학습 목표 카드로 구성한다. */
.hero { min-height: 100svh; display: grid; align-items: center; padding: 8rem 0 5rem; overflow: hidden; }
.hero-grid { display: grid; gap: 2.5rem; align-items: end; }
.hero h1 span { color: var(--accent); }
.hero-role { font-size: 1.25rem; }
.hero-summary { max-width: 38rem; color: var(--muted); font-size: 1.05rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 2rem; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 3rem; padding: .7rem 1.1rem; border: 1px solid var(--text); border-radius: 999px; background: transparent; color: var(--text); font-weight: 800; text-decoration: none; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease; }
.button:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 0, 0, .14); }
.button.primary { background: var(--text); color: var(--bg); }
.button.secondary { border-color: var(--line); background: var(--surface); }
.button.compact { min-height: 2.65rem; padding-inline: .9rem; border-radius: .65rem; }
.hero-card { position: relative; padding: 1.7rem; background: var(--text); color: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow); transform: rotate(1.5deg); }
.hero-card::before { content: ""; position: absolute; width: 4rem; height: .7rem; top: -.3rem; left: 50%; background: var(--accent); transform: translateX(-50%); }
.hero-card p { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.hero-card strong { display: block; font-size: 1.4rem; }
.hero-card ul { padding-left: 1.2rem; margin-bottom: 0; }

/* About와 Skills의 공통 카드 레이아웃 */
.about-grid { display: grid; gap: 2.5rem; align-items: center; }
.portrait-frame { padding: 1rem; background: var(--accent-soft); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.portrait-frame img { width: 100%; border-radius: calc(var(--radius) - .5rem); }
.about-grid article > p:not(.section-kicker) { color: var(--muted); font-size: 1.06rem; }
.facts { display: grid; gap: .7rem; margin-top: 2rem; }
.facts div { padding-block: .7rem; border-top: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: .82rem; }
.facts dd { margin: .2rem 0 0; font-weight: 800; }

.skills-grid, .projects-grid { display: grid; gap: var(--space); margin-top: 2.5rem; }
.skill-card, .project-card { padding: 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 25px rgba(26, 37, 30, .07); transition: transform .2s ease, box-shadow .2s ease; }
.skill-card:hover, .project-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.skill-card span, .project-language { display: inline-block; padding: .25rem .55rem; color: var(--accent-strong); background: var(--accent-soft); border-radius: 999px; font-size: .75rem; font-weight: 850; }
.skill-card h3 { margin: 1.2rem 0 .7rem; }
.skill-card p, .project-card p { color: var(--muted); margin-bottom: 0; }

/* GitHub 프로젝트의 검색, 상태, 필터, 카드 스타일 */
.section-heading { display: grid; gap: 1.5rem; }
.github-search label { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .85rem; font-weight: 750; }
.github-search div { display: flex; gap: .5rem; }
.github-search input { min-width: 0; width: 100%; padding: .65rem .8rem; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: .65rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; min-height: 2.4rem; margin: 2rem 0 1rem; }
.filter-button { padding: .45rem .75rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface); cursor: pointer; }
.filter-button.active { color: var(--bg); background: var(--text); }
.project-status { min-height: 4rem; padding: 1rem; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: .8rem; }
.project-status:empty { display: none; }
.spinner { display: inline-block; width: 1rem; height: 1rem; margin-right: .5rem; vertical-align: -.15rem; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.project-card { display: flex; flex-direction: column; min-height: 15rem; }
.project-card h3 { margin: 1rem 0 .65rem; }
.project-card h3 a { text-decoration: none; }
.project-card h3 a:hover { color: var(--accent-strong); }
.project-meta { display: flex; gap: 1rem; margin-top: auto; padding-top: 1.2rem; color: var(--muted); font-size: .85rem; }
.retry-button { margin-left: .6rem; }

/* 폼 오류는 입력칸 바로 아래에 표시한다. */
.contact-grid { display: grid; gap: 2.5rem; }
.contact-grid > div p:last-child { color: var(--muted); }
.contact-form { padding: 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: .35rem; font-weight: 800; }
.field input, .field textarea { width: 100%; padding: .75rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: .65rem; }
.field input:focus, .field textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.field [aria-invalid="true"] { border-color: #d93131; }
.error { display: block; min-height: 1.5em; margin-top: .2rem; color: #c72b2b; font-weight: 700; }
[data-theme="dark"] .error { color: #ff9898; }
.form-result { min-height: 1.5em; margin: 1rem 0 0; font-weight: 800; transition: color .2s ease; }
.form-result.error { color: #c72b2b; }
.form-result.success { color: var(--accent); }
[data-theme="dark"] .form-result.error { color: #ff9898; }
[data-theme="dark"] .form-result.success { color: var(--accent); }

.site-footer { padding: 2rem 0; border-top: 1px solid var(--line); }
.footer-row { display: grid; gap: .8rem; color: var(--muted); font-size: .9rem; }
.footer-row p { margin: 0; }
.footer-row div { display: flex; gap: 1rem; }
.scroll-top { position: fixed; z-index: 15; right: 1rem; bottom: 1rem; width: 3rem; height: 3rem; border: 0; border-radius: 50%; color: var(--bg); background: var(--text); box-shadow: var(--shadow); cursor: pointer; opacity: 0; pointer-events: none; transform: translateY(1rem); transition: opacity .2s ease, transform .2s ease; }
.scroll-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.reveal { opacity: 0; transform: translateY(1.5rem); transition: opacity .65s ease, transform .65s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

@keyframes spin { to { transform: rotate(360deg); } }

/* 태블릿에서는 주요 영역과 카드를 두 열로 확장한다. */
@media (min-width: 768px) {
  body.menu-open { overflow: auto; }
  .menu-toggle { display: none; }
  .nav-menu { position: static; display: flex; align-items: center; gap: .2rem; padding: 0; background: transparent; border: 0; box-shadow: none; }
  .nav-menu a { padding: .55rem .75rem; }
  .hero-grid { grid-template-columns: minmax(0, 1.7fr) minmax(16rem, .7fr); }
  .about-grid { grid-template-columns: minmax(17rem, .8fr) minmax(0, 1.2fr); gap: clamp(3rem, 8vw, 7rem); }
  .skills-grid, .projects-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading { grid-template-columns: 1fr minmax(18rem, .55fr); align-items: end; }
  .contact-grid { grid-template-columns: .8fr 1.2fr; }
  .footer-row { grid-template-columns: 1fr auto; align-items: center; }
}

/* 데스크톱에서는 카드가 세 열이 된다. */
@media (min-width: 1024px) {
  .container { width: min(calc(100% - 4rem), var(--max-width)); }
  .skills-grid, .projects-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .contact-form { padding: 2rem; }
}

/* 사용자가 움직임 축소를 요청하면 애니메이션을 최소화한다. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
}
