/* ==========================================================================
   Debian 中文社区 — base.css
   月白的纸、黛色的墨、Debian 红的印泥。
   令牌 / 字体 / 重置 / 页头 / 导航 / 页脚 / 按钮 / 正文排版
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 字体：标题用霞鹜文楷子集（更名为 DCN Kai，见 fonts/OFL.txt）
   -------------------------------------------------------------------------- */
@font-face {
  font-family: "DCN Kai";
  src: url("../fonts/dcn-kai-subset.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   2. 设计令牌
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* 印泥：Debian 红 */
  --debian: #d70a53;        /* 印章、大字 */
  --debian-ink: #b0003a;    /* 链接、正文中的红 */
  --debian-wash: #fbe7ee;   /* 淡红底 */
  /* 竹青：黄历中的「宜」 */
  --qing: #24704f;
  --qing-wash: #e3f1ea;

  /* 纸与墨 */
  --paper: #eef2f1;         /* 月白：页面底色 */
  --paper-deep: #e2e8e7;    /* 页脚、分区 */
  --surface: #fbfcfc;       /* 素纸：卡片 */
  --ink: #1b2430;           /* 黛：正文 */
  --ink-2: #4d5964;         /* 次要文字 */
  --ink-3: #616d76;         /* 注释 */
  --rule: #d3dbda;          /* 细线 */
  --rule-strong: #b4bfbe;

  /* 夜色色块（Hello 区、代码块） */
  --night: #1b2430;
  --night-ink: #eef2f1;
  --night-ink-2: #a9b6bb;
  --night-accent: #ff8fae;
  --hello-bg: #1b2430;

  --ring: #d70a53;
  --shadow-paper: 0 1px 0 rgba(27, 36, 48, 0.04), 0 10px 30px -12px rgba(27, 36, 48, 0.22);
  --shadow-lift: 0 1px 0 rgba(27, 36, 48, 0.04), 0 16px 34px -14px rgba(27, 36, 48, 0.3);
  --header-bg: rgba(238, 242, 241, 0.86);

  /* 字体 */
  --font-display: "DCN Kai", "LXGW WenKai", "LXGW WenKai Screen", "Kaiti SC",
    "STKaiti", "KaiTi", "AR PL UKai CN", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "HarmonyOS Sans SC", "MiSans", "Hiragino Sans GB", "Noto Sans SC",
    "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei",
    "WenQuanYi Micro Hei", sans-serif;
  --font-mono: "Sarasa Mono SC", "JetBrains Mono", "Cascadia Code", ui-monospace,
    "SF Mono", Menlo, Consolas, "Noto Sans Mono CJK SC", "DejaVu Sans Mono",
    monospace;

  /* 尺寸 */
  --container: 1180px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --header-height: 68px;

  /* 动效 */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --fast: 160ms var(--ease);
  --base: 260ms var(--ease);
}

/* 夜间：玄青的夜，月白的字 */
:root[data-theme="dark"] {
  color-scheme: dark;

  --debian: #e8255f;
  --debian-ink: #ff7a9c;
  --debian-wash: rgba(255, 79, 128, 0.12);
  --qing: #5fc49a;
  --qing-wash: rgba(95, 196, 154, 0.12);

  --paper: #101418;
  --paper-deep: #0b0e11;
  --surface: #182027;
  --ink: #e4eae9;
  --ink-2: #a4b0b3;
  --ink-3: #85919a;
  --rule: #263039;
  --rule-strong: #36424c;

  --night: #0b0e11;
  --night-ink: #e4eae9;
  --night-ink-2: #a4b0b3;
  --night-accent: #ff8fae;
  --hello-bg: #1d1219;

  --ring: #ff7a9c;
  --shadow-paper: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 14px 34px -14px rgba(0, 0, 0, 0.7);
  --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 18px 40px -14px rgba(0, 0, 0, 0.8);
  --header-bg: rgba(16, 20, 24, 0.86);
}

/* 无 JS 时跟随系统 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;

    --debian: #e8255f;
    --debian-ink: #ff7a9c;
    --debian-wash: rgba(255, 79, 128, 0.12);
    --qing: #5fc49a;
    --qing-wash: rgba(95, 196, 154, 0.12);

    --paper: #101418;
    --paper-deep: #0b0e11;
    --surface: #182027;
    --ink: #e4eae9;
    --ink-2: #a4b0b3;
    --ink-3: #85919a;
    --rule: #263039;
    --rule-strong: #36424c;

    --night: #0b0e11;
    --night-ink: #e4eae9;
    --night-ink-2: #a4b0b3;
    --night-accent: #ff8fae;
    --hello-bg: #1d1219;

    --ring: #ff7a9c;
    --shadow-paper: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 14px 34px -14px rgba(0, 0, 0, 0.7);
    --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 18px 40px -14px rgba(0, 0, 0, 0.8);
    --header-bg: rgba(16, 20, 24, 0.86);
  }
}

/* --------------------------------------------------------------------------
   3. 重置
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--ink);
  background-color: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--debian-ink);
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color var(--fast), text-decoration-color var(--fast);
}

a:hover {
  text-decoration-color: currentColor;
}

::selection {
  background: var(--debian);
  color: #fff;
}

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

code,
kbd,
pre {
  font-family: var(--font-mono);
}

code,
kbd {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  font-size: 0.88em;
}

kbd {
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  background: var(--surface);
}

/* --------------------------------------------------------------------------
   4. 布局与工具类
   -------------------------------------------------------------------------- */
main {
  flex: 1 0 auto;
}

.container,
.section-inner {
  width: min(var(--container), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

.visually-hidden {
  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: absolute;
  top: -4rem;
  left: 1rem;
  z-index: 200;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--debian-ink);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: top var(--fast);
}

.skip-link:focus {
  top: 1rem;
}

/* 旧页面（软件源）沿用的响应式工具类 */
.d-flex { display: flex; }
.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }

@media (max-width: 768px) {
  .flex-column-sm-down { flex-direction: column; }
  .hidden-sm-down { display: none !important; }
}

@media (max-width: 544px) {
  .hidden-xs-down { display: none !important; }
}

@media (min-width: 769px) {
  .hidden-md-up { display: none !important; }
}

/* --------------------------------------------------------------------------
   5. 页头
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--rule);
}

.header-inner {
  width: min(var(--container), 100% - 2 * var(--gutter));
  margin-inline: auto;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover {
  color: var(--ink);
}

.brand-seal {
  width: 36px;
  height: 36px;
  transform: rotate(-4deg);
  transition: transform var(--base);
}

.brand:hover .brand-seal {
  transform: rotate(0deg) scale(1.04);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--ink-2);
  transition: background var(--fast), color var(--fast);
}

.icon-button:hover {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--ink);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

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

.menu-toggle {
  display: none;
}

.menu-icon,
.menu-icon::before,
.menu-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform var(--base), background var(--base);
}

.menu-icon {
  position: relative;
}

.menu-icon::before,
.menu-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-icon::before { top: -6px; }
.menu-icon::after { top: 6px; }

.site-header.is-nav-open .menu-icon {
  background: transparent;
}

.site-header.is-nav-open .menu-icon::before {
  transform: translateY(6px) rotate(45deg);
}

.site-header.is-nav-open .menu-icon::after {
  transform: translateY(-6px) rotate(-45deg);
}

/* --------------------------------------------------------------------------
   6. 导航
   -------------------------------------------------------------------------- */
.site-nav {
  flex: 1;
  min-width: 0;
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-list {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list-side {
  margin-left: auto;
}

.nav-list a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 0.95rem;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--fast), background var(--fast);
}

.nav-list a:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}

/* 当前页：一枚小小的红色印点 */
.nav-list .active > a,
.nav-list a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
}

.nav-list .active > a::after,
.nav-list a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0.15rem;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 1px;
  background: var(--debian);
  transform: rotate(45deg);
}

/* --------------------------------------------------------------------------
   7. 按钮
   -------------------------------------------------------------------------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.9rem;
  padding: 0.6rem 1.35rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: transform var(--fast), box-shadow var(--fast), background var(--fast),
    color var(--fast), border-color var(--fast);
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button-primary {
  background: var(--debian-ink);
  color: #fff;
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--debian) 80%, transparent);
}

.button-primary:hover {
  background: color-mix(in srgb, var(--debian-ink) 86%, #000);
  color: #fff;
}

:root[data-theme="dark"] .button-primary {
  background: var(--debian-ink);
  color: #16070c;
}

:root[data-theme="dark"] .button-primary:hover {
  background: color-mix(in srgb, var(--debian-ink) 85%, #fff);
  color: #16070c;
}

.button-ghost {
  border-color: var(--rule-strong);
  background: transparent;
  color: var(--ink);
}

.button-ghost:hover {
  border-color: var(--ink);
  color: var(--ink);
}

/* --------------------------------------------------------------------------
   8. 页脚
   -------------------------------------------------------------------------- */
.site-footer {
  flex-shrink: 0;
  background: var(--paper-deep);
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 0.9rem;
}

.footer-inner {
  width: min(var(--container), 100% - 2 * var(--gutter));
  margin-inline: auto;
  padding-block: clamp(2.5rem, 6vw, 4rem) 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 2.5rem;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.35rem;
  text-decoration: none;
}

.footer-brand:hover {
  color: var(--ink);
}

.footer-brand img {
  width: 40px;
  height: 40px;
  transform: rotate(-4deg);
}

.footer-about p {
  max-width: 22em;
  margin-top: 0.75rem;
}

.footer-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
}

.footer-col h2 {
  margin-bottom: 0.6rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
}

.footer-col ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-col li + li {
  margin-top: 0.3rem;
}

.footer-col a {
  color: var(--ink-2);
  text-decoration: none;
}

.footer-col a:hover {
  color: var(--debian-ink);
  text-decoration: underline;
}

.footer-legal {
  width: min(var(--container), 100% - 2 * var(--gutter));
  margin-inline: auto;
  padding-block: 1.25rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--rule);
  color: var(--ink-3);
  font-size: 0.8rem;
  line-height: 1.7;
}

.footer-legal p + p {
  margin-top: 0.25rem;
}

.footer-legal a {
  color: inherit;
}

.footer-legal a:hover {
  color: var(--debian-ink);
}

/* --------------------------------------------------------------------------
   9. 正文排版（隐私政策等文档页）
   -------------------------------------------------------------------------- */
h1,
h2,
h3,
h4 {
  color: var(--ink);
  line-height: 1.3;
  text-wrap: balance;
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 500;
}

h3,
h4 {
  font-weight: 700;
}

.prose {
  width: min(44rem, 100% - 2 * var(--gutter));
  margin-inline: auto;
  padding-block: clamp(2.5rem, 7vw, 5rem);
}

.prose-kicker {
  color: var(--debian-ink);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.prose h1 {
  margin: 0.4rem 0 1.5rem;
  font-size: clamp(2.2rem, 5vw, 3.2rem);
}

.prose h2 {
  margin: 2.5rem 0 1rem;
  font-size: 1.6rem;
}

.prose p,
.prose li {
  color: var(--ink);
}

.prose > ol {
  counter-reset: clause;
  margin: 0;
  padding: 0;
  list-style: none;
}

.prose > ol > li {
  counter-increment: clause;
  position: relative;
  padding: 0.9rem 0 0.9rem 3rem;
  border-top: 1px solid var(--rule);
}

.prose > ol > li::before {
  content: counter(clause);
  position: absolute;
  left: 0;
  top: 0.85rem;
  width: 2rem;
  color: var(--debian-ink);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-align: right;
}

.prose ul {
  margin-top: 0.4rem;
  padding-left: 1.2em;
}

.prose ul li::marker {
  color: var(--ink-3);
}

.prose-note {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   10. 响应式：窄屏折叠导航
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .menu-toggle {
    display: inline-flex;
  }

  .header-actions {
    margin-left: auto;
  }

  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: grid;
    grid-template-rows: 0fr;
    background: var(--paper);
    border-bottom: 1px solid transparent;
    transition: grid-template-rows var(--base), border-color var(--base);
  }

  .site-header.is-nav-open .site-nav {
    grid-template-rows: 1fr;
    border-bottom-color: var(--rule);
    box-shadow: 0 18px 30px -20px rgba(0, 0, 0, 0.35);
  }

  .nav-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    min-height: 0;
    overflow: hidden;
    visibility: hidden;
    transition: visibility 0s linear 260ms;
  }

  .site-header.is-nav-open .nav-inner {
    visibility: visible;
    transition-delay: 0s;
  }

  .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: min(var(--container), 100% - 2 * var(--gutter));
    margin-inline: auto;
  }

  .nav-list-main {
    padding-top: 0.5rem;
  }

  .nav-list-side {
    margin-left: auto;
    padding-bottom: 0.75rem;
  }

  .nav-list-side:not(:empty) {
    border-top: 1px solid var(--rule);
  }

  .nav-list a {
    display: flex;
    min-height: 3rem;
    padding-inline: 0.25rem;
    border-radius: 0;
    font-size: 1.05rem;
  }

  .nav-list a:hover {
    background: transparent;
    color: var(--debian-ink);
  }

  .nav-list .active > a::after,
  .nav-list a[aria-current="page"]::after {
    position: static;
    margin-left: 0.6rem;
  }

  .footer-inner {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  .brand-name {
    font-size: 1.15rem;
  }

  .footer-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* --------------------------------------------------------------------------
   11. 动效与可访问性偏好
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --rule: var(--rule-strong);
    --ink-2: var(--ink);
    --ink-3: var(--ink);
  }
}

@media print {
  .site-header,
  .site-footer,
  .almanac-actions {
    display: none;
  }
}
