/* "Omat kokoelmat": header menu, add buttons and the /omat-kokoelmat viewer. */

/**** HEADER MENU ****/
header > .div-container {
    position: relative;
}
.collections-menu {
    position: absolute;
    top: 2rem;
    right: 0.3rem;
    z-index: 1001;
}
.collections-menu-btn {
    position: relative;
    padding: 0.3rem 0.55rem;
}
.collections-count {
    position: absolute;
    top: -0.45rem;
    right: -0.45rem;
    min-width: 1.2rem;
    padding: 0 0.3rem;
    border-radius: 0.6rem;
    background: var(--taivaansini);
    color: #fff;
    font-size: 0.7rem;
    line-height: 1.2rem;
    text-align: center;
}
.collections-count[hidden] {
    display: none;
}
.collections-menu-panel {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    width: min(22rem, 92vw);
    max-height: 75vh;
    overflow-y: auto;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--kulta80);
    border-radius: 0.3rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    color: var(--pakkasyo);
    text-align: left;
}
.collections-menu-panel[hidden] {
    display: none;
}
.collections-menu-header h2 {
    font-size: 1.1rem;
    margin: 0 0 0.75rem;
}
.collections-menu-list {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
}
.collections-menu-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem;
    border-radius: 0.2rem;
}
.collections-menu-list li.active {
    background: var(--kulta30);
}
.collections-menu-name {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    overflow-wrap: anywhere;
}
.collections-menu-count {
    color: #666;
    font-size: 0.85em;
}
.collections-menu-actions {
    display: flex;
    flex-shrink: 0;
}
.collections-icon-btn,
.cv-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.4rem;
    margin: 0;
    border: none;
    border-radius: 0.3rem;
    background: none;
    color: var(--taivaansini);
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
}
.collections-icon-btn:hover,
.collections-icon-btn:focus-visible,
.cv-icon-btn:hover,
.cv-icon-btn:focus-visible {
    background: var(--kulta30);
    color: var(--pakkasyo);
}
.collections-menu-list .active .collections-icon-btn:hover,
.collections-menu-list .active .collections-icon-btn:focus-visible {
    background: #fff;
}
.cv-icon-btn:disabled {
    color: #bbb;
    background: none;
    cursor: default;
}
.collections-notify-action,
.cv-link-btn {
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    color: var(--taivaansini);
    text-decoration: underline;
    cursor: pointer;
}
.collections-name-form {
    display: flex;
    gap: 0.3rem;
    width: 100%;
}
.collections-menu-new {
    margin-bottom: 0.75rem;
}
.collections-menu-create {
    display: block;
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.4rem;
    border: 1px dashed var(--kulta);
    border-radius: 0.3rem;
    background: none;
    color: var(--taivaansini);
    cursor: pointer;
}
.collections-menu-create:hover {
    background: var(--kulta10);
}
.collections-menu-empty,
.collections-menu-note {
    font-size: 0.85rem;
    color: #555;
}
.collections-menu-note {
    margin: 0.5rem 0 0;
}
.notification-banner.collections-notify .notification a {
    color: var(--taivaansini);
}
.collections-notify-action {
    vertical-align: baseline;
    font-weight: 600;
}

@media (max-width: 900px) {
    .collections-menu {
        top: 1.1rem;
        left: 1rem;
        right: auto;
    }
    .collections-menu-panel {
        left: 0;
        right: auto;
    }
}

a.pwa-bottom-bar-btn {
    text-decoration: none;
}

/**** ADD BUTTONS ****/
.collect-btn {
    border: none;
    background: none;
    padding: 0.2rem 0.4rem;
    color: var(--taivaansini);
    cursor: pointer;
    line-height: 1;
}
.collect-btn:hover,
.collect-btn:focus-visible {
    color: var(--pakkasyo);
}

/* card_view listing: the whole entry is a link, so the button sits on top */
li.list-item {
    position: relative;
}
li.list-item > .collect-btn {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    z-index: 1;
}

/* table views */
td .collect-btn {
    margin-left: 0.3rem;
}

/* library item paragraphs, stacked below the existing link icon */
.collectIcon {
    display: none;
    font-size: 12px;
    cursor: pointer;
    color: var(--taivaansini);
    position: absolute;
    margin-top: 2rem;
    margin-left: -1.5rem;
    background: #fff;
    padding: 0.3em 0 0.3em 0.3em;
}
.collectIcon.with-paragnr {
    margin-top: 3.9rem;
}
/* paragraphs without a link icon: the bookmark takes the link icon's place */
.collectIcon.anchorless {
    margin-top: 0.5rem;
}
.collect-btn.is-collected,
.collectIcon.is-collected {
    color: var(--havu);
}
.collectIcon.is-collected {
    display: block;
}
@media (max-width: 900px) {
    .collectIcon {
        margin-left: -1rem;
    }
}

/* express entry lists (prayers): icon outside the clipped .entryContent */
.entryDetails {
    position: relative;
}
/* The icon box touches the entry's edge, so the pointer never leaves the entry on its way to it */
.collectIcon.entryCollectIcon {
    margin: 0;
    top: 4.2rem;
    left: -1.3rem;
    width: 1.3rem;
    box-sizing: border-box;
    padding: 0.3em 0;
    text-align: center;
    background: none;
}
.entryDetails:hover > .collectIcon.entryCollectIcon {
    display: block;
}
@media (max-width: 900px) {
    .collectIcon.entryCollectIcon {
        left: -1rem;
        width: 1rem;
    }
}

.entryDetails.touch-active > .collectIcon.entryCollectIcon {
    display: block;
}

/* selection popup (library items and express entry lists) */
#selectionActionButtons {
    display: none;
    position: absolute;
    background: none;
    white-space: nowrap;
}

#selectionActionButtons .btn + .btn {
    margin-left: 0.5rem;
}

#selectionPdfExportBtn:disabled,
#selectionCopyQuoteBtn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.selectionActionsCloseBtn {
    position: absolute;
    top: -0.6rem;
    right: -0.6rem;
    width: 1.2rem;
    height: 1.2rem;
    padding: 0;
    border: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--taivaansini);
    color: #fff;
    border-radius: 50%;
    font-size: 0.65rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: #888 0px 1px 4px;
}

.selectionActionsCloseBtn:hover {
    background: var(--kulta);
}

/**** VIEWER (/omat-kokoelmat) ****/
.collection-viewer {
    max-width: 50em;
    margin: 0 auto 4rem;
    padding: 0 1rem;
}
.cv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 1rem 0 1.5rem;
}
.cv-toolbar-left {
    flex: 1 1 auto;
    min-width: 0;
}
.cv-toolbar-left select {
    max-width: 20rem;
}
.cv-toolbar-right {
    /* stays right even when the left side is hidden (reading mode) */
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.15rem;
    flex-shrink: 0;
}
.cv-actions-inline {
    display: flex;
    gap: 0.15rem;
}
.cv-actions-more {
    display: none;
    position: relative;
}
.cv-actions-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.3rem);
    z-index: 20;
    min-width: 13rem;
    padding: 0.4rem 0;
    background: #fff;
    border: 1px solid var(--kulta80);
    border-radius: 0.3rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.cv-actions-dropdown[hidden] {
    display: none;
}
.cv-actions-dropdown button {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    color: var(--pakkasyo);
    text-align: left;
    cursor: pointer;
}
.cv-actions-dropdown button:hover {
    background: var(--kulta30);
}
.cv-actions-dropdown i {
    width: 1.3rem;
    color: var(--taivaansini);
}
@media (max-width: 700px) {
    .cv-actions-inline {
        display: none;
    }
    .cv-actions-more {
        display: block;
    }
}
.cv-header {
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--kulta80);
    padding-bottom: 0.75rem;
}
.cv-title-row {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}
.cv-title-row h1 {
    margin: 0;
    overflow-wrap: anywhere;
}
.cv-title-row .cv-icon-btn {
    font-size: 0.8rem;
    color: #888;
}
.cv-header .cv-meta {
    margin: 0.3rem 0 0;
    color: #666;
    font-size: 0.9rem;
}
.cv-active-badge {
    color: var(--havu);
}
.cv-header .collections-name-form {
    max-width: 30rem;
}
.cv-notice {
    padding: 1rem;
    margin-bottom: 1.5rem;
    background: #fff;
    border-left: 4px solid var(--taivaansini);
}
.cv-notice p {
    margin-bottom: 0.5rem;
}
.cv-notice-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}
.cv-notice-actions .btn {
    margin: 0;
}
.cv-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.cv-items {
    list-style: none;
    margin: 0;
    padding: 0;
}
.cv-item {
    display: grid;
    grid-template-columns: 1.2rem minmax(0, 1fr);
    gap: 0.5rem;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--kulta60);
}
.cv-item.dragging {
    opacity: 0.4;
}
.cv-item.drop-before {
    box-shadow: inset 0 3px 0 var(--taivaansini);
}
.cv-item.drop-after {
    box-shadow: inset 0 -3px 0 var(--taivaansini);
}
.cv-item-handle {
    cursor: grab;
    color: var(--kulta80);
    padding-top: 0.3rem;
}
/* touch devices: drag and drop only works with a mouse, so reorder with the arrow buttons */
@media (pointer: coarse) {
    .cv-item {
        grid-template-columns: minmax(0, 1fr);
    }
    .cv-item-handle {
        display: none;
    }
}
.cv-item-content {
    font-family: 'Rasa', 'Times New Roman', serif;
    /* same size as the reading pages (library-item.css main) */
    font-size: clamp(1.3rem, 1vw + 1rem, 1.5rem);
    line-height: 1.3;
}
.cv-item-content p {
    margin: 0 0 0.6rem;
    padding-left: 0;
    margin-left: 0;
}
.cv-item-content .paragnr {
    display: none;
}
.cv-item-content .footnotes {
    font-size: 0.9rem;
}
.cv-item-document .cv-item-content {
    font-family: inherit;
    font-size: 1rem;
}
.cv-item-document h2 {
    font-size: 1.2rem;
    margin: 0 0 0.3rem;
}
.cv-item-source {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
    color: #666;
    text-align: right;
}
.cv-item-source a {
    color: var(--taivaansini);
}
.cv-item-note textarea {
    width: 100%;
    min-height: 2.2rem;
    margin-top: 0.6rem;
    font-size: 0.95rem;
    resize: none;
    overflow: hidden;
}
.cv-item-note-text {
    display: none;
    margin-top: 0.6rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--kulta);
    font-style: italic;
    white-space: pre-wrap;
}
/* read-only preview of a shared/imported collection (no drag handle column) */
.cv-item.cv-item-readonly {
    grid-template-columns: minmax(0, 1fr);
}
.cv-item-readonly .cv-item-note-text {
    display: block;
}
.cv-item-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.15rem;
    margin-top: 0.4rem;
}
.cv-item-actions select {
    width: auto;
    max-width: 14rem;
    margin-left: 0.3rem;
}
.cv-empty {
    padding: 2rem 0;
    color: #555;
}

/* "Piilota toiminnot": only the texts (and written notes) remain */
.cv-reading .cv-toolbar-left,
.cv-reading .cv-actions-inline,
.cv-reading .cv-actions-more,
.cv-reading .cv-title-row .cv-icon-btn,
.cv-reading .cv-meta-action,
.cv-reading .cv-item-handle,
.cv-reading .cv-item-actions,
.cv-reading .cv-item-note textarea,
.cv-reading .cv-notice:not(.cv-backup),
.cv-reading .cv-storage-line {
    display: none;
}
.cv-reading .cv-item {
    grid-template-columns: minmax(0, 1fr);
}
.cv-reading .cv-item-note-text:not(:empty) {
    display: block;
}

@media print {
    #collectionsMenu,
    .collectIcon,
    .collect-btn,
    .cv-toolbar,
    .cv-notice,
    .cv-storage-line,
    .cv-meta-action,
    .cv-title-row .cv-icon-btn,
    .cv-item-handle,
    .cv-item-actions,
    .cv-item-note textarea,
    .notification-banner {
        display: none !important;
    }
    /* the @page margins are enough: drop the screen widths and paddings */
    .grid-container:has(.collection-viewer) {
        padding: 0;
    }
    main:has(.collection-viewer) {
        max-width: none;
    }
    /* view.php wraps single pages in Bootstrap's container/row/col */
    main:has(.collection-viewer) .container,
    main:has(.collection-viewer) .row,
    main:has(.collection-viewer) .col-sm-12 {
        max-width: none;
        width: 100%;
        margin: 0;
        padding: 0;
    }
    .collection-viewer {
        max-width: none;
        margin: 0;
        padding: 0;
    }
    .cv-item {
        display: block;
        margin-top: 14pt;
        padding: 0 0 24pt;
        break-inside: avoid;
    }
    .cv-item-content {
        font-size: 12pt;
        line-height: 1.6;
    }
    .cv-item-note-text:not(:empty) {
        display: block;
    }
}

/* default / full width page lists */
.ccm-block-page-list-page-entry > .collect-btn,
.ccm-block-page-list-page-entry-horizontal > .collect-btn {
    float: right;
}

/* backup / sync */
.cv-storage-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem 0.75rem;
    width: fit-content;
    max-width: 100%;
    margin: -1rem 0 1.5rem auto;
    font-size: 0.9rem;
    color: #444;
}
.cv-storage-text .fas {
    margin-right: 0.2rem;
}
.cv-tone-ok .cv-storage-text .fas {
    color: var(--havu);
}
.cv-tone-bad .cv-storage-text {
    color: #b00020;
}
.cv-tone-bad .cv-storage-text .fas {
    color: var(--puolukka);
}
.cv-tone-neutral .cv-storage-text .fas {
    color: #777;
}
.cv-pill {
    padding: 0.15em 0.75em;
    border: 1px solid var(--pakkasyo);
    border-radius: 10rem;
    background: #fff;
    color: var(--pakkasyo);
    font-size: 0.85rem;
    line-height: 1.5;
    cursor: pointer;
}
.cv-pill:hover,
.cv-pill:focus-visible {
    background: var(--pakkasyo);
    color: #fff;
}
.cv-backup h3 {
    font-size: 1.05rem;
}
.collections-sync-status strong {
    display: block;
}
.cv-backup h2 {
    font-size: 1.4rem;
    margin-top: 0;
    margin-bottom: 1rem;
}
.cv-backup .cv-notice-actions + .cv-notice-actions,
.cv-backup .cv-restore-row,
.cv-backup .cv-account {
    margin-top: 1rem;
}
.cv-key-block input {
    margin-bottom: 0.5rem;
    font-family: monospace;
}
.cv-warning {
    margin-top: 0.75rem;
    font-weight: 600;
}
.cv-error {
    color: #b00020;
}
.cv-import-list {
    margin-top: 1rem;
}
.collections-sync-status {
    font-size: 0.85rem;
}
.cv-restore-row summary {
    cursor: pointer;
}
.cv-restore-row input {
    max-width: 24rem;
    margin-top: 0.5rem;
}
.cv-backup .cv-account {
    font-size: 0.9rem;
}
.cv-backup-files {
    margin-top: 1rem;
}
.cv-backup {
    position: relative;
}
.cv-backup .cv-backup-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}
.cv-backup-files summary {
    cursor: pointer;
}

/* --- storage wizard & settings --- */
.cv-notice button.btn.cv-btn-outline,
.cv-notice button.btn.cv-btn-danger,
.cv-notice button.btn.cv-btn-havu {
    border: 2px solid var(--pakkasyo);
}
.cv-notice button.btn.cv-btn-outline {
    background: #fff;
    color: var(--pakkasyo);
    text-transform: none;
}
.cv-notice button.btn.cv-btn-outline:hover {
    background: var(--pakkasyo);
    color: #fff;
}
.cv-notice button.btn.cv-btn-havu {
    background: var(--havu);
    border-color: var(--havu);
    color: #fff;
}
.cv-notice button.btn.cv-btn-havu:hover {
    background: #fff;
    color: var(--havu);
}
.cv-notice button.btn.cv-btn-danger {
    background: #fff;
    border-color: var(--puolukka);
    color: var(--puolukka);
    text-transform: none;
}
.cv-notice button.btn.cv-btn-danger:hover {
    background: var(--puolukka);
    color: #fff;
}
.cv-btn-havu .fas, .cv-btn-outline .fas, .cv-btn-danger .fas {
    margin-right: 0.25rem;
}
.cv-backup {
    position: relative;
}
.cv-backup h2 {
    padding-right: 2.5rem;
}
.cv-backup h2 .fas, .cv-section h3 .fas, .cv-step-title .fas {
    color: var(--pakkasyo);
    margin-right: 0.35rem;
}
.cv-steps {
    display: flex;
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0;
    gap: 0.5rem;
}
.cv-steps li {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #777;
    font-size: 0.9rem;
}
.cv-steps li:not(:last-child)::after {
    content: '';
    flex: 1;
    height: 2px;
    background: #bbb;
}
.cv-steps li.is-done:not(:last-child)::after {
    background: var(--havu);
}
.cv-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    border: 2px solid #999;
    font-weight: 600;
    background: #fff;
}
.cv-steps li.is-current {
    color: var(--pakkasyo);
    font-weight: 600;
}
.cv-steps li.is-current .cv-step-num {
    background: var(--taivaansini);
    border-color: var(--taivaansini);
    color: #fff;
}
.cv-steps li.is-done .cv-step-num {
    background: var(--havu);
    border-color: var(--havu);
    color: #fff;
}
.cv-steps .cv-step-label {
    white-space: nowrap;
}
@media (max-width: 36rem) {
    .cv-steps .cv-step-label { display: none; }
    .cv-steps li.is-current .cv-step-label { display: inline; }
}
.cv-step-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
}
.cv-steps + .cv-step-title {
    margin-top: 1.5rem;
}
.cv-step-title.cv-step-done .fas {
    color: var(--havu);
}
.cv-step-actions {
    margin-top: 1.25rem;
}
.cv-warning-box {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    margin: 1rem 0 0;
    padding: 0.75rem 1rem;
    background: rgba(246, 200, 198, 0.55);
    border-left: 4px solid var(--puolukka);
    font-weight: 500;
}
.cv-warning-box .fas {
    color: var(--puolukka);
    margin-top: 0.2rem;
}
.cv-key-label {
    display: block;
    margin: 0.75rem 0 0.25rem;
    font-weight: 600;
}
.cv-more-options {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(9, 19, 171, 0.2);
}
.cv-more-options > summary,
.cv-restore-row > summary {
    cursor: pointer;
}
.cv-more-options > summary {
    font-weight: 600;
    color: var(--pakkasyo);
}
/* the options inside are one level down: no nested disclosure look, just spaced blocks */
.cv-more-options > .cv-restore-row,
.cv-more-options > .cv-option-title {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(9, 19, 171, 0.12);
}
.cv-more-options > .cv-restore-row:first-of-type {
    margin-top: 1rem;
    padding-top: 0;
    border-top: 0;
}
.cv-restore-row > summary {
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.cv-option-title {
    margin: 1rem 0 0;
    font-weight: 600;
}
.cv-restore-row .cv-option-title {
    margin-top: 1.25rem;
    font-weight: 400;
}
.cv-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(9, 19, 171, 0.2);
}
.cv-section h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
}
.cv-danger-zone {
    padding: 1rem;
    border: 1px dashed var(--puolukka);
    background: rgba(246, 200, 198, 0.2);
}
.cv-danger-zone h3 .fas {
    color: var(--puolukka);
}
.cv-status-row .fas {
    margin-right: 0.3rem;
}
.cv-status-ok .fas {
    color: var(--havu);
}
.cv-status-bad {
    color: #b00020;
    font-weight: 600;
}
.cv-status-bad .fas {
    color: var(--puolukka);
}

/* recovery request form */
.collection-recovery {
    max-width: 40rem;
}
.collection-recovery .cv-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.collection-recovery small {
    display: block;
    margin-top: 0.25rem;
    color: #555;
}

.cv-help-link {
    margin: 1.25rem 0 0;
    font-size: 0.9rem;
}

/* in-page confirmations: shown in place of the control that triggered them */
.cv-confirm {
    margin: 0.5rem 0 1rem;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--puolukka);
    background: rgba(246, 200, 198, 0.35);
}
.cv-confirm h3 {
    font-size: 1.05rem;
    margin: 0 0 0.5rem;
}
.cv-confirm p {
    margin-bottom: 0.5rem;
}
.cv-danger-zone .cv-confirm {
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}
.collections-menu-confirm {
    padding: 0.5rem;
    background: rgba(246, 200, 198, 0.35);
    border-left: 3px solid var(--puolukka);
    font-size: 0.9rem;
}
.collections-menu-confirm p {
    margin: 0 0 0.4rem;
}
.collections-menu-confirm-actions {
    display: flex;
    gap: 0.5rem;
}
.collections-menu-danger,
.collections-menu-cancel {
    padding: 0.15em 0.75em;
    border: 1px solid var(--puolukka);
    border-radius: 10rem;
    background: #fff;
    color: var(--puolukka);
    cursor: pointer;
}
.collections-menu-danger {
    background: var(--puolukka);
    color: #fff;
}
.collections-menu-cancel {
    border-color: var(--pakkasyo);
    color: var(--pakkasyo);
}
