/* === Minimal Theme - matching pseudoyu.com === */

/* --- Reset --- */
*, *:before, *:after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: var(--border-color, #e5e7eb);
}

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  font-feature-settings: normal;
  font-variation-settings: normal;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  line-height: inherit;
  font-family: inherit;
}

hr {
  height: 0;
  color: inherit;
  border-top-width: 1px;
}

h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
}

a {
  color: inherit;
  text-decoration: inherit;
}

b, strong {
  font-weight: bolder;
}

code, kbd, samp, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1em;
}

small {
  font-size: 80%;
}

blockquote, dl, dd, p, figure, pre {
  margin: 0;
}

img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  vertical-align: middle;
}

img, video {
  max-width: 100%;
  height: auto;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 100%;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
}

table {
  text-indent: 0;
  border-collapse: collapse;
}

/* --- Light / Dark Mode --- */
:root {
  --c-bg: #fff;
  --c-text: #374151;
  --c-text-light: #6b7280;
  --c-border: #e5e7eb;
  --c-bg-code: #f3f4f6;
  --c-link: #4b5563;
}

.dark {
  --c-bg: #111827;
  --c-text: #e5e7eb;
  --c-text-light: #9ca3af;
  --c-border: #374151;
  --c-bg-code: #1f2937;
  --c-link: #d1d5db;
}

body {
  background-color: var(--c-bg);
  color: var(--c-text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Layout --- */
main {
  padding: 2.5rem 1.75rem;
  overflow-x: hidden;
}

.container {
  max-width: 65ch;
  margin: 0 auto;
}

/* --- Header / Avatar --- */
.header {
  z-index: 40;
}

.header a.avatar-link {
  width: 3rem;
  height: 3rem;
  position: absolute;
  margin: 1.25rem;
  display: block;
  outline: none;
}

.header a.avatar-link img.avatar {
  width: 100%;
  height: auto;
  max-width: 100px;
  border-radius: 50%;
  animation: avatar-pulse 10s ease forwards infinite;
  transform-origin: center;
}

@media (prefers-reduced-motion) {
  .header a.avatar-link img.avatar {
    animation: none;
  }
}

@keyframes avatar-pulse {
  0% { transform: scale(0.9); }
  40% { transform: scale(1); }
  85% { transform: scale(1); }
  95%, to { transform: scale(0.9); }
}

/* --- Navigation --- */
.nav {
  padding: 2rem;
  width: 100%;
  display: grid;
  grid-template-columns: auto max-content;
  box-sizing: border-box;
}

.nav > * {
  margin: auto;
}

.nav .spacer {
  /* Takes left column, pushes right column to the right */
}

.nav .right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: flex-end;
}

.nav .right > * {
  margin: auto 0;
}

.nav a {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.2s ease;
  opacity: 0.6;
  outline: none;
  white-space: nowrap;
}

.nav a:hover {
  opacity: 1;
  text-decoration-color: inherit;
}

/* --- Scroll to top --- */
.scroll-top {
  position: fixed;
  right: 0.75rem;
  bottom: 0.75rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg-code);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, background-color 0.3s ease;
  z-index: 100;
  cursor: pointer;
  color: var(--c-text);
  border: 1px solid var(--c-border);
}

.scroll-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.scroll-top:hover {
  opacity: 0.8;
}

/* --- Prose / Typography --- */
.prose {
  color: var(--c-text);
}

.prose h1 {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.prose h2 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.prose h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.prose h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.prose p {
  margin-top: 1.25em;
  margin-bottom: 1.25em;
}

.prose a {
  color: var(--c-text);
  text-decoration: underline;
  text-decoration-color: var(--c-text-light);
  text-underline-offset: 2px;
  transition: opacity 0.2s ease;
}

.prose a:hover {
  opacity: 0.7;
}

.prose strong {
  font-weight: 600;
}

.prose blockquote {
  border-left: 3px solid var(--c-border);
  padding-left: 1rem;
  margin: 1.5em 0;
  color: var(--c-text-light);
}

.prose ul, .prose ol {
  margin-top: 1.25em;
  margin-bottom: 1.25em;
  padding-left: 1.5em;
}

.prose li {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
}

.prose li > ul, .prose li > ol {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
}

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

.prose img {
  margin: 1.5rem auto;
  border-radius: 0.5rem;
}

.prose pre {
  background: var(--c-bg-code);
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1.25rem 0;
  font-size: 0.9em;
  line-height: 1.6;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875em;
  background: var(--c-bg-code);
  padding: 0.15em 0.4em;
  border-radius: 0.25rem;
}

.prose pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.prose table {
  width: 100%;
  margin: 1.5rem 0;
  overflow: auto;
  display: block;
}

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

.prose table th {
  font-weight: 600;
  background: var(--c-bg-code);
}

/* --- Archive listing (section pages) --- */
.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.archive-list li {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 0;
  align-items: baseline;
}

.archive-list li .post-date {
  flex-shrink: 0;
  color: var(--c-text-light);
  font-size: 0.875rem;
  min-width: 6rem;
}

.archive-list li a {
  color: var(--c-text);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.archive-list li a:hover {
  opacity: 0.6;
}

/* --- Tags list --- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.tag-list li a {
  display: inline-block;
  padding: 0.2rem 0.75rem;
  background: var(--c-bg-code);
  border-radius: 1rem;
  font-size: 0.875rem;
  color: var(--c-text);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.tag-list li a:hover {
  opacity: 0.6;
}

.tag-list li .tag-count {
  color: var(--c-text-light);
  font-size: 0.8rem;
  margin-left: 0.25rem;
}

/* --- Header underline (replaces old .header-underline) --- */
.header-underline {
  width: 50px;
  height: 3px;
  background: var(--c-text-light);
  margin: 1rem 0;
  opacity: 0.5;
}

/* --- Back link --- */
.back-link {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--c-text-light);
  text-decoration: none;
  font-size: 0.9rem;
  transition: opacity 0.2s ease;
}

.back-link:hover {
  opacity: 0.6;
}

/* --- Post meta --- */
.post-meta {
  color: var(--c-text-light);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 2rem;
}

.post-tags a {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: var(--c-bg-code);
  border-radius: 1rem;
  font-size: 0.8rem;
  color: var(--c-text);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.post-tags a:hover {
  opacity: 0.6;
}

/* --- Footer --- */
.site-footer {
  margin-top: 2.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  color: var(--c-text-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-footer a {
  color: inherit;
  transition: opacity 0.2s ease;
}

.site-footer a:hover {
  opacity: 0.6;
}

/* --- Dark mode toggle --- */
.color-scheme-toggle {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease;
  background: none;
  border: none;
  color: inherit;
  font-size: 1.2rem;
  padding: 0;
  line-height: 1;
}

.color-scheme-toggle:hover {
  opacity: 1;
}

.color-scheme-toggle .sun-icon,
.color-scheme-toggle .moon-icon {
  display: none;
}

/* Light mode: show moon icon (to switch to dark) */
.color-scheme-toggle .moon-icon {
  display: block;
}

/* Dark mode: show sun icon (to switch to light) */
.dark .color-scheme-toggle .sun-icon {
  display: block;
}

.dark .color-scheme-toggle .moon-icon {
  display: none;
}

/* --- Slide enter animation --- */
@keyframes slide-enter {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-enter {
  animation: slide-enter 0.5s ease forwards;
}

.slide-enter-delay {
  animation: slide-enter 0.5s ease forwards;
  animation-delay: 0.2s;
  opacity: 0;
}

/* --- Magic link (favicon image) --- */
.markdown-magic-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.markdown-magic-link-image {
  display: inline-block;
  width: 1em;
  height: 1em;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 2px;
  flex-shrink: 0;
}

/* --- Sponsor buttons --- */
.btn-sponsor {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  border-radius: 0.4rem;
  font-size: 0.875rem;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.btn-sponsor:hover {
  opacity: 0.8;
}

.btn-sponsor-rose {
  background: #f43f5e20;
  color: #f43f5e;
}

.btn-sponsor-yellow {
  background: #eab30820;
  color: #eab308;
}

/* --- Syntax highlighting (Zola) --- */
pre.z-code {
  background: var(--c-bg-code);
}

/* --- Search --- */
.search-box {
  margin: 1rem 0;
}

.search-box input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--c-border);
  border-radius: 0.5rem;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 0.95rem;
}

.search-box input:focus {
  outline: none;
  border-color: var(--c-text-light);
}

/* --- Related posts --- */
.related-posts {
  margin-top: 3rem;
}

.related-posts h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 2rem 0;
  list-style: none;
  padding: 0;
}

.pagination a {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 0.3rem;
  color: var(--c-text);
  text-decoration: none;
  transition: opacity 0.2s ease;
  border: 1px solid var(--c-border);
}

.pagination a:hover {
  opacity: 0.6;
}

.pagination .active {
  font-weight: 600;
  background: var(--c-bg-code);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  main {
    padding: 1.5rem 1rem;
  }

  .nav {
    padding: 1rem;
  }

  .nav .right {
    gap: 0.5rem;
  }

  .archive-list li {
    flex-direction: column;
    gap: 0.15rem;
  }

  .archive-list li .post-date {
    min-width: auto;
  }

  .header a.avatar-link {
    position: relative;
    margin: 0 auto 1rem;
    display: block;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .nav .spacer {
    display: none;
  }

  .nav .right {
    justify-content: center;
  }
}

@media print {
  .header, .site-footer, .scroll-top, .color-scheme-toggle {
    display: none;
  }
}
