/* Plotlines: a colored tab for each one a scene is in, on its card and above its heading. */
.plotline-tab {
  display: inline-grid;
  place-items: center;
  min-width: 1.7em;
  height: 1.4em;
  padding: 0 0.35em;
  border-radius: 0.3em;
  background: var(--plotline, #888);
  color: #fff;
  font: 700 0.72rem/1 var(--font-ui);
  letter-spacing: 0.02em;
}
.plotline-tab--add { background: rgb(255 255 255 / 0.85); color: var(--sheet-soft); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.2); }

.plotlines__tabs {
  display: flex;
  gap: 0.15em;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
}
.plotlines__tabs:focus-visible { outline: 2px solid var(--accent, #2f6fc0); outline-offset: 2px; border-radius: 0.3em; }

/* The + shows where there's a pointer to hover with, on hover; on touch screens it's always there. A scene
   in no plotline yet keeps a faint one all the time, so it's plain it can be woven in. */
@media (hover: hover) {
  .plotlines .plotline-tab--add { display: none; }
  :is(.card:hover, .card:focus-within, .card:popover-open, .scene:hover, .scene:focus-within) .plotlines .plotline-tab--add,
  .plotlines__tabs:focus-visible .plotline-tab--add,
  .plotlines__tabs--none .plotline-tab--add { display: inline-grid; }
}
.plotlines__tabs--none .plotline-tab--add { opacity: 0.55; transition: opacity 150ms ease; }
:is(.card:hover, .card:focus-within, .card:popover-open, .scene:hover, .scene:focus-within) .plotlines__tabs--none .plotline-tab--add,
.plotlines__tabs--none:focus-visible .plotline-tab--add { opacity: 1; }

/* On a card the tabs stick up from behind its top edge, like tabs on real index cards. */
.card > .plotlines {
  position: absolute;
  z-index: -1;
  bottom: calc(100% - 0.35 * var(--u));
  left: calc(1.2 * var(--u));
  font-size: var(--u);
}
.card > .plotlines > .plotlines__tabs .plotline-tab {
  height: calc(1.55 * var(--u));
  padding-bottom: calc(0.3 * var(--u));
  border-radius: calc(0.3 * var(--u)) calc(0.3 * var(--u)) 0 0;
  font-size: calc(0.72 * var(--u));
  box-shadow: 0 -1px 2px rgb(0 0 0 / 0.2);
}
.card:popover-open:has(.plotlines__tabs) { --card-top: calc(1.8 * var(--u)); }
.card:popover-open > .plotlines { bottom: auto; top: calc(var(--card-top) - 1.2 * var(--u)); left: calc(2.7 * var(--u)); }

/* In the script they sit just above the heading, on the left, clear of who's writing on the right. */
.scene > .plotlines {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-120%);
  font-size: 1rem;
}

/* The list of plotlines, to weave a scene in or out. */
.plotlines__picker {
  width: min(19rem, calc(100vw - 2rem));
  padding: 0.6rem;
  border: 1px solid var(--sheet-line);
  border-radius: 8px;
  background: #fff;
  color: #222;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.25);
  font: 0.95rem/1.3 var(--font-ui);
  cursor: auto;
}
.plotlines__title { margin: 0 0 0.4rem; color: var(--sheet-soft); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.plotlines__picker form { margin: 0; }
.plotlines__choice {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.3rem 0.4rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.plotlines__choice:hover { background: var(--sheet-tint); }
.plotlines__name { flex: 1; overflow-wrap: anywhere; }
.plotlines__check { width: 1em; color: #2f8f4e; font-weight: 700; }
.plotlines__new, .yarn-menu__new { display: flex; gap: 0.4rem; margin: 0.4rem 0 0; padding-top: 0.5rem; border-top: 1px solid var(--sheet-line); }
.plotlines__new input[type="text"], .yarn-menu__new input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--sheet-line);
  border-radius: 5px;
  background: #fff;
  color: #222;
  font: inherit;
  field-sizing: fixed;
}
.plotlines__manage { display: block; margin-top: 0.4rem; padding: 0.4rem; color: var(--sheet-soft); font-size: 0.85rem; }

/* Yarn on the corkboard, drawn over the cards, held under their pins. */
.corkboard { position: relative; }
.corkboard__yarn { position: absolute; top: 0; left: 0; z-index: 2; overflow: visible; pointer-events: none; }
.yarn path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.yarn__shadow { stroke: rgb(0 0 0 / 0.3); stroke-width: 4; transform: translate(1.5px, 3px); }
.yarn__strand { stroke: var(--yarn); stroke-width: 3; }
.yarn__twist { stroke: rgb(255 255 255 / 0.35); stroke-width: 1.2; stroke-dasharray: 2 5; }
.yarn__reach { stroke: transparent; stroke-width: 14; } /* how near the pointer has to come to pluck it */
.yarn__pin { fill: url(#yarn_pin); }
.yarn__knot ellipse { fill: none; stroke: var(--yarn); stroke-width: 2.6; filter: drop-shadow(0.5px 1.5px 0.5px rgb(0 0 0 / 0.35)); }

.corkboard--yarn > .card { transition: opacity 200ms ease; }
.corkboard--yarn > .card--off-thread:not(:popover-open) { opacity: 0.5; }
/* Pointed at, a faded card comes back, so its tabs and + are easy to find while weaving. */
.corkboard--yarn > .card--off-thread:is(:hover, :focus-within) { opacity: 1; }

.yarn-menu__count { margin-left: 0.35em; padding: 0 0.45em; border-radius: 999px; background: var(--desk); color: var(--chrome); font-size: 0.75em; }
.yarn-menu__choice { display: flex; align-items: center; gap: 0.5rem; padding: 0.45em 0.7em; border-radius: 4px; color: var(--desk); cursor: pointer; }
.yarn-menu__choice:hover { background: var(--chrome-muted); }
.yarn-menu__empty { max-width: 15rem; margin: 0.3rem 0.7rem; color: var(--desk); font-size: 0.85rem; }
.yarn-menu__tip { max-width: 15rem; margin: 0 0.7rem 0.3rem 2.95rem; color: var(--desk); font-size: 0.8rem; }
.yarn-menu__tip .plotline-tab { font-size: 0.65rem; vertical-align: 0.1em; }
.yarn-menu__new { margin: 0.35rem 0.7rem 0.2rem; padding-top: 0.55rem; border-top-color: var(--chrome-rule, rgb(0 0 0 / 0.15)); font: 0.9rem/1.3 var(--font-ui); }
.yarn-menu__new input[type="text"] { width: 11rem; }
