/* The engine's neutral base: every blog starts here and lays its own design over it. Warm greys with an
   olive accent and the reader's system fonts, so no blog borrows another's look. Every text color holds
   WCAG AA (4.5:1) against the page background. */
:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --panel-2: #eeeeeb;
  --ink: #222222;
  --soft: #555555;
  --faint: #666666;
  --line: #dcdcd8;
  --line-2: #e5e5e1;
  --accent: #5a6b2e;
  --on-accent: #fff;
  --warm: #8a5a2b;
  --on-warm: #fff;
  --chip-bg: #ecece7;
  --chip-line: #d8d8d2;
  --chip-text: #3f4a20;
  --toggle-bg: #ebebe7;
  --card-soft: #f1f1ee;
  --shadow: rgba(0, 0, 0, 0.08);
  --notice-bg: #f1ead6;
  --notice-text: #6b5414;
  --danger: #a03a2c;
  --code-keyword: #a03a2c;
  --code-string: #3d6b4a;
  --code-comment: #666666;
  --code-type: #5a6b2e;
  --code-number: #6b5414;
  --code-title: #222222;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Menlo, monospace;
}

:root[data-theme="dark"] {
  --bg: #181818;
  --panel: #202020;
  --panel-2: #2a2a2a;
  --ink: #ebebeb;
  --soft: #b0b0b0;
  --faint: #929292;
  --line: #333333;
  --line-2: #333333;
  --accent: #b8c78a;
  --on-accent: #1d220f;
  --warm: #d9a066;
  --on-warm: #24160a;
  --chip-bg: #26291e;
  --chip-line: #3a3f2c;
  --chip-text: #cfd9ac;
  --toggle-bg: #232323;
  --card-soft: #1c1c1c;
  --shadow: rgba(0, 0, 0, 0.35);
  --notice-bg: rgba(214, 190, 120, 0.15);
  --notice-text: #d6be78;
  --danger: #de8c7d;
  --code-keyword: #de8c7d;
  --code-string: #8fc4aa;
  --code-comment: #929292;
  --code-type: #b8c78a;
  --code-number: #d6be78;
  --code-title: #ebebeb;
}

*,
*::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(--warm);
  color: var(--on-warm);
}

a {
  color: var(--accent);
  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;
  }

  .site-brand {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 10px;
  }

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

    &::before {
      content: "- ";
    }
  }

  .author-profiles {
    flex-basis: 100%;
    display: flex;
    gap: 12px;
    margin: 6px 0 0;
    padding: 0;
    list-style: none;

    a {
      display: flex;
      color: var(--soft);

      &:hover,
      &:focus-visible {
        color: var(--accent);
      }
    }
  }

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

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

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

  /* Collapsed to its icon until focused; a typed query keeps it open. The label wraps the input, so a click on the icon focuses it without script. */
  .header-search label {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--soft);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
  }

  .header-search input {
    width: 0;
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--ink);
    font: inherit;
    transition: width 0.2s ease, padding 0.2s ease;
  }

  .header-search:focus-within label,
  .header-search:has(input:not(:placeholder-shown)) label {
    border-color: var(--line);
    background: var(--panel);
    color: var(--ink);

    input {
      width: 180px;
      padding-left: 8px;
    }
  }
}

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);
}

/* Skills aside */
.skills-aside {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 32px 40px;
  font-size: 0.875rem;

  h2 {
    font-size: 1.125rem;
  }

  h3 {
    font-size: 0.9375rem;
    margin: 12px 0 4px;
  }

  ul {
    margin: 0;
    padding-left: 20px;
  }
}

/* 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(--accent);
    }
  }

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

  /* Heroes have no fixed aspect ratio, so each fills a fixed-height band and is cropped around its centre. */
  .summary-hero {
    display: block;
    width: 100%;
    height: 160px;
    margin: 0 0 16px;
    object-fit: cover;
    object-position: center;
    border-radius: 10px;
  }

  &.recent .summary-hero {
    height: 320px;
  }
}

/* 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(--accent);
      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;
  }
}

.post-share {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;

  a {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;

    &:hover,
    &:focus-visible {
      color: var(--accent);
    }
  }
}

.share-label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.share-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;

  .post-share {
    gap: 10px;
  }

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

  svg {
    width: 14px;
    height: 14px;
  }
}

.share-panel {
  position: relative;
  margin: 32px 0 0;
  padding: 18px 22px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-soft);

  .share-label {
    margin: 0 0 12px;
  }

  .post-share {
    gap: 8px;
  }

  a {
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--chip-line);
    background: var(--chip-bg);
    color: var(--chip-text);
    font-size: 0.8125rem;
    font-weight: 500;

    &:hover,
    &:focus-visible {
      border-color: var(--accent);
    }
  }

  svg {
    width: 14px;
    height: 14px;
  }
}

.share-sticker {
  position: absolute;
  top: -10px;
  right: 18px;
  margin: 0;
  padding: 2px 9px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  transform: rotate(3deg);
  box-shadow: 0 2px 6px var(--shadow);

  /* Mid-tone hues that carry white text on both the light and the dark theme. */
  &.moss { background: #5d7a4a; }
  &.clay { background: #a2571d; transform: rotate(-2deg); }
  &.plum { background: #6a3f6b; }
  &.rust { background: #9b3a2e; transform: rotate(-3deg); }
  &.olive { background: #7a6a1f; }
  &.pine { background: #2f5d50; transform: rotate(-2deg); }
}

.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);
  }
}

.search-form {
  display: flex;
  gap: 10px;
  margin: 16px 0 32px;

  input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    color: var(--ink);
    font: inherit;
  }

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

.search-outcome {
  color: var(--soft);
}

/* 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: 1440px;
    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(--accent);
    color: var(--on-accent);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
  }

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

  .report-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
  }

  .report-card {
    display: block;
    padding: 16px 20px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    color: inherit;
    text-decoration: none;
    font-size: 0.9rem;

    h2 {
      margin: 0 0 8px;
      font-size: 1rem;
    }

    p {
      margin: 0;
    }

    .report-count {
      font-size: 1.5rem;
      font-weight: 600;
    }

    &.needs-attention {
      border-color: var(--danger);

      .report-count {
        color: var(--danger);
      }
    }

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

  .broken-links,
  .social-outcomes {
    overflow-wrap: anywhere;
  }

  .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;
  }

  .post-editor textarea {
    display: block;
    margin-bottom: 12px;
    font-family: ui-monospace, monospace;
    font-size: 0.9rem;
  }

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

    form {
      margin: 0;
    }
  }
}

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

    .site-nav {
      gap: 16px;
    }

    .header-search:focus-within label input,
    .header-search:has(input:not(:placeholder-shown)) label input {
      width: 120px;
    }
  }

  main {
    padding: 0 20px 48px;
  }

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