/* ==========================================================================
   Learning Analytics Tools — 每週頁面（也給 404 用）
   和首頁同一套風格：黑白為主、琥珀色點綴、影片放在一段膠捲裡。
   一週只有一頁：標題、影片、片段、幾則重點，不再往下分頁。
   ========================================================================== */
:root {
  --bg: #ebe9e4;
  --ink: #111111;
  --ink-2: #4a4843;
  --ink-3: #7a776f;
  --line: rgba(17, 17, 17, .14);
  --btn: rgba(17, 17, 17, .06);
  --btn-hover: rgba(17, 17, 17, .12);
  --accent: #a36500;
  --film: #0d0c0b;
  --hole: #ebe9e4;

  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --gutter: clamp(16px, 4vw, 44px);
  --wide: 72rem;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070707; --ink: #f1efe9; --ink-2: #b9b6ae; --ink-3: #85827b;
    --line: rgba(241, 239, 233, .16); --btn: rgba(241, 239, 233, .07); --btn-hover: rgba(241, 239, 233, .14);
    --accent: #f0b545; --film: #151412; --hole: #d9d6ce;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #070707; --ink: #f1efe9; --ink-2: #b9b6ae; --ink-3: #85827b;
  --line: rgba(241, 239, 233, .16); --btn: rgba(241, 239, 233, .07); --btn-hover: rgba(241, 239, 233, .14);
  --accent: #f0b545; --film: #151412; --hole: #d9d6ce;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.75;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, p, ol { margin: 0; }
code { font-family: var(--font-mono); font-size: .9em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }

/* 片基的顆粒感（靜態） */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 30; pointer-events: none; opacity: .06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1.4 -.2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page { width: 100%; max-width: var(--wide); margin-inline: auto; padding: 0 var(--gutter) 4rem; }

/* ---------- 頂列（和首頁一樣） ---------- */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding-top: max(14px, env(safe-area-inset-top)); }
.brand { display: flex; flex-direction: column; gap: .1rem; text-decoration: none; min-width: 0; padding-top: .35rem; }
.brand-name { font-size: 1.02rem; font-weight: 700; line-height: 1.3; }
.brand-sub { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .08em; color: var(--ink-3); }
.brand:hover .brand-name { text-decoration: underline; text-underline-offset: .2em; }
.pill {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  height: 2.5rem; min-width: 2.5rem; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--btn); font-size: .86rem; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .2s;
}
.pill:hover { background: var(--btn-hover); }
.pill svg { width: 1.05rem; height: 1.05rem; flex: none; }
.pill.icon-only { width: 2.5rem; padding: 0; }
.pill.icon-only span { display: none; }
.pill.solid { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- 標題 ---------- */
.head { padding-block: clamp(2.2rem, 7vw, 4.5rem) clamp(1.4rem, 3vw, 2rem); display: flex; flex-direction: column; gap: .7rem; max-width: 46rem; }
.kicker { display: flex; align-items: center; gap: .55rem; font-family: var(--font-mono); font-size: .76rem; font-weight: 700; letter-spacing: .14em; color: var(--ink-2); }
.kicker .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); flex: none; }
.head h1 { font-size: clamp(2rem, 5.2vw, 3.6rem); font-weight: 700; line-height: 1.14; letter-spacing: .005em; text-wrap: balance; }
.head .lede { font-size: clamp(1.02rem, 1.6vw, 1.15rem); color: var(--ink-2); line-height: 1.75; text-wrap: pretty; }

/* ---------- 影片：放在一段膠捲裡 ---------- */
.film {
  position: relative; background: var(--film); border-radius: 14px;
  padding: clamp(26px, 3.4vw, 40px) clamp(10px, 1.6vw, 18px);
}
.film::before, .film::after {
  content: ""; position: absolute; left: clamp(10px, 1.6vw, 18px); right: clamp(10px, 1.6vw, 18px); height: clamp(8px, 1vw, 12px);
  background: repeating-linear-gradient(90deg, var(--hole) 0 clamp(10px, 1.3vw, 16px), transparent 0 clamp(20px, 2.6vw, 32px));
  border-radius: 2px; opacity: .92;
}
.film::before { top: clamp(9px, 1.2vw, 14px); }
.film::after { bottom: clamp(9px, 1.2vw, 14px); }
.player { position: relative; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: #000; }
.player video { display: block; width: 100%; height: 100%; background: #000; }

/* 片段：影片下面一條時間軸，點了直接跳過去 */
.chapters { list-style: none; margin: 0; padding: 1.1rem 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .2rem 1rem; }
.chapters button {
  appearance: none; width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  padding: .7rem 0 .55rem; border: 0; border-top: 2px solid var(--line); background: none; cursor: pointer; text-align: left;
  transition: border-color .2s;
}
.chapters .k { font-family: var(--font-mono); font-size: .74rem; font-weight: 700; color: var(--ink-3); letter-spacing: .06em; }
.chapters .t { font-size: .95rem; font-weight: 700; color: var(--ink-2); line-height: 1.45; }
.chapters button:hover { border-top-color: var(--ink-3); }
.chapters button:hover .t { color: var(--ink); }
.chapters button[aria-current="true"] { border-top-color: var(--accent); }
.chapters button[aria-current="true"] .t { color: var(--ink); }
.chapters button[aria-current="true"] .k { color: var(--accent); }

/* ---------- 重點：幾則短文字，不加小標題 ---------- */
.points { list-style: none; padding: clamp(2.4rem, 6vw, 4rem) 0 0; margin: 0; counter-reset: p; display: flex; flex-direction: column; max-width: 50rem; }
.points li {
  counter-increment: p; display: grid; grid-template-columns: 4.2rem minmax(0, 1fr); gap: 1rem; align-items: baseline;
  padding: 1.3rem 0; border-top: 1px solid var(--line);
}
.points li:last-child { border-bottom: 1px solid var(--line); }
.points li::before { content: counter(p, decimal-leading-zero); font-family: var(--font-mono); font-weight: 700; font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1; color: var(--ink-3); letter-spacing: -.02em; }
.points p { font-size: clamp(1.02rem, 1.7vw, 1.14rem); line-height: 1.8; text-wrap: pretty; }
.points strong { font-weight: 700; }
.points code { background: var(--btn); border-radius: 6px; padding: .05em .4em; white-space: nowrap; }

/* ---------- 上一週／下一週（course.js 產生內容） ---------- */
.pager { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: clamp(2.6rem, 6vw, 4rem); font-size: .9rem; }
.pager a, .pager span { font-weight: 700; text-decoration: none; }
.pager a:hover { text-decoration: underline; text-underline-offset: .2em; }
.pager span { color: var(--ink-3); font-weight: 500; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem 1.2rem; padding-top: 2.4rem; font-size: .78rem; color: var(--ink-3); }
.foot a { color: var(--ink-3); }

@media (max-width: 760px) {
  .chapters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .points li { grid-template-columns: 2.8rem minmax(0, 1fr); gap: .6rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .001ms !important; }
}
