/* Minimal plaintext-style CSS */

:root, [data-theme="dark"] {
  --bg: #111;
  --fg: #ddd;
  --fg-muted: #888;
  --link: #6af;
  --link-visited: #a8b;
  --border: #333;
  --code-bg: #1a1a1a;
}

[data-theme="light"] {
  --bg: #fff;
  --fg: #111;
  --fg-muted: #666;
  --link: #0066cc;
  --link-visited: #551a8b;
  --border: #ddd;
  --code-bg: #f5f5f5;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: "Courier New", Courier, monospace;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  margin: 0;
  padding: 2rem;
  max-width: 700px;
  margin: 0 auto;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: normal;
  margin: 2rem 0 1rem 0;
  line-height: 1.3;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

h1::before { content: "# "; }
h2::before { content: "## "; }
h3::before { content: "### "; }

p {
  margin: 1rem 0;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:visited {
  color: var(--link-visited);
}

a:hover {
  text-decoration: underline;
}

/* Lists */
ul, ol {
  padding-left: 2rem;
  margin: 1rem 0;
}

li {
  margin: 0.25rem 0;
}

/* Code */
code {
  font-family: inherit;
  background: var(--code-bg);
  padding: 0.1rem 0.3rem;
  border-radius: 2px;
}

pre {
  background: var(--code-bg);
  padding: 1rem;
  overflow-x: auto;
  border-left: 2px solid var(--border);
  margin: 1rem 0;
}

pre code {
  background: none;
  padding: 0;
}

/* Blockquotes */
blockquote {
  border-left: 2px solid var(--border);
  margin: 1rem 0;
  padding-left: 1rem;
  color: var(--fg-muted);
  font-style: italic;
}

/* Horizontal rule */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* Header */
header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
}

header h1::before {
  content: "";
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

header .location {
  margin: 0.25rem 0 0.5rem 0;
  color: var(--fg-muted);
  font-size: 0.7rem;
}

nav {
  margin-top: 0.5rem;
  overflow: hidden;
}

nav a {
  margin-right: 1rem;
}

nav .theme-toggle {
  float: right;
}

nav a::before {
  content: "[";
}

nav a::after {
  content: "]";
}

/* Main content */
main {
  min-height: 60vh;
}

/* Avatar and intro */
.intro {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
}

.intro-text .location {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

/* Footer */
footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 0.875rem;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
}

/* Gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}

.gallery a {
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
}

.gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.2s;
}

.gallery a:hover img {
  opacity: 0.8;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  padding: 1rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.lightbox-nav:hover {
  opacity: 1;
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.lightbox-close:hover {
  opacity: 1;
}

/* Post list */
.post-list {
  list-style: none;
  padding: 0;
}

.post-list li {
  margin: 0.5rem 0;
}

.post-list .date {
  color: var(--fg-muted);
  font-size: 0.875rem;
}

/* Post meta */
.post-meta {
  color: var(--fg-muted);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

/* Links section */
.links {
  margin: 1rem 0;
}

.links a {
  display: block;
  margin: 0.25rem 0;
}

.links a::before {
  content: "-> ";
  color: var(--fg-muted);
}

/* Small text */
small, .small {
  font-size: 0.875rem;
  color: var(--fg-muted);
}

/* Math (KaTeX) adjustments */
.katex {
  font-size: 1.1em;
}

/* TikZ diagrams */
svg[data-tikz] {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5em auto;
}

/* Dark mode inversion for TikZ (black lines become visible) */
[data-theme="dark"] svg[data-tikz] {
  filter: invert(1);
}

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
}

th, td {
  border: 1px solid var(--border);
  padding: 0.5rem;
  text-align: left;
}

th {
  background: var(--code-bg);
}

/* Responsive */
@media (max-width: 600px) {
  body {
    padding: 1rem;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* Syntax highlighting (minimal) - dark mode default */
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp,
.highlight .kr, .highlight .kt { color: #b388ff; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb,
.highlight .sc, .highlight .sd, .highlight .se, .highlight .sh,
.highlight .si, .highlight .sx, .highlight .sr, .highlight .ss { color: #69f0ae; }
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs,
.highlight .cp, .highlight .cpf { color: var(--fg-muted); font-style: italic; }
.highlight .nf, .highlight .nc, .highlight .nn { color: #82b1ff; }
.highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo { color: #ffd180; }
.highlight .o, .highlight .p { color: var(--fg); }

[data-theme="light"] .highlight .k, [data-theme="light"] .highlight .kd, [data-theme="light"] .highlight .kn, [data-theme="light"] .highlight .kp,
[data-theme="light"] .highlight .kr, [data-theme="light"] .highlight .kt { color: #7c4dff; }
[data-theme="light"] .highlight .s, [data-theme="light"] .highlight .s1, [data-theme="light"] .highlight .s2, [data-theme="light"] .highlight .sb,
[data-theme="light"] .highlight .sc, [data-theme="light"] .highlight .sd, [data-theme="light"] .highlight .se, [data-theme="light"] .highlight .sh,
[data-theme="light"] .highlight .si, [data-theme="light"] .highlight .sx, [data-theme="light"] .highlight .sr, [data-theme="light"] .highlight .ss { color: #4caf50; }
[data-theme="light"] .highlight .nf, [data-theme="light"] .highlight .nc, [data-theme="light"] .highlight .nn { color: #2196f3; }
[data-theme="light"] .highlight .mi, [data-theme="light"] .highlight .mf, [data-theme="light"] .highlight .mh, [data-theme="light"] .highlight .mo { color: #ff9800; }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0;
}

.theme-toggle:hover {
  color: var(--fg);
}

/* PDF embed container */
.pdf-container {
  width: 100%;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.pdf-container iframe {
  display: block;
  min-height: 800px;
}

@media (max-width: 600px) {
  .pdf-container iframe {
    min-height: 500px;
  }
}
