/* ==========================================================================
   Sivan — 个人主页
   版式参考 egoist.dev：36rem 单栏、小型顶栏、双列项目卡片、紧凑页脚。
   排印契约：Times New Roman 承担拉丁字母与数字，宋体承担中文。
   单一杏色主题，无构建步骤与外部依赖。
   ========================================================================== */

:root {
  /* 字体栈：西文优先命中 Times，中文回落至宋体族 */
  --font-serif: "Times New Roman", "Songti SC", "STSong", "SimSun",
    "Noto Serif CJK SC", "Source Han Serif SC", serif;

  /* 杏色纸面 + 墨色 */
  --paper: #f7e5d1;
  --paper-rgb: 247, 229, 209;
  --paper-raise: #fcf1e2;
  --ink: #211a15;
  --ink-soft: #5d5045;
  --ink-faint: #6f6054;
  --rule: rgba(33, 26, 21, 0.15);
  --rule-strong: rgba(33, 26, 21, 0.34);
  --accent: #9b3a24;
  --accent-soft: rgba(155, 58, 36, 0.38);
  --selection: #efd0ae;
  --glow: rgba(155, 58, 36, 0.1);
  --shadow: rgba(33, 26, 21, 0.55);

  --measure: 36rem;
  --skill-card-width: min(263px, calc(100vw - 120px));
  --skill-gap: 10px;
  --skill-step: calc(var(--skill-card-width) + var(--skill-gap));
  --skill-view: min(536px, calc(100vw - 40px));
  --skill-center: calc((var(--skill-view) - var(--skill-card-width)) / 2);
  --skill-fade: 18px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

html[data-theme="dark"] {
  --paper: #17130f;
  --paper-rgb: 23, 19, 15;
  --paper-raise: #211b16;
  --ink: #ece4d8;
  --ink-soft: #b5a898;
  --ink-faint: #8c7f70;
  --rule: rgba(236, 228, 216, 0.16);
  --rule-strong: rgba(236, 228, 216, 0.34);
  --accent: #d9855f;
  --accent-soft: rgba(217, 133, 95, 0.42);
  --selection: #3a2f26;
  --glow: rgba(217, 133, 95, 0.16);
  --shadow: rgba(0, 0, 0, 0.55);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  color-scheme: light;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.7;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  hanging-punctuation: first last;
}

::selection {
  background-color: var(--selection);
  color: var(--ink);
}

.page {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding: 0 20px 64px;
}

.skip-link {
  position: absolute;
  top: 0;
  left: -9999px;
  z-index: 30;
  padding: 10px 16px;
  background-color: var(--ink);
  color: var(--paper);
  text-decoration: none;
}

.skip-link:focus {
  top: 16px;
  left: 16px;
}

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

/* --------------------------------------------------------------------------
   顶栏：小型字标 + 稀疏导航
   -------------------------------------------------------------------------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  flex: none;
  background-color: rgba(var(--paper-rgb), 0.92);
  border-bottom: 1px solid transparent;
  transition: border-color 320ms var(--ease);
}

.masthead.is-scrolled {
  border-bottom-color: var(--rule);
}

@supports ((backdrop-filter: blur(1px)) or
  (-webkit-backdrop-filter: blur(1px))) {
  .masthead {
    background-color: rgba(var(--paper-rgb), 0.64);
    -webkit-backdrop-filter: blur(18px) saturate(1.15);
    backdrop-filter: blur(18px) saturate(1.15);
  }
}

.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding: 16px 20px;
}

.wordmark {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.wordmark a {
  color: var(--ink);
  text-decoration: none;
}

.wordmark-initial {
  color: var(--accent);
}

.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 0.8125rem;
  color: var(--ink-faint);
}

.nav a {
  color: inherit;
  text-decoration: none;
  transition: color 180ms var(--ease);
}

.nav a:hover,
.nav a:focus-visible {
  color: var(--ink);
}

.nav .github-link {
  display: flex;
  width: 18px;
  height: 18px;
  color: var(--ink-faint);
}

.nav .github-link svg {
  width: 100%;
  height: 100%;
}

.nav .github-link:hover,
.nav .github-link:focus-visible {
  color: var(--ink);
}

.nav .theme-toggle {
  display: flex;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: color 180ms var(--ease);
}

.nav .theme-toggle svg {
  display: block;
  width: 100%;
  height: 100%;
}

.nav .theme-toggle:hover,
.nav .theme-toggle:focus-visible {
  color: var(--ink);
}

.nav .theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] .nav .theme-toggle .icon-sun {
  display: block;
}

html[data-theme="dark"] .nav .theme-toggle .icon-moon {
  display: none;
}

/* --------------------------------------------------------------------------
   引文与项目
   -------------------------------------------------------------------------- */

main {
  flex: 1;
  margin-top: clamp(40px, 5vw, 64px);
}

.verse {
  max-width: 30rem;
  margin: 0;
  padding-left: 20px;
  border-left: 1px solid var(--rule-strong);
  font-family: "Times New Roman", Times, serif;
  font-size: clamp(1rem, 1.8vw, 1.125rem);
  font-style: italic;
  line-height: 1.75;
  text-wrap: pretty;
}

.verse p {
  margin: 0 0 0.45em;
}

.verse p:last-of-type {
  margin-bottom: 0;
}

.verse cite {
  display: block;
  margin-top: 16px;
  color: var(--ink-faint);
  font-family: "Times New Roman", Times, serif;
  font-size: 0.6875rem;
  font-style: normal;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.projects {
  margin-top: 64px;
}

.section-title {
  margin: 0 0 14px;
  color: var(--ink-faint);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.skills {
  margin-top: 64px;
}

.skills .section-title {
  margin-bottom: 18px;
}

.skill-carousel {
  position: relative;
  width: 100%;
  margin-block: -6px;
  padding-block: 6px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 var(--skill-fade),
    #000 calc(100% - var(--skill-fade)),
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 var(--skill-fade),
    #000 calc(100% - var(--skill-fade)),
    transparent 100%
  );
}

.skill-track {
  display: flex;
  width: max-content;
  transform: translateX(
    calc(var(--skill-center) - 3 * var(--skill-step))
  );
  transition: transform 600ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.skill-track.is-resetting {
  transition: none;
}

.skill-set {
  display: flex;
  gap: var(--skill-gap);
  padding-right: var(--skill-gap);
}

.skill-card {
  flex: none;
  width: var(--skill-card-width);
}


.project-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  --x: 50%;
  --y: 35%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background-color: var(--paper-raise);
  color: inherit;
  text-decoration: none;
  transition: transform 480ms cubic-bezier(0.2, 0.8, 0.2, 1.2),
    border-color 300ms var(--ease), box-shadow 480ms var(--ease);
}

.project-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(
    180px circle at var(--x) var(--y),
    var(--glow),
    transparent 70%
  );
  opacity: 0;
  transition: opacity 400ms var(--ease);
  pointer-events: none;
}

@media (hover: hover) {
  .project-card:hover,
  .project-card:focus-visible {
    transform: translateY(-3px) scale(1.01);
    border-color: var(--accent-soft);
    box-shadow: 0 18px 30px -24px var(--shadow);
  }

  .project-card:hover::before,
  .project-card:focus-visible::before {
    opacity: 1;
  }

  .project-card:hover .project-icon,
  .project-card:focus-visible .project-icon {
    transform: translateY(-2px) rotate(-3deg) scale(1.05);
  }
}

.project-icon {
  display: block;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  transform-origin: center;
  transition: transform 480ms cubic-bezier(0.2, 0.8, 0.2, 1.2);
}

.project-icon-mark {
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  background-color: var(--paper);
  color: var(--ink-soft);
}

.project-icon-mark svg {
  width: 17px;
  height: 17px;
}

.project-card:hover .project-icon {
  transform: translateY(-1px) scale(1.03);
}

.project-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.project-name {
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.project-desc {
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.65;
  text-wrap: pretty;
}

/* --------------------------------------------------------------------------
   页脚
   -------------------------------------------------------------------------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 10px 20px;
  margin-top: 112px;
  color: var(--ink-faint);
  font-size: 0.8125rem;
  text-align: center;
}

.foot p {
  margin: 0;
}

/* --------------------------------------------------------------------------
   入场：默认可见，仅在 JS 可用时隐藏后揭示
   -------------------------------------------------------------------------- */

.reveal {
  opacity: 1;
  transform: none;
}

.js .reveal {
  opacity: 0;
  transform: translateY(10px);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
  transition: opacity 600ms var(--ease), transform 600ms var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .js .reveal,
  .js .reveal.is-visible {
    opacity: 1;
    transform: none;
    transition: none;
  }


}

/* --------------------------------------------------------------------------
   宽屏：项目卡片改为双列纵向布局
   -------------------------------------------------------------------------- */

@media (min-width: 640px) {
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  :root {
    --skill-card-width: 263px;
    --skill-view: 536px;
    --skill-fade: 40px;
  }

  .project-card {
    flex-direction: column;
    gap: 14px;
    min-height: 152px;
    padding: 16px;
  }
}

/* --------------------------------------------------------------------------
   打印
   -------------------------------------------------------------------------- */

@media print {
  :root,
  html[data-theme="dark"] {
    --paper: #fff;
    --paper-raise: #fff;
    --paper-rgb: 255, 255, 255;
    --ink: #000;
    --ink-soft: #333;
    --ink-faint: #555;
    --rule: rgba(0, 0, 0, 0.2);
    --rule-strong: rgba(0, 0, 0, 0.4);
    --accent: #000;
    --accent-soft: rgba(0, 0, 0, 0.3);
    --selection: #fff;
    --glow: transparent;
    --shadow: transparent;
  }

  .page {
    display: block;
    min-height: 0;
  }

  .masthead {
    position: static;
    background: none;
    border-bottom: 0;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .skip-link,
  .nav {
    display: none;
  }

  .js .reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  .project-card {
    break-inside: avoid;
  }

  .skill-carousel {
    width: 100%;
    margin: 0;
    overflow: visible;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .skill-track {
    display: block;
    width: auto;
    transition: none;
    transform: none !important;
  }

  .skill-set {
    flex-wrap: wrap;
    gap: 10px;
    padding-right: 0;
  }

  .skill-set[aria-hidden="true"] {
    display: none;
  }

}
