/* Comment pins (comments.js). Ink-and-paper chrome that reads on every section colour:
   square cards like the rest of the site, pill buttons, and teardrop pins with a white ring. */

:root {
  --cmt-ink: #14100f;
  --cmt-paper: #ffffff;
  --cmt-soft: #f1eeec;
  --cmt-accent: var(--gummy-head);
  --cmt-error: #c2183f;
}

.cmt-fab {
  position: fixed;
  /* Beside the roll in the corner (styles.css). */
  right: calc(16px + var(--roll-slot, 0px));
  bottom: 16px;
  z-index: 60;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px solid var(--cmt-paper);
  border-radius: 999px;
  background: var(--cmt-ink);
  color: var(--cmt-paper);
  cursor: pointer;
  transition: transform 0.18s var(--ease);
}
.cmt-fab:hover {
  transform: translateY(-2px);
}
.cmt-fab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linejoin: round;
}
.cmt-fab[aria-pressed="true"] {
  background: var(--cmt-accent);
  color: var(--cmt-ink);
  border-color: var(--cmt-ink);
}
.cmt-fab:focus-visible {
  outline: 3px solid var(--cmt-accent);
  outline-offset: 3px;
}
.cmt-fab-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--cmt-accent);
  color: var(--cmt-ink);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 800;
  line-height: 22px;
}

/* Comment mode: crosshair everywhere except the comment UI itself. */
html.is-commenting,
html.is-commenting a,
html.is-commenting button,
html.is-commenting summary,
html.is-commenting input,
html.is-commenting textarea {
  cursor: crosshair;
}
html.is-commenting .cmt-fab,
html.is-commenting .cmt-pin,
html.is-commenting .cmt-card button,
html.is-commenting .cmt-panel button {
  cursor: pointer;
}
html.is-commenting .cmt-card .cmt-in {
  cursor: text;
}

/* Pins: the author's initial in an ink teardrop pointing at the spot. */
.cmt-pin {
  position: fixed;
  z-index: 58;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: -27px 0 0 -3px;
  padding: 0;
  border: 2px solid var(--cmt-paper);
  border-radius: 50% 50% 50% 4px;
  background: var(--cmt-ink);
  color: var(--cmt-accent);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}
.cmt-pin:hover {
  transform: scale(1.12);
}
.cmt-pin-open {
  background: var(--cmt-accent);
  color: var(--cmt-ink);
  border-color: var(--cmt-ink);
}
.cmt-pin:focus-visible {
  outline: 3px solid var(--cmt-accent);
  outline-offset: 2px;
}
/* How many replies a thread has, in a small paper bubble on the pin's shoulder. */
.cmt-pin-count {
  position: absolute;
  top: -9px;
  right: -11px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 2px solid var(--cmt-ink);
  border-radius: 999px;
  background: var(--cmt-paper);
  color: var(--cmt-ink);
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}
.cmt-pin-count:empty {
  display: none;
}

/* Compose and read cards */
.cmt-card {
  position: fixed;
  z-index: 62;
  display: grid;
  gap: 10px;
  width: min(320px, calc(100vw - 32px));
  padding: 16px;
  border: 2px solid var(--cmt-ink);
  background: var(--cmt-paper);
  color: var(--cmt-ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
}
.cmt-card p {
  margin: 0;
}
.cmt-in {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--cmt-ink);
  border-radius: 0;
  background: var(--cmt-paper);
  color: var(--cmt-ink);
  font: inherit;
}
.cmt-in:focus-visible {
  outline: 3px solid var(--cmt-accent);
  outline-offset: 1px;
}
.cmt-in-area {
  min-height: 96px;
  resize: vertical;
}
.cmt-who,
.cmt-meta {
  font-size: 14px;
}
.cmt-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cmt-err {
  color: var(--cmt-error);
  font-size: 14px;
  font-weight: 600;
}
.cmt-err:empty {
  display: none;
}
.cmt-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.cmt-btn {
  min-height: 36px;
  padding: 6px 16px;
  border: 2px solid var(--cmt-ink);
  border-radius: 999px;
  background: var(--cmt-ink);
  color: var(--cmt-paper);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.cmt-btn-quiet {
  background: transparent;
  color: var(--cmt-ink);
}
.cmt-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.cmt-btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 14px 4px 12px;
  font-size: 13px;
}
.cmt-btn svg,
.cmt-status-icon svg,
.cmt-item-status svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cmt-btn-quiet:hover:not(:disabled) {
  background: color-mix(in srgb, var(--cmt-accent) 45%, var(--cmt-paper));
}
.cmt-link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

/* Thread card: complete/close on top, the conversation, then the reply box. */
.cmt-popover {
  width: min(340px, calc(100vw - 32px));
  gap: 12px;
}
.cmt-thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cmt-popover .cmt-x {
  width: 32px;
  height: 32px;
  font-size: 18px;
}
.cmt-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--cmt-accent);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}
.cmt-status[hidden] {
  display: none;
}
.cmt-status-icon {
  display: inline-flex;
  flex: none;
}
.cmt-thread-list {
  display: grid;
  max-height: min(45vh, 360px);
  margin: 0 -16px;
  padding: 0 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.cmt-msg {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-top: 2px solid var(--cmt-soft);
}
.cmt-msg:first-child {
  padding-top: 0;
  border-top: 0;
}
.cmt-msg:last-child {
  padding-bottom: 0;
}
.cmt-msg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.cmt-tools {
  display: flex;
  flex: none;
  gap: 10px;
  font-size: 13px;
}
.cmt-text-gone {
  font-style: italic;
  opacity: 0.6;
}
.cmt-edit {
  display: grid;
  gap: 8px;
}
.cmt-popover-done .cmt-msg {
  opacity: 0.7;
}
.cmt-reply {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 2px solid var(--cmt-ink);
}
.cmt-reply .cmt-in-area {
  min-height: 64px;
}
.cmt-reply-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cmt-reply-row .cmt-who {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.cmt-reply-row .cmt-btn {
  margin-left: auto;
}

/* Panel: every comment, sliding in from the right */
.cmt-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  width: min(380px, calc(100vw - 48px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 20px 96px;
  border-left: 2px solid var(--cmt-ink);
  background: var(--cmt-paper);
  color: var(--cmt-ink);
  font-family: var(--font-body);
  transform: translateX(105%);
  transition: transform 0.35s var(--ease-soft);
}
.cmt-panel-open {
  transform: none;
}
.cmt-panel p {
  margin: 0;
}
.cmt-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cmt-panel-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-stretch: 125%;
  font-size: 22px;
  text-transform: uppercase;
}
.cmt-panel-close,
.cmt-x {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid var(--cmt-ink);
  border-radius: 999px;
  background: transparent;
  color: var(--cmt-ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.cmt-panel-hint {
  margin: 8px 0 16px !important;
  font-size: 14px;
  line-height: 1.4;
}
.cmt-panel-empty {
  font-size: 14px;
}
.cmt-panel-body {
  display: grid;
  gap: 8px;
}
.cmt-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 0;
  border-radius: 0;
  background: var(--cmt-soft);
  color: var(--cmt-ink);
  font-family: var(--font-body);
  text-align: left;
  cursor: pointer;
}
.cmt-item:hover {
  background: color-mix(in srgb, var(--cmt-accent) 45%, var(--cmt-paper));
}
.cmt-item-meta {
  font-size: 13px;
}
.cmt-item-text {
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.cmt-item-done {
  padding: 10px;
  border: 2px solid var(--cmt-soft);
  background: transparent;
}
.cmt-item-done .cmt-item-meta,
.cmt-item-done .cmt-item-text {
  opacity: 0.65;
}
.cmt-item-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}
.cmt-panel-toggle {
  justify-self: start;
  margin-top: 12px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--cmt-ink);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .cmt-panel {
    transition: none;
  }
}
