/* Article Shape — Styles
   Token-based: works in any theme that implements the CSS token contract.
   Themes can override layouts/article.njk but don't need to. */

/* ── Page wrapper ───────────────────────────────────────────────────────── */
.article-page {
  max-width: var(--article-width, 820px);
  margin: 0 auto;
  padding-top: var(--article-padding-top, var(--spacing-lg, 2.5rem));
  padding-bottom: var(--article-padding-bottom, var(--spacing-lg, 2.5rem));
  padding-left: var(--spacing-md, 1.5rem);
  padding-right: var(--spacing-md, 1.5rem);
}

/* ── Width contract ─────────────────────────────────────────────────────────
   `article` is a PRESERVE container: a nested shape renders the way it wants,
   not the way the article's prose does (docs/architecture/shapes.md →
   Container-contents policy). A shape declares `width: prose|wide|full`; the
   theme decides whether that means anything.

   Degradation is the DEFAULT state, not a special case: --shape-width-wide
   defaults to 100%, so min(100%, …) resolves to the prose column and a page
   renders exactly as it did before this rule existed. A theme opts in by
   naming a real width:  :root { --shape-width-wide: 1200px; }

   That is what lets `collection` default to `wide` in its manifest without
   touching melt, marbles-pouch, warm-kitchen or buffbaby.

   The breakout is width + margin-left:50% + translate rather than grid tracks,
   because the constraint lives on .article-page (max-width) and .article-body
   merely inherits it — tracks on the body would still be clipped by the parent.
   The calc() clamp is what prevents horizontal overflow when the declared width
   exceeds the viewport. */
.article-body > [data-width="wide"],
.article-body > [data-width="full"] {
  width: min(
    var(--shape-width-wide, 100%),
    calc(100vw - 2 * var(--spacing-md, 1.5rem))
  );
  margin-left: 50%;
  translate: -50% 0;
}

.article-body > [data-width="full"] {
  --shape-width-wide: 100vw;
}

/* Phones never break out — prose measure for everything. Keeps the card ladder
   (3/2/1) the only thing deciding phone layout. */
@media (max-width: 900px) {
  .article-body > [data-width] {
    width: 100%;
    margin-left: 0;
    translate: none;
  }
}

/* ── Folder-index frame ─────────────────────────────────────────────────────
   A folder's index page (`is_folder` → .article-page--index) is a room's front
   door, and its main content is usually a wide shape (a collection of cards).
   The centred breakout above is right for a wide figure in the MIDDLE of a
   reading article, but on an index page it gives the page two left edges: an
   820px header centred above a 1200px grid (AE /resources/, 2026-11-02).

   So on an index page the FRAME is the wide edge. The page widens to the wide
   width, the header and prose start at the same x as the wide shape, and prose
   keeps its reading measure (left-aligned, not stretched). The wide child fills
   the frame instead of breaking out of it.

   Tokens, all optional:
     --article-index-width    frame width (border-box). Default: the wide width
                              plus the page padding, so the wide child still gets
                              exactly --shape-width-wide.
     --article-index-gutter   frame side padding. Default: --spacing-md.
     --article-index-measure  max line length of header + prose. Default: the
                              reading column of an ordinary article.
   A theme can pin the frame to its own site grid: AE sets
   --article-index-width: none + --article-index-gutter to its nav's gutters.

   Degradation: with no --shape-width-wide, the default frame resolves to
   (--article-width − 2·spacing) + 2·spacing = --article-width and the measure to
   the column's own content width, so an index page renders exactly like any
   other article. Assumes border-box, which every theme sets globally.
   Guarded by tests/shape-width.test.js → "folder-index frame". */
.article-page--index {
  max-width: var(
    --article-index-width,
    calc(
      var(--shape-width-wide, calc(var(--article-width, 820px) - 2 * var(--spacing-md, 1.5rem)))
      + 2 * var(--spacing-md, 1.5rem)
    )
  );
  padding-left: var(--article-index-gutter, var(--spacing-md, 1.5rem));
  padding-right: var(--article-index-gutter, var(--spacing-md, 1.5rem));
}

.article-page--index > .article-header > *,
.article-page--index > .article-body > :not([data-width]) {
  max-width: var(
    --article-index-measure,
    calc(var(--article-width, 820px) - 2 * var(--spacing-md, 1.5rem))
  );
}

.article-page--index > .article-body > [data-width="wide"] {
  width: auto;
  margin-left: 0;
  translate: none;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.article-header {
  margin-bottom: var(--spacing-lg, 2rem);
  padding-bottom: var(--spacing-md, 1.5rem);
  border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.1));
}

.article-type {
  font-family: var(--font-body, sans-serif);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent-color, #555);
  margin: 0 0 0.6rem;
}

.article-title {
  font-family: var(--font-heading, sans-serif);
  font-size: var(--article-title-size, clamp(1.75rem, 4vw, 2.6rem));
  font-weight: 700;
  line-height: 1.15;
  color: var(--article-title-color, var(--text-color, #1a1a1a));
  margin: 0 0 0.5rem;
}

.article-subtitle {
  font-family: var(--font-body, sans-serif);
  font-size: var(--article-subtitle-size, clamp(1rem, 2vw, 1.15rem));
  color: var(--article-subtitle-color, var(--text-color, #555));
  opacity: 0.72;
  margin: 0 0 0.75rem;
  line-height: 1.5;
}

/* Optional profile fields (`logo:`, `website:` frontmatter) — a firm or person page.
   The logo is capped in both directions so a wide wordmark and a square mark both
   sit at a sensible size above the name. */
.article-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: min(260px, 70%);
  max-height: 96px;
  object-fit: contain;
  margin-bottom: var(--spacing-sm, 1rem);
}

.article-website {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
}

.article-website a {
  color: var(--accent-color, #555);
}

.article-author {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-color, #333);
  margin: 0.5rem 0 0;
}

.article-byline {
  font-size: 0.84rem;
  color: var(--text-color, #555);
  opacity: 0.7;
  margin: 0.2rem 0 0;
}

/* Frosted-glass pill, on by default for every theme (2026-07-28).

   The color is deliberately unchanged: the fill is still a wash of the theme's OWN
   --accent-color, so each site keeps its palette and only the *material* changes.
   The one substantive edit is what the accent is mixed WITH — it used to be mixed
   into an opaque --bg-color, which is why the pill read as a flat chip; mixing into
   `transparent` is what makes it translucent, so whatever is behind (melt's
   watercolor photo, a card, plain paper) shows through.

   Light edges are inset box-shadows rather than a ::before, so the rule works
   whatever element the layout wraps the date in.

   A theme that wants the old flat chip back sets --article-date-tint: 100% and
   --article-date-blur: 0. */
.article-date {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-color, #555);
  background: color-mix(in srgb, var(--accent-color, #888) var(--article-date-tint, 14%), transparent);
  -webkit-backdrop-filter: blur(var(--article-date-blur, 7px));
  backdrop-filter: blur(var(--article-date-blur, 7px));
  border: 1px solid color-mix(in srgb, var(--accent-color, #888) 22%, transparent);
  box-shadow:
    0 4px 14px color-mix(in srgb, var(--text-color, #000) 8%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 0 rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding-top: 0.22em;
  padding-bottom: 0.22em;
  padding-left: 0.7em;
  padding-right: 0.7em;
  margin-top: 0.75rem;
}

/* ── Visitor count ────────────────────────────────────────────────────────────
   Same glass pill as .article-date, one notch quieter — it is ambient information,
   not page metadata the reader came for. Starts `hidden`; the partial's script only
   unhides it once a count actually arrives. */
.visitor-count {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-light, var(--text-color, #666));
  background: color-mix(in srgb, var(--text-color, #888) var(--visitor-count-tint, 8%), transparent);
  -webkit-backdrop-filter: blur(var(--article-date-blur, 7px));
  backdrop-filter: blur(var(--article-date-blur, 7px));
  border: 1px solid color-mix(in srgb, var(--text-color, #888) 14%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  padding-top: 0.2em;
  padding-bottom: 0.2em;
  padding-left: 0.65em;
  padding-right: 0.65em;
  margin-top: 0.75rem;
}

.visitor-count[hidden] { display: none; }

.visitor-count__number { font-variant-numeric: tabular-nums; }

.visitor-count__label {
  opacity: 0.7;
  font-weight: 500;
}

/* ── Body typography ────────────────────────────────────────────────────── */
/* Base reading size. All body text (p, li, blockquote) inherits this; headings
   set their own size below. Themes tune via --article-body-size — see the
   "Article-shape sizing tokens" section in docs/architecture/themes.md. */
.article-body {
  font-size: var(--article-body-size, 1rem);
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
  font-family: var(--font-heading, sans-serif);
  font-weight: 700;
  line-height: 1.2;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--text-color, #1a1a1a);
}

.article-body h1 { font-size: var(--article-h1-size, clamp(1.55rem, 3.5vw, 2rem)); }
.article-body h2 { font-size: var(--article-h2-size, clamp(1.25rem, 3vw, 1.65rem)); }
.article-body h3 { font-size: var(--article-h3-size, 1.2rem); }
.article-body h4 { font-size: var(--article-h4-size, 1rem); }
.article-body h5 { font-size: var(--article-h5-size, 0.9rem); }
.article-body h6 { font-size: var(--article-h6-size, 0.82rem); }

.article-body :is(h1, h2, h3):first-child { margin-top: 0; }

.article-body p {
  margin: 0 0 1rem;
  line-height: var(--article-body-line-height, 1.7);
  color: var(--text-color, #333);
}

.article-body a {
  color: var(--accent-color, #555);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article-body a:hover { opacity: 0.75; }

.article-body ul,
.article-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.article-body li { margin-bottom: 0.35rem; line-height: var(--article-body-line-height, 1.65); }

.article-body blockquote {
  border-left: 3px solid var(--accent-color, #888);
  margin: 1.5rem 0;
  padding: 0.5rem 0 0.5rem 1.25rem;
  color: var(--text-color, #555);
  opacity: 0.82;
  font-style: italic;
}

.article-body code {
  font-size: 0.88em;
  background: color-mix(in srgb, var(--border-color, rgba(0,0,0,0.08)) 60%, transparent);
  border-radius: 4px;
  padding: 0.15em 0.4em;
}

.article-body pre {
  background: color-mix(in srgb, var(--border-color, rgba(0,0,0,0.08)) 60%, transparent);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.article-body pre code { background: none; padding: 0; }

.article-body img {
  max-width: 100%;
  border-radius: var(--border-radius, 6px);
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--border-color, rgba(0,0,0,0.1));
  margin: 2rem 0;
}

/* ── Share bar ────────────────────────────────────────────────────────────────
   NOT HERE ANY MORE. Moved to themes/_base/assets/css/base.css on 2026-07-28.

   The markup is themes/_base/partials/share-bar.njk, which marbles-pouch's page.njk
   and _base/pages/embed-pages.njk include too — so a page can carry a share bar
   without being an article. Owning its CSS here meant the styling was gated on this
   shape's `detect` selectors, and `.share-bar` had to be listed among them purely to
   paper over that. base.css is unconditional, so the mismatch is now impossible
   rather than patched. See that file for the mechanics/skin split. ── */

/* ────────────────────────────────────────────────────────────────────────────
   Added 2026-07-27 while consolidating melt's bespoke `page.njk` onto this
   shape. Every rule below was previously theme-local in melt but is entirely
   generic, so all themes gain it.

   Per this shape's DECISIONS.md convention, each token carries the value melt
   used as its fallback, so a theme that defines none of them renders exactly
   what melt rendered before.
   ──────────────────────────────────────────────────────────────────────────── */

/* ── Embedded media ───────────────────────────────────────────────────────────
   Article previously had NO iframe/video handling, so an embedded video kept
   its hardcoded width/height attributes and overflowed the reading column. */
.article-page iframe,
.article-page embed {
  width: 100%;
  display: block;
  border-radius: var(--article-media-radius, 8px);
  margin-bottom: var(--article-media-margin, 1.5rem);
}

/* Video embeds ship width/height attributes; width:100% alone leaves the height
   fixed and squashes them. Constrain by ratio instead and let height follow.
   youtu.be and youtube-nocookie.com are matched too — share links and the
   privacy-preserving embed domain are both common in vaults. */
.article-page iframe[src*="youtube.com"],
.article-page iframe[src*="youtube-nocookie.com"],
.article-page iframe[src*="youtu.be"],
.article-page iframe[src*="vimeo.com"] {
  aspect-ratio: var(--article-video-ratio, 16 / 9);
  height: auto;
}

.article-page video {
  max-width: 100%;
}

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--article-table-size, 0.9rem);
}

.article-body th,
.article-body td {
  padding: var(--article-table-cell-padding, 10px 14px);
  border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
  text-align: left;
}

/* ── Inline emphasis ─────────────────────────────────────────────────────────
   Explicit because some theme resets flatten em/strong inside prose. */
.article-body em {
  font-style: italic;
}

.article-body strong {
  font-weight: var(--article-strong-weight, 600);
}

/* ── Shape banner text (from the shape registry's banner_text column) ───────── */
.article-banner-text {
  font-size: var(--article-banner-size, 0.9rem);
  color: var(--text-light, #666);
  font-style: italic;
  margin-bottom: 8px;
}

/* ── Updated-date pill ──────────────────────────────────────────────────────── */
.article-date--updated {
  margin-top: 4px;
  opacity: 0.8;
}

/* ── Heading anchors ────────────────────────────────────────────────────────
   The anchor element itself is injected globally; these rules position it and
   reveal it on hover of the heading it belongs to. */
.article-body h2,
.article-body h3,
.article-body h4 {
  position: relative;
}

.article-body h2:hover .heading-anchor,
.article-body h3:hover .heading-anchor,
.article-body h4:hover .heading-anchor {
  opacity: 1;
}
