/* Bytecraft — reading experience for an English-language audience.
   Overrides only; the Butterfly theme files stay untouched. */

:root {
  --trans-light: rgba(255, 255, 255, 0.96);
  --trans-dark: rgba(24, 26, 32, 0.96);
  --border-soft: 1px solid rgba(0, 0, 0, 0.07);
  --bc-accent: #2f6feb;
  --bc-read-width: 720px;
}

[data-theme="dark"] {
  --border-soft: 1px solid rgba(255, 255, 255, 0.09);
}

/* ---------- typography ---------- */

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#article-container,
.post-content {
  font-size: 18px;
  line-height: 1.75;
  letter-spacing: 0.005em;
}

@media (max-width: 768px) {
  #article-container,
  .post-content {
    font-size: 17px;
    line-height: 1.7;
  }
}

/* comfortable measure: long English lines are the #1 readability killer */
#article-container > p,
#article-container > ul,
#article-container > ol,
#article-container > blockquote {
  max-width: var(--bc-read-width);
}

#article-container p {
  margin: 0 0 1.15em;
}

#article-container h2 {
  font-size: 1.5em;
  margin: 2.2em 0 0.75em;
  padding-left: 0.6em;
  border-left: 4px solid var(--bc-accent);
  line-height: 1.35;
}

#article-container h3 {
  font-size: 1.2em;
  margin: 1.8em 0 0.6em;
}

#article-container h2:first-child,
#article-container h3:first-child {
  margin-top: 0.6em;
}

#article-container a {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

/* ---------- code ---------- */

#article-container code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    monospace;
  font-size: 0.88em;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background: rgba(47, 111, 235, 0.09);
}

#article-container pre {
  border-radius: 10px;
  line-height: 1.6;
  font-size: 0.86em;
}

#article-container pre code {
  background: none;
  padding: 0;
  font-size: 1em;
}

/* ---------- tables ---------- */

#article-container table {
  font-size: 0.94em;
  border-collapse: collapse;
}

#article-container table th {
  background: rgba(47, 111, 235, 0.08);
  border-bottom: 2px solid rgba(47, 111, 235, 0.35);
  font-weight: 600;
}

#article-container table td,
#article-container table th {
  padding: 0.55em 0.85em;
}

/* ---------- surfaces ---------- */

#recent-posts > .recent-post-item {
  background: var(--trans-light);
  border-radius: 18px;
  border: var(--border-soft);
}

#aside-content .card-widget {
  background: var(--trans-light);
  border-radius: 16px;
  border: var(--border-soft);
}

div#post,
div#page,
div#category,
div#archive {
  background: var(--trans-light);
  border-radius: 18px;
  border: var(--border-soft);
}

[data-theme="dark"] #recent-posts > .recent-post-item,
[data-theme="dark"] #aside-content .card-widget,
[data-theme="dark"] div#post,
[data-theme="dark"] div#page,
[data-theme="dark"] div#category,
[data-theme="dark"] div#archive {
  background: var(--trans-dark);
}

#footer {
  background: transparent !important;
}

#footer::before {
  background: transparent !important;
}

/* ---------- above the fold ---------- */
/* The theme paints #page-header with `background-color: $light-blue` (#49b1f5).
 * On archive/category/tag pages top_img resolves to false and no inline
 * background-image is emitted, so that blue is all the visitor sees: a 400px flat
 * slab where the starfield should be.
 *
 * Clear only the COLOR. Using the `background` shorthand (or `background: none
 * !important`) would also wipe the inline `style="background-image: url(...)"`
 * that carries the homepage and post banners — an !important shorthand outranks
 * an inline longhand. Setting background-color alone leaves those images intact.
 */
#page-header {
  background-color: transparent !important;
}

/* The theme reserves 400px for a post header whose background is transparent,
   so the body copy starts ~526px down. Trimming it roughly doubles the amount
   of text visible on a 813px viewport. */
#page-header.post-bg {
  height: 260px;
}

/* Archive, category and tag pages have no banner image, so a 400px empty band is
   pure dead space. 200px keeps the title legible without pushing content down. */
#page-header.not-home-page {
  height: 200px;
}

/* The theme positions this title absolutely at top:200px and centres it against
   the whole header box. Two things break that here: the header is 200px instead
   of 400px (so 200px landed on the bottom edge, painting the title under the
   first content card), and the fixed nav overlays the top 60px, so centring on
   the full box leaves only ~10px between the nav and the title while leaving 70px
   below it.
   Anchor below the nav and centre in that remaining band instead. 60px is the
   nav height at desktop; the header is 200px, leaving a 140px band, so the title
   centre sits at 60 + 70 = 130px from the header top. */
#page-header #page-site-info {
  top: 130px;
  transform: translateY(-50%);
}

/* The theme animates #site-title in with `titleScale` (opacity 0 -> 1, scale
   .7 -> 1). A CSS animation only advances in a visible document: if the page is
   restored from the back/forward cache, opened in a background tab, or the tab is
   not composited for any reason, the animation sits at 0% and the page title is
   permanently invisible. That is a blank h1 for a category page, which is exactly
   the element search engines read.
   Setting the end state as the base style means the title is readable even if the
   animation never runs; the animation still plays when it does. */
#page-header #page-site-info h1 {
  opacity: 1;
  transform: none;
}

@media (max-width: 768px) {
  #page-header.post-bg {
    height: 210px;
  }

  #page-header.not-home-page {
    height: 150px;
  }

  /* Header is 150px and the nav is 50px tall on mobile, so the band is 100px and
     its centre sits at 50 + 50 = 100px. Scaling the desktop 130px down would
     leave the title touching the content card again. */
  #page-header #page-site-info {
    top: 100px;
  }
}

/* ---------- table of contents ---------- */

#card-toc .toc-link {
  line-height: 1.5;
}

/* ---------- list cover cropping ---------- */

/* Covers are 1200x630 (ratio 1.90); the list card is 364x235 (1.55). object-fit:
   cover therefore trims about 19% of the image width, 9.5% per side, and the
   default centred crop sliced the first letters off the cover artwork —
   "SOFTWARE" rendered as "FTWARE". The generated covers keep their kicker and
   headline inside the left 7%-75% band, so shifting the crop window left shows
   the whole type block and gives up only empty gradient on the right. */
.recent-post-item .post-bg,
#aside-content .item-thumbnail img {
  object-position: 12% center;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
