/* ------------------------------------------------------------------ *
 * Personal site — minimal monospace theme.
 * Light/dark via a `.dark` class on <html> (see theme.js).
 * ------------------------------------------------------------------ */

:root {
  --background: #fafafa;
  --foreground: #171717;
  --muted-foreground: #6b7280;
  --border: #e5e5e5;
  --border-dashed: rgba(107, 114, 128, 0.5);
  --accent-hover: rgba(23, 23, 23, 0.06);
  --ring: #9ca3af;
  --dot: rgba(23, 23, 23, 0.05);
  --max-width: 800px;
  --max-width-wide: 1180px;
}

.dark {
  --background: #171717;
  --foreground: #fafafa;
  --muted-foreground: #9ca3af;
  --border: rgba(255, 255, 255, 0.1);
  --border-dashed: rgba(156, 163, 175, 0.4);
  --accent-hover: rgba(255, 255, 255, 0.08);
  --ring: #6b7280;
  --dot: rgba(255, 255, 255, 0.04);
}

* {
  box-sizing: border-box;
}

html {
  font-family: "Geist Mono", ui-monospace, "Cascadia Code", "Source Code Pro",
    Menlo, Consolas, "DejaVu Sans Mono", monospace;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--background);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -12px -12px;
  background-attachment: fixed;
  color: var(--foreground);
  font-size: 15px;
  line-height: 1.6;
  transition: background-color 200ms ease, color 200ms ease;
}

a {
  color: inherit;
}

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

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--muted-foreground);
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- nav ---------------------------------------------------------- */

.nav {
  width: 100%;
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 24px;
  font-size: 14px;
}

.nav-logo {
  font-weight: 500;
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: color 150ms ease;
}

.nav-logo:hover {
  color: var(--muted-foreground);
}

.nav-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-link {
  color: var(--muted-foreground);
  text-decoration: none;
  text-underline-offset: 4px;
  transition: color 150ms ease;
}

.nav-link:hover {
  color: var(--foreground);
  text-decoration: underline;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  border-radius: 4px;
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease;
}

.theme-toggle:hover {
  color: var(--foreground);
  background: var(--accent-hover);
}

.theme-toggle .icon {
  display: inline-flex;
}

/* Show moon in light mode, sun in dark mode. */
.icon-sun {
  display: none;
}
.dark .icon-sun {
  display: inline-flex;
}
.dark .icon-moon {
  display: none;
}

/* ---- hero --------------------------------------------------------- */

.hero {
  padding: 80px 0 8px;
}

.hero-sub {
  padding-bottom: 8px;
}

@media (min-width: 640px) {
  .hero {
    padding-top: 112px;
  }
}

.hero-name {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

@media (min-width: 640px) {
  .hero-name {
    font-size: 40px;
  }
}

@media (min-width: 768px) {
  .hero-name {
    font-size: 48px;
  }
}

.cursor {
  display: inline-block;
  margin-left: 2px;
  font-weight: 400;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.hero-tagline {
  margin: 16px 0 0;
  color: var(--muted-foreground);
  font-size: 14px;
}

@media (min-width: 640px) {
  .hero-tagline {
    font-size: 16px;
  }
}

.page-title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ---- sections ----------------------------------------------------- */

.section {
  border-top: 1px dashed var(--border-dashed);
  padding: 56px 0;
}

@media (min-width: 768px) {
  .section {
    padding: 64px 0;
  }
}

.section-title {
  margin: 0 0 24px;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted-foreground);
}

.prose {
  margin: 0;
  color: var(--foreground);
  line-height: 1.7;
}

/* ---- stack -------------------------------------------------------- */

.stack {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

@media (min-width: 640px) {
  .stack {
    font-size: 15px;
  }
}

.stack-row {
  display: flex;
  flex-direction: column;
  gap: 2px 24px;
}

@media (min-width: 640px) {
  .stack-row {
    flex-direction: row;
  }
}

.stack-label {
  width: 128px;
  flex-shrink: 0;
  color: var(--muted-foreground);
  margin: 0;
}

.stack-items {
  margin: 0;
}

/* ---- post lists --------------------------------------------------- */

.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.post-row {
  display: flex;
  flex-direction: column;
  gap: 2px 24px;
}

@media (min-width: 640px) {
  .post-row {
    flex-direction: row;
  }
}

.post-date {
  width: 112px;
  flex-shrink: 0;
  font-size: 14px;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}

.post-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.post-title {
  text-decoration: none;
  text-underline-offset: 4px;
  transition: color 150ms ease;
}

.post-title:hover {
  text-decoration: underline;
}

.post-desc {
  font-size: 14px;
  color: var(--muted-foreground);
}

/* ---- footer ------------------------------------------------------- */

.footer {
  border-top: 1px dashed var(--border-dashed);
  padding: 40px 0;
}

.socials {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--muted-foreground);
}

.social {
  display: flex;
  align-items: center;
  gap: 8px;
}

.social-link {
  text-decoration: none;
  text-underline-offset: 4px;
  transition: color 150ms ease;
}

.social-link:hover {
  color: var(--foreground);
  text-decoration: underline;
}

/* ---- article (blog post) ------------------------------------------ */

.article {
  padding: 56px 0 0;
}

.back-link {
  display: inline-block;
  margin-bottom: 32px;
  font-size: 14px;
  color: var(--muted-foreground);
  text-decoration: none;
}

.back-link:hover {
  color: var(--foreground);
}

.article-title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.article-date {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}

.article-body {
  margin-top: 40px;
  padding-bottom: 64px;
}

/* Markdown output spacing. */
.prose p {
  margin: 0 0 1.2em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  margin: 1.8em 0 0.6em;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.prose h1 {
  font-size: 24px;
}
.prose h2 {
  font-size: 20px;
}
.prose h3 {
  font-size: 17px;
}

.prose a {
  text-underline-offset: 3px;
}

.prose ul,
.prose ol {
  margin: 0 0 1.2em;
  padding-left: 1.4em;
}

.prose li {
  margin: 0.3em 0;
}

.prose blockquote {
  margin: 0 0 1.2em;
  padding-left: 1em;
  border-left: 2px solid var(--border-dashed);
  color: var(--muted-foreground);
}

.prose code {
  font-family: inherit;
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--accent-hover);
}

.prose pre {
  margin: 0 0 1.2em;
  padding: 16px;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--accent-hover);
  line-height: 1.5;
}

.prose pre code {
  padding: 0;
  background: transparent;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.prose hr {
  border: none;
  border-top: 1px dashed var(--border-dashed);
  margin: 2em 0;
}

.prose table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 0 0 1.2em;
  font-size: 14px;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

/* ---- forms / auth / admin ----------------------------------------- */

.auth {
  padding: 80px 0;
  max-width: 360px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 28px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-grow {
  flex: 1;
}

.field-label {
  font-size: 13px;
  color: var(--muted-foreground);
}

.input {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 150ms ease;
}

.input:focus {
  outline: none;
  border-color: var(--ring);
}

.textarea {
  min-height: 420px;
  resize: vertical;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
  overflow-x: hidden;
  tab-size: 2;
}

.field-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted-foreground);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  color: var(--background);
  background: var(--foreground);
  border: 1px solid var(--foreground);
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 150ms ease;
}

.btn:hover {
  opacity: 0.85;
}

.btn-ghost {
  color: var(--foreground);
  background: transparent;
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--accent-hover);
  opacity: 1;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  font-size: 14px;
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.08);
  border: 1px solid rgba(185, 28, 28, 0.25);
  border-radius: 6px;
}

.dark .form-error {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.25);
}

.link {
  color: var(--muted-foreground);
  text-decoration: none;
  text-underline-offset: 3px;
  cursor: pointer;
  background: none;
  border: none;
  font: inherit;
  padding: 0;
}

.link:hover {
  color: var(--foreground);
  text-decoration: underline;
}

.link-danger:hover {
  color: #b91c1c;
}

.dark .link-danger:hover {
  color: #f87171;
}

/* ---- admin dashboard ---------------------------------------------- */

.admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 56px 0 0;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.inline-form {
  display: inline;
  margin: 0;
}

.admin-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
}

.admin-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 20px;
  padding: 14px 0;
  border-bottom: 1px dashed var(--border-dashed);
}

.admin-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 200px;
}

.admin-row-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}

/* ---- editor ------------------------------------------------------- */

.editor {
  padding: 40px 0 64px;
}

.editor-head {
  margin-bottom: 24px;
}

.editor-head .back-link {
  margin-bottom: 12px;
}

.editor-form {
  margin-top: 0;
}

.editor-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.editor-fields .field {
  flex: 1;
  min-width: 140px;
}

.editor-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

@media (min-width: 860px) {
  .editor-split {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.editor-pane {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.preview {
  min-height: 420px;
  max-height: 72vh;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: auto;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* The editor is wider than the reading column. */
body:has(.editor) .container,
body:has(.admin-head) .container {
  max-width: var(--max-width-wide);
}

/* Keep very long inline tokens (URLs, paths) from overflowing the column. */
.prose {
  overflow-wrap: anywhere;
}

.article-edit {
  margin: 10px 0 0;
  font-size: 14px;
}
