/* ==========================================================================
   Mobile and tablet layer for the nbs theme.

   The theme is built on the fixed Bootstrap 2 grid: `.container` is pinned to
   1090px and `bootstrap-responsive.css` is never loaded, so on a phone the
   layout viewport stretches to ~1110px and the page is cut off on the right.

   This file is loaded last, after every other stylesheet, and only overrides
   widths and flow below the desktop breakpoint. Nothing here affects the
   desktop layout above 1110px.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Applies at every width.

   MediaElement sizes the player from the video's own dimensions, so a 1920px
   clip overflows even a 1440px desktop window. Cap it to its container.
   -------------------------------------------------------------------------- */
.mejs-container,
.mejs-inner,
.mejs-mediaelement,
.mejs-layers,
.mejs-overlay,
.mejs-controls {
    max-width: 100% !important;
}

.mejs-container video,
.mejs-mediaelement video {
    max-width: 100% !important;
    height: auto;
}

/* --------------------------------------------------------------------------
   1. Anything narrower than the fixed shell: make the grid fluid
   -------------------------------------------------------------------------- */
@media (max-width: 1109px) {

    html,
    body {
        overflow-x: hidden;
    }

    .container,
    .navbar-static-top .container,
    .navbar-fixed-top .container,
    .navbar-fixed-bottom .container {
        width: auto !important;
        max-width: 100%;
        padding-left: 15px;
        padding-right: 15px;
        box-sizing: border-box;
    }

    .row,
    .row-fluid {
        width: auto !important;
        margin-left: 0 !important;
    }

    /* Bootstrap 2 columns: one under another */
    [class*="span"] {
        width: 100% !important;
        min-height: 0;
        margin-left: 0 !important;
        float: none !important;
        display: block;
        box-sizing: border-box;
    }

    /* Media must never force the page wider */
    img,
    iframe,
    video,
    embed,
    object,
    canvas {
        max-width: 100% !important;
        height: auto;
    }

    /* Inline widths baked into templates and editor content */
    .naslov-stranice,
    .uvod-stranice,
    .content-wrap,
    .trst-home-page-section,
    .presss,
    .pag {
        width: auto !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* MediaElement sets a pixel width on the player from JS */
    .mejs-container,
    .mejs-overlay,
    .mejs-mediaelement,
    .mejs-layers {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Wide tables scroll inside their own box instead of stretching the page */
    table {
        display: block;
        width: 100% !important;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Long unbroken strings (URLs, file names) */
    p,
    li,
    td,
    h1, h2, h3, h4, h5 {
        overflow-wrap: break-word;
        word-wrap: break-word;
    }
}

/* --------------------------------------------------------------------------
   2. Tablet: keep the menu on one line but let it scroll
   -------------------------------------------------------------------------- */
@media (min-width: 768px) and (max-width: 1109px) {

    .meni ul {
        white-space: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .meni ul li {
        float: none;
        display: inline-block;
    }

    .meni ul li a {
        padding: 10px 14px 13px 14px;
        font-size: 13px;
    }
}

/* --------------------------------------------------------------------------
   3. Phone
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {

    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* --- header --- */
    .header_pozadina {
        height: auto !important;
        padding: 10px 0 0 0;
    }

    .logo {
        height: auto !important;
        text-align: center;
    }

    /* The logo is absolutely positioned with fixed pixels and negative
       margins on desktop; put it back in the flow so the header can grow */
    .logo img,
    #ilogo {
        position: static !important;
        display: inline-block;
        width: auto !important;
        max-width: 72% !important;
        height: auto !important;
        margin: 6px 0 10px 0 !important;
        top: auto !important;
        left: auto !important;
    }

    /* --- main menu: stacked, full-width tap targets ---
       The blue strip behind the menu is part of .header_pozadina, which is a
       fixed-height background image. Once the menu stacks it outgrows that
       strip, so it needs a background of its own. */
    .meni {
        height: auto !important;
        background-color: #15375c;
    }

    .meni ul {
        display: block;
        margin: 0;
        padding: 0;
        list-style: none;
        white-space: normal;
    }

    .meni ul li {
        display: block;
        float: none !important;
        width: 100%;
        border-right: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    }

    .meni ul li:last-child {
        border-bottom: none;
    }

    .meni ul li a {
        display: block;
        width: 100%;
        padding: 13px 12px;
        font-size: 14px;
        box-sizing: border-box;
    }

    /* --- slider --- */
    .slajder_pozadina {
        height: auto !important;
        background-size: cover;
    }

    .flexslider,
    .flexslider .slides > li {
        height: auto !important;
    }

    .flexslider .slides img {
        width: 100% !important;
        height: auto !important;
    }

    /* --- search / newsletter strip --- */
    .newsletter_pozadina {
        height: auto !important;
        padding: 12px 0;
    }

    .newsletter_levo,
    .newsletter_desno {
        width: 100% !important;
        float: none !important;
        text-align: left;
        margin-bottom: 8px;
    }

    #searchform {
        width: 100% !important;
        max-width: 100%;
        display: flex;
        align-items: center;
        gap: 6px;
        box-sizing: border-box;
    }

    /* min-width:0 is what stops the input from pushing the button off-screen:
       a flex item will not shrink below its content width without it */
    #searchform input[type="text"],
    #searchform #s {
        width: auto !important;
        flex: 1 1 auto;
        min-width: 0;
        box-sizing: border-box;
    }

    /* The search button is absolutely positioned at margin-left:500px on
       desktop; put it back in the flex row or it lands off-screen */
    #searchform .button-search,
    .button-search {
        position: static !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        margin: 0 !important;
        flex: 0 0 auto;
    }

    #searchform input[type="submit"],
    #searchform button {
        flex: 0 0 auto;
    }

    /* --- content blocks --- */
    .vest1 img,
    .vest2 img,
    .najave img {
        float: none !important;
        display: block;
        margin: 0 0 8px 0;
        max-width: 100% !important;
        width: auto !important;
        height: auto !important;
    }

    .vest1,
    .vest2,
    .najava-tekst {
        float: none !important;
        width: 100% !important;
        margin-left: 0 !important;
    }

    /* Homepage offer sections carry inline pixel styles */
    .trst-home-page-section h2 {
        font-size: 19px !important;
        line-height: 1.3;
    }

    .trst-home-page-section h4 {
        font-size: 15px !important;
    }

    .trst-home-page-section ul {
        padding-left: 18px !important;
    }

    /* --- footer --- */
    .footer_pozadina {
        height: auto !important;
        padding: 18px 0;
    }

    .footer_pozadina .span3,
    .footer_pozadina .span4 {
        margin-bottom: 18px;
    }

    /* --- forms (Gravity Forms) --- */
    .gform_wrapper .gfield input[type="text"],
    .gform_wrapper .gfield input[type="email"],
    .gform_wrapper .gfield input[type="tel"],
    .gform_wrapper .gfield textarea,
    .gform_wrapper .gfield select {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    /* --- galleries --- */
    .galerija .span2,
    .galerija .span3,
    .galerija .span4 {
        width: 48% !important;
        float: left !important;
        margin: 0 1% 2% 1% !important;
    }

    /* --- readability --- */
    body {
        font-size: 15px;
        line-height: 1.55;
    }

    h3.naslov-stranice {
        font-size: 20px !important;
        line-height: 1.3;
    }
}

/* --------------------------------------------------------------------------
   4. Very narrow phones
   -------------------------------------------------------------------------- */
@media (max-width: 400px) {

    .logo img,
    #ilogo {
        max-width: 85% !important;
    }

    .meni ul li a {
        font-size: 13px;
        padding: 12px 10px;
    }

    .galerija .span2,
    .galerija .span3,
    .galerija .span4 {
        width: 100% !important;
        float: none !important;
        margin: 0 0 8px 0 !important;
    }
}
