/*
 * Diabec Blog — floating nav helpers:
 *   .dbb-blog   → Back-to-Blog pill (top-left, revealed past nav)
 *   .dbb-prev   → Previous-post side arrow (desktop fixed left)
 *   .dbb-next   → Next-post side arrow (desktop fixed right)
 *   .dbb-totop  → Scroll-to-top button (bottom-right, revealed on scroll)
 *   .dbb-mobile-nav → Mobile-only prev/next footer cards (below the article)
 */

/* ─────── Top-left Home pill ─────── */
.dbb-back {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 9997;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: #2c3e1f;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 14px 8px 12px;
    border-radius: 999px;
    border: 1px solid #d8d2c4;
    box-shadow: 0 4px 14px rgba(44, 62, 31, 0.18);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease, background .15s ease;
    font-family: inherit;
}

.dbb-back.dbb-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.dbb-back:hover { background: #f4f1ea; color: #2c3e1f; }
.dbb-back:focus-visible { outline: 3px solid #c8a96e; outline-offset: 2px; }
.dbb-back svg { width: 14px; height: 14px; fill: currentColor; }

/* ─────── Mid-right scroll-to-top (sits at vertical centre, between chevron and FAB) ─────── */
.dbb-totop {
    position: fixed;
    top: 50%;
    right: 16px;
    z-index: 9997;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #2c3e1f;
    color: #fff;
    border: 2px solid #c8a96e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(calc(-50% + 8px));
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease, background .15s ease;
    font-family: inherit;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.dbb-totop.dbb-visible {
    opacity: 1;
    transform: translateY(-50%);
    pointer-events: auto;
}

.dbb-totop:hover { background: #3d5430; }
.dbb-totop:focus-visible { outline: 3px solid #c8a96e; outline-offset: 3px; }
.dbb-totop svg { width: 18px; height: 18px; fill: currentColor; }

/* .dbb-totop now lives at mid-right (just below next-chevron), so it
   no longer competes with the bottom-right voice-agent FAB. The legacy
   sibling/has() shift is therefore unnecessary. */

@media (max-width: 600px) {
    .dbb-back {
        top: 10px;
        left: 10px;
        font-size: 13px;
        padding: 7px 12px 7px 10px;
    }
    .dbb-totop {
        /* On mobile, revert to traditional bottom-right (no chevrons present;
           mobile prev/next is rendered as footer cards) and clear the FAB.
           FAB on mobile is 56px high + 16px bottom = top at 72px. Adding ~40px
           gap lands totop bottom at 112px. */
        top: auto;
        bottom: calc(112px + env(safe-area-inset-bottom, 0px));
        right: 12px;
        transform: none;
    }
    .dbb-totop.dbb-visible { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .dbb-back, .dbb-totop { transition: none; }
}

@media print {
    .dbb-back, .dbb-totop, .dbb-blog, .dbb-prev, .dbb-next, .dbb-mobile-nav { display: none !important; }
}

/* ─────── Top-left Back-to-Blog pill ─────── */
.dbb-blog {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 9996;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: #2c3e1f;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 14px 8px 12px;
    border-radius: 999px;
    border: 1px solid #d8d2c4;
    box-shadow: 0 4px 14px rgba(44, 62, 31, 0.18);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease, background .15s ease;
    font-family: inherit;
}

.dbb-blog.dbb-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.dbb-blog:hover { background: #f4f1ea; color: #2c3e1f; }
.dbb-blog:focus-visible { outline: 3px solid #c8a96e; outline-offset: 2px; }
.dbb-blog svg { width: 14px; height: 14px; fill: currentColor; }

/* ─────── Side arrows (desktop) ─────── */
.dbb-prev,
.dbb-next {
    position: fixed;
    top: 38%;
    transform: translateY(-50%);
    z-index: 9995;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    color: #2c3e1f;
    border: 1px solid #d8d2c4;
    box-shadow: 0 4px 14px rgba(44, 62, 31, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
    -webkit-tap-highlight-color: transparent;
}

.dbb-prev { left: 16px; }
.dbb-next { right: 16px; }

.dbb-prev:hover,
.dbb-next:hover {
    background: #f4f1ea;
    transform: translateY(-50%) scale(1.06);
    box-shadow: 0 6px 18px rgba(44, 62, 31, 0.24);
}

.dbb-prev:focus-visible,
.dbb-next:focus-visible { outline: 3px solid #c8a96e; outline-offset: 3px; }

.dbb-prev svg,
.dbb-next svg { width: 18px; height: 18px; fill: currentColor; }

/* Tooltip on hover/focus — shows the prev/next post title */
.dbb-prev[data-title]::after,
.dbb-next[data-title]::after {
    content: attr(data-title);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #2c3e1f;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease;
}
.dbb-prev[data-title]::after { left: calc(100% + 10px); }
.dbb-next[data-title]::after { right: calc(100% + 10px); }
.dbb-prev:hover[data-title]::after,
.dbb-prev:focus-visible[data-title]::after,
.dbb-next:hover[data-title]::after,
.dbb-next:focus-visible[data-title]::after { opacity: 1; }

/* ─────── Mobile prev/next footer cards (≤768px replaces side arrows) ─────── */
.dbb-mobile-nav {
    display: none;
    margin: 2.5rem auto 1rem;
    padding: 0 1rem;
    max-width: 720px;
    gap: 0.75rem;
    grid-template-columns: 1fr 1fr;
}

.dbb-mobile-nav a {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.85rem 1rem;
    background: #fff;
    border: 1px solid #d8d2c4;
    border-radius: 10px;
    text-decoration: none;
    color: #2c3e1f;
    box-shadow: 0 2px 8px rgba(44, 62, 31, 0.06);
    min-height: 44px;
}

.dbb-mobile-nav a:hover { background: #f4f1ea; }
.dbb-mobile-nav a:focus-visible { outline: 3px solid #c8a96e; outline-offset: 2px; }

.dbb-mobile-nav .dbb-mn-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #7e632a;
}

.dbb-mobile-nav .dbb-mn-title {
    font-size: 0.92rem;
    line-height: 1.35;
    color: #2c3e1f;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dbb-mobile-nav .dbb-mn-next { text-align: right; }

@media (max-width: 768px) {
    .dbb-prev,
    .dbb-next { display: none; }
    .dbb-mobile-nav { display: grid; }
}

@media (max-width: 600px) {
    .dbb-blog {
        top: 10px;
        left: 10px;
        font-size: 13px;
        padding: 7px 12px 7px 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dbb-blog, .dbb-prev, .dbb-next, .dbb-mobile-nav a {
        transition: none;
    }
    .dbb-prev:hover, .dbb-next:hover { transform: translateY(-50%); }
}
