/* Shared tokens + layout for the site content area (/, /decks/, /articles/).
 * Notion-style: warm paper canvas, near-black Inter type, single blue accent,
 * pill marketing CTAs and tight 8px utility buttons.
 * No webfonts (system Inter / -apple-system fallback). */

:root {
  /* Notion palette — light mode */
  --paper: #F6F5F4;            /* warm paper */
  --ink: #1A1A1A;              /* near-black */
  --ink-soft: #4B4B4B;         /* secondary text */
  --ink-muted: #6B6B6B;        /* muted / supporting copy */
  --ink-faint: #9B9B9B;        /* placeholders / metadata */
  --surface: #FFFFFF;          /* card / form surface */
  --line: #E6E6E6;             /* hairline */

  --primary: #0075DE;          /* Notion Blue — the one structural accent */
  --primary-active: #005BAB;   /* pressed */
  --secondary: #213183;        /* reserved (hero-band) */
  --on-primary: #FFFFFF;

  /* Decorative sticker palette — used only as small glyphs / category dots,
     never as structural fills. */
  --accent-sky: #62AEF0;
  --accent-purple: #D6B6F6;
  --accent-pink: #FF64C8;
  --accent-orange: #DD5B00;
  --accent-teal: #2A9D99;
  --accent-green: #1AAE39;

  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif SC", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --radius-xs: 4px;
  --radius-s: 5px;
  --radius-m: 8px;
  --radius-l: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;

  /* Shared button system tokens. Pill marketing CTA + tight 8px utility. */
  --btn-primary-bg: var(--primary);
  --btn-primary-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 117, 222, 0.18);
  --btn-secondary-bg: var(--surface);
  --btn-secondary-shadow: none;
  --ghost-line: var(--line);
  --ghost-text: var(--ink-soft);

  --ease-pop: cubic-bezier(0.22, 0.9, 0.3, 1);

  --shadow-card: 0 0 0 1px var(--line);
  --shadow-card-hover: 0 0 0 1px var(--primary), 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 117, 222, 0.10);
  --shadow-card-elev: 0 0 0 1px var(--line), 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
}

/* Dark mode: a graceful inversion of the same palette (kept light-mode
   primary). Notion marketing does not push a true dark theme, but a
   mirrored dark keeps the content area readable for users with the OS
   setting. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #191919;
    --ink: #EBEBEB;
    --ink-soft: #B5B5B5;
    --ink-muted: #8C8C8C;
    --ink-faint: #6B6B6B;
    --surface: #252525;
    --line: #303030;

    --primary: #2D8FF0;
    --primary-active: #5BA9F5;
    --secondary: #4B5BD9;

    --ghost-line: var(--line);
    --ghost-text: var(--ink-soft);

    --shadow-card: 0 0 0 1px var(--line);
    --shadow-card-hover: 0 0 0 1px var(--primary);
    --shadow-card-elev: 0 0 0 1px var(--line), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--primary); }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

/* "Skip to content" — the first keyboard stop. Off-screen until focused,
   so it never adds visual weight to sighted layouts. */
.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 1000;
  padding: 10px 18px;
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-pill);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-card-elev);
}
.skip:focus-visible {
  left: 12px;
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---- shared button system ----
   .btn           primary action (blue, pill)
   .btn-secondary secondary action (white, pill)
   .btn-ghost     quiet action (transparent, hairline border, tight utility)
   Marketing CTAs are pill; utility buttons use 8px radius per the design. */

.btn, .btn-secondary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 12px 22px;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s ease, color .15s ease,
              box-shadow .15s ease, border-color .15s ease,
              transform .12s var(--ease-pop);
}

.btn {
  background: var(--btn-primary-bg);
  color: var(--on-primary);
  box-shadow: var(--btn-primary-shadow);
}
.btn:hover { background: var(--primary-active); }
.btn:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-secondary:active { transform: scale(0.97); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--ghost-line);
  border-radius: var(--radius-m);
  color: var(--ghost-text);
  padding: 8px 14px;
  font-size: 14px;
  min-height: 36px;
  box-shadow: none;
}
.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ---- layout ---- */

/* Shared content column for listing pages (/decks/, /articles/). */
.wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 20px 96px;
}

.page {
  width: 100%;
  max-width: 1080px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: 40px 20px 72px;
  display: grid;
  gap: 32px;
  align-content: center;
}

@media (min-width: 900px) {
  .page {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: 56px;
    align-items: center;
    padding: 72px 40px 104px;
  }
}

.hero {
  display: grid;
  gap: 18px;
}

/* Display-2 (54/700/-1.875) used as the homepage hero heading.
   Tight tracking reads as confident statement, not stretched text. */
.hero-title {
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: -0.04em;
  font-size: clamp(2.25rem, 6.5vw, 3.4rem);
  line-height: 1.04;
  margin: 0;
  color: var(--ink);
  text-wrap: balance;
  max-width: 18ch;
}

.entries {
  display: grid;
  gap: 12px;
}

@media (min-width: 900px) {
  .entries { grid-column: 2; }
  .hero { grid-column: 1; }
  .page-foot { grid-column: 1 / -1; }
}

/* Notion feature-card chrome: hairline + 12px radius. Hover lifts the
   border to the single blue accent — that's the only place the accent
   appears structurally. */
.entry {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  border-radius: var(--radius-l);
  background: var(--surface);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-card);
  transition: transform .12s var(--ease-pop), box-shadow .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}

.entry:hover { box-shadow: var(--shadow-card-hover); border-color: var(--primary); }
.entry:active { transform: scale(0.99); }

.entry-text {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 4px;
}
/* Title weight 600 / 20px — the .title token (no serif; Notion is Inter-only). */
.entry-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.4;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--ink);
}

.entry-arrow {
  flex: 0 0 auto;
  color: var(--ink-faint);
  transition: transform .18s ease, color .18s ease;
}
.entry:hover .entry-arrow { color: var(--primary); transform: translateX(2px); }

/* Decorative glyphs (only place the sticker palette paints structure).
   Each entry has a 32×32 sticker-square dot in a different sticker colour. */
.entry-glyph {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: 4px;
  border-radius: var(--radius-m);
}
.entry-glyph svg { display: block; }

/* Tiny dot used as the entry identifier — sticker colour, decorative only. */
.entry-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-left: 4px;
  border-radius: var(--radius-pill);
  background: var(--accent-purple);
}
.entry-dot.game { background: var(--accent-purple); }
.entry-dot.slides { background: var(--accent-teal); }
.entry-dot.articles { background: var(--accent-orange); }
.entry-dot.videos { background: var(--accent-sky); }
.entry-dot.podcasts { background: var(--accent-pink); }
.entry-dot.research { background: var(--accent-green); }

/* ---- hero avatar (kept from prior PR: a small pixel-art GIF) ---- */

.hero-avatar {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0;
  border-radius: var(--radius-l);
  object-fit: cover;
  box-shadow: var(--shadow-card);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
}

@media (min-width: 640px) {
  .hero-avatar { width: 112px; height: 112px; }
}

@media (min-width: 900px) {
  .hero-avatar { width: 128px; height: 128px; }
}

@media (prefers-reduced-motion: reduce) {
  .entry, .btn, .btn-secondary, .btn-ghost { transition: none; }
}

/* ---- page foot ---- */

.page-foot {
  color: var(--ink-faint);
  font-size: 0.8125rem;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  text-align: left;
}

/* ---- listing pages (/decks/, /articles/) ----
   Shared timeline component: heading-1 h1, type filter pills with counts,
   year groups, and one card per entry (date · type · minutes, title,
   summary, #tags, open link). */

.listing-head {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}
/* Back link wears the shared ghost utility, aligned flush left. */
.listing-head .back {
  justify-self: start;
  margin-bottom: 20px;
}
.listing-head h1 {
  font-family: var(--sans);
  font-weight: 700;
  margin: 0;
  font-size: clamp(2rem, 5.5vw, 2.625rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--ink);
  text-wrap: balance;
}
.listing-head .meta {
  color: var(--ink-muted);
  font-size: 0.9375rem;
  margin: 0;
}

/* Type filter pills. Active pill wears the single blue, just like .btn. */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 4px;
}
.filter-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s ease, color .15s ease,
              background-color .15s ease, box-shadow .15s ease,
              transform .12s var(--ease-pop);
}
.filter-pill:hover { border-color: var(--primary); color: var(--primary); }
.filter-pill:active { transform: scale(0.97); }
.filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.filter-count {
  font-size: 0.75rem;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}

/* Year groups: heading between hairline rules. */
.tl-year-group { margin-top: 32px; }
.tl-year {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 0 20px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--ink-soft);
}
.tl-year::before,
.tl-year::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--line);
}

/* The timeline rail on the left, with one dot per card. */
.tl-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0 26px;
  position: relative;
  display: grid;
  gap: 12px;
}
.tl-list::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 14px;
  bottom: 14px;
  width: 1px;
  background: var(--line);
}
.tl-item { position: relative; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -25px;
  top: 30px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--primary);
}

/* Entry card — same chrome as .entry. */
.tl-card {
  display: grid;
  gap: 6px;
  padding: 18px 20px;
  border-radius: var(--radius-l);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: inherit;
  transition: transform .12s var(--ease-pop), box-shadow .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.tl-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-card-hover);
}
.tl-card:active { transform: scale(0.99); }
.tl-card:hover .tl-title,
.tl-card:focus-visible .tl-title { color: var(--primary); }
.tl-card:hover .tl-open { transform: translateX(2px); }

.tl-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}
.tl-dot { color: var(--ink-faint); }
.tl-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-m);
  background: rgba(0, 117, 222, 0.10);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}
.tl-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-wrap: pretty;
}
.tl-desc {
  color: var(--ink-muted);
  font-size: 0.9375rem;
  max-width: 60ch;
  text-wrap: pretty;
}
.tl-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-top: 4px;
}
.tl-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.tl-tag {
  color: var(--ink-soft);
  font-size: 0.8125rem;
}
.tl-open {
  margin-left: auto;
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .18s ease;
}

.listing-empty {
  color: var(--ink-muted);
  padding: 32px 0;
}

/* ---- video listing (/videos/) ----
   One row per video: the name, then the player. No descriptions. */
.video-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 36px;
}
.video-item {
  display: grid;
  gap: 10px;
}
.video-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}
.video-frame {
  width: 100%;
  display: block;
  border-radius: var(--radius-l);
  background: #000;
}

@media (max-width: 560px) {
  .tl-list { padding-left: 20px; }
  .tl-list::before { left: 3px; }
  .tl-item::before { left: -20px; }
  .tl-card { padding: 16px 18px; }
}

/* ---- article reader shell (/articles/<slug>/) ----
   Thin topbar (← 返回 / 在新窗打开) above a framed iframe holding the
   standalone article HTML. Individual article pages carry their own
   inline fallback for the same bar, but site.css is the canonical copy. */

body.reader {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.reader-back,
.reader-open {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .15s ease, color .15s ease;
}
.reader-back:hover,
.reader-open:hover { border-color: var(--primary); color: var(--primary); }
.reader-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 0.9375rem;
  color: var(--ink-muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.reader-body {
  flex: 1;
  display: flex;
  padding: 18px;
}
.reader-frame {
  flex: 1;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

@media (max-width: 560px) {
  .reader-body { padding: 10px; }
  .reader-title { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .filter-pill, .tl-card, .tl-open { transition: none; }
}
