/* ── Reset & Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

html {
  color-scheme: light dark;           /* automatic light/dark via OS */
  hanging-punctuation: first last;
  scroll-behavior: smooth;
}

body {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  font-family: system-ui, sans-serif;
  line-height: 1.6;
}

/* ── Skip-link (accessibility) ── */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  padding: 0.5rem 1rem;
  background: Canvas;
  color: CanvasText;
  z-index: 100;
}
.skip-link:focus {
  left: 0.5rem;
}

/* ── Header / Nav ── */
header {
  margin-bottom: 2rem;
  border-bottom: 1px solid;
  padding-bottom: 0.75rem;
}

.site-branding {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.site-branding img {
  display: block;
}

.site-title {
  font-size: 1.4rem;
  font-weight: 700;
  text-decoration: none;
  color: inherit;
}

.u-logo {
  border-radius: 50%;
  border: 2px solid CanvasText;
}

/* small screens: logo, title, hamburger in one row */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-description {
  display: none;
  text-align: center;
  font-size: 0.95rem;
  color: color-mix(in srgb, currentColor 70%, transparent);
  margin: 0.25rem 0 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid CanvasText;
}

@media (min-width: 36rem) {
  .site-description {
    display: block;
  }
  .header-row {
    display: block;
  }
  .site-branding {
    flex-direction: column;
    justify-content: center;
    margin-bottom: 0.5rem;
  }
}

nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

/* ── Mobile menu ── */
.nav-toggle summary {
  font-size: 1.5rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.nav-toggle summary::-webkit-details-marker { display: none; }

/* Small screens: nav hidden until toggle opened */
header > nav {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

header:has(.nav-toggle[open]) > nav {
  display: flex;
}

.nav-toggle { display: block; }

@media (min-width: 36rem) {
  header > nav {
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
    margin-top: 0;
  }
  .nav-toggle { display: none; }
}

nav a,
.dropdown button {
  text-decoration: none;
  font-weight: 600;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
nav a:hover,
nav a[aria-current="page"],
.dropdown button:hover {
  text-decoration: underline;
}

/* ── Dropdown ── */
.dropdown {
  position: relative;
}

.dropdown ul {
  display: none;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 100%;
  margin: 0.25rem 0 0;
  padding: 0.4rem 0;
  list-style: none;
  background: Canvas;
  border: 1px solid;
  border-radius: 0.25rem;
  min-width: 10rem;
  z-index: 10;
}

.dropdown:hover ul,
.dropdown:focus-within ul {
  display: block;
}

.dropdown ul a {
  display: block;
  padding: 0.35rem 0.75rem;
  white-space: nowrap;
}

.dropdown ul a:hover,
.dropdown ul a:focus {
  background: color-mix(in srgb, CanvasText 10%, Canvas);
}

/* ── Main content ── */
main {
  min-height: 60vh;
}

/* ── Post categories ── */
.post-categories {
  font-size: 0.85rem;
  margin-top: 0.25rem;
  opacity: 0.8;
}

h1, h2, h3 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.2;
  scroll-margin-top: 1rem;
}

/* Allow post page h1 to use more width and not wrap too soon */
.p-name {
  max-width: 100%;
  word-break: break-word;
}

h1:first-child { margin-top: 0; }

p, ul, ol, pre, blockquote {
  margin-bottom: 1em;
}

a {
  color: LinkText;
}

img {
  max-width: 100%;
  height: auto;
}

pre {
  padding: 1rem;
  overflow-x: auto;
  border-radius: 0.25rem;
  background: color-mix(in srgb, CanvasText 8%, Canvas);
}

code {
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
}

blockquote {
  border-left: 3px solid;
  padding-left: 1rem;
  font-style: italic;
}

time {
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.card-meta {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-bottom: 0.5em;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.meta-sep { opacity: 0.5; }

.category-tag {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-decoration: none;
  padding: 0.1em 0.4em;
  border: 1px solid;
  border-radius: 0.2rem;
  opacity: 0.8;
  display: inline-block;
}

/* Extra spacing for category pill at bottom of post card */
.post-card .category-tag {
  margin-bottom: 1rem;
}
.category-tag:hover {
  opacity: 1;
}

/* ── Homepage: Post Grid ── */
.post-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 30rem) {
  .post-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.post-card {
  padding: 0;
  border: 1px solid;
  border-radius: 0.35rem;
  overflow: hidden;
}

.post-card--full {
  grid-column: 1 / -1;
}

.card-image {
  width: 100%;
  height: auto;
  display: block;
}

.post-card h3,
.post-card .card-meta,
.post-card p {
  padding-left: 1rem;
  padding-right: 1rem;
}

.post-card h3 {
  padding-top: 0.75rem;
  margin: 0 0 0.25em;
  font-size: 1.05rem;
  line-height: 1.3;
}
.post-card h3 a {
  color: inherit;
  text-decoration: none;
}
.post-card h3 a:hover {
  text-decoration: underline;
}

.post-card p {
  font-size: 0.9rem;
  margin-bottom: 0;
  padding-bottom: 1rem;
  opacity: 0.85;
}

/* ── Post page image ── */
.post-image {
  width: 100%;
  height: auto;
  border-radius: 0.35rem;
  margin: 1rem 0;
}

/* ── Visually hidden (accessible) ── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Pagination ── */
.pagination {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid;
}

.pagination ul {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.pagination a,
.pagination .disabled {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border: 1px solid;
  border-radius: 0.25rem;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.pagination a:hover {
  background: color-mix(in srgb, CanvasText 10%, Canvas);
}

.pagination .disabled {
  opacity: 0.35;
  cursor: default;
}

/* ── Footer ── */
footer {
  margin-top: 3rem;
  border-top: 1px solid CanvasText;
  padding-top: 0.75rem;
  font-size: 0.85rem;
  color: color-mix(in srgb, currentColor 70%, transparent);
  text-align: center;
}

/* ── Search ── */
.search-form {
  margin-bottom: 1rem;
}

#search-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  border: 1px solid;
  border-radius: 0.25rem;
  background: Canvas;
  color: CanvasText;
}

.search-status {
  font-size: 0.85rem;
  opacity: 0.7;
  min-height: 1.4em;
}

.search-results {
  list-style: none;
  padding: 0;
}

.search-results li {
  padding: 0.75rem 0;
  border-bottom: 1px solid;
}

.search-results li:last-child {
  border-bottom: none;
}

.search-results a {
  font-weight: 600;
  font-size: 1.1rem;
}

.search-results time {
  display: block;
  font-size: 0.8rem;
  margin: 0.15em 0 0.3em;
}

.search-results p {
  font-size: 0.9rem;
  opacity: 0.85;
  margin: 0;
}

/* ── Search section divider ── */
.search-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid;
}

/* ── Category list (search page) ── */
.categories-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid;
}

.category-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-list li {
  margin: 0;
}

.category-list a {
  display: inline-block;
  padding: 0.3em 0.6em;
  border: 1px solid;
  border-radius: 0.25rem;
  text-decoration: none;
  font-weight: 600;
}

.category-list a:hover {
  background: color-mix(in srgb, CanvasText 10%, Canvas);
}

.category-count {
  font-size: 0.8rem;
  font-weight: normal;
  opacity: 0.6;
}

/* ── Projects page ── */
.project-card {
  position: relative;
}

.project-card h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.project-card--old {
  opacity: 0.65;
}

.project-card--old:hover {
  opacity: 0.85;
}

/* ── Post navigation (prev / next) ── */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid;
  font-size: 0.9rem;
  font-weight: 600;
}

.post-nav a {
  max-width: 45%;
}

.post-nav a:only-child:last-child {
  margin-left: auto;
}

/* ── Focus visible (accessibility) ── */
:focus-visible {
  outline: 2px solid LinkText;
  outline-offset: 2px;
}

/* ── Print ── */
@media print {
  .skip-link,
  .nav-toggle,
  nav,
  .pagination,
  .post-nav { display: none; }

  body { max-width: none; padding: 0; }

  header { border: none; }

  a { color: inherit; text-decoration: underline; }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    font-weight: normal;
    opacity: 0.7;
  }

  nav a[href]::after,
  .category-tag[href]::after { content: none; }
}
