/* ==========================================================================
   Stories viewer — card deck, progress bars, tap zones
   Scoped under .stories-viewer so the rail and hub instances can coexist.
   ========================================================================== */

.stories-viewer {
    --sv-red: #d81f26;          /* Forbes red */
    --sv-ink: #0f0f0f;
    --sv-paper: #ffffff;
    --sv-radius: 14px;
    --sv-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
    /* Height of the reserved first-run hint row at the frame's foot. */
    --sv-hint-band: 30px;
    --sv-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: none;
}

.stories-viewer.is-open {
    display: block;
}

/* --- stage ---------------------------------------------------------------- */

.sv-stage {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(8, 8, 10, 0.94);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

/* Rail mode renders inline within the host article instead of as a takeover. */
.stories-viewer--inline .sv-stage {
    position: relative;
    inset: auto;
    z-index: 1;
    background: transparent;
    backdrop-filter: none;
    padding: 0;
}

.sv-frame {
    position: relative;
    width: min(430px, 100%);
    aspect-ratio: 9 / 16;
    max-height: calc(100vh - 32px);
    background: #111;
    border-radius: var(--sv-radius);
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
    will-change: transform;
}

.stories-viewer--inline .sv-frame {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
}

/* --- progress ------------------------------------------------------------ */

.sv-progress {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 6;
    display: flex;
    gap: 4px;
}

.sv-seg {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.32);
    overflow: hidden;
}

.sv-seg-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--sv-paper);
    border-radius: 2px;
}

/* --- header -------------------------------------------------------------- */

.sv-head {
    position: absolute;
    top: 24px;
    left: 14px;
    right: 14px;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sv-brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.sv-wordmark {
    font-family: var(--sv-serif);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--sv-paper);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.sv-kicker {
    font-family: var(--sv-sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.82);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sv-head-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.sv-btn {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: var(--sv-paper);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background 160ms ease;
}

.sv-btn:hover {
    background: rgba(0, 0, 0, 0.65);
}

.sv-btn:focus-visible {
    outline: 2px solid var(--sv-paper);
    outline-offset: 2px;
}

/* Pause glyph: two bars, becoming a triangle when paused. */
.sv-pause-icon {
    width: 10px;
    height: 11px;
    border-left: 3px solid currentColor;
    border-right: 3px solid currentColor;
}

.stories-viewer.is-paused .sv-pause-icon {
    width: 0;
    height: 0;
    border-left: 9px solid currentColor;
    border-right: none;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    margin-left: 3px;
}

/* --- cards --------------------------------------------------------------- */

/* Bottom inset reserves the hint row so card content never sits under it. */
.sv-cards {
    position: absolute;
    inset: 0 0 var(--sv-hint-band) 0;
}

.sv-card {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* Media and scrim bleed past the reserved hint row to the frame's edge. */
.sv-media {
    position: absolute;
    inset: 0 0 calc(-1 * var(--sv-hint-band)) 0;
}

.sv-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sv-scrim {
    position: absolute;
    inset: 0 0 calc(-1 * var(--sv-hint-band)) 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.55) 0%,
        rgba(0, 0, 0, 0.1) 32%,
        rgba(0, 0, 0, 0.55) 68%,
        rgba(0, 0, 0, 0.88) 100%
    );
}

.sv-content {
    position: relative;
    z-index: 4;
    padding: 22px 22px 30px;
    color: var(--sv-paper);
}

.sv-headline {
    font-family: var(--sv-serif);
    font-size: clamp(22px, 6.2vw, 30px);
    line-height: 1.16;
    font-weight: 700;
    margin: 0 0 10px;
    text-wrap: balance;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.sv-body {
    font-family: var(--sv-sans);
    font-size: 15px;
    line-height: 1.5;
    margin: 0;
    color: rgba(255, 255, 255, 0.93);
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.sv-card--cover .sv-headline {
    font-size: clamp(26px, 7.4vw, 36px);
}

/* A red rule above cover headlines, the one overtly Forbes-ish flourish. */
.sv-card--cover .sv-content::before {
    content: '';
    display: block;
    width: 44px;
    height: 4px;
    background: var(--sv-red);
    margin-bottom: 14px;
}

.sv-quote {
    margin: 0;
}

.sv-quote p {
    font-family: var(--sv-serif);
    font-size: clamp(20px, 5.6vw, 27px);
    line-height: 1.3;
    font-style: italic;
    margin: 0 0 12px;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.sv-quote p::before {
    content: '\201C';
    color: var(--sv-red);
}

.sv-quote p::after {
    content: '\201D';
    color: var(--sv-red);
}

.sv-quote cite {
    font-family: var(--sv-sans);
    font-size: 12px;
    font-style: normal;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.78);
}

.sv-meta {
    display: flex;
    gap: 14px;
    margin-top: 14px;
    font-family: var(--sv-sans);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
}

.sv-cta {
    position: relative;
    z-index: 7;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 18px;
    padding: 11px 18px;
    background: var(--sv-paper);
    color: var(--sv-ink);
    font-family: var(--sv-sans);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 999px;
    transition: transform 160ms ease;
}

.sv-cta::after {
    content: '\2192';
}

.sv-cta:hover {
    transform: translateY(-1px);
}

/* --- ad card ------------------------------------------------------------- */

.sv-card--ad {
    /* Ads have no media to bleed, so reclaim the reserved hint row and stay
       optically centred in the frame. */
    inset: 0 0 calc(-1 * var(--sv-hint-band)) 0;
    background: #16171a;
    align-items: center;
    justify-content: center;
}

.sv-ad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 24px;
}

.sv-ad-label,
.sv-ad-note {
    font-family: var(--sv-sans);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
}

.sv-ad-slot {
    width: 300px;
    min-height: 250px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
}

.sv-house {
    width: 300px;
    height: 250px;
    display: flex;
    flex-direction: column;
    background: linear-gradient(150deg, #23252b, #14151a);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 8px;
    overflow: hidden;
}

.sv-house-art {
    flex: 1;
    background:
        radial-gradient(circle at 30% 35%, rgba(216, 31, 38, 0.55), transparent 58%),
        radial-gradient(circle at 72% 66%, rgba(90, 120, 255, 0.4), transparent 58%);
}

.sv-house-copy {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: var(--sv-sans);
}

.sv-house-copy strong {
    font-size: 15px;
    color: var(--sv-paper);
}

.sv-house-copy span {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

/* --- tap zones ----------------------------------------------------------- */

.sv-zone {
    position: absolute;
    top: 58px;
    bottom: 0;
    z-index: 5;
    border: none;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sv-zone--prev {
    left: 0;
    width: 30%;
}

.sv-zone--next {
    right: 0;
    width: 70%;
}

/* --- transitions --------------------------------------------------------- */

@keyframes svInNext {
    from { opacity: 0; transform: scale(1.03); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes svInPrev {
    from { opacity: 0; transform: scale(0.98); }
    to   { opacity: 1; transform: scale(1); }
}

.sv-in-next { animation: svInNext 260ms ease both; }
.sv-in-prev { animation: svInPrev 260ms ease both; }

/* --- hint ---------------------------------------------------------------- */

/*
 * First-run affordance. Cards reserve a row for it via .sv-cards bottom inset,
 * so it never overlaps card content — the cover card's byline sits in exactly
 * this band, and an overlap there read as a bug.
 */
.sv-hint {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    z-index: 6;
    display: flex;
    justify-content: center;
    gap: 16px;
    font-family: var(--sv-sans);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
    animation: svHintFade 600ms ease 5s forwards;
}

@keyframes svHintFade {
    to { opacity: 0; }
}

/* ==========================================================================
   Tap affordance — an animated finger on the first story card, encouraging the
   tap into a story. Shared by the hub and the article rail. Shown only on touch
   pointers, only on the first card, and retired once the reader engages
   (see hub.js / rail.js).
   ========================================================================== */

/* Sits low-centre, clear of the card-count badge and of most focal subjects. */
.sv-tap-hint {
    position: absolute;
    left: 50%;
    bottom: 14%;
    transform: translateX(-50%);
    z-index: 3;
    width: 60px;
    height: 78px;
    pointer-events: none;
}

/* Expanding ring, as though a tap just landed. */
.sv-tap-hint::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 10px;
    margin-left: -17px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.9);
    animation: svTapRing 2.1s ease-out infinite;
}

.sv-tap-finger {
    position: absolute;
    left: 50%;
    top: 4px;
    margin-left: -21px;
    width: 42px;
    height: 42px;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.5));
    animation: svTapPress 2.1s ease-in-out infinite;
}

@keyframes svTapRing {
    0%        { transform: scale(0.5); opacity: 0; }
    18%       { transform: scale(0.5); opacity: 0.95; }
    55%, 100% { transform: scale(2.1); opacity: 0; }
}

@keyframes svTapPress {
    0%, 100% { transform: translate(0, 0) scale(1); }
    14%      { transform: translate(-3px, -5px) scale(0.94); }
    30%      { transform: translate(0, 0) scale(1); }
}

.sv-tap-label {
    position: absolute;
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(4px);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Pointer devices get the hover treatment instead; no finger. */
@media (hover: hover) and (pointer: fine) {
    .sv-tap-hint {
        display: none;
    }
}


@media (prefers-reduced-motion: reduce) {
    /* Keep the affordance, drop the motion — the label still communicates it. */
    .sv-tap-hint::before,
    .sv-tap-finger {
        animation: none;
    }
}

/* --- debug overlay ------------------------------------------------------- */

.stories-debug {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 3000;
    width: 210px;
    background: rgba(14, 15, 18, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    overflow: hidden;
}

.stories-debug__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 11px;
}

.stories-debug__close {
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.stories-debug__body {
    padding: 8px 10px 10px;
}

.stories-debug__row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}

.stories-debug__row .is-ok { color: #4ade80; }
.stories-debug__row .is-under { color: #fbbf24; }

.stories-debug__log {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.45);
    line-height: 1.5;
}

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 480px) {
    .sv-stage { padding: 0; }

    .sv-frame {
        width: 100%;
        height: 100%;
        max-height: none;
        aspect-ratio: auto;
        border-radius: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sv-in-next,
    .sv-in-prev { animation: none; }
    .sv-hint { animation: none; }
    .sv-seg-fill { transition: none !important; }
}
