/* Custom utilities on top of Tailwind CDN */

.prose-blog {
    max-width: 65ch;
}

    .prose-blog h1, .prose-blog h2, .prose-blog h3 {
        font-weight: 700;
        letter-spacing: -0.02em;
        margin-top: 1.75em;
        margin-bottom: 0.5em;
        color: #0f172a;
    }

    .prose-blog h1 {
        font-size: 1.875rem;
    }

    .prose-blog h2 {
        font-size: 1.5rem;
    }

    .prose-blog h3 {
        font-size: 1.25rem;
    }

    .prose-blog p {
        margin-bottom: 1.25em;
        line-height: 1.75;
        color: #334155;
    }

    .prose-blog a {
        color: #2563eb;
        text-decoration: underline;
        text-underline-offset: 2px;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

        .prose-blog a:hover {
            color: #1d4ed8;
        }

    .prose-blog ul, .prose-blog ol {
        margin: 1.25em 0;
        padding-left: 1.5em;
    }

    .prose-blog ul {
        list-style-type: disc;
    }

    .prose-blog ol {
        list-style-type: decimal;
    }

    .prose-blog ul ul {
        list-style-type: circle;
    }

        .prose-blog ul ul ul {
            list-style-type: square;
        }

    .prose-blog ol ol {
        list-style-type: lower-alpha;
    }

        .prose-blog ol ol ol {
            list-style-type: lower-roman;
        }

    .prose-blog li {
        margin-bottom: 0.4em;
    }

        .prose-blog li > ul,
        .prose-blog li > ol {
            margin-top: 0.35em;
            margin-bottom: 0.35em;
        }

    .prose-blog blockquote {
        border-left: 4px solid #3b82f6;
        padding-left: 1rem;
        margin: 1.5em 0;
        color: #475569;
        font-style: italic;
    }

    .prose-blog img {
        border-radius: 0.75rem;
        margin: 1.5em 0;
        max-width: 100%;
        height: auto;
    }

    .prose-blog pre {
        background: #0f172a;
        color: #e2e8f0;
        padding: 1rem 1.25rem;
        border-radius: 0.75rem;
        overflow-x: auto;
        margin: 1.5em 0;
        font-size: 0.875rem;
    }

    .prose-blog code {
        font-size: 0.875em;
        background: #f1f5f9;
        padding: 0.15em 0.4em;
        border-radius: 0.25rem;
    }

    .prose-blog pre code {
        background: transparent;
        padding: 0;
    }

    .prose-blog table {
        width: 100%;
        border-collapse: collapse;
        margin: 1.5em 0;
    }

    .prose-blog th, .prose-blog td {
        border: 1px solid #e2e8f0;
        padding: 0.5rem 0.75rem;
        text-align: left;
    }

    .prose-blog th {
        background: #f8fafc;
        font-weight: 600;
    }

/* Quill editor in admin */
.ql-toolbar.ql-snow {
    border-radius: 0.75rem 0.75rem 0 0;
    border-color: #e2e8f0;
    background: #f8fafc;
}

.ql-container.ql-snow {
    border-radius: 0 0 0.75rem 0.75rem;
    border-color: #e2e8f0;
    font-family: Inter, system-ui, sans-serif;
    font-size: 16px;
    min-height: 360px;
}

.ql-editor {
    min-height: 360px;
}


/* ——— Custom RTF editor (no external deps) ——— */
.rtf-wrap {
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

.rtf-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
    padding: 0.5rem 0.6rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

    .rtf-toolbar .rtf-sep {
        width: 1px;
        height: 1.25rem;
        background: #e2e8f0;
        margin: 0 0.2rem;
    }

    .rtf-toolbar button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 2rem;
        height: 2rem;
        padding: 0 0.4rem;
        border-radius: 0.4rem;
        border: none;
        background: transparent;
        color: #334155;
        font-size: 0.8rem;
        font-weight: 600;
        cursor: pointer;
        line-height: 1;
    }

        .rtf-toolbar button:hover {
            background: #e2e8f0;
        }

        .rtf-toolbar button.is-active {
            background: #dbeafe;
            color: #1d4ed8;
        }

    .rtf-toolbar .rtf-swatch {
        width: 1.15rem;
        height: 1.15rem;
        border-radius: 9999px;
        border: 2px solid #fff;
        box-shadow: 0 0 0 1px #cbd5e1;
        padding: 0;
        min-width: 0;
    }

.rtf-editor {
    min-height: 360px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    outline: none;
    font-size: 0.95rem;
    line-height: 1.65;
    color: #334155;
}

    /* When an image is selected, never ring the whole editor */

    .rtf-editor p {
        margin: 0 0 0.75em;
    }

    .rtf-editor h2 {
        font-size: 1.35rem;
        font-weight: 700;
        margin: 1em 0 0.5em;
        color: #0f172a;
    }

    .rtf-editor h3 {
        font-size: 1.15rem;
        font-weight: 600;
        margin: 1em 0 0.4em;
        color: #0f172a;
    }

    .rtf-editor ul,
    .rtf-editor ol {
        margin: 0.5em 0 0.75em;
        padding-left: 1.75em;
        list-style-position: outside;
    }

    .rtf-editor ul {
        list-style-type: disc;
    }

    .rtf-editor ol {
        list-style-type: decimal;
    }

    .rtf-editor ul ul {
        list-style-type: circle;
    }

        .rtf-editor ul ul ul {
            list-style-type: square;
        }

    .rtf-editor ol ol {
        list-style-type: lower-alpha;
    }

        .rtf-editor ol ol ol {
            list-style-type: lower-roman;
        }

    .rtf-editor li {
        margin: 0.25em 0;
    }

        .rtf-editor li > ul,
        .rtf-editor li > ol {
            margin-top: 0.25em;
            margin-bottom: 0.25em;
        }

    .rtf-editor a {
        color: #2563eb;
        text-decoration: underline;
    }

    .rtf-editor img {
        max-width: 100%;
        height: auto;
        border-radius: 0.5rem;
    }

    .rtf-editor blockquote {
        border-left: 3px solid #cbd5e1;
        margin: 0.75em 0;
        padding: 0.25em 0 0.25em 1em;
        color: #64748b;
    }

    .rtf-editor pre {
        background: #f1f5f9;
        padding: 0.75em 1em;
        border-radius: 0.5rem;
        overflow-x: auto;
        font-size: 0.85em;
    }


/* Prevent horizontal scroll from long words/URLs on mobile */
.prose-blog {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

    .prose-blog pre,
    .prose-blog code {
        max-width: 100%;
        overflow-x: auto;
        white-space: pre-wrap;
        word-break: break-word;
    }

    .prose-blog img,
    .prose-blog video,
    .prose-blog iframe {
        max-width: 100%;
        height: auto;
    }

    .prose-blog table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }

/* Admin mobile */
.admin-shell {
    min-width: 0;
    overflow-x: hidden;
}

.admin-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}



/* Dim sibling content slightly when an image is selected */
.rtf-editor:has(img.rtf-img-selected) > *:not(img.rtf-img-selected) {
    /* only mild — don't break nested content readability */
}

.rtf-editor img.rtf-img-selected::after {
    /* pseudo not reliable on img — use wrapper approach in JS if needed */
}

.rtf-img-toolbar {
    display: none;
    position: absolute;
    z-index: 50;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.4rem 0.45rem;
    background: #0f172a;
    border: 2px solid #3b82f6;
    border-radius: 0.6rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.35);
    max-width: min(100%, 24rem);
}

    .rtf-img-toolbar.is-visible {
        display: flex;
    }

    .rtf-img-toolbar button {
        border: 0;
        background: transparent;
        color: #e2e8f0;
        font-size: 0.7rem;
        font-weight: 600;
        padding: 0.35rem 0.5rem;
        border-radius: 0.35rem;
        cursor: pointer;
        white-space: nowrap;
    }

        .rtf-img-toolbar button:hover {
            background: #1e293b;
            color: #fff;
        }

        .rtf-img-toolbar button.is-active {
            background: #2563eb;
            color: #fff;
        }

    .rtf-img-toolbar .rtf-img-sep {
        width: 1px;
        background: #334155;
        margin: 0 0.15rem;
        align-self: stretch;
    }

/* RTF image selection — CSS only, not saved into post HTML */
.rtf-editor:focus {
    outline: none;
    box-shadow: none;
}

.rtf-editor.rtf-has-img-selection {
    outline: none !important;
    box-shadow: none !important;
}

.rtf-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    cursor: pointer;
    /* no permanent border */
    outline: 3px solid transparent;
    outline-offset: 3px;
    box-sizing: border-box;
    vertical-align: middle;
}

    .rtf-editor img.rtf-img-selected {
        outline-color: #2563eb;
        box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.3);
    }

.rtf-img-toolbar {
    display: none;
    position: absolute;
    z-index: 50;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.4rem 0.45rem;
    background: #0f172a;
    border: 2px solid #3b82f6;
    border-radius: 0.6rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.35);
    max-width: min(100%, 24rem);
}

    .rtf-img-toolbar.is-visible {
        display: flex;
    }

    .rtf-img-toolbar button {
        border: 0;
        background: transparent;
        color: #e2e8f0;
        font-size: 0.7rem;
        font-weight: 600;
        padding: 0.35rem 0.5rem;
        border-radius: 0.35rem;
        cursor: pointer;
        white-space: nowrap;
    }

        .rtf-img-toolbar button:hover {
            background: #1e293b;
            color: #fff;
        }

        .rtf-img-toolbar button.is-active {
            background: #2563eb;
            color: #fff;
        }

    .rtf-img-toolbar .rtf-img-sep {
        width: 1px;
        background: #334155;
        margin: 0 0.15rem;
        align-self: stretch;
    }
