/* Settings › Triggers, the line menu, "make a trigger from this line" and
   the chat window. Colours come from the page's tokens in index.html. */

/* Groups | list | edit pane, wrapping when narrow. */
#sec-triggers:not([hidden]) { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
#tr-groups-col { flex: 0 0 160px; display: flex; flex-direction: column; gap: 8px; }
#tr-groups-col .grow { flex: 1; }
#sec-triggers .note { margin-left: 0; }
.tr-group-list { display: flex; flex-direction: column; gap: 8px; }
.tr-grp { display: flex; align-items: center; gap: 8px; }
.tr-grp .x, #sec-triggers .act .x { margin-left: auto; background: none; border: 0; color: var(--muted); font: inherit; font-size: 16px; cursor: pointer; padding: 0 4px; }
.tr-grp .x:hover, .tr-grp .x:focus-visible, #sec-triggers .act .x:hover, #sec-triggers .act .x:focus-visible { color: var(--gilt); outline: none; }
.tr-rules a { color: var(--gilt); }
#tr-main { flex: 1 1 320px; min-width: 0; }
#tr-search { width: 220px; max-width: 100%; }
.tr-head, #tr-list li { display: grid; grid-template-columns: 18px 22px minmax(0, 1fr) minmax(120px, 34%) auto; gap: 4px 8px; align-items: center; }
.tr-head { color: var(--muted); font-size: 12px; padding: 8px 4px 4px; border-bottom: 1px solid var(--rule); grid-template-columns: 48px minmax(0, 1fr) minmax(120px, 34%) auto; }
#tr-list { list-style: none; margin: 0 0 10px; padding: 0; }
#tr-list li { padding: 6px 4px; border-bottom: 1px solid var(--rule); }
#tr-list li:focus-visible { outline: 1px solid var(--gilt); outline-offset: -1px; }
#tr-list li.editing { background: var(--ink); box-shadow: inset 2px 0 0 var(--gilt); }
#tr-list li.drop { box-shadow: inset 0 2px 0 var(--gilt); }
#tr-list li.off .pat, #tr-list li.off .chips { opacity: 0.5; }
#tr-list li.kept { display: block; color: var(--muted); font-size: 12px; }
#tr-list .grip { color: var(--i8); cursor: grab; letter-spacing: -2px; font-size: 12px; }
#tr-list .pat { font-family: var(--font); font-size: 13px; overflow-wrap: anywhere; }
#tr-list .tr-name { color: var(--muted); font-family: var(--chrome-font); }
#sec-triggers .cap, #fromline .cap { color: var(--gilt-bright); }
.tr-err { color: var(--combat-text); font-size: 12px; margin: 2px 0; min-height: 0; }
#tr-list .chips { display: flex; flex-wrap: wrap; gap: 4px; }
#sec-triggers .chip { font-size: 11px; color: var(--muted); border: 1px solid var(--rule-strong); padding: 0 5px; white-space: nowrap; }
#tr-list .tools { display: flex; gap: 4px; }
#tr-list .tools button { color: var(--muted); font-size: 12px; background: none; border: 1px solid var(--rule); font-family: inherit; padding: 1px 7px; cursor: pointer; }
#tr-list .tools button:hover, #tr-list .tools button:focus-visible { border-color: var(--gilt); color: var(--gilt); outline: none; }
/* Moving buttons only where the row is pointed at or in use. */
#tr-list li:not(:hover):not(:focus-within) .tools button:not(:last-child) { opacity: 0; }
#tr-status { color: var(--parchment); font-size: 12px; min-height: 1em; margin: 6px 0; }
#tr-form { flex: 1 1 340px; max-width: 460px; min-width: 260px; border-left: 1px solid var(--rule); background: var(--ink-high); padding: 0 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
#tr-form h3 { font-size: 15px; color: var(--verdigris); margin: 0; font-weight: normal; }
#tr-form .mono, #fromline .mono, #chat .mono, #settings #tr-form input.mono, #fromline input.mono { font-family: var(--font); font-size: 13px; }
/* While a trigger is edited the groups give the list and the pane room. */
#sec-triggers.with-form #tr-groups-col { display: none; }
#sec-triggers.with-form #tr-main { flex-basis: 300px; }
#sec-triggers.with-form .tr-head { display: none; }
#sec-triggers.with-form #tr-list li { grid-template-columns: 18px 22px minmax(0, 1fr) auto; }
#sec-triggers.with-form #tr-list .chips { grid-column: 3; grid-row: 2; }
#sec-triggers.with-form #tr-list .tools { grid-column: 4; grid-row: 1; }
#tr-pattern, #fl-pattern { width: 100%; box-sizing: border-box; }
.tr-kinds { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.tr-kinds .adv { color: var(--muted); }
#tr-form .col, #fromline .col { display: flex; flex-direction: column; gap: 4px; }
.tr-actions { display: flex; flex-direction: column; gap: 6px; }
#sec-triggers .act { border: 1px solid var(--rule); background: var(--ink); padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; }
#sec-triggers .act-head { display: flex; align-items: center; font-size: 13px; }
#sec-triggers .act-body { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#sec-triggers .act-body textarea, #sec-triggers .act-body input[type="text"] { flex: 1 1 100%; box-sizing: border-box; }
#sec-triggers .act-body select { flex: 0 1 auto; min-height: 28px; }
#sec-triggers .act-body .note { flex-basis: 100%; margin: 0; }
#tr-form > .col > select { border-style: dashed; color: var(--muted); }
.tr-test { border: 1px solid var(--rule); background: var(--ink); padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.tr-test p { margin: 0; }
.tr-test .line { color: var(--i8); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-test .line.hit { white-space: normal; overflow-wrap: anywhere; }
.tr-test .line.hit { color: var(--parchment-bright); background: color-mix(in srgb, var(--gilt) 15%, transparent); padding: 1px 4px; }
.tr-test mark, #fromline mark { background: none; color: var(--gilt-bright); text-decoration: underline; }
.tr-test .caught { font-size: 13px; margin-left: 4px; }
#sec-triggers .ok, #fromline .ok { color: var(--verdigris); }
.tr-original pre { white-space: pre-wrap; color: var(--muted); max-height: 8em; overflow: auto; }
#tr-form-msg { color: var(--combat-text); font-size: 12px; min-height: 1em; margin: 0; }
@media (max-width: 640px) {
  #tr-form { border-left: 0; padding-left: 0; }
  .tr-head { display: none; }
  #tr-list li { grid-template-columns: 18px 22px minmax(0, 1fr); }
  #tr-list .chips, #tr-list .tools { grid-column: 3; }
}

/* The line menu (right-click a line of the game). */
#line-menu {
  position: fixed;
  z-index: 20;
  min-width: 260px;
  padding: 4px 0;
  background: var(--ink-high);
  border: 1px solid var(--rule-strong);
  box-shadow: var(--shadow);
  font-family: var(--chrome-font);
  font-size: var(--chrome-size);
}
#line-menu[hidden] { display: none; }
#line-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--parchment); font: inherit; padding: 6px 14px; cursor: pointer; }
#line-menu button:hover, #line-menu button:focus-visible { background: color-mix(in srgb, var(--gilt) 15%, transparent); color: var(--gilt-bright); outline: none; }

/* Panels: "make a trigger from this line" and the chat window, movable and
   resizable like help. */
#fromline, #chat {
  position: absolute;
  z-index: 4;
  width: min(480px, calc(100vw - 16px));
  height: min(560px, calc(100vh - 40px));
  min-width: min(280px, calc(100vw - 16px));
  min-height: 180px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  display: flex;
  flex-direction: column;
  background: var(--ink-high);
  border: 1px solid var(--gilt);
  box-shadow: var(--shadow);
  overflow: hidden;
  resize: both;
  font-family: var(--chrome-font);
  font-size: var(--chrome-size);
  color: var(--parchment);
}
#chat { width: min(460px, calc(100vw - 16px)); height: min(320px, calc(100vh - 40px)); }
#fromline[hidden], #chat[hidden] { display: none; }
#fromline.front, #chat.front { z-index: 7; }
#chat:focus { outline: none; }
#fromline > header, #chat > header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 2px 10px;
  color: var(--gilt);
  border-bottom: 1px solid var(--rule);
  cursor: move;
  touch-action: none;
  user-select: none;
}
#fromline > header span { color: var(--verdigris); }
.fromline-body { flex: 1; min-height: 0; overflow: auto; padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.fromline-body p { margin: 0; }
.fromline-body .lbl { color: var(--muted); font-size: 12px; }
.fromline-body .note { color: var(--muted); font-size: 12px; }
.fl-line { line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px !important; }
.fl-line .word { font: inherit; color: inherit; background: none; border: 0; border-bottom: 2px dotted var(--gilt-bright); padding: 0; cursor: pointer; }
.fl-line .word[aria-pressed="true"] { background: color-mix(in srgb, var(--gilt) 25%, transparent); }
.fl-line .word:focus-visible { outline: 1px solid var(--gilt); }
.fl-then { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#fromline label { display: flex; gap: 8px; align-items: baseline; cursor: pointer; }
#fromline .field { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#fromline input[type="text"], #chat input { font: inherit; font-size: 14px; background: var(--ink); color: var(--parchment); border: 1px solid var(--rule); padding: 4px 6px; }
#fromline input[type="checkbox"] { accent-color: var(--gilt); }
#fromline .close, #fromline .primary { color: var(--muted); font-size: 12px; background: none; border: 1px solid var(--rule); font-family: inherit; padding: 4px 12px; cursor: pointer; }
#fromline .primary { color: var(--ink); background: var(--gilt); border-color: var(--gilt); font-size: 13px; }
#fromline .close:disabled { opacity: 0.4; cursor: default; }
#fromline .close:hover:enabled, #fromline .close:focus-visible { border-color: var(--gilt); color: var(--gilt); outline: none; }
#fromline .primary:focus-visible { outline: 1px solid var(--parchment); }

.chat-tabs { flex: none; display: flex; gap: 2px; padding: 4px 8px 0; border-bottom: 1px solid var(--rule); }
.chat-tabs[hidden] { display: none; }
.chat-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; padding: 4px 8px; cursor: pointer; }
.chat-tabs button[aria-selected="true"] { color: var(--gilt); border-bottom-color: var(--gilt); }
.chat-tabs button:focus-visible { outline: 1px solid var(--gilt); }
.chat-lines { flex: 1; min-height: 0; overflow: auto; padding: 6px 10px; background: var(--ink); font-family: var(--font); font-size: var(--size); line-height: var(--row); }
.chat-lines:focus-visible { outline: 1px solid var(--gilt); outline-offset: -1px; }
.chat-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-time { color: var(--muted); font-size: 0.85em; margin-right: 8px; }
.chat-tab { color: var(--muted); font-size: 0.8em; border: 1px solid var(--rule-strong); padding: 0 4px; margin-right: 6px; font-family: var(--chrome-font); }
.chat-empty { flex: none; margin: 0; padding: 8px 10px; color: var(--muted); background: var(--ink); }
.chat-empty[hidden] { display: none; }

/* Patterns are typed in the game font. */
#settings input#tr-pattern, #fromline input#fl-pattern { font-family: var(--font); font-size: 13px; }
/* Event triggers, Set variable and Make a link (scripting M1). */
#tr-list .tr-event { color: var(--verdigris); font-family: var(--chrome-font); }
#sec-triggers .act-body input.tr-var[type="text"] { flex: 0 1 9em; }
#sec-triggers .act-body .tr-at { color: var(--gilt); }
#sec-triggers .act-body .tr-help { flex-basis: 100%; margin: 0; color: var(--muted); }
#sec-triggers .act-body .tr-help p { margin: 0; }
#sec-triggers .act-body .tr-err:empty { display: none; }
