/*
 * Pitchd Action Text / Trix styles.
 *
 * This file is named `pitchd_action_text.css` (not `actiontext.css`) so a stale
 * precompiled `actiontext-{digest}.css` from an old `rails assets:precompile`
 * cannot be served instead of our source — browsers keep caching that URL.
 *
 * If edits still seem ignored: `bin/rails assets:clobber` and restart the server.
 *
 * Do NOT add `import "trix/dist/trix.css"` to application.js. Do NOT add
 * `stylesheet_link_tag "trix"` to layouts — gem `trix.css` reintroduces default
 * chrome; overrides below beat it only when this sheet loads after tailwind.css.
 *
 * - Toolbar layout: Tailwind on ActionTextWithSubmitComponent
 * - Toolbar chrome removal: scoped under .action-text-with-submit (+ !important block)
 * - In-editor attachments: global trix-editor rules
 * - .trix-content: rendered rich text
 */

/* ActionTextWithSubmitComponent — base resets */
.action-text-with-submit trix-toolbar * {
  box-sizing: border-box;
}

.action-text-with-submit trix-toolbar .trix-button-group {
  border: none;
  border-radius: 0;
}

.action-text-with-submit trix-toolbar .trix-button {
  margin: 0;
  outline: none;
  border: none;
  border-radius: 0;
  background: transparent;
}

.action-text-with-submit trix-toolbar .trix-button:not(:first-child) {
  border-left: none;
}

.action-text-with-submit trix-toolbar .trix-button.trix-active {
  background: transparent;
}

.action-text-with-submit trix-toolbar .trix-button:not(:disabled) {
  cursor: pointer;
}

.action-text-with-submit trix-toolbar .trix-button.pitchd-toolbar-btn {
  color: var(--color-pitchd-black-600, #14141f);
}

.action-text-with-submit trix-toolbar .trix-button.pitchd-toolbar-btn:hover,
.action-text-with-submit trix-toolbar .trix-button.pitchd-toolbar-btn:focus-visible {
  color: var(--color-pitchd-purple-600, #9991e8);
}

.action-text-with-submit trix-toolbar .trix-button.pitchd-toolbar-btn.trix-active {
  color: var(--color-pitchd-purple-600, #9991e8);
}

.action-text-with-submit trix-editor {
  border: none;
  margin: 0;
  outline: none;
}

/*
 * Force-remove Trix default chrome (gem trix.css, UA, or cached defaults).
 * !important is intentional — only inside .action-text-with-submit.
 */
.action-text-with-submit trix-toolbar {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.action-text-with-submit trix-toolbar .trix-button-row,
.action-text-with-submit trix-toolbar .trix-button-group {
  border: 0 !important;
  border-bottom: 0 !important;
  margin-bottom: 0 !important;
  box-shadow: none !important;
}

.action-text-with-submit trix-toolbar .trix-button,
.action-text-with-submit trix-toolbar button[type="button"] {
  border: 0 !important;
  border-left: 0 !important;
  border-bottom: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}

.action-text-with-submit trix-toolbar .trix-button.trix-active {
  background: transparent !important;
  color: var(--color-pitchd-purple-600, #9991e8) !important;
}

.action-text-with-submit trix-editor {
  border: 0 !important;
  border-top: 0 !important;
  border-bottom: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* In-editor attachment and selection behavior (if attachments are used) */
trix-editor [data-trix-mutable]:not(.attachment__caption-editor) {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

trix-editor [data-trix-mutable]::-moz-selection,
trix-editor [data-trix-cursor-target]::-moz-selection,
trix-editor [data-trix-mutable] ::-moz-selection {
  background: none;
}

trix-editor [data-trix-mutable]::selection,
trix-editor [data-trix-cursor-target]::selection,
trix-editor [data-trix-mutable] ::selection {
  background: none;
}

trix-editor .attachment__caption-editor:focus[data-trix-mutable]::-moz-selection {
  background: highlight;
}

trix-editor .attachment__caption-editor:focus[data-trix-mutable]::selection {
  background: highlight;
}

trix-editor [data-trix-mutable].attachment.attachment--file {
  box-shadow: 0 0 0 2px highlight;
  border-color: transparent;
}

trix-editor [data-trix-mutable].attachment img {
  box-shadow: 0 0 0 2px highlight;
}

trix-editor .attachment {
  position: relative;
}

trix-editor .attachment:hover {
  cursor: default;
}

trix-editor .attachment--preview .attachment__caption:hover {
  cursor: text;
}

trix-editor .attachment__progress {
  position: absolute;
  z-index: 1;
  height: 20px;
  top: calc(50% - 10px);
  left: 5%;
  width: 90%;
  opacity: 0.9;
  transition: opacity 200ms ease-in;
}

trix-editor .attachment__progress[value="100"] {
  opacity: 0;
}

trix-editor .attachment__caption-editor {
  display: inline-block;
  width: 100%;
  margin: 0;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
  color: inherit;
  text-align: center;
  vertical-align: top;
  border: none;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

trix-editor .attachment__toolbar {
  position: absolute;
  z-index: 1;
  top: -0.9em;
  left: 0;
  width: 100%;
  text-align: center;
}

trix-editor .trix-button-group {
  display: inline-flex;
}

trix-editor .trix-button {
  position: relative;
  float: left;
  color: #666;
  white-space: nowrap;
  font-size: 80%;
  padding: 0 0.8em;
  margin: 0;
  outline: none;
  border: none;
  border-radius: 0;
  background: transparent;
}

trix-editor .trix-button:not(:first-child) {
  border-left: 1px solid #ccc;
}

trix-editor .trix-button.trix-active {
  background: #cbeefa;
}

trix-editor .trix-button:not(:disabled) {
  cursor: pointer;
}

trix-editor .trix-button--remove {
  text-indent: -9999px;
  display: inline-block;
  padding: 0;
  outline: none;
  width: 1.8em;
  height: 1.8em;
  line-height: 1.8em;
  border-radius: 50%;
  background-color: #fff;
  border: 2px solid highlight;
  box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.25);
}

trix-editor .trix-button--remove::before {
  display: inline-block;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  opacity: 0.7;
  content: "";
  background-image: url("data:image/svg+xml,%3Csvg%20height%3D%2224%22%20width%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2003%2Fsvg%22%3E%3Cpath%20d%3D%22M19%206.41%2017.59%205%2012%2010.59%206.41%205%205%206.41%2010.59%2012%205%2017.59%206.41%2019%2012%2013.41%2017.59%2019%2019%2017.59%2013.41%2012z%22%2F%3E%3Cpath%20d%3D%22M0%200h24v24H0z%22%20fill%3D%22none%22%2F%3E%3C%2Fsvg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 90%;
}

trix-editor .trix-button--remove:hover {
  border-color: #333;
}

trix-editor .trix-button--remove:hover::before {
  opacity: 1;
}

trix-editor .attachment__metadata-container {
  position: relative;
}

trix-editor .attachment__metadata {
  position: absolute;
  left: 50%;
  top: 2em;
  transform: translate(-50%, 0);
  max-width: 90%;
  padding: 0.1em 0.6em;
  font-size: 0.8em;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 3px;
}

trix-editor .attachment__metadata .attachment__name {
  display: inline-block;
  max-width: 100%;
  vertical-align: bottom;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

trix-editor .attachment__metadata .attachment__size {
  margin-left: 0.2em;
  white-space: nowrap;
}

/* Rendering saved rich text (e.g. comment body) */
.trix-content {
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: break-word;
}

.trix-content * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.trix-content h1 {
  font-size: 1.2em;
  line-height: 1.2;
}

.trix-content blockquote {
  border: 0 solid #ccc;
  border-left-width: 0.3em;
  margin-left: 0.3em;
  padding-left: 0.6em;
}

.trix-content [dir=rtl] blockquote,
.trix-content blockquote[dir=rtl] {
  border-width: 0;
  border-right-width: 0.3em;
  margin-right: 0.3em;
  padding-right: 0.6em;
}

.trix-content li {
  margin-left: 1em;
}

.trix-content [dir=rtl] li {
  margin-right: 1em;
}

.trix-content pre {
  display: inline-block;
  width: 100%;
  vertical-align: top;
  font-family: monospace;
  font-size: 0.9em;
  padding: 0.5em;
  white-space: pre;
  background-color: #eee;
  overflow-x: auto;
}

.trix-content img {
  max-width: 100%;
  height: auto;
}

.trix-content .attachment {
  display: inline-block;
  position: relative;
  max-width: 100%;
}

.trix-content .attachment a {
  color: inherit;
  text-decoration: none;
}

.trix-content .attachment a:hover,
.trix-content .attachment a:visited:hover {
  color: inherit;
}

.trix-content .attachment__caption {
  text-align: center;
}

.trix-content .attachment__caption .attachment__name + .attachment__size::before {
  content: " \2022 ";
}

.trix-content .attachment--preview {
  width: 100%;
  text-align: center;
}

.trix-content .attachment--preview .attachment__caption {
  color: #666;
  font-size: 0.9em;
  line-height: 1.2;
}

.trix-content .attachment--file {
  color: #333;
  line-height: 1;
  margin: 0 2px 2px 2px;
  padding: 0.4em 1em;
  border: 1px solid #bbb;
  border-radius: 5px;
}

.trix-content .attachment-gallery {
  display: flex;
  flex-wrap: wrap;
  position: relative;
}

.trix-content .attachment-gallery .attachment {
  flex: 1 0 33%;
  padding: 0 0.5em;
  max-width: 33%;
}

.trix-content .attachment-gallery.attachment-gallery--2 .attachment,
.trix-content .attachment-gallery.attachment-gallery--4 .attachment {
  flex-basis: 50%;
  max-width: 50%;
}

/* Action Text: wrap attachments in <action-text-attachment>; fix gallery layout */
.trix-content .attachment-gallery > action-text-attachment,
.trix-content .attachment-gallery > .attachment {
  flex: 1 0 33%;
  padding: 0 0.5em;
  max-width: 33%;
}

.trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment,
.trix-content .attachment-gallery.attachment-gallery--2 > .attachment,
.trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment,
.trix-content .attachment-gallery.attachment-gallery--4 > .attachment {
  flex-basis: 50%;
  max-width: 50%;
}

.trix-content action-text-attachment .attachment {
  padding: 0 !important;
  max-width: 100% !important;
}
