/* Edit-mode UI. Loaded by consumer pages; only takes effect when edit cookie is present. */

body.edit-mode { padding-top: 36px; }

.edit-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 36px;
    z-index: 100;
    background: linear-gradient(90deg, var(--saffron) 0%, var(--saffron-deep) 100%);
    color: var(--paper);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    font-family: var(--font-display);
    font-size: 0.92rem;
    letter-spacing: 0.04em;
    box-shadow: 0 1px 6px rgba(45, 36, 24, 0.2);
}
.edit-bar-left  { display: flex; align-items: center; gap: 0.75rem; }
.edit-bar-right { display: flex; align-items: center; gap: 0.5rem; }
.edit-bar-tag {
    background: rgba(255, 255, 255, 0.16);
    padding: 2px 8px;
    border-radius: 3px;
    font-style: italic;
    letter-spacing: 0.08em;
    font-size: 0.85rem;
}
.edit-bar-status { font-style: italic; opacity: 0.92; font-size: 0.88rem; }
.edit-bar-btn {
    background: transparent;
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 3px;
    padding: 3px 12px;
    font: inherit;
    cursor: pointer;
    transition: background 0.15s;
}
.edit-bar-btn:hover { background: rgba(255, 255, 255, 0.18); }

/* Lift the sticky app-header below the edit-bar */
body.edit-mode .app-header { top: 36px; }

/* Hover affordance on editable text */
body.edit-mode [data-edit] {
    cursor: text;
    border-radius: 3px;
    transition: background 0.15s, box-shadow 0.15s;
}
body.edit-mode [data-edit]:hover {
    background: rgba(232, 118, 43, 0.07);
    box-shadow: 0 0 0 2px rgba(232, 118, 43, 0.18);
}
body.edit-mode [data-edit].editing {
    background: transparent;
    box-shadow: none;
}

/* Inline editor pane: a textarea that replaces the field in place. */
.edit-pane {
    width: 100%;
    box-sizing: border-box;
    background: var(--paper);
    border: 2px solid var(--saffron);
    border-radius: 4px;
    padding: 0.5rem 0.65rem;
    font: inherit;
    color: var(--ink);
    resize: vertical;
    outline: none;
    min-height: 2.5em;
    box-shadow: 0 2px 10px rgba(232, 118, 43, 0.18);
}
.edit-pane.deva { font-family: var(--font-deva); }
.edit-pane-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.4rem;
    font-size: 0.85rem;
    font-family: var(--font-display);
    align-items: center;
}
.edit-pane-actions .edit-pane-hint {
    color: var(--ink-mute);
    font-style: italic;
    margin-left: auto;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}
.edit-pane-actions button {
    background: var(--saffron);
    color: var(--paper);
    border: none;
    padding: 4px 14px;
    border-radius: 3px;
    cursor: pointer;
    font: inherit;
    letter-spacing: 0.04em;
}
.edit-pane-actions button.ghost {
    background: transparent;
    color: var(--ink-soft);
    border: 1px solid var(--ink-mute);
}
.edit-pane-actions button:disabled { opacity: 0.5; cursor: progress; }

/* Tiny toast for save success / failure */
.edit-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--paper);
    padding: 0.55rem 1.1rem;
    border-radius: 4px;
    font-family: var(--font-display);
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 200;
}
.edit-toast.show { opacity: 1; }
.edit-toast.error { background: var(--vermillion); }
.edit-toast.success { background: var(--peacock-deep); }

/* Draft article badge — only shown in edit mode on /srivachan and /antas list */
.article-draft-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 1px 8px;
    font-size: 0.65rem;
    font-family: var(--font-display);
    font-style: italic;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-mute);
    background: rgba(138, 117, 88, 0.12);
    border: 1px solid rgba(138, 117, 88, 0.35);
    border-radius: 2px;
    vertical-align: middle;
}
.article-card.is-draft { opacity: 0.85; }

/* Published toggle pill (on verses, groups, docs). Hidden outside edit mode. */
.published-pill {
    display: none;
    margin-left: 0.5rem;
    padding: 1px 9px;
    font-size: 0.68rem;
    font-family: var(--font-display);
    font-style: italic;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    border-radius: 2px;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s;
}
body.edit-mode .published-pill { display: inline-block; }
.published-pill[data-state="published"] {
    color: var(--peacock-deep);
    background: rgba(61, 139, 61, 0.12);
    border: 1px solid rgba(61, 139, 61, 0.35);
}
.published-pill[data-state="draft"] {
    color: var(--ink-mute);
    background: rgba(138, 117, 88, 0.12);
    border: 1px solid rgba(138, 117, 88, 0.35);
}
.published-pill:hover { filter: brightness(1.08); }
.published-pill.pending { opacity: 0.55; cursor: progress; }

/* Visual draft state on cards — only dimmed in edit mode (drafts otherwise hidden) */
body.edit-mode .verse-card.is-draft,
body.edit-mode .doc-article.is-draft { opacity: 0.78; }

/* Empty-field placeholders. Hidden by default; revealed as dashed slots in edit mode. */
.is-empty { display: none; }
body.edit-mode .is-empty {
    display: block;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 0.92rem;
    color: var(--ink-mute);
    background: transparent;
    border: 1px dashed rgba(138, 117, 88, 0.5);
    border-radius: 3px;
    padding: 0.35rem 0.75rem;
    margin: 0.5rem 0;
    text-align: center;
    cursor: pointer;
    letter-spacing: 0.02em;
    line-height: 1.4;
    min-height: 1.6em;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
body.edit-mode .is-empty:hover {
    background: rgba(232, 118, 43, 0.07);
    border-color: var(--saffron);
    color: var(--saffron-deep);
}
/* Hide the divider when the adjacent meaning slot is empty (both modes) */
.verse-divider:has(+ .verse-meaning.is-empty) { display: none; }
/* figcaption / cite stay inline-block when empty so they fit under figures */
body.edit-mode figcaption.is-empty,
body.edit-mode cite.is-empty {
    display: inline-block;
    margin-top: 0.4rem;
    font-size: 0.78rem;
}

/* ── Block structural ops (srivachan/antas) ── */

.block-wrap { position: relative; }

.block-controls { display: none; }
body.edit-mode .block-controls {
    display: flex;
    justify-content: flex-end;
    gap: 0.25rem;
    margin-bottom: 0.3rem;
    opacity: 0.45;
    transition: opacity 0.15s;
}
body.edit-mode .block-wrap:hover .block-controls,
body.edit-mode .block-wrap:focus-within .block-controls { opacity: 1; }

.block-ctrl {
    width: 28px; height: 28px;
    border: 1px solid rgba(212, 160, 59, 0.4);
    background: var(--paper);
    color: var(--ink-soft);
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.block-ctrl:hover { background: rgba(232, 118, 43, 0.10); border-color: var(--saffron); }
.block-ctrl:disabled { opacity: 0.3; cursor: not-allowed; }
.block-ctrl.danger:hover {
    background: rgba(183, 58, 26, 0.10);
    color: var(--vermillion);
    border-color: rgba(183, 58, 26, 0.5);
}

.block-insert-row { display: none; }
body.edit-mode .block-insert-row {
    display: block;
    position: relative;
    height: 1.2rem;
    margin: 0.15rem 0;
}
.btn-block-insert {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    background: transparent;
    border: 1px dashed rgba(232, 118, 43, 0.45);
    color: var(--saffron-deep);
    padding: 0.2rem 0.8rem;
    font-family: var(--font-display);
    font-style: italic;
    cursor: pointer;
    border-radius: 3px;
    font-size: 0.78rem;
    letter-spacing: 0.03em;
    opacity: 0.35;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
body.edit-mode .block-insert-row:hover .btn-block-insert,
.btn-block-insert:focus { opacity: 1; background: rgba(232, 118, 43, 0.08); border-color: var(--saffron); }

/* Block-type picker modal (created dynamically by edit-mode.js) */
.block-picker-overlay {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(45, 36, 24, 0.5);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.block-picker {
    background: var(--paper);
    border-radius: 6px;
    padding: 1.25rem 1.5rem;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 12px 40px rgba(45, 36, 24, 0.3);
    border: 1px solid var(--gold);
}
.block-picker h4 {
    margin: 0 0 0.85rem 0;
    font-family: var(--font-display);
    font-style: italic;
    color: var(--saffron-deep);
    text-align: center;
    letter-spacing: 0.06em;
}
.block-picker button {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.25rem;
    border: 1px solid rgba(212, 160, 59, 0.3);
    background: transparent;
    color: var(--ink);
    border-radius: 3px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.95rem;
    text-align: left;
    gap: 0.6rem;
    transition: background 0.12s, border-color 0.12s;
}
.block-picker button:hover { background: rgba(232, 118, 43, 0.07); border-color: var(--saffron); }
.block-picker button em {
    color: var(--ink-mute);
    font-style: italic;
    font-size: 0.82em;
    margin-left: auto;
}
.block-picker button.cancel {
    text-align: center;
    justify-content: center;
    color: var(--ink-mute);
    margin-top: 0.5rem;
    border-style: dashed;
}

/* Media picker — reuses .block-picker-overlay / .block-picker shell */
.media-picker { max-width: 460px; }
.media-picker-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.85rem;
}
.media-picker-label {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--ink-soft);
    letter-spacing: 0.04em;
}
.media-picker input[type="file"],
.media-picker input[type="text"] {
    background: var(--paper-deep);
    border: 1px solid rgba(212, 160, 59, 0.4);
    border-radius: 3px;
    padding: 0.4rem 0.55rem;
    font: inherit;
    color: var(--ink);
    width: 100%;
    box-sizing: border-box;
}
.media-picker input[type="text"]:focus,
.media-picker input[type="file"]:focus {
    outline: none;
    border-color: var(--saffron);
}
.media-picker-status {
    min-height: 1.2em;
    color: var(--vermillion);
    font-style: italic;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}
.media-picker-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}
.media-picker-actions button {
    display: inline-block;
    width: auto;
    margin: 0;
    padding: 0.4rem 1rem;
    background: var(--saffron);
    color: var(--paper);
    border: none;
    border-radius: 3px;
    font: inherit;
    cursor: pointer;
}
.media-picker-actions button:hover { background: var(--saffron-deep); }
.media-picker-actions button:disabled { opacity: 0.55; cursor: progress; }
.media-picker-actions button.cancel {
    background: transparent;
    color: var(--ink-soft);
    border: 1px solid var(--ink-mute);
    margin-top: 0;
}
.media-picker-actions button.cancel:hover { background: rgba(45, 36, 24, 0.06); }

/* Cover edit/clear controls on the figure */
.cover-controls {
    display: none;
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    gap: 0.3rem;
    z-index: 5;
}
body.edit-mode .doc-cover { position: relative; }
body.edit-mode .doc-cover .cover-controls { display: flex; }
.cover-ctrl {
    background: var(--paper);
    color: var(--ink-soft);
    border: 1px solid rgba(212, 160, 59, 0.5);
    border-radius: 3px;
    padding: 0.25rem 0.7rem;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(45, 36, 24, 0.15);
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.cover-ctrl:hover { background: rgba(232, 118, 43, 0.10); border-color: var(--saffron); }
.cover-ctrl.danger:hover {
    background: rgba(183, 58, 26, 0.10);
    color: var(--vermillion);
    border-color: rgba(183, 58, 26, 0.5);
}

/* Empty cover slot (no doc.cover) — larger placeholder */
body.edit-mode .doc-cover-empty.is-empty {
    min-height: 5rem;
    padding: 1.25rem 1rem;
    font-size: 1rem;
    margin: 1rem 0;
}

/* Empty media block slot (image/audio/video without src) — larger area to telegraph "drop media here" */
body.edit-mode .block-media-empty.is-empty {
    min-height: 4rem;
    padding: 1rem;
    font-size: 0.95rem;
    margin: 0.5rem 0;
}

/* ── References (verses) ── */

.verse-references.is-empty-refs { display: none; }
body.edit-mode .verse-references.is-empty-refs { display: block; }

.ref-chip {
    display: inline-flex;
    align-items: center;
    margin-right: 0.4rem;
}
.ref-chip-remove { display: none; }
body.edit-mode .ref-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px; height: 16px;
    margin-left: 0.25rem;
    background: transparent;
    color: var(--ink-mute);
    border: 1px solid rgba(138, 117, 88, 0.5);
    border-radius: 50%;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
body.edit-mode .ref-chip-remove:hover {
    background: var(--vermillion);
    color: var(--paper);
    border-color: var(--vermillion);
}

.ref-add-btn { display: none; }
body.edit-mode .ref-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    margin-left: 0.4rem;
    background: transparent;
    color: var(--saffron-deep);
    border: 1px dashed var(--saffron);
    border-radius: 50%;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background 0.12s, border-style 0.12s;
}
body.edit-mode .ref-add-btn:hover {
    background: rgba(232, 118, 43, 0.10);
    border-style: solid;
}

/* Reference-add picker (reuses block-picker shell) */
.ref-picker { max-width: 320px; }
.ref-picker-hint {
    color: var(--ink-mute);
    font-style: italic;
    font-size: 0.82rem;
    text-align: center;
    margin: 0 0 0.6rem 0;
    letter-spacing: 0.04em;
}
.ref-picker input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    background: var(--paper-deep);
    border: 1px solid rgba(212, 160, 59, 0.4);
    border-radius: 3px;
    padding: 0.5rem 0.7rem;
    font: inherit;
    color: var(--ink);
    text-align: center;
    letter-spacing: 0.04em;
}
.ref-picker input[type="text"]:focus {
    outline: none;
    border-color: var(--saffron);
}

/* New-doc button on srivachan/antas list pages */
.btn-new-doc { display: none; }
body.edit-mode .btn-new-doc {
    display: inline-block;
    margin-top: 1rem;
    background: var(--saffron);
    color: var(--paper);
    border: none;
    border-radius: 3px;
    padding: 0.55rem 1.3rem;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.12s;
}
body.edit-mode .btn-new-doc:hover { background: var(--saffron-deep); }
.new-doc-picker { max-width: 380px; }
