/* ==========================================================================
   C++ Mastery · Design Tokens & Base
   Apple-inspired design system: fluid type, soft depth, cinematic motion
   ========================================================================== */

/* 可动画的自定义属性：让进度环（conic-gradient）平滑增长 */
@property --p {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

:root {
  /* Palette — light base, true-black feature sections (Apple style) */
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #86868b;
  --paper: #ffffff;
  --paper-2: #f5f5f7;
  --paper-3: #e8e8ed;
  --line: rgba(0, 0, 0, 0.09);
  --line-strong: rgba(0, 0, 0, 0.16);

  /* Dark feature surfaces */
  --void: #000000;
  --void-2: #0a0a0c;
  --void-3: #141416;
  --void-line: rgba(255, 255, 255, 0.11);
  --on-void: #f5f5f7;
  --on-void-2: #a1a1a6;

  /* Brand */
  --blue: #0071e3;
  --blue-bright: #2997ff;
  --indigo: #5e5ce6;
  --violet: #bf5af2;
  --cyan: #5ac8fa;
  --green: #30d158;
  --amber: #ff9f0a;
  --red: #ff453a;

  --grad-signature: linear-gradient(115deg, #5ac8fa 0%, #2997ff 34%, #5e5ce6 66%, #bf5af2 100%);
  --grad-ink: linear-gradient(180deg, #1d1d1f 0%, #1d1d1f 55%, #6e6e73 100%);
  --grad-void: linear-gradient(120deg, #f5f5f7 0%, #a1a1a6 50%, #f5f5f7 100%);

  /* Type scale (fluid) */
  --f-display: clamp(2.75rem, 7.4vw, 6.5rem);
  --f-h1: clamp(2.2rem, 4.6vw, 3.9rem);
  --f-h2: clamp(1.7rem, 3.1vw, 2.75rem);
  --f-h3: clamp(1.22rem, 1.7vw, 1.7rem);
  --f-lead: clamp(1.06rem, 1.5vw, 1.42rem);
  --f-body: 1.0625rem;
  --f-sm: 0.9375rem;
  --f-xs: 0.8125rem;

  /* Space */
  --gut: clamp(1.25rem, 4.5vw, 3rem);
  --section-y: clamp(5rem, 11vw, 9.5rem);
  --max: 1180px;
  --max-wide: 1440px;

  /* Radii + depth */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-xl: 34px;
  --r-pill: 980px;
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.05), 0 6px 20px rgba(0, 0, 0, 0.05);
  --sh-2: 0 4px 12px rgba(0, 0, 0, 0.06), 0 24px 60px rgba(0, 0, 0, 0.1);
  --sh-glow: 0 18px 60px -18px rgba(41, 151, 255, 0.55);

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --nav-h: 52px;
  --font-mono: "SF Mono", "JetBrains Mono", "Cascadia Code", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Dark app theme (opt-in via data-theme="dark" on <html>) */
html[data-theme="dark"] {
  --ink: #f5f5f7;
  --ink-2: #a1a1a6;
  --ink-3: #86868b;
  --paper: #0b0b0d;
  --paper-2: #141416;
  --paper-3: #1d1d20;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.5), 0 6px 20px rgba(0, 0, 0, 0.4);
  --sh-2: 0 8px 40px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: var(--f-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, video { max-width: 100%; display: block; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.022em; line-height: 1.08; }
p { margin: 0; }
::selection { background: rgba(41, 151, 255, 0.28); }

/* ------------------------------------------------------------------ layout */
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gut); }
.wrap-wide { width: 100%; max-width: var(--max-wide); margin: 0 auto; padding: 0 var(--gut); }
.section { padding: var(--section-y) 0; position: relative; }
.center { text-align: center; }
.stack-sm > * + * { margin-top: 0.6rem; }
.stack > * + * { margin-top: 1.1rem; }
.stack-lg > * + * { margin-top: 2rem; }
.mt-l { margin-top: clamp(2.5rem, 5vw, 4.5rem); }

.eyebrow {
  font-size: var(--f-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.eyebrow.grad {
  background: var(--grad-signature);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.lead { font-size: var(--f-lead); line-height: 1.45; color: var(--ink-2); letter-spacing: -0.012em; }
.muted { color: var(--ink-2); }
.tiny { font-size: var(--f-xs); color: var(--ink-3); }
.mono { font-family: var(--font-mono); font-variant-ligatures: none; }
.grad-text {
  background: var(--grad-signature);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.ink-grad-text {
  background: var(--grad-ink);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
html[data-theme="dark"] .ink-grad-text {
  background: linear-gradient(180deg, #fff 0%, #fff 55%, #a1a1a6 100%);
  -webkit-background-clip: text; background-clip: text;
}
.void { background: var(--void); color: var(--on-void); }
.void .lead, .void .muted { color: var(--on-void-2); }
.void .eyebrow { color: #6e6e73; }
.soft { background: var(--paper-2); }

/* ---------------------------------------------------------------- buttons */
.btn {
  --btn-bg: var(--blue);
  --btn-fg: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  padding: 0.72em 1.5em;
  border: 0; border-radius: var(--r-pill);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: var(--f-sm); font-weight: 500; letter-spacing: -0.01em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out),
    background 0.25s var(--ease-io), opacity 0.2s;
}
.btn:hover { text-decoration: none; transform: translateY(-2px) scale(1.02); box-shadow: var(--sh-glow); }
.btn:active { transform: translateY(0) scale(0.99); }
.btn-lg { padding: 0.9em 1.9em; font-size: 1.0625rem; }
.btn-sm { padding: 0.5em 1em; font-size: var(--f-xs); }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--ink); border: 1px solid var(--line-strong); }
.btn-ghost:hover { box-shadow: none; background: var(--paper-2); }
.btn-soft { --btn-bg: var(--paper-2); --btn-fg: var(--ink); }
.btn-soft:hover { box-shadow: var(--sh-1); }
.btn-void { --btn-bg: #fff; --btn-fg: #000; }
.btn-link { background: none; border: 0; color: var(--blue); cursor: pointer; font-size: var(--f-sm); padding: 0; }
.btn-link:hover { text-decoration: underline; }
.void .btn-link { color: var(--blue-bright); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.chev::after { content: "›"; font-size: 1.25em; line-height: 0.8; margin-left: 0.1em; }

/* ------------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.28em 0.7em; border-radius: var(--r-pill);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.01em;
  background: var(--paper-2); color: var(--ink-2); white-space: nowrap;
}
.chip-blue { background: rgba(0, 113, 227, 0.1); color: #0066cc; }
.chip-green { background: rgba(48, 209, 88, 0.14); color: #1d7f37; }
.chip-amber { background: rgba(255, 159, 10, 0.16); color: #a8620a; }
.chip-red { background: rgba(255, 69, 58, 0.13); color: #c0291f; }
.chip-violet { background: rgba(191, 90, 242, 0.13); color: #8b32cc; }
html[data-theme="dark"] .chip-blue { color: #79b8ff; }
html[data-theme="dark"] .chip-green { color: #6ee787; }
html[data-theme="dark"] .chip-amber { color: #ffcf70; }
html[data-theme="dark"] .chip-red { color: #ff9b93; }
html[data-theme="dark"] .chip-violet { color: #d8a6ff; }

/* ------------------------------------------------------------ nav (shared) */
.nav {
  position: fixed; inset: 0 0 auto 0; height: var(--nav-h); z-index: 90;
  display: flex; align-items: center;
  background: rgba(251, 251, 253, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: background 0.4s var(--ease-io), border-color 0.4s;
}
.nav.scrolled { border-bottom-color: var(--line); }
.nav-inner { width: 100%; max-width: var(--max-wide); margin: 0 auto; padding: 0 var(--gut);
  display: flex; align-items: center; gap: 1.6rem; }
.brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 600; font-size: 0.95rem;
  color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 9px; background: var(--grad-signature);
  display: grid; place-items: center; color: #fff; font-family: var(--font-mono);
  font-size: 0.62rem; font-weight: 700; letter-spacing: -0.02em;
  box-shadow: 0 4px 14px -4px rgba(41, 151, 255, 0.7);
}
.nav-links { display: flex; gap: 1.5rem; margin-left: auto; align-items: center; }
.nav-links a {
  color: var(--ink); font-size: var(--f-xs); text-decoration: none; opacity: 0.82;
  transition: opacity 0.2s, color 0.2s;
}
.nav-links a:hover { opacity: 1; color: var(--blue); text-decoration: none; }
@media (max-width: 760px) { .nav-links .hide-sm { display: none; } }

/* --------------------------------------------------------------- utilities */
.grid { display: grid; gap: clamp(1rem, 2.2vw, 1.6rem); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 980px) { .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g-2, .g-3, .g-4 { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(1.3rem, 2.4vw, 1.9rem);
  box-shadow: var(--sh-1);
}
.card-flat { box-shadow: none; }
.void .card, .card-void {
  background: var(--void-3); border-color: var(--void-line); box-shadow: none;
}

/* Scroll reveal */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.9s var(--ease-out), transform 1s var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }
.reveal-d1 { transition-delay: 0.08s; }
.reveal-d2 { transition-delay: 0.16s; }
.reveal-d3 { transition-delay: 0.24s; }
.reveal-d4 { transition-delay: 0.32s; }
.reveal-d5 { transition-delay: 0.4s; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001s !important; }
}

/* Progress bits */
.bar { height: 6px; border-radius: 99px; background: var(--paper-3); overflow: hidden; }
html[data-theme="dark"] .bar { background: rgba(255, 255, 255, 0.1); }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--grad-signature);
  width: 0; transition: width 1.1s var(--ease-out); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.22); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.36); background-clip: content-box; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); background-clip: content-box; }

/* Footer */
.foot { background: var(--paper-2); color: var(--ink-2); font-size: var(--f-xs); padding: 2.5rem 0 3rem; }
.foot-grid { display: grid; grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr)); gap: 1.5rem; }
@media (max-width: 760px) { .foot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.foot h4 { font-size: var(--f-xs); color: var(--ink); margin-bottom: 0.7rem; }
.foot a { display: block; color: var(--ink-2); padding: 0.2rem 0; }
