/* ==========================================================================
   BlockQuotes 1.2.1
   Everything is scoped to .bq and driven by custom properties, so a host page
   can restyle the ticker and the dialog without touching this file:

     .bq { --bq-accent: #ffb000; --bq-font-quote: "Iosevka", monospace; }

   Colours follow the visitor's system theme by default. Force one with
   <html data-bq-theme="dark"> or <html data-bq-theme="light">.
   ========================================================================== */

.bq {
  /* Palette — cool slate rather than pure grey, with a verdigris accent. */
  --bq-bg: #ffffff;
  --bq-bg-raised: #f3f5f7;
  --bq-fg: #161d24;
  --bq-muted: #5c6b78;
  --bq-accent: #2f6f5e;
  --bq-border: #d8dee4;
  --bq-shadow: 0 1px 2px rgb(16 29 36 / 8%), 0 12px 32px rgb(16 29 36 / 12%);
  --bq-backdrop: rgb(16 29 36 / 45%);

  /* Type — a characterful serif for the quote, system sans for chrome,
     monospace for the source chip. No web fonts: a library should not decide
     what the host page downloads. */
  --bq-font-quote: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --bq-font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bq-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bq-radius: 10px;
  --bq-ticker-height: 2.75rem;
  --bq-z: 2147483000;

  color: var(--bq-fg);
  font-family: var(--bq-font-ui);
  box-sizing: border-box;
}

.bq *,
.bq *::before,
.bq *::after {
  box-sizing: inherit;
}

@media (prefers-color-scheme: dark) {
  .bq {
    --bq-bg: #12171c;
    --bq-bg-raised: #1a2129;
    --bq-fg: #e7edf2;
    --bq-muted: #93a2b0;
    --bq-accent: #5fc3a6;
    --bq-border: #2a343e;
    --bq-shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 16px 40px rgb(0 0 0 / 45%);
    --bq-backdrop: rgb(6 10 14 / 62%);
  }
}

[data-bq-theme="dark"] .bq {
  --bq-bg: #12171c;
  --bq-bg-raised: #1a2129;
  --bq-fg: #e7edf2;
  --bq-muted: #93a2b0;
  --bq-accent: #5fc3a6;
  --bq-border: #2a343e;
  --bq-shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 16px 40px rgb(0 0 0 / 45%);
  --bq-backdrop: rgb(6 10 14 / 62%);
}

[data-bq-theme="light"] .bq {
  --bq-bg: #ffffff;
  --bq-bg-raised: #f3f5f7;
  --bq-fg: #161d24;
  --bq-muted: #5c6b78;
  --bq-accent: #2f6f5e;
  --bq-border: #d8dee4;
  --bq-shadow: 0 1px 2px rgb(16 29 36 / 8%), 0 12px 32px rgb(16 29 36 / 12%);
  --bq-backdrop: rgb(16 29 36 / 45%);
}

.bq :focus-visible {
  outline: 2px solid var(--bq-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------------- ticker --- */

.bq-ticker {
  position: fixed;
  left: 0;
  right: 0;
  z-index: var(--bq-z);
  display: flex;
  align-items: stretch;
  min-height: var(--bq-ticker-height);
  background: var(--bq-bg);
  border-block: 1px solid var(--bq-border);
  contain: layout paint;
}

.bq-ticker--top {
  top: 0;
  border-top: 0;
}

.bq-ticker--bottom {
  bottom: 0;
  border-bottom: 0;
}

.bq-ticker__viewport {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  min-width: 0;
}

/* The track is taken out of flow so items never wrap; JS translates it. */
.bq-ticker__track {
  position: absolute;
  top: 0;
  display: flex;
  align-items: center;
  gap: var(--bq-ticker-gap, 64px);
  height: 100%;
  white-space: nowrap;
  will-change: transform;
}

.bq-ticker--left .bq-ticker__track {
  left: 0;
}

/* Mirrored geometry: anchor right and reverse the row, then the same offset
   maths drives movement in the opposite direction. */
.bq-ticker--right .bq-ticker__track {
  right: 0;
  flex-direction: row-reverse;
}

.bq-ticker__item {
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  padding-inline: 0.75rem;
  font-family: var(--bq-font-quote);
  font-size: 0.95rem;
  line-height: 1.4;
}

.bq-ticker__quote p,
.bq-ticker__quote ol,
.bq-ticker__quote ul {
  display: inline;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bq-ticker__quote li {
  display: inline;
}

.bq-ticker__quote li + li::before {
  content: " · ";
  color: var(--bq-accent);
}

.bq-ticker__quote ol li::before {
  counter-increment: bq-item;
}

.bq-ticker__quote ol {
  counter-reset: bq-item;
}

.bq-ticker__attribution {
  font-family: var(--bq-font-ui);
  font-size: 0.82rem;
  color: var(--bq-muted);
  font-style: italic;
}

.bq-ticker__source {
  font-family: var(--bq-font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bq-accent);
  border: 1px solid color-mix(in srgb, var(--bq-accent) 40%, transparent);
  border-radius: 999px;
  padding: 0.15em 0.6em;
  align-self: center;
}

/* The signature mark: a small lozenge that meters out the stream. */
.bq-ticker__mark {
  color: var(--bq-accent);
  font-size: 0.5rem;
  opacity: 0.7;
  align-self: center;
}

.bq-ticker__controls {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding-inline: 0.4rem;
  border-inline-start: 1px solid var(--bq-border);
  background: var(--bq-bg);
}

.bq-ticker__button {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--bq-muted);
  cursor: pointer;
  font: inherit;
  line-height: 1;
}

.bq-ticker__button:hover {
  background: var(--bq-bg-raised);
  color: var(--bq-fg);
}

.bq-ticker__icon {
  font-size: 0.7rem;
  letter-spacing: -0.1em;
}

/* Fade mode: one quote at a time, centred, no motion. */
.bq-ticker--fade .bq-ticker__track {
  position: static;
  justify-content: center;
  width: 100%;
  transform: none !important;
  white-space: normal;
}

.bq-ticker--fade .bq-ticker__item {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.bq-ticker__item--fade {
  animation: bq-fade-in 400ms ease both;
}

@keyframes bq-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bq-ticker__item--fade {
    animation: none;
  }
}

/* Space reserved for the bar so it never covers page content. */
html.bq-has-ticker-bottom body {
  padding-bottom: var(--bq-ticker-space-bottom, 0px);
}

html.bq-has-ticker-top body {
  padding-top: var(--bq-ticker-space-top, 0px);
}

html.bq-has-ticker-bottom {
  scroll-padding-bottom: var(--bq-ticker-space-bottom, 0px);
}

html.bq-has-ticker-top {
  scroll-padding-top: var(--bq-ticker-space-top, 0px);
}

/* --------------------------------------------------------------- dialog --- */

.bq-dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--bq-fg);
  max-width: min(34rem, calc(100vw - 2rem));
  width: 100%;
  overflow: visible;
}

.bq-dialog::backdrop {
  background: var(--bq-backdrop);
  backdrop-filter: blur(2px);
}

.bq-dialog[open] {
  animation: bq-dialog-in 220ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes bq-dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.bq-dialog__panel {
  position: relative;
  background: var(--bq-bg);
  border: 1px solid var(--bq-border);
  border-radius: var(--bq-radius);
  box-shadow: var(--bq-shadow);
  padding: 1.25rem 1.5rem 1.1rem;
  overflow: hidden;
}

/* Accent rule along the top edge — the dialog's tie back to the ticker. */
.bq-dialog__panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--bq-accent),
    color-mix(in srgb, var(--bq-accent) 25%, transparent)
  );
}

.bq-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.bq-dialog__title {
  margin: 0;
  font-size: 0.75rem;
  font-family: var(--bq-font-mono);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bq-muted);
}

.bq-dialog__position {
  font-family: var(--bq-font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--bq-muted);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.bq-dialog__dismiss {
  border: 0;
  background: transparent;
  color: var(--bq-muted);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.35rem;
  border-radius: 6px;
}

.bq-dialog__dismiss {
  margin-left: 0.5rem;
}

.bq-dialog__dismiss:hover {
  background: var(--bq-bg-raised);
  color: var(--bq-fg);
}

.bq-dialog__intro {
  margin: 0.6rem 0 0;
  font-size: 0.9rem;
  color: var(--bq-muted);
}

.bq-dialog__figure {
  position: relative;
  margin: 1rem 0 0;
}

/* Oversized opening mark, bled off the corner. */
.bq-dialog__mark {
  position: absolute;
  top: -2.1rem;
  left: -0.6rem;
  font-family: var(--bq-font-quote);
  font-size: 5rem;
  line-height: 1;
  color: var(--bq-accent);
  opacity: 0.16;
  pointer-events: none;
  user-select: none;
}

.bq-dialog__quote {
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
  font-family: var(--bq-font-quote);
  font-size: 1.2rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.bq-dialog__quote.is-entering {
  animation: bq-quote-in 320ms ease both;
}

@keyframes bq-quote-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.bq-dialog__quote p {
  margin: 0 0 0.7em;
}

.bq-dialog__quote p:last-child {
  margin-bottom: 0;
}

.bq-dialog__quote ol,
.bq-dialog__quote ul {
  margin: 0;
  padding-left: 1.6em;
  display: grid;
  gap: 0.55em;
}

.bq-dialog__quote li::marker {
  color: var(--bq-accent);
  font-family: var(--bq-font-mono);
  font-size: 0.85em;
}

.bq-dialog__quote code {
  font-family: var(--bq-font-mono);
  font-size: 0.85em;
  background: var(--bq-bg-raised);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.bq-dialog__meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
  font-family: var(--bq-font-ui);
  font-size: 0.82rem;
  color: var(--bq-muted);
}

.bq-dialog__meta:empty {
  display: none;
}

.bq-dialog__author {
  font-style: normal;
}

.bq-dialog__author::before {
  content: "— ";
}

.bq-dialog__source {
  margin-left: auto;
  font-family: var(--bq-font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bq-accent);
}

/* The checkbox gets its own line; the buttons get one row that never wraps. */
.bq-dialog__footer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.8rem;
  margin-top: 1.4rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--bq-border);
}

.bq-dialog__remember {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--bq-muted);
  cursor: pointer;
}

.bq-dialog__checkbox {
  accent-color: var(--bq-accent);
}

.bq-dialog__actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.bq-button {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.45rem 0.95rem;
  white-space: nowrap;
  border-radius: 7px;
  border: 1px solid var(--bq-border);
  background: var(--bq-bg-raised);
  color: var(--bq-fg);
  cursor: pointer;
}

.bq-button:hover {
  border-color: color-mix(in srgb, var(--bq-accent) 55%, var(--bq-border));
}

.bq-button--primary {
  background: var(--bq-accent);
  border-color: var(--bq-accent);
  color: var(--bq-bg);
  font-weight: 600;
}

.bq-button--primary:hover {
  filter: brightness(1.08);
}

.bq-button--ghost {
  background: transparent;
}

.bq-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.bq-button:disabled:hover {
  border-color: var(--bq-border);
}

/* Prev/Next keep their arrow at all widths; the word drops out when the row
   gets tight, which is what stops four buttons from wrapping on a phone. */
.bq-button--nav {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding-inline: 0.7rem;
}

.bq-button__glyph {
  font-size: 1.05em;
  line-height: 1;
  color: var(--bq-accent);
}

.bq-button:disabled .bq-button__glyph {
  color: inherit;
}

/* Narrow screens: the row still must not wrap, so the buttons give up
   padding, then the words "Previous" and "Next" give up their labels. The
   arrows and the aria-labels stay, so nothing becomes unreachable. */
@media (max-width: 30rem) {
  .bq-dialog__actions {
    gap: 0.35rem;
  }

  .bq-button {
    padding-inline: 0.7rem;
    font-size: 0.8rem;
  }

  .bq-button--nav {
    padding-inline: 0.55rem;
  }

  .bq-button--nav .bq-button__label {
    /* Hidden visually; the button keeps its aria-label. */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .bq-ticker__attribution,
  .bq-ticker__source {
    display: none;
  }
}

@media (max-width: 24rem) {
  .bq-dialog__actions {
    gap: 0.25rem;
  }

  .bq-button {
    padding-inline: 0.55rem;
    font-size: 0.75rem;
  }

  .bq-button--nav {
    padding-inline: 0.45rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bq-dialog[open],
  .bq-dialog__quote.is-entering {
    animation: none;
  }
}
