/* Blog-specific accessibility and reading layer */
/* Designed to sit safely on top of main site CSS */

/* ------------------------------ */
/* Base safety                    */
/* ------------------------------ */

html {
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
}

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

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
  height: auto;
}

/* ------------------------------ */
/* Skip link                      */
/* ------------------------------ */

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 1000;
  padding: 0.75rem 1rem;
  background: #ffffff;
  color: #000000;
  border: 2px solid currentColor;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 1rem;
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

/* ------------------------------ */
/* Reading helpers                */
/* ------------------------------ */

.lede {
  font-size: 1.15rem;
  line-height: 1.75;
  max-width: 60ch;
  margin-bottom: 1.25rem;
}

.hint {
  font-size: 0.95rem;
  line-height: 1.6;
  opacity: 0.85;
}

/* ------------------------------ */
/* Main reading container         */
/* ------------------------------ */

main .content.wide,
article,
.post-content,
.post-body {
  width: 100%;
  max-width: 74ch;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* ------------------------------ */
/* Base article typography        */
/* ------------------------------ */

main .content.wide,
main .content.wide p,
main .content.wide li,
article,
article p,
article li,
.post-content,
.post-content p,
.post-content li,
.post-body,
.post-body p,
.post-body li,
.post-excerpt {
  font-size: 1.0625rem;
  line-height: 1.8;
}

main .content.wide p,
article p,
.post-content p,
.post-body p {
  margin-top: 0;
  margin-bottom: 1.15rem;
}

main .content.wide ul,
main .content.wide ol,
article ul,
article ol,
.post-content ul,
.post-content ol,
.post-body ul,
.post-body ol {
  margin-top: 0;
  margin-bottom: 1.25rem;
  padding-left: 1.4rem;
}

main .content.wide li,
article li,
.post-content li,
.post-body li {
  margin-bottom: 0.45rem;
}

/* ------------------------------ */
/* Headings                       */
/* ------------------------------ */

main .content.wide h1,
main .content.wide h2,
main .content.wide h3,
main .content.wide h4,
article h1,
article h2,
article h3,
article h4,
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4 {
  line-height: 1.2;
  margin-top: 2rem;
  margin-bottom: 0.85rem;
  scroll-margin-top: 1rem;
}

main .content.wide h1,
article h1,
.post-content h1,
.post-body h1 {
  font-size: clamp(2rem, 6vw, 2.75rem);
  letter-spacing: -0.02em;
  text-wrap: pretty;
}

main .content.wide h2,
article h2,
.post-content h2,
.post-body h2 {
  font-size: clamp(1.45rem, 4vw, 1.9rem);
}

main .content.wide h3,
article h3,
.post-content h3,
.post-body h3 {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
}

/* ------------------------------ */
/* Post shell                     */
/* ------------------------------ */

.post-content {
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
}

.post-header {
  margin-bottom: 1.25rem;
}

.post-content > h1,
article h1 {
  max-width: none;
  margin-bottom: 0.75rem;
}

.post-meta {
  font-size: 0.95rem;
  line-height: 1.6;
  opacity: 0.85;
  margin-bottom: 1rem;
}

/* ------------------------------ */
/* Callouts / quotes / rules      */
/* ------------------------------ */

main .content.wide blockquote,
article blockquote,
.post-content blockquote,
.post-body blockquote {
  margin: 1.75rem 0;
  padding: 1rem 1.1rem;
  border-left: 4px solid currentColor;
  background: rgba(0, 0, 0, 0.04);
}

main .content.wide hr,
article hr,
.post-content hr,
.post-body hr {
  margin: 2rem 0;
}

/* ------------------------------ */
/* Wrapping and links             */
/* ------------------------------ */

main .content.wide,
main .content.wide a,
article,
.post-content,
.post-body,
.post-title a,
.archive-item a,
.post-excerpt,
.post-meta {
  overflow-wrap: anywhere;
  word-break: break-word;
}

main .content.wide a,
article a,
.post-content a,
.post-body a,
.post-excerpt a {
  text-decoration: underline;
  text-underline-offset: 0.16em;
  text-decoration-thickness: 0.08em;
}

a:hover {
  text-decoration-thickness: 0.12em;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
.topic-btn:focus-visible,
.archive-search:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

/* ------------------------------ */
/* Featured post                  */
/* ------------------------------ */

.post-featured {
  padding: 1.5rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 0.75rem;
  margin-bottom: 2rem;
  background: rgba(0, 0, 0, 0.03);
}

.post-featured .post-title,
.post-featured h2,
.post-featured h3 {
  margin-top: 0;
}

.post-excerpt {
  margin-bottom: 1rem;
  max-width: 65ch;
}

/* ------------------------------ */
/* Card grid                      */
/* ------------------------------ */

.post-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.post-grid > * {
  min-width: 0;
}

@media (min-width: 900px) {
  .post-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.post-card {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.75rem;
  background: rgba(0, 0, 0, 0.015);
}

.post-card > * {
  min-width: 0;
  max-width: 100%;
}

.post-card .post-title,
.post-card h2,
.post-card h3 {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 0;
  margin-bottom: 0.75rem;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-wrap: pretty;
}

.post-card .post-title a,
.post-card h2 a,
.post-card h3 a {
  display: inline;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-wrap: pretty;
}

.post-card .post-meta,
.post-card .post-excerpt,
.post-card p,
.post-card li {
  max-width: 100%;
  min-width: 0;
}

.post-card .post-meta {
  margin-bottom: 0.75rem;
}

.post-card .post-excerpt,
.post-card p {
  margin-bottom: 1rem;
}

/* ------------------------------ */
/* Archive search                 */
/* ------------------------------ */

.archive-search {
  width: 100%;
  max-width: 32rem;
  min-height: 44px;
  padding: 0.7rem 0.85rem;
  margin: 1rem 0 1.25rem;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 0.5rem;
  font: inherit;
  line-height: 1.4;
}

/* ------------------------------ */
/* Archive list                   */
/* ------------------------------ */

.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.archive-item {
  padding: 0.8rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.archive-item a {
  display: inline-block;
  line-height: 1.5;
}

.archive-date {
  font-size: 0.92rem;
  line-height: 1.5;
  opacity: 0.8;
  margin-left: 0.5rem;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .archive-date {
    display: block;
    margin-left: 0;
    margin-top: 0.25rem;
    white-space: normal;
  }
}

/* ------------------------------ */
/* Topic buttons                  */
/* ------------------------------ */

.topic-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0 2rem;
}

.topic-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  line-height: 1.3;
  text-align: center;
}

/* ------------------------------ */
/* Tables and code overflow       */
/* ------------------------------ */

table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

pre,
code {
  overflow-wrap: normal;
  word-break: normal;
}

pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 0.9rem 1rem;
}

/* ------------------------------ */
/* Screen reader utility          */
/* ------------------------------ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------ */
/* Motion preferences             */
/* ------------------------------ */

@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------ */
/* Mobile refinements             */
/* ------------------------------ */

@media (max-width: 767px) {
  main .content.wide,
  article,
  .post-content,
  .post-body {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  main .content.wide,
  main .content.wide p,
  main .content.wide li,
  article,
  article p,
  article li,
  .post-content,
  .post-content p,
  .post-content li,
  .post-body,
  .post-body p,
  .post-body li,
  .post-excerpt {
    font-size: 1rem;
    line-height: 1.8;
  }

  .post-content > h1,
  article h1 {
    font-size: clamp(1.9rem, 8vw, 2.4rem);
    max-width: none;
    text-wrap: pretty;
  }

  .post-featured,
  .post-card {
    padding: 1rem;
  }

  .post-meta {
    font-size: 0.92rem;
  }
}

/* ------------------------------ */
/* Desktop reading rebalance      */
/* ------------------------------ */

@media (min-width: 1000px) {
  main .content.wide,
  article,
  .post-content,
  .post-body {
    width: min(92vw, 1120px);
    max-width: 1120px;
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .post-header {
    width: min(100%, 920px);
    max-width: 920px;
    margin-bottom: 1.5rem;
  }

  .post-content > h1,
  article h1 {
    max-width: 920px;
    font-size: clamp(2.5rem, 4vw, 4rem);
    line-height: 1.08;
    letter-spacing: -0.025em;
    margin-bottom: 1rem;
    text-wrap: balance;
  }

  .post-content > .post-meta,
  .post-meta {
    max-width: 920px;
    margin-bottom: 1.25rem;
  }

  .post-content p,
  article p,
  .post-content ul,
  .post-content ol,
  article ul,
  article ol,
  .post-content blockquote,
  article blockquote,
  .post-content hr,
  article hr {
    max-width: 760px;
  }

  .post-content,
  .post-content p,
  .post-content li,
  article,
  article p,
  article li {
    font-size: 1.125rem;
    line-height: 1.8;
  }
}
