/* Comments as post-it notes: a bubble after the words, which zooms up a post-it. */

/* Post-it papers: classic canary yellow first, then the Postits colors. Ink stays dark warm
   gray on every color. A blank post-it takes the color picked on it while it's being written. */
.note--yellow, .postit:has(.note--yellow:checked) { --note: #fff59d; }
.note--pink,   .postit:has(.note--pink:checked)   { --note: #ffc4d6; }
.note--blue,   .postit:has(.note--blue:checked)   { --note: #bfe2f6; }
.note--green,  .postit:has(.note--green:checked)  { --note: #c8ecae; }
.note--orange, .postit:has(.note--orange:checked) { --note: #ffd2a3; }
.note--purple, .postit:has(.note--purple:checked) { --note: #dacff6; }
.note--resolved { --note: #e8dcc9; }

/* A layer over the paper, so bubbles sit by the words without being part of the script. */
.comment-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* A little speech bubble, its tail pointing down at the end of the words. */
.comment-bubble {
  position: absolute;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.45rem;
  height: 1.05rem;
  padding: 0 0.25rem;
  border: 1px solid rgb(0 0 0 / 0.3);
  border-radius: 0.6rem 0.6rem 0.6rem 0.15rem;
  background: var(--note);
  color: #2b2a24;
  font: 700 0.65rem/1 var(--font-typed);
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.2), 0 2px 5px -1px rgb(0 0 0 / 0.3);
  pointer-events: auto;
  cursor: pointer;
}
.comment-bubble[hidden] { display: none; }
.comment-bubble:hover, .comment-bubble:focus-visible { scale: 1.15; }
.comment-bubble--resolved { color: #6b6253; }

@media (prefers-reduced-motion: no-preference) {
  .comment-bubble { transition: scale 120ms ease; }
}

/* The post-it, a wide 6×4 note a little askew, in the middle of the screen. It grows from where
   it was opened (--from, set by the script) and shrinks back there when it closes. */
.postit {
  --note-ink: #2b2a24;
  --note-ink-2: #55524a;
  --zoom-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  width: min(38rem, calc(100vw - 32px));
  min-height: min(25rem, 80dvh);
  max-height: 88dvh;
  margin: auto;
  padding: 2.25rem 2rem 1.5rem;
  border: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* The sticky strip along the top, and the bottom corner lifting off the page. */
  background:
    linear-gradient(to bottom, rgb(0 0 0 / 0.045) 0 1.4rem, transparent 1.4rem),
    linear-gradient(to top left, rgb(0 0 0 / 0.1), transparent 22%),
    var(--note);
  color: var(--note-ink);
  font: 1.4rem/1.4 var(--font-hand);
  box-shadow: 0 2px 2px rgb(0 0 0 / 0.15), 0 24px 48px rgb(0 0 0 / 0.45);
  pointer-events: auto;
  rotate: -0.8deg;
  opacity: 0;
  scale: 0.1;
  translate: var(--from, 0 0);
}
/* A column, so the buttons sit along the bottom edge however short the thread is. */
.postit:popover-open { display: flex; flex-direction: column; gap: 0.9rem; opacity: 1; scale: 1; translate: 0 0; }

@media (prefers-reduced-motion: no-preference) {
  .postit:not(.postit--instant) {
    transition: opacity 200ms, scale 300ms var(--zoom-ease), translate 300ms var(--zoom-ease),
      display 300ms allow-discrete, overlay 300ms allow-discrete;
  }
  @starting-style {
    .postit:popover-open { opacity: 0; scale: 0.1; translate: var(--from, 0 0); }
  }
}

.postit::backdrop { background: rgb(20 12 6 / 0.5); }

.postit__close {
  position: absolute;
  top: 0.1rem;
  right: 0.4rem;
  padding: 0 0.3rem;
  border: 0;
  background: none;
  color: var(--note-ink-2);
  font: 1.6rem/1 var(--font-typed);
  cursor: pointer;
}

.postit__title { margin: 0; font: 700 1.6rem var(--font-hand); }

/* The words, clipped from the script in its typewriter face. */
.postit__quote {
  margin: 0;
  padding: 0.45rem 0.75rem;
  border-left: 3px solid rgb(0 0 0 / 0.25);
  background: rgb(255 255 255 / 0.4);
  font: 0.95rem/1.45 var(--font-typed);
  overflow-wrap: anywhere;
}
.postit__quote:empty { display: none; }

.postit__form { display: grid; }
/* The new post-it's form fills the paper, with its swatches and button at the bottom. */
#comment_composer .postit__form { flex: 1; display: flex; flex-direction: column; gap: 0.9rem; }
#comment_composer .postit__writing { flex: 1; }

/* Swatches for the post-it's paper, in a row under the close button. */
.postit__colors { display: flex; gap: 0.5rem; margin: 0; padding: 0; border: 0; }
.postit__color {
  appearance: none;
  width: 1.4rem;
  height: 1.4rem;
  margin: 0;
  padding: 0;
  border: 1.5px solid rgb(0 0 0 / 0.35);
  border-radius: 50%;
  background: var(--note);
  cursor: pointer;
}
.postit__color:is(:checked, [aria-pressed="true"]) { outline: 2px solid var(--note-ink); outline-offset: 1px; }
.postit__color:focus-visible { outline: 2px solid var(--note-ink); outline-offset: 2px; }

/* Written straight onto the paper. */
.postit__writing {
  width: 100%;
  padding: 0.2rem 0;
  border: 0;
  border-bottom: 1.5px dashed rgb(0 0 0 / 0.25);
  background: transparent;
  color: inherit;
  font: inherit;
  resize: vertical;
}
.postit__writing:focus { outline: none; border-bottom-style: solid; border-bottom-color: var(--note-ink-2); }
.postit__writing::placeholder { color: var(--note-ink-2); opacity: 0.7; }

.postit__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.postit__actions form.button_to { display: inline; }
.postit__actions--spread { justify-content: space-between; }

.postit__button {
  padding: 0.35rem 1.1rem;
  border: 1.5px solid var(--note-ink);
  border-radius: 999px;
  background: var(--note-ink);
  color: var(--note);
  font: 700 1.15rem var(--font-hand);
  cursor: pointer;
}
.postit__button--quiet { background: rgb(255 255 255 / 0.35); color: var(--note-ink); }
.postit__button--quiet:hover { background: rgb(255 255 255 / 0.7); }

.comment-thread { display: grid; gap: 0.75rem; }
/* An open thread fills the paper, its reply box and buttons pushed down to the bottom edge. */
.comment-thread:not(.comment-thread--resolved) { flex: 1; display: flex; flex-direction: column; }
.comment-thread:not(.comment-thread--resolved) > .postit__form { margin-top: auto; }
.comment-thread + .comment-thread { padding-top: 0.75rem; border-top: 1.5px dashed rgb(0 0 0 / 0.2); }
.comment-thread__changed { margin: 0; color: #8a3a00; font-size: 1rem; }

.comment__byline { display: flex; align-items: baseline; gap: 0.5rem; margin: 0; white-space: nowrap; font-size: 1.05rem; }
.comment__byline strong { overflow: hidden; text-overflow: ellipsis; }
.comment__byline time { color: var(--note-ink-2); font-size: 0.9rem; }
.comment__byline form.button_to { margin-left: auto; }
.comment__delete { padding: 0; border: 0; background: none; color: var(--note-ink-2); font: inherit; font-size: 0.9rem; text-decoration: underline; cursor: pointer; }
.comment__body { margin: 0.1rem 0 0; overflow-wrap: anywhere; }

/* Offered at the paper's right edge, level with the first selected line. */
.comment-button {
  position: absolute;
  right: 0.25rem;
  z-index: 5;
  padding: 0.3rem 0.6rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--typed-ink);
  font: 700 0.9rem/1.2 var(--font-typed);
  white-space: nowrap;
  box-shadow: 0 3px 10px rgb(0 0 0 / 0.35);
  cursor: pointer;
}
.comment-button[hidden] { display: none; }

::highlight(comment) { background-color: rgb(232 176 74 / 0.35); }
::highlight(comment-active) { background-color: rgb(232 176 74 / 0.8); }

@media print {
  .comment-layer, .comment-button { display: none; }
}

/* A note from set: the line was said differently on the day. */
.comment-thread__on-set { align-self: flex-start; justify-self: start; margin: 0; padding: 0.15rem 0.5rem; border: 1px solid currentColor; border-radius: 4px; font: 700 0.8rem var(--font-typed); letter-spacing: 0.06em; text-transform: uppercase; }
.postit__check { display: flex; align-items: flex-start; gap: 0.5rem; min-height: 44px; padding-top: 0.6rem; font-size: 1rem; line-height: 1.35; cursor: pointer; }
.postit__check input { flex: none; width: 1.15rem; height: 1.15rem; margin-top: 0.1rem; }

/* Scene notes: comments on the whole scene, as small post-its in the left margin beside the heading
   (comments_controller.js places them). Past two they make a pile with a count. With no room beside
   the paper, a post-it tab after the heading stands in. */
.scene-notes { position: absolute; z-index: 4; display: flex; flex-direction: column; gap: 0.6rem; width: 168px; }
.scene-notes[hidden] { display: none; }
.scene-note {
  position: relative;
  display: block;
  width: 100%;
  padding: 0.55rem 0.7rem 0.6rem;
  border: 0;
  background: var(--note);
  color: #2b2a24;
  font: 1rem/1.25 var(--font-hand);
  text-align: left;
  box-shadow: 0 2px 0 rgb(0 0 0 / 0.08), 0 8px 16px rgb(0 0 0 / 0.35);
  rotate: -1.5deg;
  pointer-events: auto;
  cursor: pointer;
}
.scene-note + .scene-note { rotate: 1deg; }
.scene-note:hover, .scene-note:focus-visible { rotate: 0deg; }
.scene-note__body { display: block; overflow-wrap: anywhere; }
.scene-note__by { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.4rem; color: #55524a; font: 600 0.7rem var(--font-ui); }
.scene-note__replies { margin-left: auto; }

.scene-notes--pile { isolation: isolate; }
.scene-notes__sheet { position: absolute; top: 0; left: 0; z-index: -1; width: 100%; height: 5.5rem; background: var(--note); box-shadow: 0 6px 12px rgb(0 0 0 / 0.3); }
.scene-notes__sheet--one { rotate: 3deg; translate: 5px 5px; }
.scene-notes__sheet--two { z-index: -2; rotate: -4deg; translate: -4px 9px; }
.scene-notes__count {
  position: absolute;
  top: -9px;
  right: -9px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brass);
  color: var(--brass-ink);
  font: 700 0.72rem var(--font-ui);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.4);
}

/* "+ post-it", offered while the pointer's on the scene. */
.scene-notes__add {
  align-self: flex-start;
  padding: 0.1rem 0.5rem;
  border: 1.5px dashed var(--brass-line);
  border-radius: 6px;
  background: transparent;
  color: var(--chrome-muted);
  font: 1rem var(--font-hand);
  opacity: 0;
  pointer-events: auto;
  cursor: pointer;
}
.scene-notes--near .scene-notes__add, .scene-notes__add:focus-visible, .scene-notes__add:hover { opacity: 1; }
.scene-notes__add--fan { opacity: 1; margin-top: 0.4rem; color: var(--sheet-soft); border-color: var(--sheet-line); }
@media (prefers-reduced-motion: no-preference) {
  .scene-notes__add { transition: opacity 150ms ease; }
  .scene-note { transition: rotate 150ms ease; }
}
@media (hover: none) and (pointer: coarse) { .scene-notes__add:not(.scene-notes__add--fan) { display: none; } }

/* The tab after the heading where there's no room in the margin. */
.scene-notes__tab { min-width: 1.15rem; border-radius: 2px; font: 700 0.7rem/1 var(--font-ui); rotate: -4deg; }
.scene-notes__tab::before { content: ""; position: absolute; top: -3px; left: 30%; width: 40%; height: 4px; background: rgb(255 255 255 / 0.55); }

/* Past two: all the scene's post-its spread on a sheet, each opening its own. */
.scene-notes__fan {
  width: min(24rem, calc(100vw - 32px));
  max-height: 80dvh;
  margin: auto;
  padding: 1.25rem;
  border: 0;
  border-radius: var(--radius-sheet, 10px);
  overflow-y: auto;
  background: var(--sheet);
  color: var(--sheet-ink);
  box-shadow: var(--shadow-lifted, 0 18px 40px rgb(0 0 0 / 0.5));
}
.scene-notes__fan .postit__title { margin-bottom: 0.8rem; font-size: 1.4rem; }
.scene-notes__fan .scene-note { margin-bottom: 0.8rem; }
.scene-notes__fan::backdrop { background: rgb(0 0 0 / 0.35); }

.postit__quote:empty { display: none; }
