/* ==========================================================================
   CMU 15-445 学习站 - 仿 Berkeley CS188 / Just the Docs 风格
   ========================================================================== */

:root {
  --link-color: #2869dc;
  --link-color-hover: #1f56b8;
  --body-bg: #ffffff;
  --body-text: #111111;
  --border-color: #e6e1e8;
  --table-stripe: #f7f7f7;
  --table-border: #e6e1e8;
  --sidebar-bg: #ffffff;
  --sidebar-text: #555555;
  --sidebar-active: #2869dc;
  --header-bg: #ffffff;
  --header-text: #111111;
  --code-bg: #f5f5f5;
  --tag-bg: #eef4ff;
  --tag-text: #1f56b8;
  --sidebar-width: 264px;
  --header-height: 60px;
  --content-max-width: 900px;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji";
  --mono-stack: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background: var(--body-bg);
  color: var(--body-text);
  font-family: var(--font-stack);
  font-size: 16px;
  line-height: 1.6;
}

/* ---------- 无障碍：跳过链接 ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 8px 16px;
  background: var(--link-color);
  color: #fff;
  border-radius: 0 0 4px 0;
  font-size: 14px;
}
.skip-link:focus {
  left: 0;
}

/* ---------- 顶部导航 ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  z-index: 50;
}

.site-header .header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0 20px;
}

.site-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--header-text);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.site-title:hover {
  color: var(--link-color);
}
.site-icon {
  width: 24px;
  height: 24px;
  fill: var(--link-color);
  transition: transform 0.2s ease;
}
.site-title:hover .site-icon {
  transform: rotate(10deg);
}

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  width: 40px;
  height: 34px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.menu-toggle svg {
  width: 20px;
  height: 20px;
  fill: var(--body-text);
}

/* ---------- 布局 ---------- */
.side-bar {
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  z-index: 40;
  transition: transform 0.25s ease;
}

.side-bar nav {
  padding: 24px 0;
}

.side-bar .nav-section {
  margin-bottom: 24px;
}

.side-bar .nav-section-title {
  padding: 0 24px;
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #999;
}

/* 导航层级结构 */
.side-bar .nav-item {
  margin-bottom: 4px;
}

.side-bar .nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
}

.side-bar .nav-link .nav-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

.side-bar .nav-item-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 24px;
}

.side-bar .nav-item-toggle .nav-link {
  flex: 1;
  padding: 0;
  border-left: 3px solid transparent;
}

.side-bar .nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  width: 24px;
  height: 24px;
  cursor: pointer;
  padding: 0;
  margin-left: 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

.side-bar .nav-toggle:hover {
  background: #f0f0f0;
}

.side-bar .nav-toggle svg {
  width: 16px;
  height: 16px;
  fill: var(--sidebar-text);
  transition: transform 0.2s ease;
}

.side-bar .nav-toggle[aria-expanded="false"] svg {
  transform: rotate(-90deg);
}

.side-bar .nav-submenu {
  display: none;
  padding-left: 8px;
}

.side-bar .nav-submenu.nav-submenu-open {
  display: block;
}

.side-bar .nav-submenu .nav-link {
  display: block;
  padding: 6px 24px 6px 32px;
  font-size: 14px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.side-bar a.nav-link:hover {
  color: var(--link-color);
}

.side-bar a.nav-link.active {
  color: var(--sidebar-active);
  border-left-color: var(--sidebar-active);
  font-weight: 600;
}

.main-content {
  margin-left: var(--sidebar-width);
  padding-top: var(--header-height);
  min-height: 100vh;
}

.main-content .content-wrap {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 40px 32px 80px;
}

/* ---------- 正文标题 ---------- */
h1 {
  font-size: 30px;
  font-weight: 700;
  margin: 0 0 8px;
  line-height: 1.3;
}

h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 40px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 28px 0 8px;
}

p {
  margin: 12px 0;
}

/* ---------- 链接 ---------- */
a {
  color: var(--link-color);
  text-decoration: none;
}
a:hover {
  color: var(--link-color-hover);
  text-decoration: underline;
}

/* ---------- 公告 ---------- */
.announcements .announcement {
  border-left: 3px solid var(--link-color);
  padding: 4px 0 4px 16px;
  margin: 16px 0;
}
.announcement .ann-date {
  font-size: 13px;
  color: #777;
  font-weight: 600;
}
.announcement .ann-body {
  margin: 2px 0 0;
}

/* ---------- 表格 ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  margin: 16px 0 24px;
}

thead th {
  text-align: left;
  font-weight: 600;
  background: #efefef;
  padding: 10px 12px;
  border: 1px solid var(--table-border);
}

tbody td {
  padding: 10px 12px;
  border: 1px solid var(--table-border);
  vertical-align: top;
}

tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

tbody tr:hover {
  background: #f0f0ff;
}

td .muted {
  color: #888;
}

td.center {
  text-align: center;
}

/* 本周高亮 */
tbody tr.current-week td {
  background: #fffbe6;
}
tbody tr.current-week:hover td {
  background: #fff3b0;
}

/* ---------- 视频链接按钮 ---------- */
.video-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.video-links a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.video-links a:hover {
  text-decoration: none;
}
.video-links a svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}
.video-links .yt {
  background: #ffdfdf;
  color: #c00;
}
.video-links .yt:hover {
  background: #c00;
  color: #fff;
}
.video-links .bili {
  background: #e3f0ff;
  color: #00a1d6;
}
.video-links .bili:hover {
  background: #00a1d6;
  color: #fff;
}
.video-links .official {
  background: #eee;
  color: #555;
}
.video-links .official:hover {
  background: #555;
  color: #fff;
}

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  background: var(--link-color);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--link-color);
}
.btn:hover {
  background: var(--link-color-hover);
  text-decoration: none;
  color: #fff;
}
.btn-outline {
  background: transparent;
  color: var(--link-color);
}
.btn-outline:hover {
  background: var(--link-color);
  color: #fff;
}

/* ---------- 卡片 ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px 18px;
}
.card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}
.card .card-desc {
  margin: 0;
  font-size: 14px;
  color: #555;
}
.card .card-tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 10px;
  padding: 2px 10px;
}

/* ---------- 课程卡片 ---------- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.course-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 18px 20px;
  background: #fff;
  transition: box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
}
.course-card:hover {
  border-color: var(--link-color);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.course-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.course-head h3 {
  margin: 0;
  font-size: 18px;
}
.course-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 10px;
  padding: 2px 10px;
}
.course-tag.alt {
  background: #f0f0f0;
  color: #555;
}
.course-desc {
  margin: 0 0 10px;
  font-size: 14px;
  color: #555;
  flex: 1;
}
.course-cost {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: #333;
}
.course-cost b {
  color: #1a7f37;
}
.course-links {
  margin: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ---------- 课程目录卡片 ---------- */
.course-catalog {
  max-width: 700px;
  margin: 24px auto;
  padding: 0 16px 16px;
}
.catalog-header {
  position: relative;
  background: #3d4a6e;
  color: #fff;
  text-align: center;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: 0 6px 18px rgba(61, 74, 110, 0.22);
}
.catalog-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.hanger {
  position: absolute;
  top: 18px;
  width: 8px;
  height: 30px;
  background: #8aa4c8;
  border-radius: 4px;
}
.hanger.left { left: 28px; }
.hanger.right { right: 28px; }
.hanger::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  background: #c9d8ed;
  border-radius: 50%;
}
.catalog-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.catalog-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: 10px;
  padding: 16px 18px;
  color: #3d4a6e;
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid #e8ecf3;
}
.catalog-list .num {
  font-size: 16px;
  font-weight: 700;
  color: #6d7b9c;
  min-width: 30px;
  letter-spacing: 0.5px;
}
.catalog-list .summary .icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  background: #6d7b9c;
  border-radius: 4px;
  margin-right: 2px;
}

/* ---------- 个人简介（仿 roseruan 风格：左文 + 右图） ---------- */
.profile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 48px;
  align-items: center;
  padding: 32px 0 16px;
  margin-bottom: 24px;
  text-align: left;
}
.profile-text { min-width: 0; }
.profile-name {
  margin: 0 0 18px;
  font-size: 44px;
  line-height: 1.15;
  font-weight: 700;
  color: #1a1a1a;
}
.profile-name-accent {
  font-style: italic;
  font-weight: 700;
  background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 50%, #6d3bff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  padding-right: 4px;
}
.profile-bio {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.75;
  color: #4b5563;
}
.profile-highlight {
  background: linear-gradient(180deg, transparent 60%, rgba(217, 70, 239, 0.18) 60%);
  padding: 0 2px;
  font-weight: 600;
  color: #1a1a1a;
}
.profile-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 18px 0 14px;
}
.profile-pill {
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #1a1a1a;
  background: #f3f4f6;
  border-radius: 999px;
}
.profile-pill-arrow {
  color: #9ca3af;
  font-size: 13px;
}
.profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 22px;
}
.profile-tag {
  padding: 4px 10px;
  font-size: 12.5px;
  color: #6d28d9;
  background: #ede9fe;
  border-radius: 6px;
}
/* 教授课程（行内链接） */
.profile-course {
  text-decoration: none;
  font-size: 15px;
  color: var(--link-color, #5b5bd6);
  white-space: nowrap;
}
.profile-course:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 右侧大头像 */
.profile-photo {
  position: relative;
  width: 320px;
  height: 320px;
  border-radius: 24px;
  overflow: hidden;
  background: #e0e7ff;
  box-shadow: 0 20px 50px -12px rgba(109, 59, 255, 0.25);
  animation: photo-float 5s ease-in-out infinite;
}
.profile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 42% 30%;
  display: block;
  filter: contrast(1.05) saturate(1.1);
}
@keyframes photo-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@media (prefers-reduced-motion: reduce) {
  .profile-photo { animation: none; }
}

/* 移动端：单列堆叠 */
@media (max-width: 760px) {
  .profile { grid-template-columns: 1fr; gap: 24px; padding-top: 16px; }
  .profile-photo { width: 100%; max-width: 320px; margin: 0 auto; aspect-ratio: 1 / 1; height: auto; }
  .profile-name { font-size: 34px; }
}

/* ---------- 信息框 ---------- */
.note {
  border-left: 4px solid #e6a700;
  background: #fff8e6;
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  margin: 16px 0;
  font-size: 15px;
}
.info {
  border-left: 4px solid var(--link-color);
  background: #eef4ff;
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  margin: 16px 0;
  font-size: 15px;
}

/* ---------- 代码 ---------- */
code {
  font-family: var(--mono-stack);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ---------- 列表 ---------- */
ul, ol {
  margin: 12px 0;
  padding-left: 24px;
}
li {
  margin: 4px 0;
}

/* ---------- 页脚 ---------- */
.footer {
  margin-top: 60px;
  padding-top: 20px;
  font-size: 13px;
  color: #777;
}
.footer a {
  color: var(--link-color);
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .menu-toggle {
    display: flex;
  }
  .side-bar {
    transform: translateX(-100%);
  }
  .side-bar.open {
    transform: translateX(0);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  }
  .main-content {
    margin-left: 0;
  }
  .main-content .content-wrap {
    padding: 24px 16px 60px;
  }
  table {
    font-size: 14px;
  }
}


/* ---------- 联系卡片：公众号 + Bilibili ---------- */
.contact-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 16px;
  padding-top: 24px;
}
.contact-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: #f8f9fb;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.contact-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -8px rgba(109, 59, 255, 0.18);
  border-color: rgba(109, 59, 255, 0.3);
}
.contact-card-link:hover { text-decoration: none; }

.contact-card-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.contact-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #8b5cf6 0%, #6d3bff 100%);
  border-radius: 50%;
  box-shadow: 0 4px 10px -2px rgba(109, 59, 255, 0.35);
}
.contact-icon svg { width: 28px; height: 28px; fill: currentColor; }

.contact-info { min-width: 0; }
.contact-title {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
}
.contact-sub {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-qr {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  padding: 4px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.contact-qr img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

@media (max-width: 640px) {
  .contact-cards { grid-template-columns: 1fr; }
  .contact-sub { white-space: normal; }
}


/* ---------- 主页紧凑布局：单屏显示 ---------- */
.home-page .main-content .content-wrap {
  padding-top: 20px;
  padding-bottom: 28px;
}
.home-page .profile {
  padding: 8px 0 8px;
  margin-bottom: 8px;
  gap: 40px;
}
.home-page .profile-name {
  margin-bottom: 10px;
  font-size: 36px;
}
.home-page .profile-bio {
  margin-bottom: 12px;
  line-height: 1.65;
}

.home-page .profile-tags {
  margin-bottom: 18px;
  gap: 6px;
}
.home-page .profile-tag {
  padding: 3px 9px;
}
.home-page .profile-photo {
  width: 260px;
  height: 260px;
}
.home-page .contact-cards {
  margin-top: 4px;
  padding-top: 14px;
  gap: 16px;
}
.home-page .contact-card {
  padding: 12px 16px;
  gap: 12px;
}
.home-page .contact-qr {
  width: 60px;
  height: 60px;
}
.home-page .contact-icon {
  width: 48px;
  height: 48px;
}
.home-page .contact-icon svg { width: 26px; height: 26px; }
@media (max-width: 760px) {
  .home-page .profile-photo { width: 100%; max-width: 260px; }
}

/* 文字区块之间的空行分隔 */
.profile-gap {
  height: 15px;
}
