/* Design tokens shared with gauffin's public site: one warm palette, themed via [data-theme]. */
:root {
  --bg: #f7f2ea;
  --panel: #fff;
  --panel-2: #f4eee4;
  --ink: #2a2520;
  --soft: #6b6258;
  --faint: #a89f92;
  --line: #e7dfd3;
  --line-2: #eae1d4;
  --clay: #c26a45;
  --on-clay: #fff;
  --chip-bg: #f4e7dd;
  --chip-line: #ebd8c9;
  --chip-text: #7a4a2e;
  --toggle-bg: #efe7da;
  --card-soft: #fbf7f0;
  --shadow: rgba(40, 30, 20, 0.07);
  --notice-bg: #f3e7cf;
  --notice-text: #99711e;
  --danger: #b0532e;
  --code-keyword: #b0532e;
  --code-string: #2f7a65;
  --code-comment: #a89f92;
  --code-type: #7a4a2e;
  --code-number: #99711e;
  --code-title: #2a2520;
  --serif: "Newsreader", Georgia, serif;
  --sans: "Hanken Grotesk", system-ui, sans-serif;
  --mono: "Spline Sans Mono", ui-monospace, monospace;
}

:root[data-theme="dark"] {
  --bg: #1c1815;
  --panel: #241e18;
  --panel-2: #2a231b;
  --ink: #f2eadf;
  --soft: #a89c8c;
  --faint: #8a8275;
  --line: #352d24;
  --line-2: #352d24;
  --clay: #d98a5e;
  --on-clay: #221208;
  --chip-bg: #2a2017;
  --chip-line: #3a2a1e;
  --chip-text: #e6a079;
  --toggle-bg: #2a2219;
  --card-soft: #221c16;
  --shadow: rgba(0, 0, 0, 0.3);
  --notice-bg: rgba(224, 188, 110, 0.16);
  --notice-text: #e0bc6e;
  --danger: #e6a079;
  --code-keyword: #e6a079;
  --code-string: #8fd0bb;
  --code-comment: #8a8275;
  --code-type: #e0bc6e;
  --code-number: #e0bc6e;
  --code-title: #f2eadf;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.3s ease, color 0.3s ease;
}

::selection {
  background: var(--clay);
  color: var(--on-clay);
}

a {
  color: var(--clay);
  text-underline-offset: 2px;
}

main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 32px 64px;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-wrap: balance;
}

/* Top bar */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 40px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);

  .site-name {
    font-family: var(--serif);
    font-size: 1.375rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--ink);
    text-decoration: none;
  }

  .tagline {
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--clay);
    margin: 4px 0 0;
  }

  .site-nav {
    display: flex;
    align-items: center;
    gap: 26px;

    a {
      color: var(--soft);
      text-decoration: none;
      font-weight: 500;
    }

    a:hover {
      color: var(--ink);
    }
  }
}

theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 6px;
  border-radius: 999px;
  background: var(--toggle-bg);
  cursor: pointer;
  user-select: none;

  .knob {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 12px;
    color: var(--faint);
    transition: background 0.2s ease, color 0.2s ease;
  }
}

:root[data-theme="light"] theme-toggle .knob.sun,
:root[data-theme="dark"] theme-toggle .knob.moon {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 40px;
  font-size: 0.8125rem;
  color: var(--faint);
  text-align: center;

  p {
    margin: 0;
  }

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

/* Home and lists */
/* The home page has no heading of its own, so its first post keeps the room a heading would take. */
main > .post-summary:first-child {
  padding-top: 60px;
}

.listing-heading {
  padding: 56px 0 8px;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
}

.post-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.post-summary {
  padding: 26px 0;
  border-bottom: 1px solid var(--line);

  h2 {
    margin: 6px 0 8px;
    font-size: 1.5rem;

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

    a:hover {
      color: var(--clay);
    }
  }

  p {
    margin: 0;
    color: var(--soft);
  }
}

/* Post */
.post {
  header {
    padding: 56px 0 24px;
  }

  h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.08;
    letter-spacing: -0.02em;
    margin: 10px 0 0;
  }

  .post-hero {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 0 32px;
    border-radius: 10px;
  }

  .post-body {
    font-size: 1.0625rem;

    h2 {
      font-size: 1.75rem;
      margin-top: 2.2em;
    }

    h3 {
      font-size: 1.35rem;
      margin-top: 1.8em;
    }

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

    pre {
      overflow-x: auto;
      padding: 18px 20px;
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 10px;
      box-shadow: 0 1px 2px var(--shadow);
      font-size: 0.875rem;
      line-height: 1.55;
    }

    code {
      font-family: var(--mono);
    }

    :not(pre) > code {
      padding: 0.1em 0.35em;
      background: var(--panel-2);
      border-radius: 4px;
      font-size: 0.88em;
    }

    blockquote {
      margin: 1.5em 0;
      padding: 4px 0 4px 20px;
      border-left: 3px solid var(--clay);
      font-family: var(--serif);
      font-size: 1.15rem;
      color: var(--soft);
    }

    table {
      border-collapse: collapse;

      th,
      td {
        border: 1px solid var(--line);
        padding: 6px 10px;
      }
    }
  }
}

.post-notices {
  margin-top: 24px;
  display: grid;
  gap: 10px;
}

.post-notice {
  margin: 0;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--notice-bg);
  color: var(--notice-text);
  font-size: 0.9375rem;

  a {
    color: inherit;
    font-weight: 600;
  }
}

.post-tags {
  list-style: none;
  padding: 0;
  margin: 40px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;

  a {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    background: var(--chip-bg);
    border: 1px solid var(--chip-line);
    color: var(--chip-text);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
  }
}

.tag-index {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;

  .post-count {
    color: var(--faint);
  }
}

.post-neighbours,
.pagination {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);

  a {
    text-decoration: none;
    font-weight: 500;
  }

  span {
    color: var(--faint);
  }
}

/* Code highlighting: highlight.js token classes in the site palette, so code follows the theme. */
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-doctag {
  color: var(--code-keyword);
}

.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-attribute {
  color: var(--code-string);
}

.hljs-comment,
.hljs-quote,
.hljs-meta {
  color: var(--code-comment);
  font-style: italic;
}

.hljs-type,
.hljs-built_in,
.hljs-title.class_ {
  color: var(--code-type);
}

.hljs-number,
.hljs-symbol,
.hljs-variable.constant_ {
  color: var(--code-number);
}

.hljs-title,
.hljs-title.function_,
.hljs-section {
  color: var(--code-title);
  font-weight: 500;
}

.hljs-deletion {
  color: var(--danger);
}

/* Admin */
.admin {
  main {
    max-width: 1100px;
    padding-top: 32px;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;

    th,
    td {
      text-align: left;
      padding: 8px 10px;
      border-bottom: 1px solid var(--line);
    }
  }

  fieldset {
    margin: 24px 0;
    padding: 16px 20px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
  }

  button {
    padding: 6px 14px;
    border: 0;
    border-radius: 999px;
    background: var(--clay);
    color: var(--on-clay);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
  }

  .outcome-rejected {
    color: var(--danger);
  }

  .share {
    margin: 16px 0;
    padding: 16px 20px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);

    textarea {
      width: 100%;
      margin: 10px 0;
      font: inherit;
    }
  }

  .share-posted {
    opacity: 0.6;
  }

  .share-actions {
    display: flex;
    gap: 8px;

    form {
      margin: 0;
    }
  }

  fieldset > textarea {
    width: 100%;
    font: inherit;
  }
}

@media (max-width: 680px) {
  .site-header {
    padding: 16px 20px;

    .site-nav {
      gap: 16px;
    }
  }

  main {
    padding: 0 20px 48px;
  }

  .site-footer {
    padding: 20px;
  }
}
