
/* =========================================================
   Questionary – Tiptap Rich Text Editor
   public/utils/tiptap-editor.css
   ========================================================= */
/* Light mode */
:root {
    --qe-highlight-red: #bc2b1aaa;
    --qe-highlight-orange: #e37140aa;
    --qe-highlight-yellow: #f7b05baa;
    --qe-highlight-green: #5ea145aa;
    --qe-highlight-blue: #619cbcaa;
    --qe-highlight-purple: #7f62adaa;
    --qe-highlight-pink: #e579acaa;
}

/* Dark mode */
html.dark,
html[data-theme="dark"],
body.dark {
    --qe-highlight-red: #57150acc;
    --qe-highlight-orange: #bb3818cc;
    --qe-highlight-yellow: #e59a37cc;
    --qe-highlight-green: #386527cc;
    --qe-highlight-blue: #446881cc;
    --qe-highlight-purple: #4e3673cc;
    --qe-highlight-pink: #b35f87cc;
}

/* Highlight colors */
mark[data-color="red"] {
    background-color: var(--qe-highlight-red);
    color: inherit;
}

mark[data-color="orange"] {
    background-color: var(--qe-highlight-orange);
    color: inherit;
}

mark[data-color="yellow"] {
    background-color: var(--qe-highlight-yellow);
    color: inherit;
}

mark[data-color="green"] {
    background-color: var(--qe-highlight-green);
    color: inherit;
}

mark[data-color="blue"] {
    background-color: var(--qe-highlight-blue);
    color: inherit;
}

mark[data-color="purple"] {
    background-color: var(--qe-highlight-purple);
    color: inherit;
}

mark[data-color="pink"] {
    background-color: var(--qe-highlight-pink);
    color: inherit;
}

blockquote {
    margin: 0.8em 0;
    padding: 0.3em 0 0.3em 12px;
    color: var(--muted);
    border-left: 3px solid var(--primary);
}
/* =========================================================
   Base editor
   ========================================================= */

.qe-editor {
    width: 100%;
    min-width: 0;
    color: var(--text);
    background: var(--input-field);
    font-family: inherit;

    border: 2px solid var(--border);
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 16px;
    outline: none;

    max-height: 12rem;
    overflow-y: auto;
}

/* =========================================================
   Editable content
   ========================================================= */

.qe-editor .qe-prose {
    width: 100%;
    box-sizing: border-box;
}

.qe-editor .qe-prose p {
    margin: 0;
}

/* =========================================================
   Medium editor
   ========================================================= */

.qe-editor-medium {
    height: 7rem;
    max-height: 7rem;
    overflow-y: auto;
}

.qe-editor-medium .qe-prose {
    min-height: 100% !important;
    max-height: none !important;
    overflow: visible;
}

/* =========================================================
   Small editor
   ========================================================= */

.qe-editor-small {
    height: 3rem;
    max-height: 3rem;
    overflow-y: auto;
}

.qe-editor-small .qe-prose {
    min-height: 100% !important;
    max-height: none !important;
    overflow: visible;
}

/* =========================================================
   Avoid unnecessary scrolling in empty compact editors
   ========================================================= */

.qe-editor-small:not(:focus-within),
.qe-editor-medium:not(:focus-within) {
    overflow-y: hidden;
}

.qe-editor-small:focus-within,
.qe-editor-medium:focus-within {
    overflow-y: auto;
}

.qe-editor *,
.qe-editor *::before,
.qe-editor *::after {
    box-sizing: border-box;
}

.qe-editor:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-shadow);
}

/* Keep all toolbar controls in a single row */
.qe-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 3px;

    width: max-content;
    min-width: 100%;
    padding: 0;
    background: transparent;
    border: 0;
}

.qe-toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;

    min-width: 32px;
    min-height: 32px;
    padding: 5px 8px;

    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;

    font-family: inherit;
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;

    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;

    transition:
            background-color 0.15s ease,
            border-color 0.15s ease;
}

.qe-toolbar button:hover {
    background: var(--bg);
    border-color: var(--border);
}

.qe-toolbar button:active {
    background: var(--border);
}

.qe-toolbar button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.qe-toolbar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}


/* =========================================================
   Editor area
   ========================================================= */

.qe-content {
    min-height: 150px;
    /*padding: 12px;*/
    cursor: text;
}

.qe-prose {
    width: 100%;
    min-height: 125px;

    color: var(--text);
    font-family: inherit;
    font-size: inherit;
    line-height: 1.6;

    outline: none;
    overflow-wrap: anywhere;
    word-break: normal;
    white-space: normal;
}

.qe-prose:focus {
    outline: none;
}

.qe-prose p {
    margin: 0 0 0.7em;
}

.qe-prose p:last-child {
    margin-bottom: 0;
}

/* Headings */

.qe-prose h1,
.qe-prose h2,
.qe-prose h3 {
    color: var(--text);
    line-height: 1.35;
    font-weight: 650;
}

.qe-prose h1 {
    margin: 1em 0 0.5em;
    font-size: 1.6em;
}

.qe-prose h2 {
    margin: 1em 0 0.5em;
    font-size: 1.3em;
}

.qe-prose h3 {
    margin: 0.9em 0 0.4em;
    font-size: 1.1em;
}

/* Lists */

.qe-prose ul,
.qe-prose ol {
    margin: 0.5em 0;
    padding-left: 1.7em;
}

.qe-prose ul {
    list-style-type: disc;
}

.qe-prose ol {
    list-style-type: decimal;
}

.qe-prose li {
    margin: 0.2em 0;
    padding-left: 0.1em;
}

.qe-prose li p {
    margin: 0.2em 0;
}

.qe-prose li > ul,
.qe-prose li > ol {
    margin: 0.2em 0;
}

/* Blockquotes */

.qe-prose blockquote {
    margin: 0.8em 0;
    padding: 0.3em 0 0.3em 12px;
    color: var(--muted);
    border-left: 3px solid var(--primary);
}

.qe-prose blockquote p:last-child {
    margin-bottom: 0;
}

/* Links */

.qe-prose a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
    cursor: text;
}

.qe-prose a:hover {
    text-decoration-thickness: 2px;
}

/* Superscript and subscript */

.qe-prose sup,
.qe-prose sub {
    position: relative;
    font-size: 0.75em;
    line-height: 0;
    vertical-align: baseline;
}

.qe-prose sup {
    top: -0.5em;
}

.qe-prose sub {
    bottom: -0.25em;
}

/* Inline code */

.qe-prose code {
    padding: 2px 4px;
    border-radius: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    font-family: monospace;
    font-size: 0.9em;
}

/* Horizontal rule */

.qe-prose hr {
    margin: 1em 0;
    border: 0;
    border-top: 1px solid var(--border);
}

/* Text selection */

.qe-prose ::selection {
    background: var(--primary-shadow);
}

/* =========================================================
   Special-character picker
   ========================================================= */

.qe-special-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.qe-special-category {
    min-height: 30px;
    padding: 5px 8px;

    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;

    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    touch-action: manipulation;
}

.qe-special-category:hover {
    border-color: var(--primary);
}

.qe-special-category[aria-pressed="true"] {
    color: var(--primary);
    border-color: var(--primary);
    font-weight: 600;
}

.qe-special-category:focus-visible,
.qe-special-character:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.qe-special-symbols {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    gap: 5px;
}

.qe-special-character {
    display: flex;
    align-items: center;
    justify-content: center;

    min-width: 0;
    min-height: 40px;
    padding: 5px;

    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 5px;

    font-family: inherit;
    font-size: 19px;
    line-height: 1.2;

    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;

    transition:
            background-color 0.15s ease,
            border-color 0.15s ease;
}

.qe-special-character:hover {
    background: var(--bg);
    border-color: var(--primary);
}

.qe-special-character:active {
    background: var(--border);
}

/* Active formatting options */
.qe-toolbar button.is-active,
.qe-toolbar button[aria-pressed="true"] {
    color: var(--primary);
    background: var(--bg);
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.qe-toolbar button.is-active:hover,
.qe-toolbar button[aria-pressed="true"]:hover {
    background: var(--bg);
}

/* Keep keyboard focus visible */
.qe-toolbar button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
/* =========================================================
   Reduced motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    .qe-toolbar button,
    .qe-special-character {
        transition: none;
    }
}

/* =========================================================
   Floating toolbar
   ========================================================= */

.qe-floating-toolbar {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;

    width: max-content;
    max-width: min(900px, calc(100vw - 24px));
    max-height: 45vh;

    overflow-x: auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;

    padding: 6px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgb(0 0 0 / 14%);
}

.qe-floating-toolbar[hidden] {
    display: none !important;
}

/* Dividers between toolbar groups */
.qe-separator {
    display: block;
    flex: 0 0 1px;
    align-self: stretch;
    width: 1px;
    min-height: 24px;
    margin: auto 5px;

    background: var(--border);
    border: 0;
    border-radius: 1px;
}

/* Mobile */
html.mobile-phone .qe-floating-toolbar {
    top: auto;
    bottom: 8px;
    left: 8px;
    right: 8px;
    transform: none;

    width: auto;
    max-width: none;
    max-height: 38vh;

    padding: 6px;
    border-radius: 12px;
}

html.mobile-phone .qe-toolbar {
    justify-content: flex-start;
    gap: 4px;
}

html.mobile-phone .qe-toolbar button {
    flex: 0 0 auto;
    min-width: 38px;
    min-height: 38px;
    padding: 6px 9px;
    font-size: 15px;
}

html.mobile-phone .qe-separator {
    flex: 0 0 1px;
    align-self: stretch;
    height: 26px;
    margin: auto 3px;
}

/* Separate special-character popup */
.qe-special-picker {
    position: fixed;
    z-index: 10001;

    width: 100%;
    max-height: 240px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;

    padding: 12px;
    box-sizing: border-box;

    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgb(0 0 0 / 16%);
}

.qe-special-picker[hidden] {
    display: none;
}

.qe-special-picker * {
    box-sizing: border-box;
}

html.mobile-phone .qe-special-picker {
    padding: 10px;
}


.qe-highlight-picker {
    position: fixed;
    z-index: 10001;
    box-sizing: border-box;
    padding: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgb(0 0 0 / 16%);
}

.qe-highlight-picker-title {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
}

.qe-highlight-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.qe-highlight-color {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border: 2px solid var(--border);
    border-radius: 35%;
    cursor: pointer;
}

.qe-highlight-color:hover,
.qe-highlight-color:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.qe-highlight-remove {
    background: transparent;
}

.qe-highlight-remove:hover {
    background: transparent;
}

html.mobile-phone .qe-highlight-picker {
    padding: 10px;
}


.qe-prose mark {
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* Tiptap placeholder: show whenever the editor is empty */
.qe-editor .qe-prose p.is-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    color: var(--muted);
    pointer-events: none;
    height: 0;
}

/* Container between toolbar and editable text */
.qe-content {
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 0;
    box-sizing: border-box;
    cursor: text;
}

/* Actual Tiptap editing area */
.qe-prose {
    width: 100%;
    min-height: 125px;
    padding: 12px;
    box-sizing: border-box;
    outline: none;
    overflow-wrap: anywhere;
    line-height: 1.6;
    cursor: text;
}

/* Remove default paragraph spacing */
.qe-prose p {
    margin: 0;
}

/* Compact answer editor */
.qe-editor-small .qe-editor {
    max-height: 3rem;
}

.qe-editor-small .qe-prose {
    min-height: calc(3rem) !important;
}

/* Medium-sized editor */
.qe-editor-medium .qe-editor {
    max-height: 7rem;
}

.qe-editor-medium .qe-prose {
    min-height: calc(7rem) !important;
}

.qe-floating-toolbar {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

/* Keep your existing mobile positioning rules */
html.mobile-phone .qe-floating-toolbar {
    top: auto;
    bottom: 8px;
    left: 8px;
    right: 8px;
    transform: none;
}

html,
body,
.qe-editor,
.qe-content,
.qe-floating-toolbar,
.qe-highlight-color,
.qe-highlight-colors,
.qe-highlight-picker,
.qe-highlight-picker-title,
.qe-highlight-remove,
.qe-prose,
.qe-separator,
.qe-special-categories,
.qe-special-category,
.qe-special-character,
.qe-special-picker,
.qe-special-symbols,
.qe-toolbar {
    transition: background-color .25s ease,
    color .25s ease,
    border-color .25s ease,
    box-shadow .25s ease;
}