/* ---------------------------------------------------------
   VISIBILITY CONTROL
--------------------------------------------------------- */

/* Hidden state */
.learn-citation-box[aria-hidden="true"] {
  opacity: 0;
  transform: translateX(10px) scale(0.98);
  pointer-events: none;
  visibility: hidden;
}

/* Visible state (aria-hidden removed) */
.learn-citation-box:not([aria-hidden="true"]) {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}
/* ---------------------------------------------------------
   OPTIONAL: NICE SCROLLBAR FOR THE BOX
--------------------------------------------------------- */

/* Firefox */
.learn-citation-box {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.25) transparent;
}

/* WebKit */
.learn-citation-box::-webkit-scrollbar {
  width: 10px;
}
.learn-citation-box::-webkit-scrollbar-track {
  background: transparent;
}
.learn-citation-box::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.18);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.learn-citation-box::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.28);
}
.copy-citation:hover {
  border-color: var(--gb-md-divider);
  box-shadow: 0 10px 24px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}

.copy-citation:active {
  transform: translateY(0) scale(0.98);
}

.copy-citation:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--gb-md-link-underline);
}
/* ---------------------------------------------------------
   ACTIONS (COPY)
--------------------------------------------------------- */

.citation-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: transparent;
}

.copy-citation {
  border: 1px solid var(--gb-md-divider);
  background: var(--gb-md-surface-soft);
  color: var(--gb-md-text-secondary);

  border-radius: 10px;
  padding: 8px 12px;

  font-size: 13px;
  font-weight: 600;

  cursor: pointer;

  transition:
    background-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}
/* =========================================================
   LEARN — CITATION UI (DISCREET + ACADEMIC)
   Scope: Learn mode only
   - Trigger button sits on right side of article
   - Citation box floats to the left like a speech bubble
   - Bubble animation on open/close
========================================================= */




/* ---------------------------------------------------------
   TRIGGER BUTTON (RIGHT SIDE, DISCREET)
--------------------------------------------------------- */
#learn-cite-trigger {
    /* content: "“"; */
    /* width: 100%; */
    all: unset;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    padding: 2px 35px;
    border-radius: 999px;
    border: 1px solid rgb(29 27 27 / 23%);
    background: var(--gb-md-surface-soft);
    color: #c1c3c8;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 160ms ease,
    background-color 160ms ease,
    box-shadow 220ms ease,
    border-color 200ms ease;
    position: relative;
    left: 10px;
    /* background-image: url("../../image/quote.svg"); */
    background-repeat: no-repeat;
    background-position: 5px 3px;
    background-color: rgba(255,255,255,0.08);
    background-size: 14%;
}
#learn-cite-trigger svg {
    position: absolute;
    color: inherit;
    width: 12px;
    height: 12px;
    margin-right: 8px;
    flex-shrink: 0;
    left: 7px;
    top: 7px;
}

#learn-cite-trigger:hover {
  opacity: 1;
  border-color: var(--gb-md-divider);
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}

#learn-cite-trigger:active {
  transform: scale(0.97);
}

#learn-cite-trigger:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--gb-md-link-underline),
    0 8px 22px rgba(0,0,0,0.25);
}
/* ---------------------------------------------------------
   CITATION BOX (FLOATING BUBBLE)
--------------------------------------------------------- */
/* ---------------------------------------------------------
   CITATION BOX (FLOATING BUBBLE — CONTENT SIZED)
--------------------------------------------------------- */

.learn-citation-box {
  position: absolute;
  top: 4.5rem;
  right: 1rem;

  width: min(360px, 90vw);

  /* 🔑 Let content define height */
  height: auto;
  max-height: unset;
  overflow: visible;

  background: var(--gb-surface-header);
  color: var(--gb-md-text-primary);

  border: 1px solid var(--gb-md-divider);
  border-radius: 14px;

  box-shadow:
    0 24px 60px rgba(0,0,0,0.18),
    0 6px 18px rgba(0,0,0,0.08);

  padding: 18px 20px;
  z-index: 30;

  opacity: 0;
  transform: translateX(10px) scale(0.98);
  pointer-events: none;
  visibility: hidden;

  transition:
    opacity 200ms ease,
    transform 260ms cubic-bezier(.22,.61,.36,1),
    visibility 0s linear 200ms;

  will-change: opacity, transform;
}


/* OPEN STATE */
.learn-citation-box[aria-hidden="false"] {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}


/* =====================================================
   CITATION BUBBLE TAIL — SHARP & ACADEMIC
===================================================== */

.learn-citation-box::after {
  content: "";
  position: absolute;

  /* align vertically with header text */
  top: 26px;
  right: -10px;

  width: 18px;
  height: 18px;

  background: var(--gb-md-surface);

  /* crisp paper edge */
  border-right: 1px solid var(--gb-md-divider);
  border-bottom-right-radius: 3px;

  transform: rotate(-45deg);

  /* subtle lift to match box shadow */
  box-shadow: 6px 6px 12px rgba(0,0,0,0.06);
  
}


/* ---------------------------------------------------------
   CITATION HEADER
--------------------------------------------------------- */

.citation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  margin-bottom: 12px;
  padding-bottom: 10px;

  border-bottom: 1px solid var(--gb-md-divider-soft);
}

.citation-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gb-md-heading-sub);
}

.citation-close {
  background: transparent;
  border: none;

  font-size: 18px;
  line-height: 1;

  color: var(--gb-md-text-muted);
  cursor: pointer;

  padding: 4px 6px;
  border-radius: 8px;

  transition:
    color 140ms ease,
    background-color 140ms ease,
    transform 160ms ease;
}

.citation-close:hover {
  color: var(--gb-md-text-primary);
  background: var(--gb-md-surface-soft);
}

.citation-close:active {
  transform: scale(0.96);
}

.citation-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--gb-md-link-underline);
}

/* ---------------------------------------------------------
   FORMAT TABS
--------------------------------------------------------- */

.citation-formats {
  display: flex;
  gap: 8px;
  margin: 8px 0 8px 0;
}

.citation-tab {
  appearance: none;
  border: 1px solid var(--gb-md-divider);
  background: var(--gb-md-surface-soft);
  color: var(--gb-md-text-secondary);

  border-radius: 8px;
  padding: 6px 10px;

  font-size: 13px;
  font-weight: 600;

  cursor: pointer;

  transition:
    background-color 160ms ease,
    transform 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.citation-tab:hover {
  border-color: var(--gb-md-divider);
  transform: translateY(-1px);
}

.citation-tab.active {
  background: var(--gb-md-alice-blue);
  border-color: var(--gb-md-link-underline);
  color: var(--gb-md-heading-sub);
}


/* ---------------------------------------------------------
   CITATION CONTENT (MONO BLOCK)
--------------------------------------------------------- */

.citation-content {
    /* vertical-align: middle; */
    /* position: relative; */
    /* height: 100px; */
    /* max-height: 100px; */
    overflow: hidden;
    margin-top: 10px;
    background: var(--gb-md-pre-bg);
    border: 1px solid var(--gb-md-divider-soft);
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    /* line-height: 1.6; */
    color: var(--gb-md-code-text);
    /* white-space: pre-wrap; */
    word-break: break-word;
    overflow-wrap: anywhere;
    box-sizing: border-box;
}
/* =========================================================
   CITATION BOX — HORIZONTAL SCROLL PREVENTION
========================================================= */

/* 🚫 Never allow horizontal scroll in citation */
.learn-citation-box,
.citation-content {
  overflow-x: hidden !important;
}
/* OPTIONAL: NICE SCROLLBAR FOR THE BOX */
.learn-citation-box {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.25) transparent;
}

/* =========================================================
   CITATION BOX — CONTENT HUGGING
========================================================= */

.learn-citation-box {
  display: inline-flex;
  flex-direction: column;
}

/* ---------------------------------------------------------
   CITATION FORMATS
--------------------------------------------------------- */

.copy-citation.is-copied {
  background: #22c55e;
  color: white;
  transition: all 0.2s ease;
}
.citation-format {
  opacity: 0.6;
  transition: all 0.2s ease;
}

.citation-format.active {
  opacity: 1;
  color: #7aa6ff;
  border-bottom: 2px solid #7aa6ff;
}

.citation-format:hover {
  opacity: 1;
}
/* =================================
   CITATION FORMAT BUTTONS
================================= */

.citation-formats {
  display: inline-flex;
  gap: 0.4rem;

  background: rgba(255,255,255,0.06);
  padding: 0.3rem;
  border-radius: 10px;

  backdrop-filter: blur(6px);
}

/* Base button */
.citation-format {
  border: none;
  background: transparent;

  padding: 0.35rem 0.75rem;
  border-radius: 7px;

  font-size: 0.75rem;
  font-weight: 600;

  color: rgba(255,255,255,0.65);

  cursor: pointer;
  transition: all 0.18s ease;
}

/* Hover */
.citation-format:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.08);
}

/* Active (selected tab) */
.citation-format.active {
  background: #ffffff;
  color: #0f172a;

  box-shadow:
    0 2px 6px rgba(0,0,0,0.25),
    inset 0 0 0 1px rgba(0,0,0,0.05);
}
/* =================================
   CITATION CONTENT (PREMIUM WHITE)
================================= */

.citation-content {
  margin-top: 0.8rem;
}

/* White card */
.citation-text {
  background: #ffffff;
  color: #1f2937;

  padding: 1rem 1.1rem;
  border-radius: 10px;

  font-size: 0.85rem;
  line-height: 1.6;

  border: 1px solid rgba(0,0,0,0.06);

  box-shadow:
    0 8px 24px rgba(0,0,0,0.25),
    0 2px 6px rgba(0,0,0,0.15);

  transition: all 0.25s ease;
}

/* Smooth switch effect */
.citation-text[hidden] {
  display: none;
}

/* Emphasis inside citation */
.citation-text em {
  font-style: italic;
  color: #374151;
}

/* URL styling */
.citation-text a {
  color: #2563eb;
  text-decoration: none;
  border-bottom: 1px dotted rgba(37,99,235,0.5);
}

.citation-text a:hover {
  border-bottom: 1px solid rgba(37,99,235,0.8);
}
.learn-citation-box {
  display: none;
  opacity: 0;
}

.learn-citation-box.is-open {
  display: inline-flex;
  animation: citationFadeIn 180ms ease, citationScale 220ms ease;
}

@keyframes citationScale {
  from { transform: scale(0.98); }
  to   { transform: scale(1); }
}