.reading-bookmark {
  --reading-bookmark-gold: var(--gold, #c9a961);
  --reading-bookmark-gold-bright: var(--gold-bright, #e4c478);
  --reading-bookmark-surface: var(--ink-2, #10162a);
  --reading-bookmark-text: var(--parchment, #f5ecd7);
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  height: 40px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  margin: 0;
  isolation: isolate;
}

.article > p:has(+ .reading-bookmark) {
  margin-bottom: 0;
}

.reading-bookmark__button {
  position: relative;
  z-index: 1;
  display: inline-flex;
  min-width: 40px;
  min-height: 40px;
  max-width: calc(100% - 1rem);
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.35rem 0.65rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--reading-bookmark-gold-bright);
  font: inherit;
  cursor: pointer;
  opacity: 0;
  transition: opacity 160ms ease, color 160ms ease, background-color 160ms ease;
}

.reading-bookmark__button:hover,
.reading-bookmark__button:focus-visible,
.reading-bookmark.is-active .reading-bookmark__button {
  opacity: 1;
}

.reading-bookmark__button:focus-visible {
  outline: 2px solid var(--reading-bookmark-gold-bright);
  outline-offset: 2px;
}

.reading-bookmark__icon {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: color-mix(in srgb, var(--reading-bookmark-surface) 88%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--reading-bookmark-surface) 72%, transparent);
}

.reading-bookmark__icon::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 6px;
  width: 4px;
  height: 7px;
  border-radius: 1px 1px 0 0;
  background: currentColor;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
}

.reading-bookmark__label {
  width: 0;
  overflow: hidden;
  color: var(--reading-bookmark-text);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.62rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transition: width 160ms ease, opacity 160ms ease;
}

.reading-bookmark:hover .reading-bookmark__label,
.reading-bookmark__button:focus-visible .reading-bookmark__label,
.reading-bookmark.is-active .reading-bookmark__label {
  width: auto;
  opacity: 1;
}

.reading-bookmark.is-active {
  height: 40px;
}

.reading-bookmark.is-active::before {
  content: '';
  position: absolute;
  right: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--reading-bookmark-gold), transparent);
  opacity: 0.8;
}

.reading-bookmark.is-active .reading-bookmark__button {
  background: color-mix(in srgb, var(--reading-bookmark-surface) 92%, transparent);
  color: var(--reading-bookmark-gold-bright);
}

.reading-bookmark__status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

:root[data-theme="light"] .reading-bookmark {
  --reading-bookmark-gold: var(--gold, #9a6f24);
  --reading-bookmark-gold-bright: var(--gold-bright, #7d5519);
  --reading-bookmark-surface: var(--ink-2, #fff8e9);
  --reading-bookmark-text: var(--parchment, #2b2116);
}

@media (hover: none), (pointer: coarse) {
  .reading-bookmark__button {
    opacity: 0.52;
  }

  .reading-bookmark.is-active .reading-bookmark__button {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reading-bookmark__button,
  .reading-bookmark__label {
    transition: none;
  }
}
