/* ─────────────────────────────────────────────────────────────────────────
   CiteKit — Tooltips, Footnotes, Bibliography
   Class changes in 3.1.0:
     .ck-footnote (tooltip, 3.0.x)       → .ck-tooltip
     .ck-footnote-popup (tooltip, 3.0.x) → .ck-tooltip-popup
   The .ck-footnote / .ck-footnote-popup classes are now used by the new
   numbered-footnote feature (superscript marker with popup + bottom list).
   ───────────────────────────────────────────────────────────────────────── */


/* ── TOOLTIPS ──────────────────────────────────────────────────────────── */

.ck-tooltip {
  position: relative;
  cursor: help;
}

.ck-tooltip.ck-tooltip-dashed {
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: currentColor;
  text-underline-offset: 0.15em;
  text-decoration-thickness: from-font;
}

.ck-tooltip.ck-tooltip-dotted {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: currentColor;
  text-underline-offset: 0.15em;
  text-decoration-thickness: from-font;
}

.ck-tooltip.ck-tooltip-symbol {
  cursor: pointer;
}

.ck-tooltip.ck-tooltip-symbol > sup {
  font-size: 0.75em;
  line-height: 0;
  vertical-align: baseline;
  position: relative;
  top: -0.5em;
}

/* Shared floating popup for footnotes + tooltips. tooltip.js renders one of
   these at the end of <body>, fills it from the active marker's data-ck-popup
   attribute, and positions it next to the marker. Because it lives at body
   level (not inside an inline <sup>/<span>), it can safely hold block content
   such as lists and paragraphs. */
.ck-popup {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 99999;
  box-sizing: border-box;
  width: min(300px, 90vw);
  max-width: min(300px, 90vw);
  background: #fff;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 8px 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  font-size: 0.9rem;
  font-weight: normal;
  line-height: 1.5;
  white-space: normal;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.ck-popup.is-open { opacity: 1; visibility: visible; pointer-events: auto; }
.ck-popup > :first-child { margin-top: 0; }
.ck-popup > :last-child { margin-bottom: 0; }
.ck-popup p { margin: 0 0 0.6em; }
.ck-popup ul,
.ck-popup ol { margin: 0.5em 0; padding-left: 1.4em; }
.ck-popup li { margin: 0.15em 0; }
.ck-popup figure,
.ck-footnotes figure { margin: 0.6em 0; }
.ck-popup img,
.ck-footnotes img { max-width: 100%; height: auto; display: block; border-radius: 3px; }
.ck-popup figcaption,
.ck-footnotes figcaption { font-size: 0.85em; color: #666; line-height: 1.4; margin-top: 4px; }


/* ── FOOTNOTES (numbered, with hover popup + bottom-of-post list) ───────── */

.ck-footnote {
  position: relative;
  cursor: pointer;
  font-size: 0.75em;
  line-height: 0;
  vertical-align: baseline;
  top: -0.5em;
  margin: 0 0.05em;
  font-weight: 600;
}

.ck-footnote > .ck-footnote-ref {
  text-decoration: none;
  color: inherit;
  padding: 0 0.1em;
}

.ck-footnote > .ck-footnote-ref:hover {
  text-decoration: underline;
}

/* Bottom-of-post list — framed by the shared .ck-bibliography shell; text
   mirrors the bibliography reference typography for a consistent look. */
.ck-footnotes {
  margin: 0;
  padding: 0 0 0 1.6em;
}
.ck-footnotes li {
  margin: 0;
  padding: 8px 0;
  color: #292927;
  font-family: var(--ck-bib-serif);
  font-size: 16.5px;
  font-weight: 400;
  line-height: 1.75;
}
.ck-footnotes li + li { margin-top: 6px; }
.ck-footnotes li::marker {
  color: #777772;
  font-family: var(--ck-bib-mono);
  font-size: 12px;
  font-weight: 500;
}

.ck-footnotes li:target {
  animation: ck-fn-flash 1.8s ease-out;
  border-radius: 3px;
}
@keyframes ck-fn-flash {
  0%, 25% { background: #fff7d6; }
  100%    { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .ck-footnotes li:target { animation: none; }
}

.ck-footnote-back {
  text-decoration: none;
  margin-left: 0.35em;
  font-size: 0.9em;
  color: #3b8edd;
}

.ck-footnote-back:hover {
  text-decoration: underline;
}


/* == BIBLIOGRAPHY =========================================================
   CiteKit bibliography box. Every part is a BEM-style class under
   .ck-bibliography / .ck-reference, and the tokens below can be overridden
   from a theme (e.g. .ck-bibliography { --ck-bib-accent: #b4531f; }).
   ======================================================================== */

.ck-bibliography {
  /* Customization tokens */
  --ck-bib-text:        #222220;
  --ck-bib-secondary:   #696964;
  --ck-bib-muted:       #85857f;
  --ck-bib-rule:        #cecec8;
  --ck-bib-accent:      #111;
  --ck-bib-serif:       Newsreader, Georgia, "Times New Roman", serif;
  --ck-bib-sans:        "Inter Tight", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ck-bib-mono:        "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ck-bib-frame:       52px;

  position: relative;
  width: 100%;
  margin: 2em 0;
  padding: 0 24px;
  color: var(--ck-bib-text);
  font-family: var(--ck-bib-sans);
  box-sizing: border-box;
}
.ck-bibliography *,
.ck-bibliography *::before,
.ck-bibliography *::after { box-sizing: border-box; }

/* Corner frame (top-left + bottom-right only) */
.ck-bibliography::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: var(--ck-bib-frame); height: 32px;
  border-top: 1px solid var(--ck-bib-rule);
  border-left: 1px solid var(--ck-bib-rule);
  pointer-events: none;
}
.ck-bibliography::after {
  content: "";
  position: absolute;
  right: 0; bottom: 0;
  width: var(--ck-bib-frame); height: 32px;
  border-right: 1px solid var(--ck-bib-rule);
  border-bottom: 1px solid var(--ck-bib-rule);
  pointer-events: none;
}

/* Dropdown */
.ck-bibliography__details { margin: 0; padding: 0; }

.ck-bibliography__summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 23px 0 22px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  color: var(--ck-bib-text);
}
.ck-bibliography__summary::-webkit-details-marker { display: none; }
.ck-bibliography__summary::marker { content: ""; }

.ck-bibliography__title {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  color: #252523;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  line-height: 1;
  text-transform: uppercase;
}
.ck-bibliography__count,
.ck-bibliography__label { color: inherit; font: inherit; }

.ck-bibliography__caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 17px; height: 17px;
  color: #40403c;
}
.ck-bibliography__caret svg {
  display: block;
  width: 16px; height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .18s ease, stroke .15s ease;
}
.ck-bibliography__summary:hover .ck-bibliography__caret,
.ck-bibliography__summary:focus-visible .ck-bibliography__caret { color: #000; }
.ck-bibliography__details[open] .ck-bibliography__caret svg { transform: rotate(180deg); }

/* Open content */
.ck-bibliography__content { padding: 0 0 22px; }

.ck-bibliography__description {
  max-width: 680px;
  margin: 0 0 24px;
  color: var(--ck-bib-secondary);
  font-size: 14px;
  line-height: 1.7;
}

/* Reference list — separation is whitespace only */
.ck-bibliography__list {
  margin: 0; padding: 0; border: 0;
  list-style: none;
}
.ck-reference { margin: 0; padding: 8px 0; border: 0; }
.ck-reference + .ck-reference { margin-top: 6px; }

.ck-reference__citation {
  margin: 0; padding: 0;
  color: #292927;
  font-family: var(--ck-bib-serif);
  font-size: 16.5px;
  font-weight: 400;
  line-height: 1.75;
}
.ck-reference__number {
  display: inline;
  margin-right: 6px;
  color: #777772;
  font-family: var(--ck-bib-mono);
  font-size: 10px;
  font-weight: 500;
  vertical-align: .08em;
}
a.ck-reference__number { text-decoration: none; cursor: pointer; transition: color .15s ease; }
a.ck-reference__number:hover,
a.ck-reference__number:focus-visible { color: var(--ck-bib-accent); }

/* Per-style / per-type entry hook (author & title emphasis come from the
   citation style itself, so they are not forced here). */
.ck-reference__citation .ck-bib-entry { color: inherit; }

.ck-reference__citation a {
  color: inherit;
  text-decoration: none;
  border: 0;
  box-shadow: none;
}
.ck-reference__citation a:hover,
.ck-reference__citation a:focus { color: var(--ck-bib-accent); }

/* External source link (compact arrow) */
.ck-reference__source-link {
  display: inline;
  margin-left: 3px;
  color: #656560 !important;
  font-family: var(--ck-bib-sans);
  font-style: normal;
  font-weight: 500;
  text-decoration: none !important;
  white-space: nowrap;
}
.ck-reference__source-link::after {
  content: "\2197";
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  transition: transform .15s ease;
}
.ck-reference__source-link:hover::after,
.ck-reference__source-link:focus-visible::after { transform: translate(1px, -1px); }
.ck-reference__source-link:hover,
.ck-reference__source-link:focus-visible {
  color: var(--ck-bib-accent) !important;
  text-decoration: none !important;
}

/* Footer credit */
.ck-bibliography__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin: 0;
  padding: 17px 0 0;
}
.ck-bibliography__powered {
  color: #aaa9a3;
  font-size: 10px;
  line-height: 1.2;
  text-decoration: none;
}
.ck-bibliography__powered strong { color: #777772; font-weight: 650; }
.ck-bibliography__powered:hover { color: #777772; }
.ck-bibliography__logo {
  display: inline-flex;
  align-items: center;
  color: #85857f;
  text-decoration: none;
  transition: color .15s ease;
}
.ck-bibliography__logo:hover { color: var(--ck-bib-accent); }
.ck-bibliography__logo-svg { display: block; height: 15px; width: auto; }

/* Screen-reader-only utility */
.ck-screen-reader-text {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 640px) {
  .ck-bibliography { padding: 0 17px; --ck-bib-frame: 38px; }
  .ck-bibliography::before,
  .ck-bibliography::after { height: 25px; }
  .ck-bibliography__summary { padding: 20px 0 19px; }
  .ck-bibliography__description { margin-bottom: 20px; font-size: 13.5px; }
  .ck-reference__citation { font-size: 16px; line-height: 1.7; }
  .ck-reference { padding: 7px 0; }
  .ck-reference + .ck-reference { margin-top: 5px; }
}


/* ── CITATION MARKER ───────────────────────────────────────────────────── */

.ck-cite {
  /* Inline, baseline — matches IEEE style and reads cleanly in prose.
     Visually distinct from footnotes (which are superscript) so readers
     can tell citations and footnotes apart at a glance. */
  font-size: inherit;
  vertical-align: baseline;
  white-space: nowrap;
  margin: 0 0.1em;
}

.ck-cite a {
  text-decoration: none;
  color: inherit;
}

.ck-cite a:hover {
  text-decoration: underline;
}


/* ── PRINT ─────────────────────────────────────────────────────────────── */

@media print {
  .ck-popup {
    display: none !important;
  }

  .ck-footnotes-section {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
