/*
 * jcts-message-cards.css
 *
 * Card layout for the /Messages/{title} and /Testimony/{title} pages - the Messages and
 * Testimony dropdowns - and for the hand-written card grids on /Home/Events and /Home/Index.
 *
 * The filename says "message-cards" because that is where it started; it now covers all four.
 * The hand-written grids live in their own clearly marked block at the bottom and are opt-in
 * via a `jcts-card-grid` class, because their markup differs from the generated cards - see
 * that block's header.
 *
 * The card markup is generated into App_Data/StaticContent/*.html and injected via
 * @Html.Raw(ViewBag.Table) by Views/Home/Messages.cshtml and Views/Home/Testimony.cshtml, which
 * are the same template rendering out of the same directory. All 29 files come out of the same
 * generator and are structurally identical, so this sheet fixes every page at once - and it
 * fixes them without touching generated content that would be overwritten on the next run.
 *
 * Note the class names below say "testimony" throughout (.testimony-section, and the images'
 * alt='Testimony'). That is the generator's naming on *both* sets of pages, message pages
 * included - it is not a sign this sheet is scoped to the Testimony dropdown only.
 *
 * What was wrong, in the generated markup:
 *   1. The `box-shadow` is an inline style on the *grid column*, not on the card. Bootstrap
 *      columns carry the gutter as padding, so the shadow was painted around the gutter box -
 *      the shadows of adjacent cards butted up against each other and there was no visible gap.
 *   2. `.sermon-body` carries an inline `height: auto` that overrides the `height: 100%` in the
 *      generated stylesheet, so cards in a row never matched heights and their audio players and
 *      Share links sat at different heights.
 *   3. The card box had no padding, so text ran to the edge of the shadow.
 *   4. The image has `.rounded` but the shadowed box is square, so rounded corners sat inside
 *      square ones.
 *   5. A dead `<div id='scrollUp'>` is emitted as a direct child of the `.row` - a non-column
 *      flex child inside the grid. Its CSS is commented out in the generated file and no JS in
 *      wwwroot/js references it, so it is inert; it just perturbs the row.
 *
 * Specificity note: this sheet has to outrank the theme's `.sermon-entry .sermon-body` block
 * at style.css:9321-9330, which reaches 0-3-0 at `.sermon-entry .sermon-body h3`. Selectors
 * here include `.sermon-entry` in the chain wherever the theme also styles that element,
 * putting them a full class above it rather than level with it, so this does not depend on
 * load order.
 *
 * The message/testimony fragments used to carry their own duplicated <style> block, a stray
 * <head>, inline `style` attributes on the column and body, Bootstrap spacing utilities and a
 * dead #scrollUp div - all of which this sheet had to fight with `!important`. Those were
 * removed from the source HTML, so the rules below are now plain declarations. If a future
 * export reintroduces them, the `!important`s come back with it.
 */

/* ---------------------------------------------------------------------------
   Section rhythm
   --------------------------------------------------------------------------- */
.testimony-section {
    padding: 72px 0 80px;
    background: #f8f9fb;
}

.testimony-section .section-title {
    font-size: 32px;
    font-weight: 700;
    color: #2196f3;
    margin: 0;
}

/* Even gutters in both directions; the markup only asks for `g-4` horizontally. */
.testimony-section .row.g-4 {
    --bs-gutter-x: 1.75rem;
    --bs-gutter-y: 1.75rem;
    align-items: stretch;
}

/* Shown instead of the grid on a topic that has no messages yet - currently only
   RenewingtheMind.html. Keeps the section from ending on a bare heading. */
.testimony-section .testimony-empty {
    margin: 0;
    padding: 28px;
    text-align: center;
    font-size: 15px;
    color: #67717f;
    background: #fff;
    border: 1px dashed #dfe4ea;
    border-radius: 14px;
}

/* ---------------------------------------------------------------------------
   1. The column is a flex parent so the card can fill the full height of the
   row - this is what makes equal-height cards possible.
   --------------------------------------------------------------------------- */
.testimony-section .row.g-4 > [class*="col-"] {
    display: flex;
}

.testimony-section .sermon-entry {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #fff;
    border: 1px solid #ecf0f4;
    border-radius: 14px;
    overflow: hidden; /* clips the image to the card's radius */
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.07);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.testimony-section .sermon-entry:hover {
    transform: translateY(-6px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.12);
}

/* ---------------------------------------------------------------------------
   2. Image flush to the top edge. A fixed height keeps every card's text
   starting at the same y.
   --------------------------------------------------------------------------- */
.testimony-section .sermon-entry > img.img-fluid {
    display: block;
    width: 100%;
    height: 200px;
    object-fit: cover;
}

/* ---------------------------------------------------------------------------
   3. Body: real padding, and a column flex context for the bottom-pinning below.
   --------------------------------------------------------------------------- */
.testimony-section .sermon-entry .sermon-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: 22px 22px 20px;
}

.testimony-section .sermon-entry .sermon-body h3 {
    font-size: 16.5px;
    font-weight: 600;
    line-height: 1.45;
    color: #1f2733;
    margin: 0 0 10px;
    /* Reserve two lines so a one-line title does not pull its card's rhythm out of
       step with its neighbours. Longer titles are free to wrap - nothing is clipped. */
    min-height: 2.9em;
}

/* The description absorbs the card's spare vertical space. This is what aligns the
   audio player and Share row across every card in a row, and it does so without
   clamping or truncating any text - short descriptions simply leave a gap below
   themselves rather than pulling the controls up. */
.testimony-section .sermon-excerpt {
    font-size: 14px;
    line-height: 1.75;
    color: #67717f;
    margin: 0 0 auto;
    padding-bottom: 18px;
}

/* ---------------------------------------------------------------------------
   4. Audio + Share pinned to the card bottom as one footer block.
   --------------------------------------------------------------------------- */
.testimony-section .sermon-audio {
    margin-bottom: 14px;
}

    .testimony-section .sermon-audio audio {
        display: block;
        width: 100%;
        height: 40px;
    }

.testimony-section .sermon-share {
    padding-top: 14px;
    border-top: 1px solid #f0f2f5;
}

    .testimony-section .sermon-share a {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        font-size: 13.5px;
        font-weight: 600;
        color: #0d6efd;
        text-decoration: none;
    }

        .testimony-section .sermon-share a:hover {
            text-decoration: underline;
        }

    .testimony-section .sermon-share a i {
        font-size: 15px;
    }

/* =============================================================================
   HAND-WRITTEN CARD GRIDS - opt in with class="jcts-card-grid"
   =============================================================================
 * Currently applied to:
 *   - /Home/Events   "Events" grid          Views/Home/Events.cshtml
 *   - /Home/Index    "Recent Sermons" grid  Views/Home/Index.cshtml
 *
 * Both reuse the same .sermon-entry / .sermon-body class names as the message cards
 * above, but their markup is hand-written in the view rather than generated, and
 * differs in three ways that stop the rules above from being reused directly:
 *
 *   1. There is no .testimony-section wrapper, which is why these views carry a
 *      `jcts-card-grid` class - added for this sheet to hook onto. It is opt-in, so
 *      no other .sermon-entry on the site is touched by anything below.
 *   2. The <img> is wrapped in an <a>, so it is a grandchild of .sermon-entry rather
 *      than a direct child.
 *   3. The body ends in a button ("Join on Zoom" / "Read more") rather than an audio
 *      player plus Share link. Events additionally has a <span class="date">; on the
 *      Home page that span is commented out, so the .date rule simply finds nothing.
 *
 * Unlike the message cards there are no inline styles here, so `!important` is needed
 * only against Bootstrap spacing utilities (mb-2/mb-3/mb-5), which ship !important.
 * ============================================================================= */
/* Scoped to `.row.g-5` - the card row - and deliberately NOT to every `.row` inside the
   section. The Home page's grid sits under a heading row (`.row.mb-4.text-center`) whose
   single col-lg-12 holds a <span> above an <h2>; making that column `display: flex` would
   lay those two out side by side. Both card grids use `g-5`, so this targets exactly them. */
.jcts-card-grid .row.g-5 {
    --bs-gutter-x: 1.75rem;
    --bs-gutter-y: 1.75rem;
    align-items: stretch;
}

.jcts-card-grid .row.g-5 > [class*="col-"] {
    display: flex;
}

.jcts-card-grid .sermon-entry {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #fff;
    border: 1px solid #ecf0f4;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.07);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.jcts-card-grid .sermon-entry:hover {
    transform: translateY(-6px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.12);
}

/* Difference 2: the image sits inside an anchor. */
.jcts-card-grid .sermon-entry > a {
    display: block;
    line-height: 0;
}

.jcts-card-grid .sermon-entry > a > img.img-fluid {
    display: block;
    width: 100%;
    height: 200px;
    object-fit: cover;
    margin-bottom: 0 !important; /* mb-3 */
    border-radius: 0 !important; /* .rounded - the card clips instead */
}

/* The theme sets `.sermon-entry .sermon-body { padding: 20px }` at style.css:9321.
   These selectors carry .sermon-entry too so they outrank it on specificity rather
   than relying on this sheet being loaded later. */
.jcts-card-grid .sermon-entry .sermon-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: 22px 22px 20px;
}

/* Difference 3a: the schedule line, styled as small-caps meta rather than the
   theme's plain grey (style.css:9323). */
.jcts-card-grid .sermon-entry .sermon-body .date {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #2196f3;
    margin-bottom: 8px;
}

.jcts-card-grid .sermon-entry .sermon-body h3 {
    font-size: 16.5px;
    font-weight: 600;
    line-height: 1.45;
    margin: 0 0 10px !important; /* mb-2 */
    /* Two lines reserved: "Counseling for Family Restoration" wraps, the others do
       not, and without this their descriptions would start at different heights. */
    min-height: 2.9em;
}

.jcts-card-grid .sermon-entry .sermon-body h3 a {
    color: #1f2733;
    text-decoration: none;
}

.jcts-card-grid .sermon-entry .sermon-body h3 a:hover {
    color: #0d6efd;
}

/* Same approach as the message cards: the description absorbs the card's spare
   space so every "Join on Zoom" button lands on the card's bottom edge. The view
   currently fakes this with `mb-5` (3rem), which only lines up when the
   descriptions happen to be the same length - they are not. Nothing is truncated. */
.jcts-card-grid .sermon-entry .sermon-body > p:not(:last-child) {
    font-size: 14px;
    line-height: 1.75;
    color: #67717f;
    margin: 0 0 auto !important; /* mb-5 */
    padding-bottom: 18px;
}

/* Difference 3b: button footer, mirroring the Share row on the message cards. */
.jcts-card-grid .sermon-entry .sermon-body > p:last-child {
    margin: 0 !important;
    padding-top: 14px;
    border-top: 1px solid #f0f2f5;
}

.jcts-card-grid .sermon-entry .sermon-body > p:last-child .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13.5px;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 8px;
}

@media (max-width: 575.98px) {
    .jcts-card-grid .sermon-entry > a > img.img-fluid {
        height: 210px;
    }

    .jcts-card-grid .sermon-entry .sermon-body {
        padding: 18px;
    }

    .jcts-card-grid .sermon-entry .sermon-body h3 {
        min-height: 0;
    }
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .testimony-section {
        padding: 56px 0 60px;
    }

    .testimony-section .section-title {
        font-size: 27px;
    }
}

@media (max-width: 575.98px) {
    .testimony-section {
        padding: 44px 0 48px;
    }

    .testimony-section .sermon-entry > img.img-fluid {
        height: 210px;
    }

    .testimony-section .sermon-body {
        padding: 18px;
    }

    /* Single column on phones - reserving two title lines only adds dead space. */
    .testimony-section .sermon-body h3 {
        min-height: 0;
    }
}

/* =============================================================================
   VIDEO GRID - /LatestVideo, Views/Home/LatestVideo.cshtml
   =============================================================================
 * Same card language as everything above, applied to embedded YouTube players.
 *
 * The tile class is `.video-tile`, deliberately NOT `.video-card` - that name is
 * already taken by the scrolling carousel in Views/Home/Index.cshtml, which links
 * this same sheet. Everything is scoped under `.jcts-video-grid` as well, so the
 * two cannot collide either way.
 * ============================================================================= */
.jcts-video-grid {
    padding: 72px 0 80px;
    background: #f5f5f5;
}

.jcts-video-grid .section-title {
    font-size: 32px;
    font-weight: 700;
    color: #2196f3;
    margin: 0;
}

.jcts-video-grid .row.g-4 {
    --bs-gutter-x: 1.75rem;
    --bs-gutter-y: 1.75rem;
    align-items: stretch;
}

.jcts-video-grid .row.g-4 > [class*="col-"] {
    display: flex;
}

.jcts-video-grid .video-tile {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #fff;
    border: 1px solid #ecf0f4;
    border-radius: 14px;
    overflow: hidden; /* clips the player to the card's radius */
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.07);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

    .jcts-video-grid .video-tile:hover {
        transform: translateY(-6px);
        box-shadow: 0 14px 34px rgba(0, 0, 0, 0.12);
    }

/* Fixed 16:9 box.

   The previous rules used `border-radius: 5%` on the wrapper and the iframe. A
   percentage radius resolves separately against width and height, so on a non-square
   box it draws an ellipse - the corners curved much harder horizontally than
   vertically, and differently again at each breakpoint. The card's own 14px radius
   clips the player now, so the frame needs no radius of its own. */
.jcts-video-grid .video-frame {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: #000;
}

    .jcts-video-grid .video-frame iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border: 0;
    }

@media (max-width: 991.98px) {
    .jcts-video-grid {
        padding: 56px 0 60px;
    }

    .jcts-video-grid .section-title {
        font-size: 27px;
    }
}

@media (max-width: 575.98px) {
    .jcts-video-grid {
        padding: 44px 0 48px;
    }
}
