/* ============================================================
   editorial-tech-doc — styles.css
   NCKU CIS palette · Noto type system · clean editorial structure
   ============================================================ */

:root {
  /* Backgrounds */
  --bg: #FFFFFF;                  /* page background — white, matches web.ncku.edu.tw */
  --surface: #F5F5F6;             /* code blocks, callout cards (light silver tint) */
  --surface-alt: #FAFAFA;         /* alternating table rows */

  /* Text */
  --ink: #2A2A2A;                 /* primary headings, near-black */
  --ink-soft: #555559;            /* NCKU Dark Grey 11C — body text */
  --ink-muted: #8A8A8E;           /* captions, footnotes (silver tint) */

  /* Borders */
  --border: #E5E5E7;              /* subtle dividers (silver tint) */
  --border-strong: #A6A9AB;       /* NCKU Silver 877C — table borders */

  /* NCKU CIS palette — accents */
  --ncku-red: #A31F34;            /* PANTONE 201C — primary accent */
  --ncku-gold: #8C6E4A;           /* PANTONE 874C — supporting */
  --ncku-silver: #A6A9AB;         /* PANTONE 877C — supporting */
  --ncku-dark-grey: #555559;      /* PANTONE Cool Gray 11C */

  /* International additions (English-facing only) */
  --ncku-maroon: #420A15;         /* PANTONE 4102C — deeper red for emphasis */

  /* Semantic accents */
  --accent: var(--ncku-red);                /* primary — links, code rule, progress bar */
  --accent-tip: var(--ncku-gold);           /* tip / supplementary callout */
  --accent-warn: var(--ncku-red);           /* warning callout */
  --accent-pitfall: var(--ncku-maroon);     /* don't / pitfall callout */

  /* Type stacks — Noto family per NCKU CIS */
  --font-sans:  'Noto Sans TC', 'Noto Sans', 'PingFang TC',
                'Microsoft JhengHei', system-ui, sans-serif;
  --font-serif: 'Noto Serif TC', 'Noto Serif', 'PMingLiU',
                Georgia, serif;
  --font-mono:  'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 1.5rem;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.7;
  color: var(--ink-soft);            /* body uses NCKU Dark Grey */
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { text-decoration-thickness: 2px; }

/* ─── Top utility strip (NCKU brand touch — echoes live site) ── */
.utility-strip {
  height: 4px;
  background: var(--ncku-gold);
  width: 100%;
}

/* ─── Reading progress bar ─────────────────────────────────── */
.progress {
  position: fixed; top: 4px; left: 0;
  height: 2px; background: var(--accent);
  width: 0; z-index: 100;
  transition: width 0.1s linear;
}

/* ─── Header ───────────────────────────────────────────────── */
.page-header {
  max-width: 64rem;
  margin: 4rem auto 2rem;
  padding: 0 2rem;
}
/* h1: NCKU Light-weight headline — intentional, on-brand */
.page-header h1 {
  font-family: var(--font-sans);
  font-size: 3rem;
  font-weight: 300;                /* Noto Sans Light per NCKU CIS */
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
  color: var(--ink);
}
.page-header .subtitle {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--ink-soft);
  margin: 0 0 1rem;
}
.page-header .byline {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--ink-muted);
  margin: 0;
}

/* ─── Layout ───────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 46rem);
  gap: 3rem;
  max-width: 72rem;
  margin: 2rem auto;
  padding: 0 2rem;
}

/* ─── TOC sidebar ──────────────────────────────────────────── */
.toc {
  position: sticky;
  top: 2rem;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  font-size: 0.875rem;
  line-height: 1.5;
  border-left: 1px solid var(--border);
  padding-left: 1rem;
  align-self: start;
}
.toc h2 {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin: 0 0 0.75rem;
}
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 0.25rem 0; }
.toc a {
  color: var(--ink-soft);
  text-decoration: none;
  display: block;
  padding: 0.125rem 0;
}
.toc a:hover { color: var(--accent); }
.toc a.active { color: var(--accent); font-weight: 500; }
.toc .toc-h3 { padding-left: 1rem; font-size: 0.8125rem; }

/* ─── Content — Light headings per NCKU rule ───────────────── */
main h2 {
  font-family: var(--font-sans);
  font-size: 2rem;
  font-weight: 300;                /* Noto Sans Light */
  line-height: 1.3;
  letter-spacing: -0.005em;
  margin: 2.5em 0 0.75em;
  color: var(--ink);
}
main h3 {
  font-family: var(--font-sans);
  font-size: 1.375rem;
  font-weight: 500;                /* Medium — uses weight rather than size for hierarchy */
  line-height: 1.3;
  margin: 1.75em 0 0.5em;
  color: var(--ink);
}
main h4 {
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 1.5em 0 0.5em;
  color: var(--ink);
}
main p { margin: 0 0 1em; }
main ul, main ol { padding-left: 1.5rem; margin: 0 0 1em; }
main li { margin: 0.25em 0; }
main strong { color: var(--ink); font-weight: 700; }

/* Pull quotes — only place Noto Serif appears, per NCKU rule */
main blockquote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--ink);
  border-left: 3px solid var(--ncku-gold);
  margin: 1.5rem 0;
  padding: 0.5rem 0 0.5rem 1.25rem;
}

/* ─── Code ─────────────────────────────────────────────────── */
pre {
  background: var(--surface);
  border-left: 3px solid var(--accent);    /* NCKU Red rule */
  border-radius: 2px;                       /* minimal — NCKU live site uses no rounded corners */
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.95em;
  line-height: 1.5;
  margin: 1.5rem 0;
}
code { font-family: var(--font-mono); }
:not(pre) > code {
  background: var(--surface);
  padding: 0.1em 0.4em;
  border-radius: 2px;
  font-size: 0.9em;
  color: var(--ncku-maroon);
}

/* Prism token colors — NCKU palette tints only */
.token.comment      { color: var(--ink-muted); font-style: italic; }
.token.keyword,
.token.boolean      { color: var(--ncku-red); font-weight: 500; }
.token.string,
.token.char         { color: var(--ncku-gold); }
.token.number       { color: var(--ncku-maroon); }
.token.function     { color: var(--ncku-dark-grey); font-weight: 600; }
.token.operator,
.token.punctuation  { color: var(--ink-soft); }

/* ─── Callouts ─────────────────────────────────────────────── */
.callout {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-radius: 2px;
  background: var(--surface);
  border-left: 3px solid var(--ncku-silver);   /* default = neutral silver */
}
.callout strong { display: block; margin-bottom: 0.25rem; color: var(--ink); }
.callout p:last-child { margin-bottom: 0; }
.callout-tip      { border-left-color: var(--accent-tip); }      /* gold */
.callout-warn     { border-left-color: var(--accent-warn); }     /* NCKU Red */
.callout-pitfall  { border-left-color: var(--accent-pitfall); }  /* Maroon */

/* ─── Tables — NCKU live-site style: plain, horizontal rules only ── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95em;
}
th {
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border-strong);
  padding: 0.5rem 0.75rem;
  color: var(--ink);
}
td {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  vertical-align: top;
}
tbody tr:nth-child(even) { background: var(--surface-alt); }

/* ─── Figures ──────────────────────────────────────────────── */
figure {
  margin: 2rem auto;
  text-align: center;
}
figure svg, figure img { max-width: 100%; height: auto; }
figure .mermaid { display: flex; justify-content: center; }
figcaption {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
  font-style: italic;
}

/* ─── Footer ───────────────────────────────────────────────── */
.page-footer {
  max-width: 64rem;
  margin: 4rem auto 2rem;
  padding: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--ink-muted);
}

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 0 1.25rem; }
  .toc { display: none; }
  .page-header { padding: 0 1.25rem; }
  .page-header h1 { font-size: 2.25rem; }
  main h2 { font-size: 1.625rem; }
}

/* ─── Print ────────────────────────────────────────────────── */
@media print {
  .toc, .progress, .page-footer, .utility-strip { display: none; }
  body { background: white; }
  .layout { grid-template-columns: 1fr; max-width: none; }
  pre { page-break-inside: avoid; }
  h2, h3 { page-break-after: avoid; }
}

/* ============================================================
   WikiTA 使用手冊 — 補充樣式 (manual additions)
   ============================================================ */

figure.screenshot { width: 100%; margin: 2rem 0; }
figure.screenshot img {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 6px 24px rgba(42,42,42,0.10);
}
figure.screenshot figcaption { text-align: left; }

.role-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.28em 0.6em;
  border-radius: 999px;
  margin-right: 0.35em;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.role-student { background: #e8f1ee; color: #1f6b58; }
.role-interviewer { background: #f1ece2; color: #7a5f37; }
.role-mentor { background: #eceef1; color: #4a4f57; }
.role-pi { background: #f6e4e7; color: var(--ncku-red); }

.section-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ncku-red);
  background: #f6e4e7;
  padding: 0.25em 0.7em;
  border-radius: 999px;
  margin-bottom: 0.4rem;
}

.is-new {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  color: #fff;
  background: var(--ncku-gold);
  padding: 0.18em 0.5em;
  border-radius: 3px;
  margin-left: 0.5em;
  vertical-align: middle;
  letter-spacing: 0.04em;
}

.no-shot {
  font-size: 0.85rem;
  color: var(--ink-muted);
  border-left: 3px solid var(--border-strong);
  background: var(--surface-alt);
  padding: 0.5rem 0.85rem;
  margin: 1rem 0;
  border-radius: 2px;
}

.tab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
  margin: 1.5rem 0;
}
.tab-grid a {
  display: block;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  transition: border-color .15s, color .15s;
}
.tab-grid a:hover { border-color: var(--ncku-red); color: var(--ncku-red); }
.tab-grid a .t { display:block; font-weight:600; color: var(--ink); margin-bottom: 0.1rem; }
.tab-grid a:hover .t { color: var(--ncku-red); }

ol.steps { counter-reset: step; list-style: none; padding-left: 0; }
ol.steps > li {
  position: relative;
  padding-left: 2.4rem;
  margin: 0.6rem 0;
}
ol.steps > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 1.7rem; height: 1.7rem;
  background: var(--ncku-red); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 600;
}

.section-rule { border: none; border-top: 1px solid var(--border); margin: 3.5rem 0 0; }
