/* oh-my-gist — main stylesheet. Design language follows GitHub Gist:
   Primer neutral palette, gray header bar, bordered file boxes with
   filename headers, and line-numbered code blocks. */

/* ---------------------------------------------------------------------------
   Tokens (GitHub Primer light / dark)
-------------------------------------------------------------------------------- */
:root {
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #ffffff;
  --surface: #f6f8fa;
  --ink: #1f2328;
  --muted: #59636e;
  --faint: #818c98;
  --border: #d1d9e0;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --danger: #d1242f;
  --ring: rgba(9, 105, 218, 0.25);
  --selection: rgba(9, 105, 218, 0.18);
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --ink: #f0f6fc;
  --muted: #9198a1;
  --faint: #6e7681;
  --border: #3d444d;
  --accent: #4493f8;
  --accent-hover: #6aa6f8;
  --danger: #f85149;
  --ring: rgba(68, 147, 248, 0.3);
  --selection: rgba(68, 147, 248, 0.3);
}

/* ---------------------------------------------------------------------------
   Reset / base
-------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }

.container { width: min(100% - 2.5rem, 46rem); margin-inline: auto; }

::selection { background: var(--selection); }

/* ---------------------------------------------------------------------------
   Accessibility
-------------------------------------------------------------------------------- */
.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--ink); color: var(--bg); padding: 0.5rem 0.9rem;
  z-index: 100; font-size: 0.9rem;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------------------
   Header — gray bar, dark links (gist.github.com)
-------------------------------------------------------------------------------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding-block: 0.7rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 1rem; color: var(--ink); }
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-icon { display: block; }

.nav { display: flex; align-items: center; gap: 1rem; }
.nav-link { color: var(--ink); font-size: 0.9rem; font-weight: 500; }
.nav-link:hover { color: var(--accent); text-decoration: none; }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; padding: 0.2rem; cursor: pointer;
  color: var(--muted);
}
.theme-toggle:hover { color: var(--ink); }
.theme-toggle svg { display: block; }
[data-theme="light"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: none; }

/* ---------------------------------------------------------------------------
   Index — profile header (gist account page)
-------------------------------------------------------------------------------- */
.profile {
  display: flex; align-items: center; gap: 1.4rem;
  padding: 2rem 0 1.75rem;
}
.profile-avatar {
  width: 96px; height: 96px; border-radius: 50%;
  object-fit: cover; flex: none;
  border: 1px solid var(--border);
}
.profile-info { min-width: 0; }
.profile-name {
  margin: 0; font-size: 1.5rem; font-weight: 600;
  line-height: 1.25; letter-spacing: -0.01em;
}
.profile-username { margin: 0.15rem 0 0; font-size: 1.05rem; color: var(--muted); }
.profile-bio { margin: 0.6rem 0 0; font-size: 0.92rem; color: var(--muted); max-width: 44ch; }
.profile-links { margin: 0.5rem 0 0; }
.profile-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.88rem; color: var(--ink);
}
.profile-link:hover { color: var(--accent); }
.profile-link:hover span { text-decoration: underline; text-underline-offset: 2px; }
.profile-count { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--faint); }

/* ---------------------------------------------------------------------------
   Index
-------------------------------------------------------------------------------- */
.hero { padding: 0 0 1.5rem; }
.page-meta { margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--muted); }
.hero-title {
  margin: 0 0 1.4rem;
  font-weight: 600; font-size: clamp(1.5rem, 3.5vw, 1.85rem);
  line-height: 1.25; letter-spacing: -0.01em;
  max-width: 28ch;
}

.search {
  position: relative; display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 0 0.75rem;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.search-icon { color: var(--faint); flex: none; }
#search-input {
  flex: 1; border: 0; background: transparent; padding: 0.6rem 0.6rem;
  font-family: var(--font-body); font-size: 0.95rem; color: var(--ink);
}
#search-input:focus { outline: none; }
#search-input::placeholder { color: var(--faint); }
.search-kbd {
  flex: none; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.1rem 0.4rem; margin-left: 0.5rem;
}
.search-results {
  position: absolute; top: calc(100% + 0.35rem); left: 0; right: 0; z-index: 40;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 22rem; overflow: auto; padding: 0.25rem;
}
.search-result { display: block; padding: 0.55rem 0.65rem; border-radius: 6px; color: var(--ink); }
.search-result:hover, .search-result.active { background: var(--surface); text-decoration: none; color: var(--ink); }
.search-result-title { font-weight: 600; font-size: 0.95rem; }
.search-result-excerpt { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 0.1rem; }
.search-result-date { display: block; font-size: 0.75rem; color: var(--faint); margin-top: 0.15rem; }
.search-empty { padding: 0.75rem; color: var(--muted); font-size: 0.9rem; }

/* ---------------------------------------------------------------------------
   Notes list — flat entries separated by hairlines (gist list)
-------------------------------------------------------------------------------- */
.notes { display: flex; flex-direction: column; padding-bottom: 3rem; }
.note-card { padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.note-card:first-child { border-top: 1px solid var(--border); }
.note-card[hidden] { display: none; }
.note-meta {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--muted);
  margin: 0 0 0.4rem;
}
.note-title { margin: 0 0 0.25rem; font-weight: 600; font-size: 1.2rem; line-height: 1.3; }
.note-main { color: var(--accent); }
.note-excerpt { margin: 0 0 0.55rem; color: var(--muted); font-size: 0.94rem; }
.note-tags { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.empty { color: var(--muted); font-size: 0.92rem; }

/* tags — plain text links */
.tag { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.tag:hover { color: var(--accent); }

/* tag filter indicator */
.tag-filter-note {
  font-size: 0.85rem; color: var(--muted);
  padding: 0.75rem 0; border-bottom: 1px solid var(--border);
}

/* ---------------------------------------------------------------------------
   Note page
-------------------------------------------------------------------------------- */
.crumbs { padding-top: 1.5rem; }
.crumb { font-size: 0.88rem; color: var(--muted); }
.crumb:hover { color: var(--accent); }
.note-header { padding: 1.25rem 0 1.5rem; }
.note-header .note-title { margin: 0 0 0.6rem; font-size: clamp(1.55rem, 4vw, 2rem); font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.note-header .note-meta { margin-bottom: 0.6rem; }
.badge {
  font-size: 0.72rem; font-weight: 500;
  color: var(--danger); border: 1px solid var(--danger); border-radius: 999px;
  padding: 0.05rem 0.55rem;
}

/* file box — the signature gist container */
.file-box {
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
  margin-bottom: 1rem;
}
.file-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0.4rem 1rem;
  font-family: var(--font-mono); font-size: 0.82rem;
}
.file-body { padding: 1.25rem 1.5rem; }
.file-body > :last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------------------
   Gist header — avatar + "user / filename.md" (gist.github.com)
------------------------------------------------------------------------------- */
.gist-header { padding-top: 1.5rem; }
.gist-id { display: flex; align-items: flex-start; gap: 0.85rem; }
.gist-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; flex: none; border: 1px solid var(--border);
}
.gist-id-text { min-width: 0; }
.gist-title {
  margin: 0; font-size: 1.4rem; font-weight: 600;
  line-height: 1.25; letter-spacing: -0.01em; overflow-wrap: anywhere;
}
.gist-title .gist-user { color: var(--ink); }
.gist-title .gist-filename { color: var(--accent); }
.gist-slash { color: var(--faint); }
.gist-meta { margin: 0.25rem 0 0; font-size: 0.82rem; color: var(--muted); }
.gist-report { color: var(--muted); }
.gist-report:hover { color: var(--accent); }
.gist-meta .note-tags { margin-top: 0.3rem; }

/* ---------------------------------------------------------------------------
   Gist tab bar — full-width toolbar (Code / Revisions)
------------------------------------------------------------------------------- */
.gist-tabs {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-top: 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 0 0.75rem;
}
.gist-tab-group { display: flex; align-items: stretch; gap: 0.25rem; }
.file-tab {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: none; border: 0; border-bottom: 2px solid transparent;
  margin: 0 -0.75rem; padding: 0.65rem 0.85rem;
  font-family: var(--font-body); font-size: 0.85rem; font-weight: 500;
  color: var(--muted); cursor: pointer; white-space: nowrap;
}
.file-tab:first-child { margin-left: 0.75rem; }
.file-tab:hover { color: var(--ink); }
.file-tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.file-tab svg { flex: none; }
.file-tab-count { font-size: 0.72rem; color: var(--faint); }
.tab-panel[hidden] { display: none; }

/* gist description line above the file box */
.gist-desc { margin: 1.1rem 0 0.6rem; font-size: 0.9rem; color: var(--muted); }

/* Raw button in the file head */
.file-name { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--ink); }
.file-name a { color: var(--accent); }
.file-name svg { color: var(--muted); }
.btn-raw {
  font-family: var(--font-body); font-size: 0.78rem; font-weight: 500;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 0.2rem 0.65rem; margin-left: auto;
}
.btn-raw:hover { color: var(--accent); text-decoration: none; background: var(--surface); }
.file-hint { margin-left: auto; }

/* ---------------------------------------------------------------------------
   Prose
-------------------------------------------------------------------------------- */
.prose { max-width: 46rem; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  font-weight: 600; letter-spacing: -0.01em; line-height: 1.3;
}
.prose h1 { font-size: 1.5rem; margin: 2rem 0 0.9rem; }
.prose h2 { font-size: 1.3rem; margin: 2rem 0 0.8rem; }
.prose h3 { font-size: 1.12rem; margin: 1.75rem 0 0.6rem; }
.prose h4 { font-size: 1rem; margin: 1.5rem 0 0.5rem; }
.prose p { margin: 0 0 1rem; }

.prose ul, .prose ol { margin: 0 0 1rem; padding-left: 1.4rem; }
.prose li { margin: 0.25rem 0; }

.prose blockquote {
  margin: 0 0 1rem; padding: 0.1rem 0 0.1rem 1rem;
  border-left: 0.25rem solid var(--border); color: var(--muted);
}
.prose blockquote p { margin: 0.35rem 0; }

.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

.prose code {
  font-family: var(--font-mono); font-size: 0.85em;
  background: var(--surface); border-radius: 4px; padding: 0.12rem 0.35rem;
}

/* fenced code — line-numbered like a gist file */
.prose pre {
  position: relative; margin: 0 0 1.25rem; padding: 0.75rem 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.45;
  counter-reset: ln;
}
.prose pre code { background: none; padding: 0; font: inherit; }
.prose pre .cl { display: block; padding: 0 1rem 0 0.5rem; }
.prose pre .cl::before {
  counter-increment: ln; content: counter(ln);
  display: inline-block; width: 2.5em; margin-right: 1em;
  text-align: right; color: var(--faint);
}
.hljs { background: transparent; }

/* tables */
.prose table { border-collapse: collapse; width: 100%; margin: 0 0 1.25rem; font-size: 0.92rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.45rem 0.75rem; text-align: left; }
.prose th { background: var(--surface); font-weight: 600; }

/* kbd */
.prose kbd, kbd {
  font-family: var(--font-mono); font-size: 0.75em; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.08rem 0.35rem;
}

/* task lists */
.prose .contains-task-list { list-style: none; padding-left: 0.2rem; }
.prose .task-list-item { list-style: none; position: relative; padding-left: 1.6rem; }
.prose .task-list-item input[type="checkbox"] {
  position: absolute; left: 0; top: 0.32rem; width: 0.95rem; height: 0.95rem;
  accent-color: var(--accent); margin: 0;
}

/* footnotes */
.prose .footnote-ref { font-size: 0.8em; }
.prose .footnotes { margin-top: 2rem; font-size: 0.88rem; color: var(--muted); }

/* math */
.prose .katex-display { margin: 1.25rem 0; overflow-x: auto; overflow-y: hidden; padding: 0.2rem 0; }

/* images */
.prose img { margin: 1.2rem auto; }

/* ---------------------------------------------------------------------------
   Revisions (tab panel below the tab bar)
------------------------------------------------------------------------------- */
.tab-panel[data-panel="revisions"] { padding: 1.5rem; }
.revision-title { font-weight: 600; font-size: 1rem; margin: 0 0 0.75rem; }
.revision-count { font-weight: 400; color: var(--faint); font-size: 0.85rem; margin-left: 0.35rem; }
.rev-list { list-style: none; margin: 0; padding: 0; }
.rev {
  display: flex; align-items: baseline; gap: 0.7rem; flex-wrap: wrap;
  font-size: 0.9rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border);
}
.rev:last-child { border-bottom: 0; }
.rev-hash { font-family: var(--font-mono); font-size: 0.8rem; }
.rev-date { font-size: 0.8rem; color: var(--muted); }
.revisions-none { color: var(--muted); font-size: 0.92rem; }

/* ---------------------------------------------------------------------------
   Misc
-------------------------------------------------------------------------------- */
.muted { color: var(--muted); }

.notfound { padding: 4rem 0; }
.notfound .hero-title { margin-bottom: 0.5rem; }

/* ---------------------------------------------------------------------------
   Responsive
-------------------------------------------------------------------------------- */
@media (max-width: 560px) {
  .container { width: min(100% - 2rem, 46rem); }
  .hero { padding-top: 2rem; }
  .nav { gap: 0.8rem; }
  .file-body { padding: 1rem 1.1rem; }
  .prose pre { font-size: 0.8rem; }
}

/* ---------------------------------------------------------------------------
   Syntax highlighting (GitHub light / dark)
-------------------------------------------------------------------------------- */
.hljs-comment, .hljs-quote { color: var(--faint); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal { color: #cf222e; }
.hljs-string, .hljs-regexp { color: #0a3069; }
.hljs-number, .hljs-meta, .hljs-symbol, .hljs-bullet { color: #0550ae; }
.hljs-title, .hljs-section, .hljs-function .hljs-title { color: #8250df; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-name { color: #953800; }
.hljs-type, .hljs-class .hljs-title, .hljs-built_in { color: #0550ae; }
.hljs-operator, .hljs-subst { color: var(--ink); }
.hljs-strong { font-weight: 700; }
.hljs-emphasis { font-style: italic; }
.hljs-addition { color: #116329; }
.hljs-deletion { color: #82071e; }
.hljs-link { color: var(--accent); }

[data-theme="dark"] .hljs-keyword, [data-theme="dark"] .hljs-selector-tag, [data-theme="dark"] .hljs-literal { color: #ff7b72; }
[data-theme="dark"] .hljs-string, [data-theme="dark"] .hljs-regexp { color: #a5d6ff; }
[data-theme="dark"] .hljs-number, [data-theme="dark"] .hljs-meta, [data-theme="dark"] .hljs-symbol, [data-theme="dark"] .hljs-bullet { color: #79c0ff; }
[data-theme="dark"] .hljs-title, [data-theme="dark"] .hljs-section, [data-theme="dark"] .hljs-function .hljs-title { color: #d2a8ff; }
[data-theme="dark"] .hljs-attr, [data-theme="dark"] .hljs-attribute, [data-theme="dark"] .hljs-variable, [data-theme="dark"] .hljs-template-variable, [data-theme="dark"] .hljs-name { color: #ffa657; }
[data-theme="dark"] .hljs-type, [data-theme="dark"] .hljs-class .hljs-title, [data-theme="dark"] .hljs-built_in { color: #79c0ff; }
[data-theme="dark"] .hljs-addition { color: #3fb950; }
[data-theme="dark"] .hljs-deletion { color: #f85149; }

/* copy button on code blocks — icon-only, top-right corner */
.copy-btn {
  position: absolute; top: 0.45rem; right: 0.45rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem; padding: 0;
  color: var(--muted);
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; opacity: 0;
  transition: opacity 0.15s ease;
}
.copy-btn svg { display: block; }
.prose pre:hover .copy-btn, .prose pre:focus-within .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--ink); }
.copy-btn.copied { color: #1a7f37; }
[data-theme="dark"] .copy-btn.copied { color: #3fb950; }
