/* Mobile feed (see feed.js) — two staggered columns instead of the canvas.
 *
 * Active once feed.js has said so by putting `feed-mode` on the body:
 * everything here is scoped to that class so the canvas can never
 * accidentally inherit it. Below the iPad's width that happens by itself;
 * above it, only when the menu's Mobile-Ansicht switch was used.
 */

/* The canvas pins html and body to the viewport with overflow:hidden so
   nothing scrolls behind it. A feed is nothing but scrolling, so both of
   them have to be let go - overriding only `body` leaves `html` clamped
   and the page silently refuses to move. */
html.feed-mode,
body.feed-mode {
  height: auto;
  min-height: 100%;
  overflow-y: visible;
  overflow-x: hidden;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

body.feed-mode #viewport,
body.feed-mode #bg-canvas,
body.feed-mode #admin-generate-pdf {
  display: none;
}

/* The canvas pins these to the corners of a viewport that no longer
   scrolls. In the feed they belong in the flow, at the end. */
body.feed-mode #footer-links {
  position: static;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px 18px;
  padding: 28px 16px calc(28px + env(safe-area-inset-bottom));
  border-top: 2px solid #000;
  background: #fff;
}

#mobile-feed {
  /* Zero side padding: the columns run to both edges of the screen. */
  padding: 0;
  /* Clears the fixed header. */
  padding-top: 62px;
}

#mobile-feed[hidden] { display: none; }

/* On a phone the columns run to both edges, which is the whole look. On a
   desktop - where this view is now reachable through the menu switch - two
   columns across the full width would be billboards, so it settles into a
   phone-shaped column in the middle instead. */
@media (min-width: 768px) {
  #mobile-feed {
    max-width: 720px;
    margin: 0 auto;
  }
}

#feed-grid {
  display: flex;
  align-items: flex-start;
  /* Nothing at the screen edges - the columns run right off both sides -
     but a hair down the middle, so the two columns' borders and shadows
     stay separate instead of merging into one thick line. */
  gap: var(--feed-column-gap, 6px);
}

.feed-column {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* A little air above and below each image inside its own column. */
  gap: var(--feed-row-gap, 8px);
}

.feed-column:first-child { padding-top: 0; }

/* Offsetting the second column by half a tile guarantees the stagger even
   when two images happen to be the same height. */
.feed-column:nth-child(2) { padding-top: 26px; }

.feed-tile {
    position: relative;
    margin: 0;
    cursor: pointer;
    padding: 4px;
    -webkit-tap-highlight-color: transparent;
}

.feed-frame {
    position: relative;
    overflow: hidden;
    background: #ffffff;
    border: 2px solid #000;
    box-sizing: border-box;
}

.feed-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Matches the canvas's cull-in: transparent until decoded, then a short
     fade rather than a pop. */
  opacity: 0;
  transition: opacity 0.25s ease;
}

.feed-tile--loaded img { opacity: 1; }

/* Admin only: this piece still has no material, substrate or size (the
   same marking the canvas uses). */
.feed-tile.needs-details .feed-frame { border-color: #ff8c00; }

.feed-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #000;
  background: var(--color-primary, #ff00ff);
  border: 2px solid #000;
}

.feed-caption {
  margin: 3px 4px 0;
  font-size: 8px;
  line-height: 1.5;
  letter-spacing: 0.2px;
  color: #444;
  overflow-wrap: anywhere;
}

.feed-empty {
  padding: 40px 16px;
  text-align: center;
  font-size: 14px;
  color: #777;
}

/* ------------------------------------------------------------- viewer */

/* One image at full width, and — when the tapped image is a hero — the
   rest of its upload underneath it. */
#feed-viewer {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  flex-direction: column;
  background: #fff;
}

#feed-viewer[hidden] { display: none; }

body.feed-viewer-open { overflow: hidden; }

#feed-viewer-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 2px solid #000;
  background: #fff;
}

#feed-viewer-close {
  padding: 9px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #111;
  background: #fff;
  border: 2px solid #000;
  cursor: pointer;
}

#feed-viewer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 calc(32px + env(safe-area-inset-bottom));
}

.feed-view-figure {
  margin: 0 0 26px;
}

.feed-view-figure img {
  display: block;
  width: 100%;
  height: auto;
  background: #f2f2f2;
  border-top: 3px solid #000;
  border-bottom: 3px solid #000;
  box-sizing: border-box;
}

.feed-view-figure figcaption {
  margin: 8px 14px 0;
  font-size: 12px;
  line-height: 1.6;
  color: #333;
  overflow-wrap: anywhere;
}

.feed-view-figure .feed-view-author {
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #888;
}
