/* ── Harmony of the Gospels Modal — The Fourfold Witness ─────────────
   Chrome cloned from the ISBE modal (squared shell, F4 frosted header,
   tokens throughout). Witness hues are the locked design constants. */

:root {
    --harmony-mark: #8B4A3C;
    --harmony-matthew: #5B4B8A;
    --harmony-luke: #4A6FA5;
    --harmony-john: #7A6B2F;
}

/* Dark variants — same hue identity, lifted for contrast on #1A1A1A.
   Same treatment styles.css gives --accent-isbe (whose light value is
   the exact --harmony-luke hex, annotated there as "too dim"). */
[data-theme="dark"] {
    --harmony-mark: #BD7C6E;
    --harmony-matthew: #8D7DBC;
    --harmony-luke: #7C9FD6;
    --harmony-john: #AC9D61;
}

.harmony-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10200;
    display: none;
    align-items: center;
    justify-content: center;
}
.harmony-backdrop.visible { display: flex; }

.harmony-modal {
    width: 95vw;
    height: 92vh;
    background: var(--background, #FAF9F6);
    /* corners: .modal-shell (css/modal-header.css) */
    box-shadow: 0 25px 50px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Header bar: the one header bar (css/modal-header.css) — nothing of its own. */
.harmony-title-short { display: none; }

.harmony-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* ── Life-of-Christ ribbon ─────────────────────────────────────────── */

.harmony-ribbon {
    display: flex;
    gap: 2px;
    padding: 0.45rem 0.9rem 0.35rem;
    border-bottom: 1px solid var(--border, #E5E1DB);
    background: var(--surface, #fff);
    flex-shrink: 0;
}

.harmony-period-seg {
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    min-width: 0;
    padding: 0.15rem 0.3rem;
    border-radius: 6px;
}
.harmony-period-seg.active { background: rgba(var(--primary-rgb, 91,75,138), 0.06); }

.harmony-period-label {
    border: none;
    background: none;
    padding: 0;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary, #6B5D54);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    text-align: left;
}
.harmony-period-label:hover { color: var(--primary, #5B4B8A); }
.harmony-period-seg.active .harmony-period-label { color: var(--primary, #5B4B8A); }

.harmony-period-dots {
    display: flex;
    align-items: center;
    gap: 3px;
    min-width: 0;
}

.harmony-dot {
    flex: 1 1 4px;
    min-width: 3px;
    max-width: 9px;
    height: 7px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: var(--border, #E5E1DB);
    cursor: pointer;
    transition: background 0.15s ease;
}
.harmony-dot:hover { background: var(--primary-light, #7C6BA6); }
.harmony-dot.active {
    flex: 0 0 auto;
    width: 22px;
    max-width: 22px;
    background: var(--gold, #D4A017);
}

/* ── Event masthead ────────────────────────────────────────────────── */

.harmony-masthead {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.2rem 0.65rem;
    flex-shrink: 0;
}

.harmony-masthead-center {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.harmony-event-title {
    border: none;
    background: none;
    padding: 0.1rem 0.4rem;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.35rem;
    line-height: 1.3;
    color: var(--text-primary, #2C2416);
    cursor: pointer;
    text-align: center;
    text-wrap: balance;
    border-radius: 8px;
}
.harmony-event-title:hover { background: rgba(var(--primary-rgb, 91,75,138), 0.07); }
.harmony-title-caret {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-left: 0.25rem;
    opacity: 0.55;
}

.harmony-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary, #6B5D54);
}
.harmony-meta-dot { margin: 0 0.45rem; opacity: 0.5; }

.harmony-step {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border: 1px solid var(--border, #E5E1DB);
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text-primary, #2C2416);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.harmony-step:hover:not(:disabled) { border-color: var(--primary, #5B4B8A); color: var(--primary, #5B4B8A); }
.harmony-step:disabled { opacity: 0.35; cursor: default; }

/* ── Content area ──────────────────────────────────────────────────── */

.harmony-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1.2rem 1.2rem;
}

.harmony-loading {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary, #6B5D54);
}

/* ── The Fourfold Witness grid ─────────────────────────────────────── */

.harmony-witness-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
    max-width: 76rem;
    margin: 0 auto;
}

.harmony-witness-card {
    background: var(--surface, #fff);
    border: 1px solid var(--border, #E5E1DB);
    border-left-width: 4px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.harmony-witness-mark    { border-left-color: var(--harmony-mark); }
.harmony-witness-matthew { border-left-color: var(--harmony-matthew); }
.harmony-witness-luke    { border-left-color: var(--harmony-luke); }
.harmony-witness-john    { border-left-color: var(--harmony-john); }
.harmony-witness-card.silent { border-style: dashed; border-left-style: solid; }

.harmony-witness-header {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.55rem 0.8rem;
    border-bottom: 1px solid var(--border, #E5E1DB);
}
.harmony-witness-card.silent .harmony-witness-header { border-bottom: none; }

.harmony-witness-name {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.harmony-witness-mark    .harmony-witness-name { color: var(--harmony-mark); }
.harmony-witness-matthew .harmony-witness-name { color: var(--harmony-matthew); }
.harmony-witness-luke    .harmony-witness-name { color: var(--harmony-luke); }
.harmony-witness-john    .harmony-witness-name { color: var(--harmony-john); }

.harmony-witness-ref {
    font-size: 0.78rem;
    color: var(--text-secondary, #6B5D54);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.harmony-open-reader {
    margin-left: auto;
    flex-shrink: 0;
    border: none;
    background: none;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary, #5B4B8A);
    cursor: pointer;
    padding: 0.1rem 0.2rem;
    white-space: nowrap;
}
.harmony-open-reader:hover { text-decoration: underline; }

.harmony-verses {
    /* generous foot so a revealed tool capsule on the last verse
       stays inside the scroll cage (FEAT-026) */
    padding: 0.5rem 0.75rem 2.6rem;
    overflow-y: auto;
    max-height: 30rem;
}
.harmony-verses-loading {
    padding: 0.8rem 0.3rem;
    color: var(--text-secondary, #6B5D54);
    font-size: 0.85rem;
    font-style: italic;
}

/* Verse cards inside witness cards: reader styling, slightly compacted */
.harmony-verses .verse-container { margin-bottom: 0.55rem; }

.harmony-silent-body {
    padding: 1.1rem 0.9rem 1.2rem;
    color: var(--text-secondary, #6B5D54);
    font-style: italic;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.harmony-silent-pointer { font-size: 0.82rem; }
.harmony-silent-pointer .bible-ref-link { font-style: normal; }

.harmony-extra-refs {
    grid-column: 1 / -1;
    font-size: 0.8rem;
    color: var(--text-secondary, #6B5D54);
    padding: 0.1rem 0.2rem;
}

/* ── Commentary band (desktop) / 5th pane (mobile) ─────────────────── */

.harmony-commentary-band {
    grid-column: 1 / -1;
    background: var(--gold-bg, rgba(255, 248, 220, 0.35));
    border: 1px solid var(--gold-border, rgba(210, 170, 50, 0.35));
    border-left: 4px solid var(--gold, #D4A017);
    border-radius: 8px;
    padding: 0.8rem 1rem 0.9rem;
}
.harmony-commentary-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold-text, #8a6a00);
    margin-bottom: 0.45rem;
}
.harmony-commentary-pane { display: none; }
.harmony-commentary-pane.active { display: block; }
.harmony-commentary-text p {
    margin: 0 0 0.7rem;
    line-height: 1.65;
    color: var(--text-primary, #2C2416);
    font-size: 0.92rem;
}
.harmony-commentary-text p:last-child { margin-bottom: 0.4rem; }
.harmony-commentary-accreditation {
    font-size: 0.78rem;
    font-style: italic;
    color: var(--text-secondary, #6B5D54);
}
.harmony-commentary-band.empty { opacity: 0.75; }
.harmony-commentary-empty {
    font-style: italic;
    color: var(--text-secondary, #6B5D54);
    font-size: 0.88rem;
}

/* ── Mobile witness deck (chips) ───────────────────────────────────── */

.harmony-deck-chips {
    display: none;
    gap: 0.35rem;
    padding: 0 0 0.6rem;
    max-width: 76rem;
    margin: 0 auto;
}
.harmony-chip {
    flex: 1;
    padding: 0.42rem 0.2rem;
    border: 1px solid var(--border, #E5E1DB);
    border-top-width: 3px;
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text-secondary, #6B5D54);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}
.harmony-chip-mark       { border-top-color: var(--harmony-mark); }
.harmony-chip-matthew    { border-top-color: var(--harmony-matthew); }
.harmony-chip-luke       { border-top-color: var(--harmony-luke); }
.harmony-chip-john       { border-top-color: var(--harmony-john); }
.harmony-chip-commentary { border-top-color: var(--gold, #D4A017); }
.harmony-chip.active {
    color: var(--text-primary, #2C2416);
    background: rgba(var(--primary-rgb, 91,75,138), 0.07);
    border-color: var(--primary-light, #7C6BA6);
}
.harmony-chip-mark.active       { border-top-color: var(--harmony-mark); }
.harmony-chip-matthew.active    { border-top-color: var(--harmony-matthew); }
.harmony-chip-luke.active       { border-top-color: var(--harmony-luke); }
.harmony-chip-john.active       { border-top-color: var(--harmony-john); }
.harmony-chip-commentary.active { border-top-color: var(--gold, #D4A017); }
.harmony-chip.silent { opacity: 0.55; }

/* ── Mobile scrubber ───────────────────────────────────────────────── */

.harmony-scrubber {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.9rem;
    border-top: 1px solid var(--border, #E5E1DB);
    background: var(--surface, #fff);
    flex-shrink: 0;
}
.harmony-scrub-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    min-width: 0;
}
.harmony-scrub-counter { font-size: 0.85rem; font-weight: 600; color: var(--text-primary, #2C2416); }
.harmony-scrub-period {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-secondary, #6B5D54);
}

/* ── Period event picker ───────────────────────────────────────────── */

.harmony-picker {
    position: absolute;
    top: 7.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: min(560px, 92%);
    max-height: min(28rem, 60vh);
    background: var(--surface, #fff);
    border: 1px solid var(--border, #E5E1DB);
    border-radius: 10px;
    box-shadow: var(--shadow-lg, 0 10px 30px rgba(0,0,0,0.12));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 5;
}

.harmony-picker-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border, #E5E1DB);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-secondary, #6B5D54);
}
.harmony-picker-count { margin-left: auto; font-weight: 500; opacity: 0.8; }
.harmony-picker-close {
    border: none;
    background: none;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary, #6B5D54);
    padding: 0 0.2rem;
}
.harmony-picker-close:hover { color: var(--text-primary, #2C2416); }

.harmony-picker-list { overflow-y: auto; padding: 0.35rem; }

.harmony-picker-item {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-primary, #2C2416);
}
.harmony-picker-item:hover { background: rgba(var(--primary-rgb, 91,75,138), 0.07); }
.harmony-picker-item.active { background: rgba(var(--primary-rgb, 91,75,138), 0.12); }

.harmony-picker-sect {
    flex-shrink: 0;
    width: 3.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary, #6B5D54);
}
.harmony-picker-title { font-size: 0.9rem; line-height: 1.35; }

/* ── Event toolbar (masthead) — the event layer's tag/note/bookmark ── */

.harmony-event-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 0.4rem;
}
.harmony-event-tag-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: 0.2rem;
}
.harmony-event-tag-dots:empty { display: none; }
.harmony-event-tag-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

/* Tagged ribbon dots — the ribbon as a topical map. Color comes inline
   from the tag; the ring makes tiny dots readable at ribbon scale. */
.harmony-dot.tagged {
    box-shadow: 0 0 0 1.5px var(--surface, #fff), 0 0 0 2.5px currentColor;
}

/* Bookmarked events show the flag in the period picker rows */
.harmony-picker-bookmark {
    flex-shrink: 0;
    margin-left: auto;
    color: var(--primary, #5B4B8A);
    display: inline-flex;
}

/* ── Tag-sidebar Harmony ref (mirrors .tag-isbe-ref in isbe-modal.css) ── */
.tag-harmony-ref {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-primary);
    transition: background 0.12s;
}
.tag-harmony-ref:hover {
    background: var(--highlight);
    color: var(--primary);
}
.tag-harmony-unassign {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    opacity: 0;
    padding: 0 2px;
    line-height: 1;
    margin-left: auto;
    flex-shrink: 0;
}
.tag-harmony-ref:hover .tag-harmony-unassign { opacity: 1; }
.tag-harmony-unassign:hover { color: var(--danger); }

/* ── The event selector (approved mock 2026-09-01): full sheet — every
   period a gold eyebrow, every event a row, searchable, your place in
   purple. Opened from the scrubber pill / event title on phones. ── */
.harmony-selector {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 12%;
    z-index: 60;
    background: var(--surface);
    border-radius: 18px 18px 0 0;
    border-top: 1px solid var(--border);
    box-shadow: 0 -16px 50px rgba(0, 0, 0, 0.28);
    display: none;
    flex-direction: column;
}
.harmony-selector-handle {
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: var(--border);
    margin: 0.55rem auto 0.35rem;
    flex-shrink: 0;
}
.harmony-selector-search {
    margin: 0.35rem 0.9rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.5rem 0.95rem;
    font-family: Inter, -apple-system, sans-serif;
    font-size: 16px; /* iOS zoom guard */
    color: var(--text-primary);
    background: var(--background);
    outline: none;
    flex-shrink: 0;
}
.harmony-selector-search:focus { border-color: var(--primary); }
.harmony-selector-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.6rem 1.1rem;
    -webkit-overflow-scrolling: touch;
}
.harmony-selector-period {
    font-family: Inter, -apple-system, sans-serif;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold-text);
    padding: 0.75rem 0.35rem 0.3rem;
}
.harmony-selector-item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    padding: 0.48rem 0.5rem;
    border-radius: 9px;
    font-family: Inter, -apple-system, sans-serif;
    font-size: 0.86rem;
    color: var(--text-primary);
    cursor: pointer;
}
.harmony-selector-item:hover { background: rgba(var(--primary-rgb), 0.08); }
.harmony-selector-item.active { background: var(--primary); color: #fff; }
.harmony-selector-sect {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    flex-shrink: 0;
    min-width: 2.3rem;
}
.harmony-selector-item.active .harmony-selector-sect { color: rgba(255, 255, 255, 0.75); }
.harmony-selector-title { min-width: 0; }
.harmony-selector-bookmark { margin-left: auto; flex-shrink: 0; display: inline-flex; }
.harmony-selector-bookmark svg { width: 13px; height: 13px; color: var(--gold); }
.harmony-selector-item.active .harmony-selector-bookmark svg { color: #fff; }

/* the scrubber's center is a door now */
.harmony-scrub-pill {
    border: 1px solid var(--border);
    background: var(--background);
    border-radius: 12px;
    padding: 0.28rem 0.7rem;
    cursor: pointer;
}
.harmony-scrub-pill::after {
    content: '▾';
    display: block;
    text-align: center;
    color: var(--primary);
    font-size: 0.62rem;
    line-height: 0.7;
}

/* ── Mobile ────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .harmony-modal { width: 100vw; height: 100dvh; }
    .harmony-title-full { display: none; }
    .harmony-title-short { display: inline; }

    /* ribbon yields to the bottom scrubber on phones */
    .harmony-ribbon { display: none; }
    .harmony-scrubber { display: flex; }

    .harmony-masthead { padding: 0.6rem 0.75rem 0.45rem; gap: 0.5rem; }
    /* steppers live in the scrubber on mobile — one pair, not two */
    .harmony-masthead .harmony-step { display: none; }
    .harmony-event-title { font-size: 1.1rem; }
    .harmony-meta { font-size: 0.6rem; }

    .harmony-content { padding: 0.5rem 0.75rem 0.9rem; }
    .harmony-picker { top: 5.5rem; }

    /* deck mode: chips on, one pane at a time, no inner scroll cage */
    .harmony-deck-chips { display: flex; }
    .harmony-witness-area { display: block; }
    .harmony-witness-card,
    .harmony-commentary-band { display: none; }
    .harmony-witness-card.pane-active,
    .harmony-commentary-band.pane-active { display: flex; flex-direction: column; }
    .harmony-commentary-band.pane-active { display: block; }
    .harmony-verses { max-height: none; overflow-y: visible; }
    .harmony-extra-refs { padding: 0.5rem 0.2rem 0; }
}

