/* Article content */
.article-container {
  max-width: var(--max-content-width);
  margin-left: var(--sidebar-width);
  padding: 1rem var(--side-padding);
  padding-bottom: 1rem;
  box-sizing: border-box;
  text-align: left;
}
.article-container h1,
.article-container h2,
.article-container h3 {
  font-family: var(--font-heading);
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 1rem;
}
.article-container p {
  margin: 1.2rem 0;
  font-size: var(--font-size-body);
  font-family: var(--font-body);
}
.article-hero figcaption,
.related-articles li {
  font-family: var(--font-body);
}
.article-hero {
  margin: 0 0 2rem;
}
.article-hero img {
  width: 100%;
  margin: 0;
  border-radius: 14px;
}
.article-hero figcaption {
  margin-top: 0.75rem;
  font-size: var(--font-size-meta);
  color: var(--color-meta);
  text-align: center;
}
.related-articles {
  margin: 3rem 0 1rem;
  padding: 1.5rem;
  border: 1px solid rgba(127, 127, 127, 0.2);
  border-radius: 12px;
  background: rgba(127, 127, 127, 0.06);
}
.related-articles h2 {
  margin-top: 0;
}
.related-articles ul {
  margin: 0;
  padding-left: 1.25rem;
}
.related-articles li + li {
  margin-top: 0.75rem;
}
.article-container img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
  border-radius: 8px;
}
.article-container a {
  color: var(--color-link);
  text-decoration: none;
}

.article-container a {
  text-decoration: underline;
}

@supports (animation-timeline: scroll()) {
  body.home-page:has(.article-container > article)::before {
    content: "";
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    height: 4px;
    background: #000000;
    transform: scaleX(0);
    transform-origin: left center;
    animation: article-scroll-progress linear both;
    animation-timeline: scroll(root block);
    pointer-events: none;
    z-index: 1000;
  }

  :root[data-theme="dark"] body.home-page:has(.article-container > article)::before {
    background: #ffffff;
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) body.home-page:has(.article-container > article)::before {
      background: #ffffff;
    }
  }

  @keyframes article-scroll-progress {
    from {
      transform: scaleX(0);
    }

    to {
      transform: scaleX(1);
    }
  }

  @media (max-width: 860px), (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
    body.home-page:has(.article-container > article)::before {
      left: 0;
      width: 100%;
    }
  }
}

/* Responsive */
@media (max-width: 900px) {
  .article-container {
    margin-left: 170px;
    padding: 1rem 1.5rem;
    padding-bottom: 1rem;
  }
}
@media (max-width: 768px) {
  .article-container {
    margin-left: 160px;
    padding: 1rem 1.2rem;
    padding-bottom: 1rem;
  }
}

:not(.mac-terminal) code {
  background-color: rgba(0, 0, 0, 0.08); /* light neutral grey */
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  box-decoration-break: clone;
}

/* Large screens (≥1600px) */
@media (min-width: 1600px) {
  .article-container {
    max-width: 800px;
    padding: 1rem 2rem;
    padding-bottom: 1rem;
  }
}

/* macOS dark terminal theme */
.mac-terminal {
  position: relative;
  background: #1e1e1e;
  color: #dcdcdc;
  border-radius: 10px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  padding: 2rem 1.25rem 1.25rem 1.25rem;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
  overflow-x: auto;
  margin: 2rem 0;
  background-color: #1e1e1e;
}

/* Traffic light buttons */
.mac-terminal::before {
  content: "";
  position: absolute;
  top: 0.7rem;
  left: 1rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff5f56;
  box-shadow:
    20px 0 #ffbd2e,
    40px 0 #27c93f;
}

/* Terminal header line (subtle separator) */
.mac-terminal::after {
  content: "";
  position: absolute;
  top: 2rem;
  left: 0;
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.05);
}

/* Code inside the terminal */
.mac-terminal code {
  padding-top: 1rem;
  display: block;
  color: #dcdcdc;
  font-size: var(--font-size-card-text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: visible;
  overflow-y: visible;
  max-height: none;
  background-color: transparent;
}

/* Shell-like syntax colors */
.mac-terminal .dir,
.mac-terminal .prompt {
  color: #4fc1ff;
}
.mac-terminal .cmd {
  color: #a0e08d;
}
.mac-terminal .error {
  color: #ff5f56;
}
.mac-terminal .success {
  color: #27c93f;
}
.mac-terminal .path {
  color: #b19cd9;
}

.mac-terminal a {
  color: #9c7bff;
  text-decoration: none;
}
.mac-terminal a:hover {
  text-decoration: underline;
}

/* Scrollbar styling */
.mac-terminal::-webkit-scrollbar {
  height: 8px;
}
.mac-terminal::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

@media (max-width: 860px), (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  body {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }
  .article-container {
    margin: 0 auto;
    padding: 1rem 1rem calc(4.5rem + env(safe-area-inset-bottom, 0px));
    padding-bottom: 1rem;
    max-width: 90%;
  }
  .mac-terminal {
    font-size: var(--font-size-meta);
    padding: 1.8rem clamp(0.75rem, 4vw, 1.15rem) 1rem;
    margin-top: 2rem;
    margin-inline: auto;
    margin-bottom: 1.5rem;
    width: min(480px, calc(100% - 1.6rem));
    border-radius: 8px;
    overflow: visible;
    z-index: 0;
  }
  .mac-terminal::before {
    top: 0.6rem;
    left: 0.8rem;
    transform: scale(0.9);
  }
}
