/* Extracted from ui/templates/components/student_stories/list.html. Linked via sekizai so a page loads it once,
   however many instances it renders. */

.student-stories-full-bleed {
    width: 100%;
    overflow-x: clip;
    font-family: "NYU Perstare", system-ui, sans-serif;
}

.student-stories-wide-inner {
    width: 100%;
    max-width: none;
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
}

/* One list of stories in reading order. Phones: a single column. lg and up: two columns filled
   left, right, left, right..., with the right-hand stories dropped 8rem to stagger them. */
.student-stories-grid {
    --story-stagger: 8rem;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 40px;
    align-items: start;
}

/* Spacing comes from the grid's row-gap, not the bubble's own mb-16. */
.student-stories-item > .story-item {
    margin-bottom: 0;
}

@media (min-width: 1024px) {
    .student-stories-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: clamp(48px, 4.8vw, 84px);
    }

    /* transform, not margin, so the drop doesn't widen the gaps under the left-hand stories. */
    .student-stories-item.is-right {
        transform: translateY(var(--story-stagger));
    }

    /* transform doesn't take up space, so make room when the last story is a dropped one. */
    .student-stories-grid.ends-right {
        padding-bottom: var(--story-stagger);
    }
}

.story-bubble {
    --story-tail-height: 58px;
    position: relative;
    isolation: isolate;
    min-height: var(--story-bubble-height, 216px);
    padding: var(--story-bubble-padding, 46px 56px calc(46px + var(--story-tail-height)));
    color: #333333;
    background: #ffffff;
    border: 0;
    clip-path: var(--story-bubble-shape);
    font-family: "NYU Perstare", system-ui, sans-serif;
}

.story-bubble p {
    margin-bottom: 0.85rem;
    line-height: 1.35;
}

.story-bubble,
.story-bubble .quote-content,
.story-author {
    font-family: "NYU Perstare", system-ui, sans-serif;
}

.story-bubble p:last-child {
    margin-bottom: 0 !important;
}
  
.story-bubble p:empty,
.story-bubble p:has(> br:only-child) {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.story-bubble br {
    display: none !important;
}
  
.story-bubble.theme-white strong,
.story-bubble.theme-white b,
.story-bubble.theme-white em,
.story-bubble.theme-outline strong,
.story-bubble.theme-outline b,
.story-bubble.theme-outline em {
    color: #57068C;
    font-style: italic;
    font-weight: 700;
}
  
.story-bubble.theme-purple strong,
.story-bubble.theme-purple b,
.story-bubble.theme-purple em {
    color: #ffffff;
    font-style: italic;
    font-weight: 800;
}
  
.bubble-wrap {
    --story-tail-height: 58px;
    --story-tail-shelf: 36px;
    --story-tail-root: 66%;
    --story-author-left: calc(var(--story-tail-root) - 92px);
    --story-bubble-shape: polygon(0 0, 100% 0, 100% calc(100% - var(--story-tail-height) - 54px), calc(100% - 48px) calc(100% - var(--story-tail-height)), 83% calc(100% - var(--story-tail-height)), var(--story-tail-root) 100%, var(--story-tail-root) calc(100% - var(--story-tail-height)), 0 calc(100% - var(--story-tail-height)));
}

.bubble-wrap.tail-left {
    --story-tail-root: 34%;
    --story-author-left: calc(var(--story-tail-root) + 92px);
    --story-bubble-shape: polygon(0 0, 100% 0, 100% calc(100% - var(--story-tail-height)), var(--story-tail-root) calc(100% - var(--story-tail-height)), var(--story-tail-root) 100%, 17% calc(100% - var(--story-tail-height)), 48px calc(100% - var(--story-tail-height)), 0 calc(100% - var(--story-tail-height) - 54px));
}

.bubble-wrap.tail-right {
    --story-tail-root: 66%;
    --story-author-left: calc(var(--story-tail-root) - 92px);
    --story-bubble-shape: polygon(0 0, 100% 0, 100% calc(100% - var(--story-tail-height) - 54px), calc(100% - 48px) calc(100% - var(--story-tail-height)), 83% calc(100% - var(--story-tail-height)), var(--story-tail-root) 100%, var(--story-tail-root) calc(100% - var(--story-tail-height)), 0 calc(100% - var(--story-tail-height)));
}

.story-bubble.theme-purple {
    background: #9100E4;
    color: #ffffff;
}

.story-bubble.theme-purple,
.story-bubble.theme-purple .quote-content,
.story-bubble.theme-purple .quote-content *,
.story-bubble.theme-purple p {
    color: #ffffff !important;
}

.story-bubble.theme-outline {
    background: #D3D3D3;
}

.story-bubble.theme-outline::before {
    content: "";
    position: absolute;
    inset: 1px;
    z-index: -1;
    background: #F7F7F7;
    clip-path: var(--story-bubble-shape);
}

.story-bubble.theme-outline::after {
    content: "";
    position: absolute;
    left: var(--story-tail-root);
    bottom: 0;
    z-index: 0;
    width: 1px;
    height: var(--story-tail-height);
    background: #D3D3D3;
    transform: translateX(-0.5px);
    pointer-events: none;
}

.story-bubble.theme-outline .story-bubble__inner {
    display: flex;
    position: relative;
    z-index: 1;
    min-height: calc(var(--story-bubble-height, 216px) - var(--story-tail-height) - 92px);
    width: 100%;
    align-items: center;
}

.story-bubble.theme-white .story-bubble__inner,
.story-bubble.theme-purple .story-bubble__inner {
    display: flex;
    min-height: calc(var(--story-bubble-height, 216px) - var(--story-tail-height) - 92px);
    align-items: center;
}

.story-author {
    position: absolute;
    top: calc(100% - var(--story-tail-height) + 10px);
    /* Set by student-stories.js to the enclosing row's colour; see paintStoryAuthorBackgrounds(). */
    background-color: var(--story-author-bg, transparent);
    left: clamp(116px, var(--story-author-left), calc(100% - 116px));
    margin-left: 0;
    transform: translateX(-50%);
    z-index: 30;
}

@media (max-width: 767px) {
    .story-bubble {
        --story-tail-height: 60px;
        min-height: 0;
        padding: 32px 28px calc(32px + var(--story-tail-height));
    }

    .story-bubble.theme-outline {
        padding: 32px 28px calc(32px + var(--story-tail-height));
    }

    .story-bubble.theme-outline .story-bubble__inner {
        min-height: 0;
    }

    .bubble-wrap,
    .bubble-wrap.tail-left,
    .bubble-wrap.tail-right {
        --story-tail-height: 60px;
        --story-tail-root: 58%;
        --story-author-left: calc(var(--story-tail-root) - 24px);
        --story-bubble-shape: polygon(0 0, 100% 0, 100% calc(100% - var(--story-tail-height) - 42px), calc(100% - 38px) calc(100% - var(--story-tail-height)), 76% calc(100% - var(--story-tail-height)), var(--story-tail-root) 100%, var(--story-tail-root) calc(100% - var(--story-tail-height)), 0 calc(100% - var(--story-tail-height)));
    }

    .bubble-wrap.tail-left {
        --story-tail-root: 42%;
        --story-author-left: calc(var(--story-tail-root) + 24px);
        --story-bubble-shape: polygon(0 0, 100% 0, 100% calc(100% - var(--story-tail-height)), var(--story-tail-root) calc(100% - var(--story-tail-height)), var(--story-tail-root) 100%, 24% calc(100% - var(--story-tail-height)), 38px calc(100% - var(--story-tail-height)), 0 calc(100% - var(--story-tail-height) - 42px));
    }

    .bubble-wrap.tail-right {
        --story-tail-root: 58%;
        --story-author-left: calc(var(--story-tail-root) - 24px);
        --story-bubble-shape: polygon(0 0, 100% 0, 100% calc(100% - var(--story-tail-height) - 42px), calc(100% - 38px) calc(100% - var(--story-tail-height)), 76% calc(100% - var(--story-tail-height)), var(--story-tail-root) 100%, var(--story-tail-root) calc(100% - var(--story-tail-height)), 0 calc(100% - var(--story-tail-height)));
    }

    .story-author {
        top: calc(100% - var(--story-tail-height) + 10px);
        left: clamp(82px, var(--story-author-left), calc(100% - 82px));
        margin-left: 0;
    }

    .bubble-wrap.has-headshot .story-author,
    .bubble-wrap.no-headshot .story-author {
        transform: none;
    }

    .bubble-wrap.tail-left .story-author {
        left: auto;
        right: 36px;
        transform: none;
    }

    .bubble-wrap.tail-right .story-author {
        left: 36px;
        right: auto;
        transform: none;
    }
}
