/*
 * Base styles shared across all Bloob Haus themes.
 * Included in every head.njk before theme main.css.
 * Theme main.css overrides these as needed.
 */

/* Prevent long URLs and unbreakable strings from overflowing their container */
a {
  overflow-wrap: break-word;
}

/* ── Internal links ───────────────────────────────────────────────────────────
   _base/assets/js/internal-links.js adds .internal-link to plain links that
   point at another page of the site (or another *.bloob.haus page).

   They read as ordinary inline links. They used to be inline-flex pills with
   an icon, which sat higher than the text around them and made their line
   taller; now nothing here touches display, padding, border, line-height or
   vertical-align, so the line keeps its height and baseline.

   Hover draws a thin pill from background + box-shadow + outline only. None of
   those take up space, so nothing moves. Themes set the colours:
     --internal-link-hover-bg    pill fill
     --internal-link-hover-ring  1px ring around it (transparent = none)

   Every selector is wrapped in :where(), so it has no specificity: a theme
   rule, or a component that happens to be a link (a tag badge, a button),
   always wins without a fight. */
:where(a.internal-link) {
  border-radius: 999px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-color 0.15s, box-shadow 0.15s, outline-color 0.15s;
}

:where(a.internal-link:hover) {
  --internal-link-pill: var(
    --internal-link-hover-bg,
    color-mix(in srgb, var(--accent-color, currentColor) 12%, transparent)
  );
  background-color: var(--internal-link-pill);
  box-shadow: 0 0 0 0.18em var(--internal-link-pill);
  outline: 1px solid var(--internal-link-hover-ring, transparent);
  outline-offset: 0.18em;
  text-decoration: none;
}

/* Shape icons, when a site turns them on (features.link_icons). Text-sized and
   on the baseline, so they add width but never height. */
:where(.internal-link__icon) {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin: 0 0.25em 0 0;
  vertical-align: -0.15em;
  object-fit: contain;
  border-radius: 0;
}

/* ── Share bar ────────────────────────────────────────────────────────────────
   MECHANICS live here; the LOOK lives in each theme's main.css.

   Why this file and not a shape's stylesheet: the markup is
   themes/_base/partials/share-bar.njk, which three unrelated hosts include — the
   `article` shape's layout, marbles-pouch's page.njk, and _base/pages/embed-pages.njk.
   A page can therefore carry a share bar without being an article at all. While these
   rules lived in lib/visualizers/article/styles.css they were per-page gated on
   article's `detect` selectors, and a page that had the markup but not the shape got
   an unstyled bar — that is the bug that hit 33 melt pages. base.css is loaded
   unconditionally by every theme, so the mismatch cannot recur.

   Load order (head.njk) is what makes the split work:
       base.css   ← these mechanics
       main.css   ← the theme's skin, wins on source order at equal specificity
   So a theme overrides with plain `.share-btn` / `.share-bar .share-btn` and never
   needs a compound selector to outrank this file.

   Themes: style background / border / color / box-shadow. Do NOT set `gap` on
   .share-bar or `margin-left` on .share-btn — spacing is the overlap below, and
   melt's `gap: 10px` silently cancelled it once already.

   Icon-first behavior: the buttons collapse to overlapping circles and reveal their
   label on hover (pointer) or on the first tap (touch — the second tap performs the
   action, wired in share-bar.njk). Every button carries an aria-label, so the
   collapsed state is not a screen-reader regression. ── */
.share-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  /* Explicitly zero: spacing is the buttons' negative margin, and any theme `gap`
     here silently cancels the overlap. */
  gap: 0;
  margin-top: 1.25rem;
}

/* The ordinary labelled pill. `.share-btn` on its own is NOT collapsed, because the
   embed modal reuses the class for its "Copy code" button, which lives outside the
   bar and has no icon. Only `.share-bar .share-btn` collapses. */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4em 0.9em;
  border-radius: 20px;
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.15));
  background: transparent;
  color: var(--text-color, #333);
  font-family: var(--font-body, sans-serif);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.share-btn:hover {
  background: color-mix(in srgb, var(--accent-color, #555) 8%, transparent);
  border-color: var(--accent-color, #555);
  color: var(--accent-color, #555);
}

.share-btn--confirmed {
  border-color: var(--accent-color, #555);
  color: var(--accent-color, #555);
}

/* Collapsed circle. Height and side padding are fixed rather than derived from the
   font, so the pill is exactly round before a label opens. */
.share-bar .share-btn {
  position: relative;
  gap: 0;
  height: var(--share-btn-size, 34px);
  padding-top: 0;
  padding-bottom: 0;
  padding-left: var(--share-btn-inset, 9px);
  padding-right: var(--share-btn-inset, 9px);
  border-radius: 999px;
  /* Squished: each button tucks under the one before it. */
  margin-left: calc(var(--share-btn-overlap, 9px) * -1);
  transition: background 0.18s, border-color 0.18s, color 0.18s,
              padding-right 0.24s ease, margin-left 0.24s ease;
}

.share-bar .share-btn:first-child { margin-left: 0; }
.share-bar .share-btn svg { flex: 0 0 auto; }

/* The label is the part that collapses. max-width animates without anyone having to
   know how wide the text is; 12rem is just "wider than any label we ship". */
.share-btn__label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width 0.24s ease, opacity 0.16s ease, margin-left 0.24s ease;
}

/* Open states that apply on every input type: the touch tap (.is-open) and the
   post-action confirmation — "Copied!" behind a collapsed label would be invisible. */
.share-bar .share-btn.is-open .share-btn__label,
.share-bar .share-btn--confirmed .share-btn__label,
.share-bar .share-btn:focus-visible .share-btn__label {
  max-width: 12rem;
  opacity: 1;
  margin-left: 0.42em;
}

.share-bar .share-btn.is-open,
.share-bar .share-btn--confirmed,
.share-bar .share-btn:focus-visible {
  padding-right: 0.95em;
  z-index: 2;
}

/* Pointer-only. Guarded by the media query rather than undone afterwards, so a tap on
   a phone can never leave a button latched in its hover state. */
@media (hover: hover) {
  /* Approaching the bar un-squishes it — the stack spreads into a row. */
  .share-bar:hover .share-btn { margin-left: var(--share-btn-gap, 0.35rem); }
  .share-bar:hover .share-btn:first-child { margin-left: 0; }

  .share-bar .share-btn:hover .share-btn__label {
    max-width: 12rem;
    opacity: 1;
    margin-left: 0.42em;
  }

  .share-bar .share-btn:hover {
    padding-right: 0.95em;
    z-index: 2;
  }
}
