@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;0,9..144,700;0,9..144,800;0,9..144,900;1,9..144,400;1,9..144,600;1,9..144,700&family=DM+Sans:wght@400;500;600;700&display=swap');

/*
 *= require components/tiptap_editor
 *= require components/emoji_picker
 *= require actiontext
 */

::selection { background: #e8553a; color: #fff; }

.font-display {
  font-family: "Fraunces", Georgia, serif;
}

/* Trix Editor Styling */
trix-editor {
  min-height: 300px !important;
  padding: 0.75rem !important;
}

/* Make headings visible in the editor */
trix-editor h1 {
  font-size: 1.8em !important;
  font-weight: bold !important;
  margin-bottom: 0.5em !important;
}

trix-editor h2 {
  font-size: 1.5em !important;
  font-weight: bold !important;
  margin-bottom: 0.5em !important;
}

trix-editor h3 {
  font-size: 1.3em !important;
  font-weight: bold !important;
  margin-bottom: 0.5em !important;
}

trix-editor h4 {
  font-size: 1.1em !important;
  font-weight: bold !important;
  margin-bottom: 0.5em !important;
}

/* Show links properly in the editor */
trix-editor a {
  color: var(--color-violet-600) !important;
  text-decoration: underline !important;
  cursor: pointer !important;
}

trix-editor a:hover {
  color: var(--color-violet-800) !important;
}

/* Show lists properly in editor */
trix-editor ul {
  list-style-type: disc !important;
  padding-left: 2em !important;
  margin-bottom: 1em !important;
}

trix-editor ol {
  list-style-type: decimal !important;
  padding-left: 2em !important;
  margin-bottom: 1em !important;
}

trix-editor li {
  display: list-item !important;
  margin-bottom: 0.3em !important;
}

/* Custom Trix Editor Content Styles */
.trix-content h1 {
  font-size: 1.8em;
  font-weight: bold;
  margin-bottom: 0.5em;
}

.trix-content h2 {
  font-size: 1.5em;
  font-weight: bold;
  margin-bottom: 0.5em;
}

.trix-content h3 {
  font-size: 1.3em;
  font-weight: bold;
  margin-bottom: 0.5em;
}

.trix-content h4 {
  font-size: 1.1em;
  font-weight: bold;
  margin-bottom: 0.5em;
}

/* Links in rendered content */
.trix-content a {
  color: var(--color-violet-600);
  text-decoration: underline;
  cursor: pointer;
}

.trix-content a:hover {
  color: var(--color-violet-800);
}

.trix-content ul {
  list-style-type: disc;
  padding-left: 2em;
  margin-bottom: 1em;
}

.trix-content ol {
  list-style-type: decimal;
  padding-left: 2em;
  margin-bottom: 1em;
}

.trix-content li {
  margin-bottom: 0.3em;
}

/* Fix for Trix toolbar buttons */
.trix-button-group {
  border: 1px solid #e4e0d8;
  border-radius: 3px;
  margin-bottom: 0.5em;
}

.trix-button--icon {
  width: 2.5em;
  height: 1.5em;
}

.chat-feedback-message p{
    margin-bottom: 10px;
}

.chat-feedback-message p:last-child{
    margin-bottom: 0;
}

.animate-pulse {
    animation: var(--animate-pulse);
}

@keyframes pulse {
    50% {
        opacity: 0.5;
    }
}

#noticePopup {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
}

/* Button with loading state */
.with-loading-state {
    position: relative;
    pointer-events: none;
}

.with-loading-state:disabled {
    opacity: 0.7;
    padding-left: 3rem;
}

/* Create the loading spinner with CSS */
.with-loading-state:after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: calc(50% - 0.5rem);
    left: 1rem;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-right-color: currentColor;
    animation: button-spinner 0.6s linear infinite;
}

@keyframes button-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* If you want to fade the text */
.with-loading-state>* {
    opacity: 0.7;
}

.article-content {
    h1, h2, h3, h4, h5 {
        margin-bottom: 1rem;
        margin-top: 1rem;
        font-weight: 600;
    }

    h1 {
        font-size: 2.7rem;
        line-height: 1.2;
        margin-top: 0;
    }

    h2 {
        font-size: 2rem;
    }

    h3 {
        font-size: 1.5rem;
    }

    h4 {
        font-size: 1.25rem;
    }

    h5 {
        font-size: 1rem;
    }

    p {
        margin-bottom: 1rem;
    }

    p:last-child {
        margin-bottom: 0;
    }

    ul, ol{
        margin-bottom: 1rem;
        list-style-type: disc;
        padding-left: 1.5rem;

        li {
            margin-bottom: 0.5rem;
        }

        li:last-child {
            margin-bottom: 0;
        }
    }

    ol {
        list-style-type: decimal;
    }

    ul:last-child, ol:last-child {
        margin-bottom: 0;
    }

    hr {
        margin-bottom: 1rem;
    }

    a {
        color: #d44a31;
        font-weight: 600;
        text-decoration: underline;

        &:hover {
            text-decoration: none;
        }
    }

    img {
        border-radius: 10px;
        box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
        margin-bottom: 2rem;
    }

    table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 2rem;
        
        th,
        td {
            padding-top: 10px;
            padding-right: 10px;
            padding-bottom: 10px;
            padding-left: 10px;
            border: 1px solid #e4e0d8;
            line-height: 1.1em;
            background-color: #faf8f4;
        }
    
        th:not([align]) {
            text-align: inherit;
        }
    }
    
    /* Header element
     * ================================= */
    
    thead {
        th, td {
            background-color: #eee;
        }
    }
}

/* Enhance Trix toolbar appearance */
.trix-button {
  background: none !important;
  border: none !important;
  margin: 0 !important;
  padding: 0.25rem !important;
  opacity: 0.7 !important;
  cursor: pointer !important;
}

.trix-button:hover {
  opacity: 1 !important;
}

.trix-button.trix-active {
  opacity: 1 !important;
  background-color: #f0ede6 !important;
}

/* Make the toolbar more prominent */
.trix-toolbar {
  border: 1px solid #e4e0d8 !important;
  padding: 0.5rem !important;
  border-bottom: none !important;
  border-top-left-radius: 0.375rem !important;
  border-top-right-radius: 0.375rem !important;
  background-color: #faf8f4 !important;
}

/* The container for the editor */
.trix-editor-container {
  margin-bottom: 1rem !important;
}

/* Style for heading buttons in toolbar */
button.trix-button[data-trix-attribute^="heading"] {
  width: auto !important;
  padding: 0 6px !important;
  font-weight: bold !important;
  display: inline-block !important;
  margin: 0 2px !important;
  line-height: 1.8 !important;
  border-radius: 3px !important;
}

/* Active state for heading buttons */
button.trix-button[data-trix-attribute^="heading"].trix-active {
  background-color: #e4e0d8 !important;
  color: #1a1628 !important;
  opacity: 1 !important;
}

/* Hover state for heading buttons */
button.trix-button[data-trix-attribute^="heading"]:hover {
  background-color: #f0ede6 !important;
}

/* Specific font sizes for each heading button */
button.trix-button[data-trix-attribute="heading1"] {
  font-size: 1rem !important;
}

button.trix-button[data-trix-attribute="heading2"] {
  font-size: 0.9rem !important;
}

button.trix-button[data-trix-attribute="heading3"] {
  font-size: 0.8rem !important;
}

button.trix-button[data-trix-attribute="heading4"] {
  font-size: 0.7rem !important;
}

/* Style images in Trix editor */
trix-editor figure img, 
trix-editor img {
  border-radius: 8px !important;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
  max-width: 100% !important;
  margin: 1rem 0 !important;
}

/* Style images in rendered content */
.changelog-entry .trix-content figure img,
.changelog-entry .trix-content img {
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
  margin: 1rem 0;
}

/* Ensure GIFs maintain their animation */
.changelog-entry .trix-content img[src*=".gif"],
.changelog-entry .trix-content figure img[src*=".gif"] {
  image-rendering: auto;
  animation: none;
}

/* Also ensure GIFs work in the editor */
trix-editor img[src*=".gif"] {
  image-rendering: auto !important;
  animation: none !important;
}

/* Hide figcaptions in Trix editor */
trix-editor figcaption {
  display: none !important;
}

.trix-content figcaption {
  display: none !important;
}

/* Video placeholder styles in Trix editor */
trix-editor p:has(strong:contains("📺 [VIDEO:")),
.changelog-entry .trix-content p:has(strong:contains("📺 [VIDEO:")) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  font-weight: bold;
  margin: 1rem 0;
  cursor: pointer;
  border: 2px dashed rgba(255, 255, 255, 0.3);
}

/* Alternative approach using attribute selector */
trix-editor strong[textContent*="📺 [VIDEO:"],
.changelog-entry .trix-content strong[textContent*="📺 [VIDEO:"] {
  display: block;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  font-weight: bold;
  margin: 1rem 0;
  cursor: pointer;
  border: 2px dashed rgba(255, 255, 255, 0.3);
}

/* Fallback: style any text containing video placeholder */
trix-editor *:contains("📺 [VIDEO:"),
.changelog-entry .trix-content *:contains("📺 [VIDEO:") {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  font-weight: bold;
  margin: 1rem 0;
  cursor: pointer;
  border: 2px dashed rgba(255, 255, 255, 0.3);
}

/* Video embed styles for rendered content */
.changelog-entry .trix-content .video-embed {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  overflow: hidden;
  max-width: 100%;
  margin: 1rem 0;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.changelog-entry .trix-content .video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
}

/* Workspace onboarding (mobile) — shared by the live stream and keywords steps
 * On mobile the page becomes two stacked cards (chat on top, main content
 * below) that fill the viewport. Both cards have their own border,
 * rounded corners, and internal scroll. Desktop keeps the original
 * side-by-side layout: single outer border, chat flows in the left column
 * without extra chrome.
 *
 * Selectors are scoped via the #workspace_creation ID so they outrank
 * cruip/style.css's Tailwind utilities (.border, .p-8, .h-[80vh], .w-2/5,
 * .w-3/5, etc.), which Propshaft links after application.css.
 */
@media (max-width: 1023px) {
  /* Give the onboarding page a small breathing frame instead of the
   * floating 80vh pill it used to be. */
  body:has(#workspace_creation) {
    padding: 0.75rem;
  }

  /* Let main fill the padded body so the two cards inside can claim the
   * whole viewport. The white main background would otherwise leak into
   * the gap between the two cards; clear it so the body's gray-50 shows. */
  body:has(#workspace_creation) main {
    height: 100%;
    background: transparent;
  }

  /* Flatten the outer container: its children each have their own card
   * chrome on mobile, so the extra border/padding makes everything cramped. */
  #workspace_creation {
    height: 100%;
    padding: 0;
    border: none;
    border-radius: 0;
  }

  /* Chat gets ~40% of the vertical space with its own bordered card.
   * width:100% overrides the desktop w-2/5 utility used on the keywords step.
   * bg-white on the element handles dark mode via the palette inversion system. */
  #workspace_creation .onboarding-chat-card {
    width: 100%;
    flex: 2 1 0%;
    min-height: 0;
    border: 1px solid var(--color-gray-200);
    border-radius: 0.75rem;
  }

  /* Main card (appetizer or keywords) gets the larger ~60% so its content
   * + pinned CTA footer are always comfortably visible.
   * width:100% overrides the desktop w-3/5 utility used on the keywords step. */
  #workspace_creation .onboarding-appetizer {
    width: 100%;
    flex: 3 1 0%;
    min-height: 0;
  }

  /* Keywords footer: stack vertically on mobile so the status text and
   * CTA button each get the full width instead of being crammed side-by-side. */
  .onboarding-keywords-footer {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .onboarding-keywords-footer > div {
    width: 100%;
  }
}

/* Trial page layout — mobile first */
.trial-page-wrapper {
  display: flex;
  flex-direction: column;
}
.trial-left-column { width: 100%; }
.trial-right-column { display: none; }
.trial-content-inner { max-width: 32rem; margin: 0 auto; width: 100%; }
.trial-price { font-size: 2rem; }
.trial-cta-desktop { display: none; }
.trial-features { flex-direction: column; gap: 0.5rem !important; }

/* Trial page — desktop */
@media (min-width: 768px) {
  .trial-page-wrapper { flex-direction: row; min-height: 100dvh; }
  .trial-left-column {
    width: 50%;
    position: relative;
    display: flex;
    flex-direction: column;
  }
  .trial-logo { position: absolute; top: 0; left: 0; z-index: 10; }
  .trial-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
  }
  .trial-content-inner { max-width: 32rem; width: 100%; }
  .trial-right-column { display: block; width: 50%; }
  .trial-price { font-size: 2.75rem; }
  .trial-cta-desktop { display: block; }
  .trial-cta-mobile { display: none; }
  .trial-features { flex-direction: row; gap: 2rem !important; }
}