/* A personal blog about code, typography and quiet evenings — a terminal theme.
   Dark background, monospace font, lines instead of cards. The boldness is in
   the typography and silence, not in shadows: there is not a single shadow here. */

:root {
  color-scheme: dark;

  --bg: #0e1113;
  --panel: #15191c;
  --fg: #d8dee3;
  --muted: #7a838c;
  --accent: #e8a33d;
  --green: #7fb069;
  --red: #cf6a5a;
  --rule: #262c31;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  /* Modular scale: the large heading works like an image,
     the rest — a calm body size. */
  --t-xs: 0.75rem;
  --t-sm: 0.8125rem;
  --t-base: 1rem;
  --t-md: 1.25rem;
  --t-lg: 1.5rem;
  --t-xl: 2rem;
  --t-hero: clamp(2rem, 7vw, 3.25rem);

  --page: 46rem;
  --measure: 42rem;
}

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

body {
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
  max-width: var(--page);
  background: var(--bg);
  color: var(--fg);
  font: var(--t-base)/1.7 var(--mono);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

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

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

/* Header: a shell prompt invitation */

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 3rem;
}

.site-title {
  color: var(--muted);
  text-decoration: none;
  font-size: var(--t-base);
}

.prompt-host { color: var(--green); }
.prompt-path { color: var(--accent); }

.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  background: var(--green);
  vertical-align: text-bottom;
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  align-items: baseline;
  font-size: var(--t-sm);
}

.site-nav > a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav > a:hover,
.site-title:hover { color: var(--accent); }

.search-form input {
  padding: 0.25rem 0;
  width: 8rem;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: var(--t-sm);
}

.search-form input:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.search-form input::placeholder { color: var(--muted); }

/* Above the fold */

.hero {
  padding: 2rem 0 3rem;
  border-bottom: 1px solid var(--rule);
}

.hero h1 {
  max-width: 18ch;
  font-size: var(--t-hero);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.hero-lead {
  margin: 1rem 0 2rem;
  max-width: 44ch;
  color: var(--muted);
  font-size: var(--t-md);
  line-height: 1.4;
}

.button {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: var(--t-sm);
  font-weight: 600;
  text-decoration: none;
}

.button:hover { background: var(--accent); color: var(--bg); }

.section-title {
  margin: 3rem 0 1rem;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Post list: rows, like ls output */

.post-list {
  border-top: 1px solid var(--rule);
}

.post-row {
  display: flex;
  gap: 1rem;
  padding: 1.2rem 0.25rem;
  border-bottom: 1px solid var(--rule);
  transition: background 0.12s;
}

.post-row:hover { background: var(--panel); }

.post-row h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.post-row h2 a {
  color: var(--fg);
  text-decoration: none;
}

.post-row h2 a::before {
  content: '> ';
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.15s;
}

.post-row:hover h2 a::before { opacity: 1; }

.post-row h2 a:hover { color: var(--accent); }

.row-thumb,
.row-letter {
  flex: 0 0 3rem;
  align-self: flex-start;
  height: 3rem;
  border-radius: 2px;
  overflow: hidden;
}

.row-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.25) contrast(1.05);
}

.row-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  font-size: var(--t-md);
  font-weight: 700;
}

/* Warm muted tones for the badges — distinguishable but not loud */
.tone-0 { background: #4a3b2a; }
.tone-1 { background: #3a4632; }
.tone-2 { background: #3a3650; }
.tone-3 { background: #4a3028; }
.tone-4 { background: #2e3d4a; }
.tone-5 { background: #463d24; }
.tone-6 { background: #33403a; }
.tone-7 { background: #4a2e3a; }

.row-text { flex: 1; min-width: 0; }

.excerpt {
  margin: 0.25rem 0 0.6rem;
  color: var(--muted);
  font-size: var(--t-sm);
  line-height: 1.6;
}

.meta {
  color: var(--muted);
  font-size: var(--t-xs);
}

.tags { color: var(--green); }

.tag {
  margin-left: 0.5rem;
  color: var(--green);
  text-decoration: none;
}

.tag:first-child { margin-left: 0; }

.tag:hover { color: var(--accent); text-decoration: underline; }

/* Featured post: a bordered panel, no shadow */

.post-featured {
  margin-bottom: 2.5rem;
  border: 1px solid var(--rule);
  background: var(--panel);
}

.post-featured-text { padding: 1.5rem 1.4rem; }

.post-featured .post-cover { display: block; }

.post-featured .post-cover img {
  display: block;
  width: 100%;
  max-height: 22rem;
  object-fit: cover;
  border-bottom: 1px solid var(--rule);
  filter: grayscale(0.25) contrast(1.05);
}

.post-featured h2 {
  font-size: var(--t-lg);
  line-height: 1.25;
}

.post-featured h2 a {
  color: var(--fg);
  text-decoration: none;
}

.post-featured h2 a:hover { color: var(--accent); }

.post-featured .excerpt {
  margin: 0.7rem 0 1rem;
  color: var(--muted);
  font-size: var(--t-sm);
}

.empty {
  padding: 3rem 0;
  color: var(--muted);
  font-size: var(--t-md);
}

/* Post page: a narrow column for reading */

.post {
  margin: 0 auto;
  padding-top: 2rem;
  max-width: var(--measure);
}

.post h1 {
  margin-bottom: 0.7rem;
  font-size: var(--t-xl);
  letter-spacing: -0.025em;
}

.post > .meta { margin: 0 0 2.5rem; }

.draft-badge {
  margin-left: 0.7rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: var(--t-xs);
}

.post-body > *:first-child { margin-top: 0; }

.post-body h2 {
  margin: 2.8rem 0 0.7rem;
  font-size: var(--t-md);
  color: var(--green);
}

.post-body h3 {
  margin: 2rem 0 0.5rem;
  font-size: var(--t-base);
}

.post-body p { margin: 0 0 1.4rem; }

.post-body ul,
.post-body ol {
  margin: 0 0 1.4rem;
  padding-left: 1.4rem;
}

.post-body li { margin-bottom: 0.4rem; }

.post-body blockquote {
  margin: 2.2rem 0;
  padding-left: 1.3rem;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}

.post-body blockquote p:last-child { margin-bottom: 0; }

.post-body img {
  display: block;
  margin: 2.2rem 0;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 2px;
}

.post-body figcaption {
  margin-top: -1.4rem;
  color: var(--muted);
  font-size: var(--t-sm);
}

.post-body hr {
  margin: 3rem 0;
  width: 3rem;
  border: 0;
  border-top: 1px solid var(--rule);
}

.post-body code {
  padding: 0.1rem 0.3rem;
  background: var(--panel);
  color: var(--accent);
  font-size: 0.9em;
}

.post-body pre {
  margin: 2rem 0;
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-left: 2px solid var(--accent);
  background: var(--panel);
  line-height: 1.55;
}

.post-body pre code {
  padding: 0;
  background: none;
  color: var(--fg);
}

/* Syntax highlighting (highlight.js — GitHub Dark adapted) */

.hljs-comment,
.hljs-quote { color: #8b949e; font-style: italic; }

.hljs-keyword,
.hljs-selector-tag,
.hljs-type,
.hljs-built_in { color: #ff7b72; }

.hljs-string,
.hljs-attr + .hljs-string,
.hljs-template-variable { color: #a5d6ff; }

.hljs-number,
.hljs-literal,
.hljs-variable,
.hljs-params { color: #79c0ff; }

.hljs-function .hljs-title,
.hljs-title.function_ { color: #d2a8ff; }

.hljs-title.class_ { color: #ffa657; }

.hljs-attr,
.hljs-attribute { color: #79c0ff; }

.hljs-symbol,
.hljs-bullet { color: #f2cc60; }

.hljs-regexp { color: #a5d6ff; }

.hljs-section { color: #1f6feb; font-weight: 700; }

.hljs-meta { color: #8b949e; }

.hljs-addition { color: #aff5b4; background: rgba(3, 58, 22, 0.5); }
.hljs-deletion { color: #ffdcd7; background: rgba(103, 6, 12, 0.5); }

.post-body table {
  margin: 2rem 0;
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
}

.post-body th,
.post-body td {
  padding: 0.6rem 0.8rem 0.6rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

/* Footnotes */

.post-body sup.footnote-ref a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.post-body sup.footnote-ref a:hover {
  text-decoration: underline;
}

.post-body hr.footnotes-sep {
  margin-top: 2.5rem;
}

.post-body section.footnotes {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: var(--t-sm);
}

.post-body section.footnotes ol {
  padding-left: 1.4rem;
}

.post-body section.footnotes li {
  margin-bottom: 0.6rem;
}

.post-body .footnote-backref {
  color: var(--accent);
  text-decoration: none;
  margin-left: 0.3rem;
}

.post-body .footnote-backref:hover {
  text-decoration: underline;
}

.post-tags {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
}

/* Pagination and footer */

.pagination {
  display: flex;
  gap: 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-size: var(--t-sm);
}

.pagination span { color: var(--muted); }

.pagination a { text-decoration: none; }

.pagination a:hover { text-decoration: underline; }

.site-footer {
  margin-top: 5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: var(--t-sm);
}

.site-footer p { margin: 0.3rem 0; }

/* Admin: the same panels and fields */

.form,
.editor {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 2rem auto 2.5rem;
  max-width: var(--measure);
}

.form label,
.editor label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--muted);
  font-size: var(--t-sm);
}

input,
textarea,
button {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--panel);
  color: var(--fg);
  font: inherit;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

input::placeholder,
textarea::placeholder { color: var(--muted); }

textarea {
  min-height: 20rem;
  font-size: var(--t-sm);
  line-height: 1.6;
  resize: vertical;
}

button {
  cursor: pointer;
  font-size: var(--t-sm);
  font-weight: 600;
}

button:hover { border-color: var(--accent); color: var(--accent); }

/* Markdown toolbar */

.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.35rem;
  border: 1px solid var(--rule);
  border-bottom: none;
  background: var(--panel);
}

.md-toolbar-btn {
  padding: 0.25rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--t-sm);
  font-weight: 600;
  line-height: 1;
  min-width: 1.8rem;
  text-align: center;
}

.md-toolbar-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: none;
}

/* Toolbar attached to textarea — remove double border */
.md-toolbar + textarea { border-top: none; }

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
}

.editor-actions button:last-of-type {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}

.editor-actions button:last-of-type:hover { color: var(--bg); }

.inline-form { display: inline; }

.link-button {
  padding: 0;
  border: none;
  background: none;
  color: var(--red);
  font-size: inherit;
  font-weight: 400;
}

.link-button:hover {
  border: none;
  color: var(--accent);
  text-decoration: underline;
}

.admin-table {
  margin: 0 auto;
  max-width: var(--measure);
  width: 100%;
  border-collapse: collapse;
}

.admin-table td {
  padding: 0.8rem 0.5rem 0.8rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}

.admin-table td:last-child {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.filters {
  margin: 2rem auto 1.5rem;
  max-width: var(--measure);
  font-size: var(--t-sm);
}

.filters a { margin-right: 1.3rem; }

.upload {
  color: var(--muted);
  font-size: var(--t-sm);
}

.error,
.notice {
  margin: 0 auto 1.5rem;
  max-width: var(--measure);
  padding: 0.75rem 1rem;
  border-left: 2px solid var(--red);
  background: var(--panel);
  font-size: var(--t-sm);
}

.error { color: var(--red); }

.notice { border-left-color: var(--green); color: var(--green); }

.preview {
  margin: 3rem auto 0;
  max-width: var(--measure);
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
}

.preview h2 {
  margin-bottom: 1.2rem;
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Narrow screen */

@media (max-width: 40rem) {
  body { padding: 1.5rem 1.1rem 4rem; }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.7rem;
  }

  .site-nav { width: 100%; }

  .search-form { flex: 1; }

  .search-form input { width: 100%; }

  .hero { padding: 1.5rem 0 2rem; }

  .hero h1 { max-width: none; }

  .hero-lead { max-width: none; }

  .editor-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print */

@media print {
  .site-header,
  .site-footer,
  .pagination,
  .hero,
  .post-tags { display: none; }

  body {
    max-width: none;
    padding: 0;
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  .post {
    max-width: none;
    padding-top: 0;
  }

  .post-body pre,
  .post-body code {
    background: none;
    color: #000;
  }
}
