/*
 * Chembe template overrides.
 *
 * Loads last. Everything before it is frozen output copied verbatim from the J3/Helix3
 * build and must not be edited - corrections belong here.
 */

/* ---------------------------------------------------------------------------
 * Typography.
 *
 * Helix3 injected these as inline <style> from the template style's `typography`
 * params (Share for h1-h3, Open Sans 300/400/600 for body and h4-h6). That param
 * system is gone, so the bindings are hard-baked to match the captured baseline.
 * --------------------------------------------------------------------------- */
body {
    font-family: 'Open Sans', sans-serif;
    font-weight: 300;
}

h1, h2, h3 {
    font-family: 'Share', sans-serif;
    font-weight: 400;
}

h4 {
    font-family: 'Open Sans', sans-serif;
    font-weight: 400;
}

h5, h6 {
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
}

/* ---------------------------------------------------------------------------
 * Page title band.
 *
 * argo set this per menu item via a Helix3 `page_title_bg_image` param, writing an
 * inline style on every request. Every inner page used the same image, so it belongs
 * in CSS. The image now lives with the template rather than in site /images.
 * --------------------------------------------------------------------------- */
.sp-page-title {
    background-image: url(../images/page-title-bg.jpg);
    background-size: cover;
    background-position: center;
}

/* ---------------------------------------------------------------------------
 * Error page.
 * --------------------------------------------------------------------------- */
.error-page-content {
    padding: 100px 0;
    text-align: center;
}

.error-page-content .error-code {
    font-size: 120px;
    line-height: 1;
    margin: 0 0 20px;
}

/* ---------------------------------------------------------------------------
 * Full-bleed content pages.
 *
 * template.css carries `#sp-main-body { padding: 50px 0 }` plus
 * `.com-sppagebuilder #sp-main-body { padding: 0 }`. All three content pages were
 * SP Page Builder pages, so on the J3 site the padding was always zero and each
 * section supplied its own. As Joomla articles the body class is `com-content`, so
 * the 50px reappears and shifts every section down.
 *
 * Ordinary articles keep the 50px default; the three migrated pages opt out by
 * setting Page Class = "cb-fullbleed" on their menu item.
 * --------------------------------------------------------------------------- */
.cb-fullbleed #sp-main-body {
    padding: 0;
}

/* ---------------------------------------------------------------------------
 * Content sections.
 *
 * Replaces the SP Page Builder addon CSS. Every value below is taken from the
 * captured J3 computed styles (reference/style/home-1280-nojs.json), not from the
 * SPPB JSON, so what is reproduced is what visitors actually saw.
 *
 *   #about-us      padding 20px, margin 0 20px 20px, container 1240px
 *   #case-studies  padding 90px 0 0
 *   #contact       padding 100px 0 50px
 *   heading        48px, uppercase, centred, margin 100px 0 50px
 *   subheading     25.6px, centred
 *   h3 in section  28px, uppercase, left
 *   divider        1px #eee, margin 30px 0
 * --------------------------------------------------------------------------- */
.cb-section {
    padding: 0;
    /* SPPB set these on every section row; reproduced so any absolutely positioned
       child behaves the same. */
    position: relative;
    z-index: 1;
}

.cb-container {
    /* Bootstrap 3's fixed container steps, which is what the SPPB row container used.
       A fluid max-width diverges below 1200px: at 768 the measured J3 content box is
       720px (750 - 2x15 gutter), not the viewport minus padding. */
    margin: 0 auto;
    padding: 0 15px;
}

@media (min-width: 768px)  { .cb-container { width: 750px; } }
@media (min-width: 992px)  { .cb-container { width: 970px; } }
@media (min-width: 1200px) { .cb-container { width: 1170px; } }

.cb-section-about {
    padding: 20px;
    margin: 0 20px 20px;
}

.cb-section-cases {
    padding: 90px 0 0;
}

.cb-section-contact {
    padding: 100px 0 50px;
}

.cb-section-title {
    font-size: 48px;
    line-height: 36px;
    color: #333;
    text-transform: uppercase;
    text-align: center;
    margin: 100px 0 50px;
}

.cb-section-subtitle {
    font-size: 25.6px;
    line-height: 30px;
    text-align: center;
    margin: 0;
    /* J3 rendered this as an inline-block capped at 80%, which is why the line wraps
       where it does. Matching it keeps the line breaks identical. */
    display: inline-block;
    max-width: 80%;
}

.cb-section h3 {
    font-size: 28px;
    color: #333;
    text-transform: uppercase;
    text-align: left;
    margin: 0 0 10px;
}

.cb-text-center {
    text-align: center;
}

/* The divider was its own full-width SPPB section on J3, not part of #about-us, so it
   spans the container rather than the padded section. */
.cb-divider-section {
    padding: 0;
}

.cb-divider {
    /* A 1px rule, not a plain spacer: J3's computed border-bottom-width is 1px in
       #707273, with the element itself 1px tall under border-box sizing. */
    border: 0;
    border-bottom: 1px solid #707273;
    height: 1px;
    overflow: visible;
    color: #707273;
    margin: 30px 0;
}

/* ---------------------------------------------------------------------------
 * Legal pages.
 *
 * The J3 pages used an SPPB 2/10 column split, leaving the prose in the right-hand
 * 10 columns with an empty spacer beside it. The spacer held a module that has been
 * unpublished for years and rendered nothing, so only the offset is reproduced.
 * --------------------------------------------------------------------------- */
.cb-legal {
    /* No max-width: the per-breakpoint widths below are the container, and a 1140 cap
       here would clamp the 1170 step and shift the whole column 15px. */
    margin: 0 auto;
    /* No vertical padding: the first heading's own margin supplies the top gap, exactly
       as it did on J3. Padding here would block margin collapse and push everything
       down by that margin again. */
    padding: 0 15px;
}

/* Note: below 768 the J3 page carried an extra 65px gap above the prose - the spacer
   column's empty_space addon, which stacked on top once the SPPB columns collapsed.
   Deliberately not reproduced: it was an artefact of the two-column layout folding, not
   intended spacing, so the mobile pages here start 65px higher than the old site. */

/* The J3 page was a 2/10 SPPB column split inside a Bootstrap 3 container: an empty
   spacer column, then the prose. The indent is therefore one sixth of the *container*
   width plus the 15px gutter, and both scale by breakpoint - a fixed 195px only happens
   to be right at >=1200. Measured J3 content boxes: 149/595 at 768, 265/945 at 1280. */
@media (min-width: 768px) {
    .cb-legal { width: 750px; padding: 0 15px 0 140px; }
}

@media (min-width: 992px) {
    .cb-legal { width: 970px; padding-left: 176.667px; }
}

@media (min-width: 1200px) {
    .cb-legal { width: 1170px; padding-left: 210px; }
}

/* ---------------------------------------------------------------------------
 * Case studies.
 *
 * Self-contained card grid. Deliberately does NOT reuse the frozen
 * .sp-simpleportfolio* rules: those describe a tile whose caption overlays the image
 * on hover, so with the caption below the image the black overlay backdrop showed
 * around the letterboxed flags, and the Bootstrap 3 float grid mis-wrapped whenever
 * two titles differed in height.
 *
 * The whole card is one <a>, so the entire surface is clickable.
 * --------------------------------------------------------------------------- */
.cb-cases {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 30px;
    margin: 50px 0 0;
}

.cb-case {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 3px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .10);
    transition: transform .25s ease, box-shadow .25s ease;
}

.cb-case:hover,
.cb-case:focus-visible {
    transform: translateY(-6px);
    box-shadow: 0 14px 28px rgba(0, 0, 0, .16);
    text-decoration: none;
}

.cb-case:focus-visible {
    outline: 2px solid #33cc66;
    outline-offset: 2px;
}

.cb-case-media {
    display: block;
    position: relative;
    overflow: hidden;
    /* The source crops are 600x400. */
    aspect-ratio: 3 / 2;
    background: #111;
}

.cb-case-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s ease;
}

.cb-case:hover .cb-case-media img {
    transform: scale(1.05);
}

.cb-case-body {
    display: block;
    padding: 18px 20px 22px;
    /* Push the body to fill, so cards in a row end level regardless of title length. */
    flex: 1 1 auto;
}

.cb-case-title {
    display: block;
    font-family: 'Share', sans-serif;
    font-size: 18px;
    line-height: 1.25;
    font-weight: 400;
    text-transform: uppercase;
    color: #339966;
    margin: 0 0 10px;
    transition: color .25s ease;
}

.cb-case:hover .cb-case-title {
    color: #33cc66;
}

.cb-case-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cb-case-tag {
    display: inline-block;
    font-size: 12px;
    line-height: 1.4;
    color: #707273;
    background: #f2f4f3;
    border-radius: 2px;
    padding: 3px 8px;
}

@media (prefers-reduced-motion: reduce) {
    .cb-case,
    .cb-case-media img {
        transition: none;
    }

    .cb-case:hover {
        transform: none;
    }

    .cb-case:hover .cb-case-media img {
        transform: none;
    }
}

@media (max-width: 991px) {
    .cb-cases {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px;
    }
}

@media (max-width: 575px) {
    .cb-cases {
        grid-template-columns: minmax(0, 1fr);
        gap: 20px;
    }
}

/* ---------------------------------------------------------------------------
 * Hero.
 *
 * Tile appearance (195px squares, #33cc66 / #339966 shades, the scaling nav-hover
 * ring, 60px icons) all comes from the frozen preset1.css via the original .brick /
 * .nav-item / .live-tile class names. Only the layout is rebuilt here.
 *
 * Desktop reproduces the J3 arrangement exactly - six 195px columns, 1170px total,
 * matching the measured baseline at 1280px:
 *
 *   [    ] [Services] [-------- lede --------] [tile1]
 *   [tile2] [Cases ] [About] [tile3] [tile4] [Work ]
 *   [    ] [      ] [tile5] [tile6] [Contact] [   ]
 * --------------------------------------------------------------------------- */
#sp-metro-ui {
    background-image: url(../images/header-bg.jpg);
    background-size: cover;
    background-attachment: fixed;
    background-position: 0% 0%;
    min-height: 830px;
    color: #fff;
    /* Top-aligned, not centred: on J3 the tile block started at y=0 and the 830px
       min-height simply left background showing beneath it. Centring shifted every
       tile down by 108px. */
    display: block;
}

.cb-hero {
    display: grid;
    grid-template-columns: repeat(6, 195px);
    grid-auto-rows: 195px;
    justify-content: center;
    width: 100%;
    /* The J3 hero block measured 615px, not 3x195=585: its first row held a
       display:none logo tile that still occupied 30px. Reproduced so the block
       centres at the same offset inside the 830px section. */
    padding-top: 30px;
}

.cb-hero-lede {
    grid-column: 3 / span 3;
    grid-row: 1;
    /* Top-aligned; the h1's own 20px margin then puts it at y=50 as on J3. */
    align-self: start;
    text-align: right;
    /* 20px, not the Bootstrap 15px: the J3 span6 measured 545px inside 585px. */
    padding: 0 20px;
}

.cb-hero-lede h1 {
    font-size: 36px;
    font-weight: 400;
    line-height: 39.6px;
    color: #fff;
    text-align: right;
    margin: 20px 0 10px;
}

.cb-hero-lede p {
    font-size: 16px;
    font-weight: 300;
    line-height: 20px;
    color: #fff;
    text-align: right;
    margin: 0 0 10px;
}

/* Explicit placement so the empty cells of the original stay empty. */
.cb-cell-services { grid-area: 1 / 2; }
.cb-cell-tile1    { grid-area: 1 / 6; }
.cb-cell-tile2    { grid-area: 2 / 1; }
.cb-cell-cases    { grid-area: 2 / 2; }
.cb-cell-about    { grid-area: 2 / 3; }
.cb-cell-tile3    { grid-area: 2 / 4; }
.cb-cell-tile4    { grid-area: 2 / 5; }
.cb-cell-work     { grid-area: 2 / 6; }
.cb-cell-tile5    { grid-area: 3 / 3; }
.cb-cell-tile6    { grid-area: 3 / 4; }
.cb-cell-contact  { grid-area: 3 / 5; }

/* Crossfading tile pair. Replaces the 52 KB metroui.js liveTile plugin. */
.cb-tile {
    position: relative;
    width: 195px;
    height: 195px;
    overflow: hidden;
}

.cb-tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cb-tile-back {
    opacity: 0;
    animation: cb-tile-fade 10s infinite;
}

.cb-cell-tile2 .cb-tile-back { animation-delay: 1.6s; }
.cb-cell-tile3 .cb-tile-back { animation-delay: 3.2s; }
.cb-cell-tile4 .cb-tile-back { animation-delay: 4.8s; }
.cb-cell-tile5 .cb-tile-back { animation-delay: 6.4s; }
.cb-cell-tile6 .cb-tile-back { animation-delay: 8s; }

@keyframes cb-tile-fade {
    0%, 40%   { opacity: 0; }
    50%, 90%  { opacity: 1; }
    100%      { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .cb-tile-back { animation: none; }
}

/* ---------------------------------------------------------------------------
 * Hero, below 1200px.
 *
 * This is the part the J3 site never had: `hidden_sm`/`hidden_xs` emitted Bootstrap 4
 * class names against a Bootstrap 3 stylesheet, so they did nothing and the hero
 * simply overflowed. The grid reflows instead, and the lede leads on small screens so
 * the page has a visible <h1> at every width.
 * --------------------------------------------------------------------------- */
@media (max-width: 1199px) {
    .cb-hero {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-auto-rows: auto;
        max-width: 780px;
    }

    .cb-hero > * { grid-area: auto !important; }

    .cb-hero-lede {
        grid-column: 1 / -1 !important;
        text-align: center;
        padding: 30px 15px;
    }

    .cb-hero-lede h1,
    .cb-hero-lede p { text-align: center; }

    .cb-hero .brick,
    .cb-hero .cb-tile {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }
}

/* SPPB scaled the section type down below 480px. */
@media (max-width: 480px) {
    .cb-section-title {
        font-size: 42px;
        line-height: 42px;
    }

    .cb-section-subtitle {
        font-size: 18px;
    }
}

@media (max-width: 767px) {
    #sp-metro-ui {
        min-height: 0;
        background-attachment: scroll;
        padding: 40px 0;
    }

    .cb-hero {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-width: 420px;
    }

    .cb-hero-lede h1 { font-size: 28px; line-height: 1.2; }
}

/* ---------------------------------------------------------------------------
 * Single case-study article.
 *
 * Core's article layout floats the image at natural size and lets the body run the
 * full column width - fine for long-form, wrong for a 300px flag and one paragraph.
 * Paired with html/com_content/article/default.php.
 * --------------------------------------------------------------------------- */
.cb-case-page .cb-article-inner {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 15px;
}

.cb-case-page .cb-article-media {
    margin: 0 0 32px;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
    line-height: 0;
    /* A banner strip rather than the image at full height. The sources are only
       300x206, so shown at the column's full width they are upscaled 2.4x and take
       ~500px of vertical space for a single paragraph of text. Cropping to a wide
       band keeps the flag recognisable, hides most of the upscale, and gives the
       image weight proportionate to the content. */
    aspect-ratio: 16 / 6;
}

.cb-case-page .cb-article-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* "Year: 2015" is authored as an h2 in the body; as the only heading on the page it
   reads better as a small eyebrow above the prose than as a 48px display heading. */
.cb-case-page .cb-article-body h2 {
    font-size: 15px;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #339966;
    margin: 0 0 12px;
}

.cb-case-page .cb-article-body p {
    font-size: 17px;
    line-height: 1.7;
    color: #4a4c4d;
    margin: 0 0 18px;
}

.cb-case-page .cb-article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 26px 0 0;
    padding: 22px 0 0;
    border-top: 1px solid #eee;
}

.cb-case-page .cb-article-back {
    margin: 26px 0 0;
}

.cb-case-page .cb-article-back a {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #707273;
    text-decoration: none;
    transition: color .2s ease;
}

.cb-case-page .cb-article-back a:hover {
    color: #33cc66;
}

/* The category listing reached from that link reuses the card grid. */
.cb-case-page .com-content-category-blog {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 15px;
}
