/*
  Homepage styles. The colour tokens match site/demos/site.css, so the page and the demo
  windows framed inside it share one palette; keep the two token sets in sync. Sections grow
  with their content and stack on narrow screens.
*/
:root {
  --page: #f5f5f7;
  --tile: #ffffff;
  --ink: #1d1d1f;
  --ink2: #424245;
  --ink3: #6e6e73;
  --line: #d2d2d7;
  --hair: #e8e8ed;
  --chip: #ececf0;
  --blue: #0066cc;
  --blue-soft: #e8f0fa;
  --blue-ink: #0b4f99;
  --green: #1d7a43;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --page: #000000;
  --tile: #1c1c1e;
  --ink: #f5f5f7;
  --ink2: #d1d1d6;
  --ink3: #a1a1a6;
  --line: #3a3a3c;
  --hair: #2c2c2e;
  --chip: #2c2c2e;
  --blue: #2997ff;
  --blue-soft: #10263f;
  --blue-ink: #8cc4ff;
  --green: #30d158;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color .5s var(--ease), color .5s var(--ease);
}
:lang(zh) h1, :lang(zh) h2 { letter-spacing: 0; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 6px; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 10; padding: .6rem 1rem; border-radius: 999px;
  background: var(--ink); color: var(--page); text-decoration: none; font-weight: 600;
}
.skip:focus { top: 1rem; }

.page { max-width: 1120px; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 1.5rem) 2.5rem; display: grid; gap: 1rem; }
.stack { display: grid; gap: inherit; }
.tile { background: var(--tile); border-radius: 24px; transition: background-color .5s var(--ease); }

/* Entrance: each tile fades up as it scrolls into view. Gated on .js so the page is fully
   visible when scripts are off. */
.js [data-reveal] { opacity: 0; transform: translateY(1.4rem); transition: opacity 1s var(--ease), transform 1s var(--ease), background-color .5s var(--ease); }
.js [data-reveal].in { opacity: 1; transform: none; }

/* ---- Hero ---- */
.hero { position: relative; padding: 3.2rem 2.8rem 2.6rem; }
.prefs { position: absolute; top: 1.4rem; right: 1.6rem; display: inline-flex; gap: .4rem; padding: .25rem; border-radius: 999px; background: var(--chip); }
.prefs button {
  display: inline-grid; place-items: center; min-width: 2.4rem; height: 2.2rem; padding: 0 .75rem; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink2); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: background-color .3s var(--ease), color .3s;
}
.prefs button:hover { background: var(--tile); color: var(--ink); }
.prefs svg { width: 1.05rem; height: 1.05rem; }
.prefs .moon { display: none; }
:root[data-theme="dark"] .prefs .sun { display: none; }
:root[data-theme="dark"] .prefs .moon { display: inline; }

h1 { margin: 0; font-size: clamp(2.4rem, 6vw, 3.6rem); line-height: 1; font-weight: 700; letter-spacing: -.04em; }
.aka { margin: .7rem 0 0; font-size: 1.1rem; line-height: 1.45; color: var(--ink2); }
.tagline { margin: 1rem 0 0; font-size: 1.15rem; line-height: 1.5; color: var(--ink2); max-width: 60ch; }
.rotator { display: inline-block; position: relative; height: 1.5em; overflow: hidden; vertical-align: bottom; cursor: pointer; color: var(--blue); font-weight: 600; }
.rotator span { display: block; white-space: nowrap; transition: transform .7s var(--ease), opacity .7s var(--ease); }
.rotator span.out { position: absolute; transform: translateY(-100%); opacity: 0; }
.rotator span.prep { transform: translateY(100%); opacity: 0; transition: none; }
.contact { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: 1.5rem; }
.btn {
  display: inline-flex; align-items: center; padding: .65rem 1.2rem; border-radius: 999px; font: inherit; font-size: 1rem; font-weight: 500;
  text-decoration: none; color: var(--ink); background: transparent; border: 1px solid var(--line); cursor: pointer;
  transition: transform .3s var(--ease), border-color .2s, opacity .2s;
}
.btn:hover { border-color: var(--ink3); transform: translateY(-1px); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { opacity: .9; }
.copy-wrap { position: relative; display: inline-flex; }
.toast {
  position: absolute; left: 0; bottom: calc(100% + .55rem); z-index: 2; white-space: nowrap; pointer-events: none;
  padding: .4rem .75rem; border-radius: 9px; font-size: .85rem; font-weight: 500; background: var(--ink); color: var(--tile);
  box-shadow: 0 6px 18px -8px rgba(0, 0, 0, .35); opacity: 0; transform: translateY(.3rem);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast::after { content: ""; position: absolute; left: 1.1rem; top: 100%; border: 5px solid transparent; border-top-color: var(--ink); }
.toast.show { opacity: 1; transform: none; }
.where { margin-left: .4rem; font-size: .95rem; color: var(--ink3); }

/* ---- Topic sections: a quiet label column, then readable content ---- */
.section { display: grid; grid-template-columns: 9.5rem 1fr; gap: 2rem; padding: 2.2rem 2.6rem; }
.section > .label { margin: 0; padding-top: .45rem; font-size: .95rem; font-weight: 600; color: var(--ink3); }
h2 { margin: 0; font-size: 1.75rem; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.section p, .section li, .project p, .project li { font-size: 1rem; line-height: 1.6; color: var(--ink2); }
.section p { margin: .35rem 0 0; max-width: 62ch; }
.headline { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .2rem 1rem; }
.when { font-size: .92rem; color: var(--ink3); white-space: nowrap; }
.bullets { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: .3rem; max-width: 66ch; }
.bullets li { position: relative; padding-left: 1.1rem; }
.bullets li::before { content: ""; position: absolute; left: .1rem; top: .7em; width: .35rem; height: .35rem; border-radius: 50%; background: var(--ink3); }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .9rem; }
.tags span { font-size: .85rem; padding: .22rem .6rem; border-radius: 7px; background: var(--chip); color: var(--ink2); }
.foot { display: flex; align-items: center; flex-wrap: wrap; gap: .8rem 1rem; margin-top: .9rem; }
.foot .tags { margin-top: 0; }
.aside-note { margin-left: auto; font-size: .92rem; color: var(--ink3); }

.facts { display: flex; flex-wrap: wrap; gap: .5rem 1.6rem; margin-top: .9rem; }
.facts div { font-size: 1rem; color: var(--ink2); }
.facts b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.sub { margin-top: 1rem !important; font-size: .9rem !important; font-weight: 600; color: var(--ink3) !important; }
.sub + .tags { margin-top: .45rem; }
.role { margin-top: .2rem !important; }

.try-proof { display: inline-flex; align-items: center; gap: .7rem; margin-left: auto; font-size: .92rem; color: var(--ink3); }
.try-proof .ok { color: var(--green); font-weight: 500; }
.pill {
  border: 0; border-radius: 999px; padding: .45rem .95rem; background: var(--ink); color: var(--page);
  font: inherit; font-size: .88rem; font-weight: 500; cursor: pointer; transition: transform .3s var(--ease), opacity .2s;
}
.pill:hover { opacity: .88; }
.pill:active { transform: scale(.96); }
.pill:disabled { opacity: .45; cursor: default; }

/* ---- Projects: a simulated running window beside the details ---- */
.projects-head { margin: 1.4rem .4rem .2rem; font-size: .95rem; font-weight: 600; color: var(--ink3); }
.project { display: grid; grid-template-columns: 55% 1fr; gap: 2.4rem; align-items: center; padding: 2.2rem 2.6rem; }
.project.chess { grid-template-columns: 47% 1fr; }
.project .eyebrow { margin: 0 0 .5rem; font-size: .92rem; font-weight: 600; color: var(--blue); }
.project p { margin: .45rem 0 0; max-width: 60ch; }
.project .bullets li { font-size: .95rem; line-height: 1.55; }
.project .try { margin-top: .7rem; font-size: .92rem; color: var(--ink3); }
.project .tags { margin-top: .8rem; }
.links-row { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; margin-top: .9rem; }
.ghlink { display: inline-flex; align-items: center; gap: .4rem; font-size: 1rem; font-weight: 500; color: var(--blue); text-decoration: none; }
.ghlink:hover { text-decoration: underline; }
.ghlink svg { width: 1.05rem; height: 1.05rem; flex: none; }
.soon { display: inline-flex; align-items: center; gap: .4rem; font-size: .95rem; color: var(--ink3); }
.frame { width: 100%; border: 0; display: block; background: transparent; }

/* ---- More + footer ---- */
.more-links { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 2rem; }
.more-links a { display: block; text-decoration: none; color: var(--ink2); font-size: .95rem; line-height: 1.5; }
.more-links b { display: block; color: var(--ink); font-size: 1.05rem; font-weight: 600; transition: color .2s; }
.more-links a:hover b { color: var(--blue); }
.funfact { margin: .4rem .4rem 0; font-size: .9rem; line-height: 1.5; color: var(--ink2); }
.funfact [data-i18n="fact.label"] { font-weight: 600; color: var(--ink3); }
.copyright { margin: .4rem .4rem 0; font-size: .85rem; color: var(--ink3); }
.footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }

/* Easter egg cheatsheet: icon button, hints open above it. */
.eggs { position: relative; flex: none; margin: 0 .4rem 0 0; }
.eggs-btn {
  display: grid; place-items: center; width: 2.2rem; height: 2.2rem; padding: 0; border: 0; border-radius: 999px;
  background: var(--chip); color: var(--ink3); cursor: pointer; transition: background-color .3s var(--ease), color .3s;
}
.eggs-btn:hover, .eggs-btn[aria-expanded="true"] { background: var(--tile); color: var(--ink); }
.eggs-btn svg { width: 1.3rem; height: 1.3rem; }
.eggs-menu {
  position: absolute; right: 0; bottom: calc(100% + .5rem); z-index: 5; width: min(20rem, calc(100vw - 2rem));
  padding: .9rem 1rem; border-radius: 16px; background: var(--tile); box-shadow: 0 0 0 1px var(--hair), 0 18px 40px -18px rgba(0, 0, 0, .45);
}
.eggs-menu[hidden] { display: none; }
.eggs-title { margin: 0 0 .4rem; font-size: .85rem; font-weight: 600; color: var(--ink3); }
.eggs-menu ul { margin: 0; padding-left: 1.1rem; display: grid; gap: .35rem; }
.eggs-menu li { font-size: .9rem; line-height: 1.45; color: var(--ink2); }
.eggs-menu .keys { white-space: nowrap; font-weight: 600; color: var(--ink); }

/* ---- Konami Code easter egg ---- */
.anteater { position: fixed; left: 0; z-index: 50; pointer-events: none; will-change: transform; }
.anteater svg { display: block; }
.anteater .f1, .anteater.step .f0 { display: none; }
.anteater.step .f1 { display: inline; }
.nom { transition: opacity .2s; }
.nom.eaten { opacity: 0; }
.egg-toast {
  position: fixed; left: 50%; bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); z-index: 51;
  padding: .6rem 1.1rem; border-radius: 999px; background: var(--ink); color: var(--tile);
  font-size: .95rem; font-weight: 600; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .45);
  opacity: 0; transform: translate(-50%, .5rem); transition: opacity .3s var(--ease), transform .3s var(--ease); pointer-events: none;
}
.egg-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- 404 ---- */
.notfound { max-width: 640px; margin: 12vh auto 0; padding: 2.6rem; text-align: left; }
.notfound .prefs { position: static; float: right; margin: 0 0 1rem 1rem; }
.notfound .code { margin: 0 0 .6rem; font-size: .95rem; font-weight: 600; color: var(--blue); }
.notfound p { margin: .7rem 0 0; font-size: 1.05rem; line-height: 1.6; color: var(--ink2); }
.notfound .contact { margin-top: 1.6rem; }

@media (max-width: 900px) {
  .project, .project.chess { grid-template-columns: 1fr; gap: 1.6rem; }
  .project .window-col { max-width: 640px; }
  .project.chess .window-col { max-width: 480px; }
}

@media (max-width: 640px) {
  .page { padding-top: 1rem; gap: .75rem; }
  .tile { border-radius: 20px; }
  .hero { padding: 4.2rem 1.25rem 1.6rem; }
  .prefs { top: 1rem; right: 1rem; }
  .aka { font-size: 1rem; }
  .tagline { font-size: 1.05rem; }
  .where { flex-basis: 100%; margin-left: 0; }
  .section { grid-template-columns: 1fr; gap: .6rem; padding: 1.5rem 1.25rem; }
  .section > .label { padding-top: 0; }
  .project, .project.chess { padding: 1.25rem; }
  h2 { font-size: 1.45rem; }
  .try-proof, .aside-note { margin-left: 0; }
  .more-links { grid-template-columns: 1fr; }
  .notfound { margin-top: 8vh; padding: 1.6rem 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-iteration-count: 1 !important; }
  .js [data-reveal] { opacity: 1; transform: none; }
}
