/*
    This file is part of m.css.

    Copyright © 2017, 2018, 2019, 2020 Vladimír Vondruš <mosra@centrum.cz>

    Permission is hereby granted, free of charge, to any person obtaining a
    copy of this software and associated documentation files (the "Software"),
    to deal in the Software without restriction, including without limitation
    the rights to use, copy, modify, merge, publish, distribute, sublicense,
    and/or sell copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included
    in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    DEALINGS IN THE SOFTWARE.
*/

/* Important basics */
*, ::before, ::after { box-sizing: border-box; }
body { margin: 0; }

/* 12-column layout. Inspired by Bootstrap and
   https://www.w3schools.com/css/css_rwd_grid.asp. The container is padded from
   sides, the row inside removes the padding and columns add it back. */
.m-container {
  width: 100%;
  margin: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}
.m-row {
  margin-left: -1rem;
  margin-right: -1rem;
}
.m-row:after { /* avoid rows floating around each other */
  content: ' ';
  clear: both;
  display: table;
}
.m-row > [class*='m-col-'] {
  position: relative;
  padding: 1rem;
}
[class*='m-clearfix-']::after {
  display: block;
  content: ' ';
  clear: both;
}
[class*='m-show-'] {
  display: none;
}

/* Margin for inflated / floating columns behaves as "padding-after" by default
   -- there's only padding on the bottom but not when the column is last. */
.m-container-inflate, :not(.m-row) > [class*='m-col-'] {
  margin-bottom: 1rem;
}
.m-container-inflate:last-child, :not(.m-row) > [class*='m-col-']:last-child {
  margin-bottom: 0;
}

/* Padding overrides for container and columns. Works for both columns inside
   rows and floating columns. */
.m-container.m-nopadr, [class*='m-col-'].m-nopadr {
  padding-right: 0;
}

/* 12-column layout -- T (portrait phones) */
[class*='m-col-t-'] { float: left; }

.m-col-t-1  { width: calc(1  * 100% / 12); }
.m-col-t-2  { width: calc(2  * 100% / 12); }
.m-col-t-3  { width: calc(3  * 100% / 12); }
.m-col-t-4  { width: calc(4  * 100% / 12); }
.m-col-t-5  { width: calc(5  * 100% / 12); }
.m-col-t-6  { width: calc(6  * 100% / 12); }
.m-col-t-7  { width: calc(7  * 100% / 12); }
.m-col-t-8  { width: calc(8  * 100% / 12); }
.m-col-t-9  { width: calc(9  * 100% / 12); }
.m-col-t-10 { width: calc(10 * 100% / 12); }
.m-col-t-11 { width: calc(11 * 100% / 12); }
.m-col-t-12 { width: calc(12 * 100% / 12); }

/* 12-column layout -- S, 576px and up (landscape phones) */
@media screen and (min-width: 576px) {
  .m-container { width: 560px; }

  .m-container-inflatable .m-col-s-10 .m-container-inflate:not([class*='m-left-']):not([class*='m-right-']) {
    margin-left: -10%;
    margin-right: -10%;
  }

  [class*='m-col-s-'] { float: left; }

  .m-clearfix-t::after { display: none; }

  .m-hide-s { display: none; }
  .m-show-s { display: block; }

  .m-col-s-none {
    width: auto;
    float: none;
  }
}

/* 12-column layout -- M, 768px and up (tablets, small desktops) */
@media screen and (min-width: 768px) {
  .m-container { width: 750px; }

  .m-container-inflatable .m-col-m-10 .m-container-inflate:not([class*='m-left-']):not([class*='m-right-']) {
    margin-left: -10%;
    margin-right: -10%;
  }
  .m-container-inflatable .m-col-m-10 .m-container-inflate.m-left-m {
    margin-left: -10%;
  }
  .m-container-inflatable .m-col-m-10 .m-container-inflate.m-right-m {
    margin-right: -10%;
  }

  [class*='m-col-m-'] { float: left; }

  .m-left-m {
    padding-right: 1rem;
    float: left;
  }
  .m-right-m, [class*='m-col-m-'].m-right-m {
    padding-left: 1rem;
    float: right;
  }
  .m-center-m, [class*='m-col-m-'].m-center-m {
    margin-left: auto;
    margin-right: auto;
    float: none;
  }

  .m-col-m-1  { width: calc(1  * 100% / 12); }
  .m-col-m-2  { width: calc(2  * 100% / 12); }
  .m-col-m-3  { width: calc(3  * 100% / 12); }
  .m-col-m-4  { width: calc(4  * 100% / 12); }
  .m-col-m-5  { width: calc(5  * 100% / 12); }
  .m-col-m-6  { width: calc(6  * 100% / 12); }
  .m-col-m-7  { width: calc(7  * 100% / 12); }
  .m-col-m-8  { width: calc(8  * 100% / 12); }
  .m-col-m-9  { width: calc(9  * 100% / 12); }
  .m-col-m-10 { width: calc(10 * 100% / 12); }
  .m-col-m-11 { width: calc(11 * 100% / 12); }
  .m-col-m-12 { width: calc(12 * 100% / 12); }

  .m-push-m-0  { left: calc(0  * 100% / 12); }
  .m-push-m-1  { left: calc(1  * 100% / 12); }
  .m-push-m-2  { left: calc(2  * 100% / 12); }
  .m-push-m-3  { left: calc(3  * 100% / 12); }
  .m-push-m-4  { left: calc(4  * 100% / 12); }
  .m-push-m-5  { left: calc(5  * 100% / 12); }
  .m-push-m-6  { left: calc(6  * 100% / 12); }
  .m-push-m-7  { left: calc(7  * 100% / 12); }
  .m-push-m-8  { left: calc(8  * 100% / 12); }
  .m-push-m-9  { left: calc(9  * 100% / 12); }
  .m-push-m-10 { left: calc(10 * 100% / 12); }
  .m-push-m-11 { left: calc(11 * 100% / 12); }

  .m-clearfix-s::after { display: none; }

  .m-hide-m { display: none; }
  .m-show-m { display: block; }

  .m-col-m-none {
    width: auto;
    float: none;
  }
}

/* 12-column layout -- L, 992px and up (desktops, very large tablets) */
@media screen and (min-width: 992px) {
  .m-container { width: 960px; }

  .m-container-inflatable .m-col-l-10 .m-container-inflate:not([class*='m-left-']):not([class*='m-right-']) {
    margin-left: -10%;
    margin-right: -10%;
  }
  .m-container-inflatable .m-col-l-10 .m-container-inflate.m-left-l {
    margin-left: -10%;
  }
  .m-container-inflatable .m-col-l-10 .m-container-inflate.m-right-l {
    margin-right: -10%;
  }

  [class*='m-col-l-'] { float: left; }

  .m-left-l {
    padding-right: 1rem;
    float: left;
  }
  .m-right-l, [class*='m-col-l-'].m-right-l {
    padding-left: 1rem;
    float: right;
  }
  .m-center-l, [class*='m-col-l-'].m-center-l {
    margin-left: auto;
    margin-right: auto;
    float: none;
  }

  .m-col-l-1  { width: calc(1  * 100% / 12); }
  .m-col-l-2  { width: calc(2  * 100% / 12); }
  .m-col-l-3  { width: calc(3  * 100% / 12); }
  .m-col-l-4  { width: calc(4  * 100% / 12); }
  .m-col-l-5  { width: calc(5  * 100% / 12); }
  .m-col-l-6  { width: calc(6  * 100% / 12); }
  .m-col-l-7  { width: calc(7  * 100% / 12); }
  .m-col-l-8  { width: calc(8  * 100% / 12); }
  .m-col-l-9  { width: calc(9  * 100% / 12); }
  .m-col-l-10 { width: calc(10 * 100% / 12); }
  .m-col-l-11 { width: calc(11 * 100% / 12); }
  .m-col-l-12 { width: calc(12 * 100% / 12); }

  .m-push-l-0  { left: calc(0  * 100% / 12); }
  .m-push-l-1  { left: calc(1  * 100% / 12); }
  .m-push-l-2  { left: calc(2  * 100% / 12); }
  .m-push-l-3  { left: calc(3  * 100% / 12); }
  .m-push-l-4  { left: calc(4  * 100% / 12); }
  .m-push-l-5  { left: calc(5  * 100% / 12); }
  .m-push-l-6  { left: calc(6  * 100% / 12); }
  .m-push-l-7  { left: calc(7  * 100% / 12); }
  .m-push-l-8  { left: calc(8  * 100% / 12); }
  .m-push-l-9  { left: calc(9  * 100% / 12); }
  .m-push-l-10 { left: calc(10 * 100% / 12); }
  .m-push-l-11 { left: calc(11 * 100% / 12); }

  .m-clearfix-m::after { display: none; }

  .m-hide-l { display: none; }
  .m-show-l { display: block; }

  .m-col-l-none {
    width: auto;
    float: none;
  }
}
