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

:root {
  --bg:       #fafaf8;
  --fg:       #1a1a1a;
  --muted:    #666;
  --accent:   #2b5fa3;
  --border:   #ddd;
  --code-bg:  #f4f4f2;
  --max-w:    860px;
}

.wip-banner {
  background: #fffbe6;
  border-bottom: 1px solid #e8d87f;
  color: #7a6000;
  font-family: monospace;
  font-size: 0.8rem;
  text-align: center;
  padding: 0.45rem 1rem;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.0625rem;
  line-height: 1.75;
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;

  &:hover {
    text-decoration: underline;
    text-decoration-thickness: 2px;
  }

  &:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    text-decoration: none;
  }
}

.skip-link {
  position: absolute;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  white-space: nowrap;
  background: var(--fg);
  color: var(--bg);
  padding: 8px;
  text-decoration: none;
  z-index: 100;

  &:focus {
    position: fixed;
    top: 0;
    left: 0;
    clip: auto;
    clip-path: none;
    width: auto;
    height: auto;
    white-space: normal;
  }
}

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

*:focus:not(:focus-visible) {
  outline: none;
}

header, main, footer {
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

header {
  padding-block: 1.1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;

  nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;

    .logo {
      font-size: 1.05rem;
      font-weight: bold;
      color: var(--fg);
      margin-right: auto;
      text-decoration: none;

      &:hover, &:focus { text-decoration: none; }
    }

    ul {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      gap: 1.25rem;

      a {
        font-size: 0.9rem;
        color: var(--muted);
        text-decoration: none;

        &:hover, &:focus {
          color: var(--fg);
          text-decoration: underline;
        }
      }
    }
  }
}

.hero {
  margin-bottom: 2.5rem;

  h1 {
    margin: 0 0 0.35rem;
    font-size: 1.75rem;
  }

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

  a {
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 0.2em;
    font-weight: 500;

    &:hover {
      text-decoration-thickness: 2.5px;
    }
  }
}

.home-layout {
  display: grid;
  grid-template-columns: 1fr 210px;
  gap: 3rem;
  align-items: start;

  @media (max-width: 620px) {
    grid-template-columns: 1fr;
  }
}

.tag {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  margin-left: 0.5rem;
}

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

.post-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.tag-filter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);

  .tag-filter-label {
    font-size: 0.78rem;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--muted);
    margin-right: 0.25rem;
  }

  .tag-link {
    font-size: 0.875rem;
    color: var(--muted);
    text-decoration: none;

    &:hover {
      color: var(--fg);
      text-decoration: underline;
    }

    &.active {
      color: var(--accent);
      font-weight: 600;
    }
  }
}

.posts {
  .post {
    padding-bottom: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);

    &:last-child { border-bottom: none; }

    .post-meta {
      display: flex;
      gap: 0.75rem;
      margin-bottom: 0.35rem;

      .date {
        font-family: monospace;
        font-size: 0.82rem;
        color: var(--muted);
      }

      .tag {
        font-size: 0.8rem;
        color: var(--accent);
      }
    }

    h2 {
      margin: 0 0 0.5rem;
      font-size: 1.2rem;

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

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

    p {
      margin: 0 0 0.6rem;
      color: var(--muted);
    }

    .read-more {
      font-size: 0.875rem;
      text-decoration: none;

      &:hover { text-decoration: underline; }
    }
  }

  .empty-state {
    color: var(--muted);
    font-style: italic;
  }
}

.link-sidebar {
  .sidebar-title {
    margin: 0 0 0.75rem;
    font-size: 0.78rem;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--muted);
  }

  .link-list {
    list-style: none;
    margin: 0;
    padding: 0;

    li {
      padding: 0.35rem 0;
      border-bottom: 1px solid var(--border);

      &:last-child { border-bottom: none; }

      a { font-size: 0.875rem; }
    }

    .link-empty {
      font-size: 0.875rem;
      font-style: italic;
      color: var(--muted);
    }
  }
}

.post-full {
  max-width: 680px;

  .post-header {
    margin-bottom: 2rem;

    .date {
      margin: 0 0 0.35rem;
      font-family: monospace;
      font-size: 0.82rem;
      color: var(--muted);
    }

    h1 {
      margin: 0;
      font-size: 2rem;
      line-height: 1.25;
    }
  }

  .post-content {
    white-space: pre-wrap;
  }

  .post-content h2,
  .post-content h3,
  .post-content h4 {
    margin-top: 2rem;
  }

  .post-content p {
    margin: 0 0 1.2rem;
  }

  .post-content a {
    text-decoration: underline;
  }

  .post-content code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875em;
    background: var(--code-bg);
    padding: 0.15em 0.35em;
    border-radius: 3px;
  }

  .post-content pre {
    background: var(--code-bg);
    padding: 1rem 1.25rem;
    overflow-x: auto;
    border-left: 3px solid var(--border);
    line-height: 1.5;
  }

  .post-content pre code {
    background: none;
    padding: 0;
    font-size: 0.875rem;
  }

  .post-content blockquote {
    margin: 1.5rem 0;
    padding: 0.2rem 1.25rem;
    border-left: 3px solid var(--border);
    color: var(--muted);
    font-style: italic;
  }

  .post-content ul,
  .post-content ol {
    padding-left: 1.5rem;
    margin-bottom: 1.2rem;
  }

  .post-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
  }
}

.post-nav {
  max-width: 680px;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);

  a {
    font-size: 0.875rem;
    color: var(--muted);

    &:hover {
      color: var(--fg);
      text-decoration: none;
    }
  }
}

.qna {
  max-width: 680px;

  details {
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0;

    &:first-child { border-top: 1px solid var(--border); }

    &[open] summary::before { content: '− '; }

    summary {
      cursor: pointer;
      font-weight: bold;
      list-style: none;
      padding: 0.2rem 0;

      &::-webkit-details-marker { display: none; }
      &::marker               { display: none; }
      &::before {
        content: '+ ';
        color: var(--muted);
      }
    }

    p {
      margin: 0.75rem 0 0.3rem;
      padding-left: 1rem;
      color: var(--muted);
    }
  }
}

footer {
  margin-top: 4rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--border);

  p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
    text-align: center;
  }
}