/* ============================================================
   Web Stories — Styles
   Covers: story circles, skeleton, story viewer modal.
   All selectors are namespaced (hb-sv-*, hb-story__*)
   to avoid collisions with existing styles.
   ============================================================ */

/* -------------------------------------------------------
   Story circle — ring wrapper
   The ring element carries the gradient / muted background.
   Inside it sits a white-bordered image container.
   ------------------------------------------------------- */

.hb-story {
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.18s ease;
    width: 92px;
    min-width: 92px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hb-story:hover,
.hb-story:focus {
    transform: translateY(-3px);
}

/* Gradient ring for new/unviewed stories */
.hb-story__ring {
    width: 82px;
    height: 82px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg, #176d66 0%, #0f9688 40%, #1a8c7e 70%, #0d5c5a 100%);
    margin: 0 auto 8px;
    display: block;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

/* Muted ring for viewed stories */
.hb-story--viewed .hb-story__ring,
.hb-story__ring.is-viewed {
    background: #c1cdd0;
}

/* Inner white gap + image container */
.hb-story__ring-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #f5f5f1;   /* matches page bg */
    background: #dce7e8;
    display: block;
}

html[data-theme="dark"] .hb-story__ring-inner {
    border-color: #1e2c2f;
}

/* Circle image */
.hb-story__ring-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.hb-story:hover .hb-story__ring-inner img,
.hb-story:focus .hb-story__ring-inner img {
    transform: scale(1.07);
}

/* Fallback placeholder */
.hb-story__ring-inner--fallback {
    background: #d0dde0;
}

/* Story label (below the ring) */
.hb-story__label {
    display: block;
    color: #6e7e82;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-align: center;
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html[data-theme="dark"] .hb-story__label {
    color: #a0b4b8;
}

/* -------------------------------------------------------
   Skeleton loading
   ------------------------------------------------------- */

.hb-stories-skeleton {
    display: flex;
    gap: 12px;
    padding: 0 42px;
    overflow: hidden;
}

/* Each skeleton circle */
.hb-story-skeleton {
    flex-shrink: 0;
    width: 82px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
}

.hb-story-skeleton::before {
    content: '';
    display: block;
    width: 82px;
    height: 82px;
    border-radius: 50%;
    background: linear-gradient(90deg, #e8ece8 25%, #d4dad4 50%, #e8ece8 75%);
    background-size: 300% 100%;
    animation: hb-shimmer 1.4s infinite linear;
}

.hb-story-skeleton::after {
    content: '';
    display: block;
    width: 60px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #e8ece8 25%, #d4dad4 50%, #e8ece8 75%);
    background-size: 300% 100%;
    animation: hb-shimmer 1.4s infinite linear;
}

@keyframes hb-shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -200% 0; }
}

html[data-theme="dark"] .hb-story-skeleton::before,
html[data-theme="dark"] .hb-story-skeleton::after {
    background: linear-gradient(90deg, #2a3a3e 25%, #344a4e 50%, #2a3a3e 75%);
    background-size: 300% 100%;
    animation: hb-shimmer 1.4s infinite linear;
}

/* -------------------------------------------------------
   Page scroll lock when viewer is open
   ------------------------------------------------------- */

body.hb-story-open {
    overflow: hidden;
}

/* -------------------------------------------------------
   Story Viewer — fullscreen overlay
   ------------------------------------------------------- */

.hb-story-viewer {
    position: fixed;
    inset: 0;
    z-index: 9990;
    display: none;             /* hidden by default */
    justify-content: center;
    align-items: center;
}

.hb-story-viewer.is-open {
    display: flex;
}

/* Backdrop */
.hb-sv-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    cursor: pointer;
}

/* -------------------------------------------------------
   Story card container
   ------------------------------------------------------- */

.hb-sv-container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100svh;             /* safe-area-aware on modern browsers */
    height: 100vh;              /* fallback */
    background: #0a0f10;
    overflow: hidden;
    display: flex;
    flex-direction: column;

    /* Smooth open/close */
    animation: hb-sv-open 0.22s ease both;
}

@keyframes hb-sv-open {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

/* Desktop: centered portrait card */
@media (min-width: 640px) {
    .hb-sv-container {
        width: 400px;
        height: min(88vh, 711px);  /* ~9:16 at 400px wide = 711px */
        border-radius: 18px;
        box-shadow: 0 32px 96px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255,255,255,0.06);
    }
}

/* -------------------------------------------------------
   Progress bars
   ------------------------------------------------------- */

.hb-sv-progress {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
    gap: 3px;
    pointer-events: none;
}

/* One bar per slide */
.hb-sv-bar {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.32);
    border-radius: 100px;
    overflow: hidden;
}

.hb-sv-bar__fill {
    height: 100%;
    width: 0%;
    background: #fff;
    border-radius: 100px;
    /* transition injected inline by JS so we can set exact duration */
    will-change: width;
}

/* -------------------------------------------------------
   Header row
   ------------------------------------------------------- */

.hb-sv-header {
    position: absolute;
    top: 24px;
    left: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.hb-sv-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    overflow: hidden;
    flex: 1;
}

.hb-sv-title {
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-shadow: 0 1px 6px rgba(0,0,0,0.55);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: uppercase;
}

.hb-sv-category {
    display: inline-block;
    background: rgba(23, 109, 102, 0.9);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 2px 8px;
    border-radius: 100px;
    text-transform: uppercase;
    flex-shrink: 0;
    white-space: nowrap;
}

.hb-sv-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.42);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.hb-sv-close:hover,
.hb-sv-close:focus {
    background: rgba(0, 0, 0, 0.72);
    transform: scale(1.08);
    outline: none;
}

/* -------------------------------------------------------
   Navigation zones (invisible, full-height)
   ------------------------------------------------------- */

.hb-sv-nav {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 5;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.hb-sv-nav--prev {
    left: 0;
    width: 32%;
}

.hb-sv-nav--next {
    right: 0;
    width: 68%;
}

/* -------------------------------------------------------
   Slide image
   ------------------------------------------------------- */

.hb-sv-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: opacity 0.28s ease;
    z-index: 1;
    background: #0a0f10;
}

.hb-sv-image.is-loading {
    opacity: 0;
}

/* -------------------------------------------------------
   Bottom gradient (text readability)
   ------------------------------------------------------- */

.hb-sv-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 68%;
    background: linear-gradient(to top,
        rgba(0, 0, 0, 0.9)  0%,
        rgba(0, 0, 0, 0.55) 40%,
        transparent         100%);
    pointer-events: none;
    z-index: 3;
}

/* -------------------------------------------------------
   Content overlay
   ------------------------------------------------------- */

.hb-sv-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 4;
    padding: 16px 18px 32px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;   /* children opt-in below */
}

.hb-sv-headline {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.28;
    letter-spacing: -0.01em;
    text-shadow: 0 1px 8px rgba(0,0,0,0.4);
    display: block;
}

.hb-sv-subheadline {
    color: rgba(255, 255, 255, 0.82);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    display: block;
}

.hb-sv-caption {
    color: rgba(255, 255, 255, 0.68);
    font-size: 12px;
    line-height: 1.55;
    margin: 3px 0 0;
}

.hb-sv-cta {
    display: inline-block;
    align-self: flex-start;
    margin-top: 12px;
    padding: 9px 20px;
    background: #176d66;
    color: #fff !important;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-radius: 100px;
    text-decoration: none;
    pointer-events: auto;      /* override parent's none */
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 14px rgba(23,109,102,0.45);
    -webkit-tap-highlight-color: transparent;
}

.hb-sv-cta:hover,
.hb-sv-cta:focus {
    background: #0f5450;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(23,109,102,0.5);
    outline: none;
    text-decoration: none;
}

/* -------------------------------------------------------
   Responsive fine-tuning
   ------------------------------------------------------- */

@media (max-width: 380px) {
    .hb-sv-headline { font-size: 17px; }
    .hb-sv-cta { font-size: 10px; padding: 8px 16px; }
}

/* Extra-tall phones (landscape) */
@media (max-height: 500px) and (orientation: landscape) {
    .hb-sv-container { height: 100vh; }
    .hb-sv-content   { padding-bottom: 16px; }
    .hb-sv-headline  { font-size: 15px; }
    .hb-sv-subheadline,
    .hb-sv-caption   { display: none; }
}
