/*
 * Layout tweaks to the starno theme.
 *
 * Tile grid columns:  phones (< 576px) 2  ·  576–767px 3  ·  768–991px 4  ·  992px+ 5
 * (the theme's own style.css sets 3 / 4 / 5; this file only changes phones)
 */
@media (max-width: 575.98px) {
  .grid-item:not(.open) {
    -ms-flex: 0 0 50%;
    flex: 0 0 50%;
    max-width: 50%;
  }
}

/*
 * Post details on phones (post pages and the inline preview on the home page):
 * two halves instead of three columns —
 *   left:  headline, with the subhead right under it (aligned with the image's left edge)
 *   right: client / category / text, starting where the right-hand tile image starts
 *          in the 2-column grid (same 50% + gutter).
 */
@media (max-width: 575.98px) {
  .preview-deets > .row:first-child {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
  }
  .preview-deets > .row:first-child > .col-20 {
    max-width: none;
    min-width: 0;
  }
  .preview-deets > .row:first-child > .col-20:nth-child(1) { grid-column: 1; grid-row: 1; }
  .preview-deets > .row:first-child > .col-20:nth-child(2) { grid-column: 1; grid-row: 2; }
  .preview-deets > .row:first-child > .col-20:nth-child(3) { grid-column: 2; grid-row: 1 / span 2; }
  .preview-deets .preview-title {
    margin-bottom: 0.25rem; /* subhead sits right under the headline */
  }
}

/*
 * Carousel dots: smaller (8px instead of 16px) and closer to the bottom of the image
 * (about 10px up instead of 26px). The transparent border keeps a comfortable tap area.
 */
.carousel-indicators {
  margin-bottom: 0;
}
.carousel-indicators li {
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
  width: 8px;
  max-width: 8px;
  height: 8px;
  margin-left: 3px;
  margin-right: 3px;
}

/* Let horizontal swipes on a carousel change slides while vertical swipes still scroll the page */
.carousel {
  touch-action: pan-y;
}
.carousel img {
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}

/*
 * Single post page: the image (and the details under it) grow smoothly with the window
 * from 576px up, instead of jumping between full width, 60% and 80% at each breakpoint.
 * Full width just below 576px, then a steady line up to the 960px maximum at 1200px.
 * Long-form posts have their own layout and are left alone.
 */
@media (min-width: 576px) {
  body.single-post:not(.post-template-template-longform) .site-content > .container-fluid > .row > .col-60.col-md-36 {
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    width: calc(63.94% + 202px);
    max-width: min(100%, 960px);
    margin-left: auto;
    margin-right: auto;
  }
}

/*
 * Phones: tile titles under the images a bit bigger (15px instead of 12px),
 * still smaller than the 18px headline in the opened preview.
 */
@media (max-width: 575.98px) {
  .grid-item .details p:first-child {
    font-size: 15px;
    line-height: 1.2;
  }
}

/*
 * Clients + Friends dropdown: the list is as wide as the button and at most 70% of the
 * window's height, then scrolls.
 */
#tag-filters .dropdown-menu {
  width: 100%;
  max-height: 70vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Casestudy menu column: styled like the Portfolio list (one column) */
#casestudy-menu ul {
  list-style: none;
  padding-left: 0;
}
#casestudy-menu li {
  display: block;
}
#casestudy-menu .nav-link {
  padding: 0.25em 0;
}
@media (min-width: 992px) {
  #casestudy-menu .nav-link {
    padding-top: 0;
    padding-bottom: 0;
  }
}
/*
 * The rules below apply only once Case Study is in the menu (.has-casestudy, i.e. a Showcase
 * post is published). Until then the menu keeps its previous layout and spacing.
 */
/* 3-column layout: Portfolio takes one column (its list in a single column) and Case Study the right-hand one */
@media (min-width: 576px) and (max-width: 767.98px) {
  .has-casestudy #portfolio-menu {
    -webkit-column-count: 1;
    column-count: 1;
  }
}
/*
 * Menu links on screens under 992px: a little extra room to tap, but half what the theme
 * had (0.125em above and below each link instead of 0.25em). Wider screens stay tight.
 */
@media (max-width: 991.98px) {
  .has-casestudy .navbar-nav .nav-link,
  .has-casestudy #portfolio-menu .nav-link,
  .has-casestudy #casestudy-menu .nav-link {
    padding-top: 0.125em;
    padding-bottom: 0.125em;
  }
}
/*
 * 2-column layout (phones): the menu follows the two tile columns. Left: Arnaud Ghelfi;
 * right: the Portfolio list in one column, with Case Study below it after some space.
 */
@media (max-width: 575.98px) {
  .menu-panel > .container-fluid > .row.has-casestudy {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  .has-casestudy #first-menu,
  .has-casestudy #second-menu,
  .has-casestudy #casestudy-column {
    max-width: none;
    min-width: 0;
  }
  .has-casestudy #first-menu { grid-column: 1; grid-row: 1; }
  .has-casestudy #second-menu { grid-column: 2; grid-row: 1; }
  .has-casestudy #casestudy-column { grid-column: 2; grid-row: 2; margin-top: 24px; }
  .has-casestudy #tag-filters { display: none; }
  .has-casestudy #portfolio-menu {
    -webkit-column-count: 1;
    column-count: 1;
  }
}
