/*
 * Note article theme — scoped entirely to `.note-content`.
 * Independent of css/base.css, layout.css, components.css: safe to include
 * only on pages that render a markdown-derived article body.
 * All colors are custom properties on `.note-content` itself, so nothing
 * here leaks into or is affected by the rest of the site's styling.
 */

.note-content {
  --note-bg: #fbfaf7;
  --note-text: #1c1b19;
  --note-muted: #6b6a63;
  --note-heading: #14130f;
  --note-border: rgba(28, 27, 25, 0.12);
  --note-accent: #2f6f52;
  --note-code-bg: #f1efe9;
  --note-inline-code-bg: rgba(28, 27, 25, 0.06);
  --note-quote-bg: rgba(47, 111, 82, 0.06);
  --note-mark-bg: rgba(242, 190, 76, 0.4);
  --note-table-header-bg: rgba(28, 27, 25, 0.04);
  --note-kbd-bg: #ffffff;
  --note-kbd-border: rgba(28, 27, 25, 0.28);
  --note-kbd-shadow: rgba(28, 27, 25, 0.2);
}

@media (prefers-color-scheme: dark) {
  .note-content {
    --note-bg: #14171a;
    --note-text: #dde2e6;
    --note-muted: #8b939b;
    --note-heading: #f3f5f6;
    --note-border: rgba(255, 255, 255, 0.13);
    --note-accent: #5fd1a0;
    --note-code-bg: #1b1f23;
    --note-inline-code-bg: rgba(255, 255, 255, 0.08);
    --note-quote-bg: rgba(95, 209, 160, 0.09);
    --note-mark-bg: rgba(242, 190, 76, 0.3);
    --note-table-header-bg: rgba(255, 255, 255, 0.05);
    --note-kbd-bg: #20242a;
    --note-kbd-border: rgba(255, 255, 255, 0.2);
    --note-kbd-shadow: rgba(0, 0, 0, 0.45);
  }
}

/* Forward-compatible hook: if the site later adds a manual theme toggle,
   it can drive the same tokens via [data-theme] instead of only relying
   on prefers-color-scheme. */
html[data-theme="dark"] .note-content {
  --note-bg: #14171a;
  --note-text: #dde2e6;
  --note-muted: #8b939b;
  --note-heading: #f3f5f6;
  --note-border: rgba(255, 255, 255, 0.13);
  --note-accent: #5fd1a0;
  --note-code-bg: #1b1f23;
  --note-inline-code-bg: rgba(255, 255, 255, 0.08);
  --note-quote-bg: rgba(95, 209, 160, 0.09);
  --note-mark-bg: rgba(242, 190, 76, 0.3);
  --note-table-header-bg: rgba(255, 255, 255, 0.05);
  --note-kbd-bg: #20242a;
  --note-kbd-border: rgba(255, 255, 255, 0.2);
  --note-kbd-shadow: rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] .note-content {
  --note-bg: #fbfaf7;
  --note-text: #1c1b19;
  --note-muted: #6b6a63;
  --note-heading: #14130f;
  --note-border: rgba(28, 27, 25, 0.12);
  --note-accent: #2f6f52;
  --note-code-bg: #f1efe9;
  --note-inline-code-bg: rgba(28, 27, 25, 0.06);
  --note-quote-bg: rgba(47, 111, 82, 0.06);
  --note-mark-bg: rgba(242, 190, 76, 0.4);
  --note-table-header-bg: rgba(28, 27, 25, 0.04);
  --note-kbd-bg: #ffffff;
  --note-kbd-border: rgba(28, 27, 25, 0.28);
  --note-kbd-shadow: rgba(28, 27, 25, 0.2);
}

.note-content {
  box-sizing: border-box;
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 32px;
  overflow-wrap: break-word;
  color: var(--note-text);
  background: var(--note-bg);
  border: 1px solid var(--note-border);
  border-radius: 10px;
  font-family: var(--font-sans, Inter), "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.8;
}

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

/* Headings ---------------------------------------------------------- */

.note-content h1,
.note-content h2,
.note-content h3,
.note-content h4,
.note-content h5,
.note-content h6 {
  color: var(--note-heading);
  font-weight: 700;
  line-height: 1.35;
}

.note-content h1 {
  margin: 0 0 0.9em;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.note-content h2 {
  margin: 2.1em 0 0.8em;
  padding-bottom: 0.35em;
  font-size: 1.5rem;
  border-bottom: 1px solid var(--note-border);
}

.note-content h3 {
  margin: 1.8em 0 0.6em;
  font-size: 1.25rem;
}

.note-content h4 {
  margin: 1.6em 0 0.5em;
  font-size: 1.1rem;
  font-weight: 600;
}

.note-content h5 {
  margin: 1.4em 0 0.4em;
  font-size: 1rem;
  font-weight: 600;
}

.note-content h6 {
  margin: 1.4em 0 0.4em;
  color: var(--note-muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.note-content > *:first-child {
  margin-top: 0;
}

/* Body text ----------------------------------------------------------- */

.note-content p {
  margin: 0 0 1.3em;
}

.note-content p:last-child {
  margin-bottom: 0;
}

/* Justify was tried here and reverted: a long unbreakable inline <code>
   token left ~250-260px gaps on the lines before it wraps. Left-aligned
   is safer for technical prose that mixes in long identifiers/URLs. */

.note-content strong {
  color: var(--note-heading);
  font-weight: 700;
}

.note-content em {
  font-style: italic;
}

.note-content del {
  color: var(--note-muted);
  text-decoration: line-through;
}

.note-content a {
  color: var(--note-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: opacity 140ms ease;
}

.note-content a:hover,
.note-content a:focus-visible {
  opacity: 0.72;
}

/* Lists ----------------------------------------------------------------- */

.note-content ul,
.note-content ol {
  margin: 0 0 1.3em;
  padding-left: 1.4em;
}

.note-content li {
  margin: 0.35em 0;
}

.note-content li > ul,
.note-content li > ol {
  margin: 0.35em 0;
}

.note-content ul {
  list-style: disc;
}

.note-content ul ul {
  list-style: circle;
}

.note-content ul ul ul {
  list-style: square;
}

.note-content ol {
  list-style: decimal;
}

/* Blockquote -------------------------------------------------------- */

.note-content blockquote {
  margin: 1.6em 0;
  padding: 0.6em 1.1em;
  color: var(--note-muted);
  background: var(--note-quote-bg);
  border-left: 3px solid var(--note-accent);
  border-radius: 0 6px 6px 0;
}

.note-content blockquote p {
  margin: 0 0 0.6em;
}

.note-content blockquote p:last-child {
  margin-bottom: 0;
}

/* Divider ------------------------------------------------------------- */

.note-content hr {
  height: 1px;
  margin: 2.4em 0;
  background: var(--note-border);
  border: 0;
}

/* Code ------------------------------------------------------------------ */

.note-content code {
  padding: 0.15em 0.4em;
  overflow-wrap: anywhere;
  color: var(--note-text);
  font-family: var(--font-mono, "SFMono-Regular"), Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--note-inline-code-bg);
  border-radius: 4px;
}

.note-content pre {
  margin: 1.6em 0;
  padding: 1em 1.1em;
  overflow-x: auto;
  background: var(--note-code-bg);
  border: 1px solid var(--note-border);
  border-radius: 8px;
  line-height: 1.6;
}

.note-content pre code {
  padding: 0;
  overflow-wrap: normal;
  color: inherit;
  font-size: 0.88em;
  background: none;
  border-radius: 0;
  white-space: pre;
}

/* Table ------------------------------------------------------------------ */

.note-content table {
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 1.6em 0;
  overflow-x: auto;
  font-size: 0.92em;
  border-collapse: collapse;
}

.note-content th,
.note-content td {
  padding: 0.55em 0.9em;
  border-bottom: 1px solid var(--note-border);
  text-align: left;
}

.note-content thead th {
  color: var(--note-heading);
  font-weight: 700;
  background: var(--note-table-header-bg);
  border-bottom: 2px solid var(--note-border);
  white-space: nowrap;
}

.note-content tbody tr:last-child td {
  border-bottom: 0;
}

/* Images ------------------------------------------------------------------- */

.note-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.6em auto;
  border-radius: 8px;
}

.note-content figure {
  margin: 1.8em 0;
  text-align: center;
}

.note-content figure img {
  margin: 0 auto 0.7em;
}

.note-content figcaption {
  color: var(--note-muted);
  font-size: 0.85em;
}

/* Misc inline elements --------------------------------------------------- */

.note-content kbd {
  display: inline-block;
  padding: 0.15em 0.5em;
  color: var(--note-text);
  font-family: var(--font-mono, "SFMono-Regular"), Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85em;
  background: var(--note-kbd-bg);
  border: 1px solid var(--note-kbd-border);
  border-bottom-width: 2px;
  border-radius: 5px;
  box-shadow: 0 1px 0 var(--note-kbd-shadow);
}

.note-content mark {
  padding: 0.1em 0.25em;
  color: inherit;
  background: var(--note-mark-bg);
  border-radius: 3px;
}

.note-content details {
  margin: 1.6em 0;
  padding: 0.8em 1em;
  background: var(--note-quote-bg);
  border: 1px solid var(--note-border);
  border-radius: 8px;
}

.note-content details > *:last-child {
  margin-bottom: 0;
}

.note-content summary {
  color: var(--note-heading);
  font-weight: 600;
  cursor: pointer;
}

.note-content details[open] summary {
  margin-bottom: 0.6em;
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 900px) {
  .note-content {
    padding: 32px 22px;
  }

  .note-content h1 {
    font-size: 1.7rem;
  }

  .note-content h2 {
    font-size: 1.3rem;
  }
}

@media (max-width: 620px) {
  .note-content {
    padding: 22px 14px;
    font-size: 15.5px;
    border-radius: 8px;
  }

  .note-content h1 {
    font-size: 1.5rem;
  }

  .note-content h2 {
    font-size: 1.18rem;
  }

  .note-content h3 {
    font-size: 1.1rem;
  }

  .note-content pre {
    padding: 0.8em 0.9em;
  }

  .note-content blockquote {
    padding: 0.5em 0.9em;
  }
}
