/* ===== 색·글꼴 변수 ===== */
:root {
  --bg: #0b0f19;
  --surface: #0f1523;
  --surface-hover: #131b2c;
  --border: #1e293b;
  --border-strong: #334155;
  --text: #cbd5e1;
  --heading: #f1f5f9;
  --muted: #8291a7;
  --indigo: #6366f1;
  --cyan: #06b6d4;
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

/* ===== 기본 초기화 ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  word-break: keep-all; /* 한글 단어 중간에서 줄바꿈 방지 */
  -webkit-font-smoothing: antialiased;
}

/* 은은한 격자 배경 (상단에서 점점 사라짐) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.35;
  mask-image: radial-gradient(ellipse 80% 50% at 50% 0%, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 50% at 50% 0%, #000 30%, transparent 80%);
}

/* 모달이 열리면 뒤 페이지 스크롤 막기 */
body:has(dialog[open]) {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3 {
  margin: 0;
  color: var(--heading);
  letter-spacing: -0.02em;
}

p {
  margin: 0 0 10px;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== 상단 바 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 25, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1040px;
  height: 56px;
  margin: 0 auto;
  padding: 0 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--heading);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--indigo), var(--cyan));
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

.topbar-contact {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.topbar-contact:hover {
  border-color: var(--border-strong);
  color: var(--heading);
}

/* ===== ① 프로필 ===== */
.profile {
  padding: 72px 0 40px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}

.profile h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.en-name {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.5em;
  letter-spacing: -0.01em;
}

.role {
  margin: 10px 0 16px;
  font-family: var(--mono);
  font-size: 0.9rem;
  background: linear-gradient(90deg, var(--indigo), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  width: fit-content;
}

.summary {
  max-width: 560px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 1.05rem;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ===== 버튼 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--heading);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.btn-primary {
  border-color: transparent;
  background: var(--heading);
  color: var(--bg);
}

.btn-primary:hover {
  border-color: transparent;
  background: #fff;
}

.btn-sm {
  margin-top: 6px;
  padding: 6px 12px;
  font-size: 0.82rem;
}

/* ===== 탭 / 필터 ===== */
.filters {
  display: flex;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 20px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter {
  flex-shrink: 0;
  padding: 6px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.filter:hover {
  color: var(--heading);
}

.filter[aria-pressed="true"] {
  background: var(--border);
  color: var(--heading);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* ===== 대시보드 그리드 ===== */
.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-bottom: 56px;
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

/* ===== 카드 ===== */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  animation: card-in 0.45s var(--ease) backwards; /* both면 호버 transform을 덮어씀 */
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease),
    transform 0.25s var(--ease);
}

.card > p:last-child {
  margin-bottom: 0;
}

/* 필터 전환 시 카드 순서대로 살짝 시차를 두고 등장 */
.card:nth-child(2) { animation-delay: 0.03s; }
.card:nth-child(3) { animation-delay: 0.06s; }
.card:nth-child(4) { animation-delay: 0.09s; }
.card:nth-child(5) { animation-delay: 0.12s; }
.card:nth-child(n+6) { animation-delay: 0.15s; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.card-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  white-space: nowrap;
}

.card-title {
  margin-bottom: 8px;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.4;
}

/* 클릭 가능한 카드: 제목 버튼이 카드 전체를 덮음 */
.is-clickable {
  cursor: pointer;
}

.is-clickable:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.card-link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: pointer;
}

.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.card-link:focus-visible {
  outline: none;
}

.card-link:focus-visible::after {
  outline: 2px solid var(--cyan);
  outline-offset: -1px;
}

.card-cta {
  margin-top: auto;
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  transition: color 0.25s var(--ease);
}

.is-clickable:hover .card-cta {
  color: var(--cyan);
}

/* 강조 테두리: 호버 시 상단에 인디고→시안 라인 */
.is-clickable::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--indigo), var(--cyan), transparent);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}

.is-clickable:hover::before {
  opacity: 1;
}

/* 통계 카드 */
.stat {
  justify-content: center;
}

.stat-num {
  margin: 0 0 6px;
  color: var(--heading);
  font-family: var(--mono);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.2;
}

/* ===== 뱃지 ===== */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.badges li {
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(11, 15, 25, 0.6);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.skill-groups {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.skill-groups h3 {
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.plain-list li {
  display: flex;
  flex-direction: column;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.plain-list li:first-child {
  padding-top: 0;
  border-top: 0;
}

.plain-list strong {
  color: var(--heading);
  font-weight: 600;
}

/* ===== ④ 비디오 카드 ===== */
.video-thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  margin: -8px -8px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.25), transparent 60%),
    radial-gradient(circle at 80% 90%, rgba(6, 182, 212, 0.18), transparent 55%),
    #0a0e17;
}

.video-thumb iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.play {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(6px);
  transition: transform 0.25s var(--ease), background 0.25s var(--ease);
}

.play::after {
  content: "";
  margin-left: 4px;
  border-style: solid;
  border-width: 9px 0 9px 15px;
  border-color: transparent transparent transparent var(--heading);
}

.video-card:hover .play {
  transform: scale(1.06);
  background: rgba(255, 255, 255, 0.1);
}

.soon {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--heading);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.video-card:hover {
  border-color: var(--border-strong);
}

/* ===== 푸터 ===== */
.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 20px;
  padding-bottom: 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.footer p {
  margin: 0;
}

#visitor-count {
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

/* ===== 모달 ===== */
.modal {
  width: min(680px, calc(100% - 32px));
  max-height: calc(100dvh - 64px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.modal[open] {
  display: flex;
  animation: modal-in 0.3s var(--ease);
}

.modal::backdrop {
  background: rgba(5, 8, 15, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade 0.3s var(--ease);
}

.modal.closing {
  animation: modal-out 0.2s ease-in forwards;
}

.modal.closing::backdrop {
  animation: fade 0.2s ease-in reverse forwards;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes modal-out {
  to { opacity: 0; transform: translateY(8px) scale(0.98); }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-body {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.modal-head h2 {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.35;
}

.modal-close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.modal-close:hover {
  border-color: var(--border-strong);
  color: var(--heading);
}

.modal-section {
  padding: 18px 0;
  border-top: 1px solid var(--border);
}

.modal-section h3 {
  margin-bottom: 8px;
  font-size: 0.98rem;
  font-weight: 600;
}

.modal-section p:last-child {
  margin-bottom: 0;
}

.modal-section ul,
.modal-section ol {
  margin: 0;
  padding-left: 20px;
}

.modal-section li {
  margin-bottom: 4px;
}

.modal-section li::marker {
  color: var(--cyan);
}

/* 아키텍처 흐름도 */
.arch {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}

.arch-node {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  text-align: center;
}

.arch-node strong {
  color: var(--heading);
  font-size: 0.88rem;
  font-weight: 600;
}

.arch-node.accent {
  border-color: rgba(99, 102, 241, 0.6);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.15);
}

.arch-tag {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.arch-link {
  position: relative;
  flex: 0.9;
  height: 1px;
  background: linear-gradient(90deg, var(--indigo), var(--cyan));
}

.arch-link span {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.65rem;
  white-space: nowrap;
}

/* 지표 표 */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 0;
}

.metrics div {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
}

.metrics dt {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.metrics dd {
  margin: 2px 0 0;
  color: var(--heading);
  font-size: 0.9rem;
  font-weight: 600;
}

.steps li strong {
  color: var(--heading);
  font-weight: 600;
}

/* ===== 태블릿 (860px 이하) ===== */
@media (max-width: 860px) {
  .dashboard {
    grid-template-columns: repeat(2, 1fr);
  }

  .span-3 {
    grid-column: span 2;
  }

  .skill-groups {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* ===== 모바일 (600px 이하) ===== */
@media (max-width: 600px) {
  .container,
  .topbar-inner {
    padding-left: 16px;
    padding-right: 16px;
  }

  .profile {
    padding: 48px 0 32px;
  }

  .dashboard {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3 {
    grid-column: auto;
  }

  .card {
    padding: 18px;
  }

  .modal {
    width: calc(100% - 20px);
    max-height: calc(100dvh - 40px);
  }

  .modal-body {
    padding: 20px;
  }

  /* 흐름도: 세로 배치 */
  .arch {
    flex-direction: column;
    align-items: stretch;
  }

  .arch-link {
    flex: none;
    width: 1px;
    height: 32px;
    margin: 0 auto;
    background: linear-gradient(var(--indigo), var(--cyan));
  }

  .arch-link span {
    left: 10px;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
  }

  .metrics {
    grid-template-columns: 1fr;
  }
}

/* ===== 움직임 줄이기 설정 존중 ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after,
  .modal::backdrop {
    animation: none !important;
    transition: none !important;
  }
}
