/*
 * The Enjin container ("module") chrome around every box (src/views/partials/module.njk).
 *   header  7px top edge, or a 37px title bar (.with-header)
 *   body    5px side edges, textured background, inner shading on both sides and the bottom
 *   footer  8px edge, 13px bar (.with-footer), or 15px for the last box in a column
 * Image halves are ::before/::after under the content (z-index:-1 inside an isolated box).
 */

.container_header,
.container_body,
.container_footer {
  position: relative;
}

.container_header,
.container_footer {
  isolation: isolate;
}

.container_header::before,
.container_header::after,
.container_footer::before,
.container_footer::after {
  content: '';
  position: absolute;
  top: 0;
  z-index: -1;
  width: 50.004%;
  height: 100%;
  background-repeat: no-repeat;
}

.container_header::before,
.container_footer::before {
  left: 0;
  background-position: left bottom;
}

.container_header::after,
.container_footer::after {
  right: 0;
  background-position: right bottom;
}

.container .container_header {
  height: 7px;
}

.container .container_header::before,
.container .container_header::after {
  background-image: url('/img/theme/module-header-plain.png');
}

.container.with-header .container_header {
  height: 37px;
  background-color: transparent;
}

.container.with-header .container_header::before,
.container.with-header .container_header::after {
  background-image: url('/img/theme/module-header-titled.png');
}

.container_header .title {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
}

.container.with-header .container_header .header_text_text {
  padding-top: 12px;
  font-family: Arial;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  color: #fff8c9;
  cursor: default;
}

.container .container_footer {
  height: 8px;
}

.container .container_footer::before,
.container .container_footer::after {
  background-image: url('/img/theme/module-footer-plain.png');
}

.container.with-footer .container_footer {
  height: 13px;
}

.container.with-footer .container_footer::before,
.container.with-footer .container_footer::after {
  background-image: url('/img/theme/module-footer.png');
}

.container.with-footer.last .container_footer {
  height: 15px;
}

.container.with-footer.last .container_footer::before,
.container.with-footer.last .container_footer::after {
  background-image: url('/img/theme/module-footer-last.png');
}

.container .container_body {
  padding-right: 5px;
  padding-left: 5px;
  background:
    url('/img/theme/module-side-left.png') left top repeat-y,
    url('/img/theme/module-side-right.png') right top repeat-y;
}

/* Background layers, bottom to top: colour, texture, left/right shading; bottom shading halves
   are the pseudo-elements, above them; the box's content is above everything. */
.container .container_content {
  position: relative;
  isolation: isolate;
  background:
    url('/img/theme/module-shade-right.png') right top repeat-y,
    url('/img/theme/module-shade-left.png') left top repeat-y,
    url('/img/theme/module-bg.jpg') left top no-repeat #181713;
}

.container .container_content::before,
.container .container_content::after {
  content: '';
  position: absolute;
  bottom: 0;
  z-index: -1;
  width: 50.004%;
  height: 50.004%;
  background-image: url('/img/theme/module-shade-bottom.png');
  background-repeat: no-repeat;
}

.container .container_content::before {
  left: 0;
  background-position: left bottom;
}

.container .container_content::after {
  right: 0;
  background-position: right bottom;
}

/* The box's own content: contains its floats and margins, as Enjin's table cell did. */
.container .module {
  position: relative;
  display: flow-root;
}

/* Phones (below 768px; DECISIONS 84): the chrome stretches to any width as it is; a title too long
   for the bar ends in "…" instead of being cut mid-letter. */
@media (max-width: 767.98px) {
  .container.with-header .container_header .header_text_text {
    padding-right: 12px;
    padding-left: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* A link on the title bar's right ("3 unread", "Calendar"); the title then keeps clear of it. */
  /* Drawn in the 37px bar; its tap area reaches 7px into the box below to make 44px, so the bar
     sits above the box's body. */
  .container_header:has(.header-link) {
    z-index: 1;
  }

  .container_header .header-link {
    position: absolute;
    top: 0;
    right: 6px;
    padding: 0 8px 7px;
    font-size: 13px;
    line-height: 37px;
  }

  .container_header:has(.header-link) .header_text_text {
    padding-right: 96px;
    padding-left: 96px;
  }

  /* Collapsed homepage boxes (DECISIONS 85): rows that open on tap, titled like a module, with the
     menu's ▼ turning over when open. Neighbouring ones share one box. */
  .phone-collapsed-item + .phone-collapsed-item {
    border-top: 1px solid #363224;
  }

  .phone-collapsed-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    color: #fff8c9;
    list-style: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .phone-collapsed-label::-webkit-details-marker {
    display: none;
  }

  .phone-collapsed-label:focus-visible {
    outline-offset: -3px;
  }

  .phone-collapsed-arrow {
    font-size: 9px;
    color: #e9bd7f;
  }

  .phone-collapsed-item[open] .phone-collapsed-arrow {
    transform: rotate(180deg);
  }

  .phone-collapsed-body {
    padding-bottom: 6px;
  }
}
