/* Site additions on top of the Arabesque theme.
   Dark mode is on when <html data-theme="dark">, or when the system is dark
   and the reader hasn't picked light: both selectors below are needed. */

/* --- Images with transparent backgrounds ---------------------------------
   Most diagrams are drawn for a white page. In dark mode, every image in a
   post gets a light, slightly dimmed backdrop so transparent ones stay
   readable; opaque images (photos, screenshots) cover it and look unchanged.

   For monochrome line art, use the `diagram` component with
   dark="invert" instead: it inverts the image in dark mode so it sits on the
   dark page like text does. Never invert anything with meaningful colours,
   logos or photos. */

:root {
  --site-img-panel: #f4f4f2;   /* light-mode backdrop for diagram panels */
}

:root[data-theme="dark"] {
  --site-img-panel: #d9dadc;   /* dimmed so it doesn't glare on a dark page */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --site-img-panel: #d9dadc;
  }
}

/* Plain Markdown images: backdrop in dark mode only. */
:root[data-theme="dark"] .zt-prose img:not(.site-diagram__img) {
  background: var(--site-img-panel);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .zt-prose img:not(.site-diagram__img) {
    background: var(--site-img-panel);
  }
}

/* The diagram component, dark="panel" (default): a padded card in both
   modes, so the diagram has the same frame whichever theme is on. */
.site-diagram--panel .site-diagram__img {
  background: var(--site-img-panel);
  padding: var(--al-space-4, 1rem);
  border-radius: var(--al-radius-md, 0.5rem);
}

/* The diagram component, dark="invert": black lines become light, and
   hue-rotate puts any colours back roughly where they were. */
:root[data-theme="dark"] .site-diagram--invert .site-diagram__img {
  filter: invert(1) hue-rotate(180deg) brightness(0.9);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .site-diagram--invert .site-diagram__img {
    filter: invert(1) hue-rotate(180deg) brightness(0.9);
  }
}

/* --- The portrait component ----------------------------------------------
   A photo floated beside the text; the following paragraphs wrap around it.
   On narrow screens it sits above the text instead, so the text keeps a
   readable width. */
.zt-prose .site-portrait {
  float: inline-end;
  inline-size: 16rem;
  max-inline-size: 40%;
  block-size: auto;
  margin-block: 0.25rem 1rem;
  margin-inline: 1.5rem 0;
  border-radius: 0.5rem;   /* the theme's radii (2px, 4px) barely show on a photo */
}
/* The theme caps prose at a reading width (--al-size-measure). With a portrait
   in it, widen the column by the photo, so the text beside it keeps that width
   instead of being squeezed. */
.zt-prose:has(> .site-portrait) {
  max-inline-size: calc(var(--al-size-measure) + 17.5rem);
}
@media (max-width: 36rem) {
  .zt-prose .site-portrait {
    float: none;
    display: block;
    inline-size: 16rem;
    max-inline-size: 100%;
    margin: 0 auto 1.5rem;
  }
}
/* Nothing after the text should have to squeeze in beside the photo. */
.zt-prose::after { content: ""; display: block; clear: both; }

/* --- AI Influence Level -----------------------------------------------------
   The badge in a post's meta line (templates/partials/page_meta.html):
   "AIL" on a solid tab, the level, and six segments filled to it. One quiet
   colour for every level, so no level reads as good or bad. */
.site-ail__link { display: inline-flex; align-items: center; gap: var(--al-space-2); color: inherit; text-decoration: none; }
.site-ail__link:hover .site-ail__name { text-decoration: underline; }
.site-ail__badge {
  flex: none;   /* never squeezed: the name beside it wraps instead */
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--al-color-line-strong); border-radius: var(--al-radius-sm);
  overflow: hidden; font-size: var(--al-text-xs); font-weight: var(--al-weight-medium);
  line-height: 1; vertical-align: middle;
}
.site-ail__mark { display: grid; place-items: center; padding: 0.2rem 0.4rem; background: var(--al-color-text-muted); color: var(--al-color-surface); letter-spacing: 0.04em; }
.site-ail__num { display: grid; place-items: center; padding: 0.2rem 0.35rem 0.2rem 0.45rem; color: var(--al-color-text); font-variant-numeric: tabular-nums; }
.site-ail__meter { display: flex; align-items: center; gap: 2px; padding-inline-end: 0.45rem; }
.site-ail__meter i { inline-size: 4px; block-size: 0.6rem; border-radius: 1px; background: var(--al-color-line-strong); }
.site-ail__meter i.on { background: var(--al-color-accent); }
@media (forced-colors: active) { .site-ail__meter i.on { background: CanvasText; } }

/* --- The ai_use component -----------------------------------------------------
   A note at the end of a post on how AI was used: the theme's notice, toned
   down to neutral colours and smaller, muted text, so it reads as a colophon
   rather than an alert, but is still clearly set apart from the post. */
.zt-prose .site-ai-use {
  --_status: var(--al-color-line-strong);
  --_wash: var(--al-color-surface-sunk);
  margin-block-start: var(--al-space-8);
  font-size: var(--al-text-sm);
  color: var(--al-color-text-muted);
}
.site-ai-use > .al-icon { color: var(--al-color-text-muted); }
.site-ai-use .al-notice__title { color: var(--al-color-text); }
.site-ai-use__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--al-space-1) var(--al-space-3); }
.site-ai-use__head .site-ail { font-weight: var(--al-weight-regular); }
.site-ai-use__head .site-ail__name { color: var(--al-color-text-muted); }
