/* ============================================================
   Anonymous inline comments — highlight, compose, thread, onboarding
   Uses the site's design tokens (teal accent, serif/sans, paper).
   ============================================================ */

/* highlighted (commented) text */
mark.cmark {
  background: rgba(29, 133, 121, 0.16);
  color: inherit;
  border-radius: 2px;
  box-shadow: inset 0 -1px 0 rgba(20, 99, 91, 0.5);
  cursor: pointer;
  transition: background 0.15s ease;
}
mark.cmark:hover,
mark.cmark.is-active {
  background: rgba(29, 133, 121, 0.32);
}

/* comment count as a small superscript on the highlight itself
   (no inline box, no word breaks, drawn via CSS so it stays out of textContent) */
mark.cmark[data-count]::after {
  content: attr(data-count);
  display: inline-block;
  margin-left: 0.25em;
  vertical-align: super;
  min-width: 0.95rem;
  height: 0.95rem;
  padding: 0 0.2em;
  box-sizing: border-box;
  font-family: var(--sans);
  font-size: 0.56rem;
  font-weight: 700;
  line-height: 0.95rem;
  text-align: center;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
}
mark.cmark:hover[data-count]::after,
mark.cmark.is-active[data-count]::after { background: var(--accent-2); }

/* toast confirmation after posting */
.ctoast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%) translateY(10px);
  z-index: 95;
  background: var(--ink);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.ctoast.is-shown {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* floating selection toolbar shown on text selection (comment + share) */
.csel-btn {
  position: absolute;
  z-index: 70;
  display: inline-flex;
  align-items: stretch;
  background: var(--ink);
  border-radius: 9px;
  overflow: hidden;
  box-shadow: 0 10px 26px -10px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.csel-btn.is-shown {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.csel-btn__action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.72rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  background: transparent;
  border: 0;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.csel-btn__action:hover { background: rgba(255, 255, 255, 0.12); }
.csel-btn__action svg { width: 0.9rem; height: 0.9rem; flex: none; }
.csel-btn__divider { width: 1px; background: rgba(255, 255, 255, 0.18); margin: 0.4rem 0; flex: none; }
/* comfortable touch targets on phones/tablets */
@media (pointer: coarse) { .csel-btn__action { min-height: 44px; } }

/* backdrop (mobile sheet + desktop click-away) */
.cpanel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(18, 18, 16, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.cpanel-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* thread + composer panel */
.cpanel {
  position: fixed;
  z-index: 81;
  width: min(360px, calc(100vw - 2rem));
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--hair);
  border-radius: 14px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  overflow: hidden;
}
.cpanel.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.cpanel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.9rem 1rem 0.65rem;
  border-bottom: 1px solid var(--hair);
}
.cpanel__title {
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.cpanel__quote {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--ink-soft);
  margin: 0.2rem 0 0;
  max-height: 3.6em;
  overflow: hidden;
}
.cpanel__close {
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
}
.cpanel__close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
}
.cpanel__list {
  overflow-y: auto;
  padding: 0.7rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.cpanel__empty {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.3rem 0;
}
.ccomment__body {
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ccomment__meta {
  font-family: var(--sans);
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.25rem;
}
.cpanel__form {
  border-top: 1px solid var(--hair);
  padding: 0.7rem 1rem 0.9rem;
  background: var(--paper-2);
}
.cpanel__form textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 3.2rem;
  max-height: 10rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--ink);
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  background: #fff;
}
.cpanel__form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.cpanel__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.cpanel__note {
  font-family: var(--sans);
  font-size: 0.7rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.cpanel__submit {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
}
.cpanel__submit:hover { background: var(--accent-2); }
.cpanel__submit:disabled { opacity: 0.5; cursor: not-allowed; }
.cpanel__err {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: #9a1b1b;
  margin: 0.45rem 0 0;
}

/* mobile bottom sheet */
@media (max-width: 700px) {
  .cpanel {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto !important;
    width: 100%;
    max-height: 84vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  .cpanel.is-open { transform: translateY(0); }
  .cpanel__grip {
    width: 2.4rem;
    height: 0.28rem;
    border-radius: 999px;
    background: var(--hair);
    margin: 0.55rem auto 0;
  }
}
.cpanel__grip { display: none; }
@media (max-width: 700px) { .cpanel__grip { display: block; } }

/* help button (bottom-left; back-to-top is bottom-right) */
.chelp {
  position: fixed;
  left: 1.1rem;
  bottom: 1.1rem;
  z-index: 55;
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 50%;
  border: 1px solid var(--hair);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 6px 22px -12px rgba(0, 0, 0, 0.5);
}
.chelp:hover { background: #fff; }

/* onboarding overlay */
.conboard {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background: rgba(18, 18, 16, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.conboard.is-open {
  opacity: 1;
  pointer-events: auto;
}
.conboard__card {
  width: min(30rem, 100%);
  background: var(--paper);
  border-radius: 16px;
  padding: 1.6rem 1.5rem 1.4rem;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6);
  transform: translateY(10px) scale(0.985);
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.conboard.is-open .conboard__card { transform: none; }
.conboard__kicker {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.5rem;
}
.conboard__title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.15;
  margin: 0 0 0.6rem;
}
.conboard__text {
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 1rem;
}
.conboard__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.conboard__anon {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.conboard__anon svg { width: 0.95rem; height: 0.95rem; color: var(--accent); }
.conboard__btn {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 9px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
}
.conboard__btn:hover { background: var(--accent-2); }

/* animated demo inside the overlay */
.demo {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 1.1rem 1.1rem 1.25rem;
  margin: 0 0 1.1rem;
  overflow: hidden;
}
.demo__lines { display: flex; flex-direction: column; gap: 0.55rem; }
.demo__line { height: 0.62rem; border-radius: 4px; background: #dcd7cb; }
.demo__line.l1 { width: 96%; }
.demo__line.l2 { position: relative; width: 82%; }
.demo__line.l3 { width: 68%; }
.demo__hl {
  position: absolute;
  left: 0;
  top: -2px;
  bottom: -2px;
  width: 64%;
  background: rgba(29, 133, 121, 0.3);
  border-radius: 4px;
  transform-origin: left center;
  transform: scaleX(0);
  animation: demoSweep 3.8s ease-in-out infinite;
}
.demo__bubble {
  position: absolute;
  left: calc(0.82 * (100% - 2.2rem) * 0.64);
  top: 50%;
  width: 1.7rem;
  height: 1.7rem;
  margin-top: -0.3rem;
  border-radius: 50% 50% 50% 4px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.5);
  transform: scale(0);
  animation: demoBubble 3.8s ease-in-out infinite;
}
@keyframes demoSweep {
  0% { transform: scaleX(0); }
  22% { transform: scaleX(1); }
  80% { transform: scaleX(1); opacity: 1; }
  92% { opacity: 0; }
  100% { transform: scaleX(1); opacity: 0; }
}
@keyframes demoBubble {
  0%, 26% { opacity: 0; transform: scale(0) translateY(6px); }
  40% { opacity: 1; transform: scale(1) translateY(0); }
  82% { opacity: 1; }
  92%, 100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .demo__hl { transform: scaleX(1); animation: none; }
  .demo__bubble { transform: scale(1); opacity: 1; animation: none; }
  .cpanel, .csel-btn, .cpanel-backdrop, .conboard, .conboard__card, .share { transition: none; }
}

/* ---------- share-image modal ---------- */
.share {
  position: fixed;
  inset: 0;
  z-index: 96;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.1rem;
  background: rgba(8, 8, 8, 0.6);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.share.is-open { opacity: 1; pointer-events: auto; }
.share__card {
  width: min(420px, calc(100vw - 1.6rem));
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 16px;
  box-shadow: 0 30px 70px -28px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.share__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem 0.7rem;
  border-bottom: 1px solid var(--hair);
}
.share__title {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.share__close {
  width: 1.7rem;
  height: 1.7rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
}
.share__close:hover { background: rgba(0, 0, 0, 0.05); color: var(--ink); }
.share__toggle { display: flex; gap: 0.4rem; padding: 0.7rem 1rem 0.1rem; }
.share__tab {
  flex: 1;
  padding: 0.45rem 0.5rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: 8px;
  cursor: pointer;
}
.share__tab.is-active { color: #fff; background: var(--accent); border-color: var(--accent); }
.share__preview {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 1rem;
  min-height: 0;
  overflow: auto;
}
.share__canvas {
  display: block;
  max-width: 100%;
  max-height: 56vh;
  width: auto;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 10px 30px -16px rgba(0, 0, 0, 0.5);
}
.share__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.7rem 1rem 0.9rem;
  border-top: 1px solid var(--hair);
  background: var(--paper-2);
}
.share__hint { font-family: var(--sans); font-size: 0.7rem; color: var(--muted); flex: 1 1 130px; }
.share__btns { display: flex; gap: 0.5rem; }
.share__btn {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 8px;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
}
.share__btn--ghost { color: var(--ink); background: transparent; border-color: var(--hair); }
.share__btn--ghost:hover { background: rgba(0, 0, 0, 0.04); }
.share__btn--primary { color: #fff; background: var(--accent); }
.share__btn--primary:hover { background: var(--accent-2); }
