/* ============================================
   feed-touch-card.css — Home post card, phones only
   Every rule scoped under .feed-post-unit--touch.
   ============================================ */

/* ---- Follow pill removed; name stays alone, no leftover gap ---- */
.feed-post-unit--touch .feed-card-follow-btn {
  display: none;
}

/* ---- Caption: one line, ellipsis, clear of the rail ---- */
.feed-post-unit--touch .feed-card-front__caption {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}

/* ---- Rail avatar wrap: hosts the follow badge at 4:30, same math as
   desktop's .feed-comments-header--home .feed-comments-avatar-wrap. ---- */
.feed-post-unit--touch .feed-card-rail__avatar-wrap {
  position: relative;
  display: inline-block;
}

.feed-post-unit--touch .feed-card-rail__avatar-wrap .feed-comments-follow-badge {
  position: absolute;
  left: 85.36%;
  top: 85.36%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-canvas);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.feed-post-unit--touch .feed-card-rail__avatar-wrap .feed-comments-follow-badge.is-success {
  background: var(--color-turquoise);
}

.feed-post-unit--touch .feed-card-rail__avatar-wrap .feed-comments-follow-badge svg {
  display: block;
}

/* ---- Rail item: icon circle + count label stacked with a tight 3px gap ---- */
.feed-post-unit--touch .feed-card-rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.feed-post-unit--touch .feed-card-rail-count {
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  line-height: 1;
}

/* ---- Rail buttons: 44px dark glass circle, white 22px icon, no per-action color ---- */
.feed-post-unit--touch .feed-card-btn {
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.feed-post-unit--touch .feed-card-btn svg {
  width: 22px;
  height: 22px;
  stroke: #ffffff;
}

/* Like: no fill by default; filled + stroked #EF4444 while liked. The circle
   itself stays dark glass (no rule needed — nothing here changes its background). */
.feed-post-unit--touch .feed-card-btn[data-action="like"] svg {
  fill: none;
  stroke: #ffffff;
}

.feed-post-unit--touch .feed-card-btn[data-action="like"].is-liked svg {
  fill: #EF4444;
  stroke: #EF4444;
}

/* ============================================
   BACK FACE
   ============================================ */

/* ---- Surface: white, dark text, 1px border. Radius unchanged — inherited
   from the shared .feed-card-face rule in feed.css. ---- */
.feed-post-unit--touch .feed-card-face--back {
  background: #ffffff;
  color: #111111;
  border: 1.5px solid #E4E4E7;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
}

/* ---- Header: face, name, post time, three-dot report ---- */
.feed-post-unit--touch .feed-card-back__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 10px 10px 16px;
  flex-shrink: 0;
}

.feed-post-unit--touch .feed-card-back__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: #ede9fe;
  color: #6D28D9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
}

.feed-post-unit--touch .feed-card-back__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.feed-post-unit--touch .feed-card-back__header-body {
  flex: 1;
  min-width: 0;
}

.feed-post-unit--touch .feed-card-back__name-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.feed-post-unit--touch .feed-card-back__name {
  font-size: 15px;
  font-weight: 600;
  color: #111111;
}

.feed-post-unit--touch .feed-card-back__time {
  font-size: 12px;
  color: #999999;
}

.feed-post-unit--touch .feed-card-back__more-btn {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #18181b;
}

/* ---- Caption + hashtags: desktop's exact rules, no color overrides needed
   (var(--color-text-secondary)/var(--color-canvas) already read correctly
   against this white surface). Just container spacing. ---- */
.feed-post-unit--touch .feed-card-back__caption-body {
  padding: 0 16px 10px;
  flex-shrink: 0;
}

/* ---- Comments: scrolls, hidden scrollbar ---- */
.feed-post-unit--touch .feed-card-back__scroll {
  scrollbar-width: none;
}
.feed-post-unit--touch .feed-card-back__scroll::-webkit-scrollbar {
  display: none;
}

.feed-post-unit--touch .feed-card-back__comment-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 -8px;
  padding: 6px 8px;
  border-radius: 12px;
  transition: background-color 0.2s ease;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.feed-post-unit--touch .feed-card-back__comment-row--pressing {
  background-color: #F4F4F6;
}

.feed-post-unit--touch .feed-card-back__comment-row--sheet-open {
  background-color: #EFE8FC;
}

.feed-post-unit--touch .feed-card-back__comment-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: #ede9fe;
  color: #6D28D9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
}

.feed-post-unit--touch .feed-card-back__comment-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.feed-post-unit--touch .feed-card-back__comment-body {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: #111111;
  line-height: 1.4;
  word-break: break-word;
}

.feed-post-unit--touch .feed-card-back__comment-body strong {
  font-weight: 600;
}

.feed-post-unit--touch .feed-card-back__comment-time {
  font-size: 11px;
  color: #999999;
  flex-shrink: 0;
  white-space: nowrap;
  margin-left: 4px;
}

.feed-post-unit--touch .feed-card-back__comments-empty {
  text-align: center;
  font-size: 13px;
  color: #999999;
  padding: 20px 0;
}

/* ---- Input row: 40px pill + 40px send circle ---- */
.feed-post-unit--touch .feed-card-back__input-row {
  border-top: 1px solid #eee;
}

.feed-post-unit--touch .feed-card-back__input {
  height: 40px;
  box-sizing: border-box;
  background: #F4F4F6;
  color: #111111;
  border-radius: 20px;
  padding: 0 14px;
  line-height: 40px;
  resize: none;
}

.feed-post-unit--touch .feed-card-back__input::placeholder {
  color: #999999;
}

.feed-post-unit--touch .feed-card-back__send {
  width: 40px;
  height: 40px;
  background: #6D28D9;
}

/* ============================================
   COMMENTS SHEET, DOUBLE TAP, STICKER GRID BACK
   The comment button opens a bottom sheet holding the header (⋯),
   caption + hashtags, comments and comment box, with a small copy of
   the page above it. The eye flips the card to the sticker grid; the
   Flip back pill returns. Built in feed-cards.js (buildPostUnit).
   ============================================ */

/* ---- Double tap to like: keep the browser from treating it as zoom ---- */
.feed-post-unit--touch .feed-card {
  touch-action: manipulation;
}

/* ---- Sheet layer: 1000 sits above the phone header (up to 201) and
   below the profile sheet (1101), sticker detail (1200) and the
   long-press comment menu (4000). ---- */
.feed-post-unit--touch .feed-csheet-veil {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  background: rgba(10, 5, 25, 0);
  transition: background-color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.feed-post-unit--touch .feed-csheet-veil.is-open {
  background: #EDEBF2;
}

/* Small copy of the page above the sheet. Height and top come from
   feed-cards.js (_layoutCommentsSheet); width follows the 9:16 shape. */
.feed-post-unit--touch .feed-csheet-page {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: auto;
  max-width: calc(100% - 32px);
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transform-origin: top left;
  transition: transform 0.32s cubic-bezier(0.3, 0.7, 0.2, 1);
}

/* Top and height come from feed-cards.js, measured against the visible
   screen so the keyboard pushes the sheet up instead of covering it. */
.feed-post-unit--touch .feed-csheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  color: #111111;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.14);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
  transform: translateY(105%);
  transition: transform 0.32s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.feed-post-unit--touch .feed-csheet-veil.is-open .feed-csheet-panel {
  transform: translateY(0);
}

.feed-post-unit--touch .feed-csheet-handle {
  width: 38px;
  height: 5px;
  border-radius: 3px;
  background: #D8D5E0;
  margin: 8px auto 2px;
  flex-shrink: 0;
}

/* A long caption expanded with "more" scrolls on its own instead of
   pushing the comments off the sheet. */
.feed-post-unit--touch .feed-csheet-panel .feed-card-back__caption-body {
  max-height: 35%;
  overflow-y: auto;
  scrollbar-width: none;
}
.feed-post-unit--touch .feed-csheet-panel .feed-card-back__caption-body::-webkit-scrollbar {
  display: none;
}

.feed-post-unit--touch .feed-csheet-panel .feed-card-back__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.feed-post-unit--touch .feed-csheet-panel .feed-card-back__input-row {
  flex-shrink: 0;
}

/* Your own post's ⋯ (Turn off comments) opens a dropdown on <body>;
   keep it above the sheet while the sheet is open. */
html.sb-csheet-open .people-modal-dropdown {
  z-index: 1100;
}

/* ---- Back of the card: sticker grid ---- */
.feed-post-unit--touch .feed-card-back__stickers-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 16px 16px 4px;
  flex-shrink: 0;
}

.feed-post-unit--touch .feed-card-back__stickers-title {
  font-size: 15px;
  font-weight: 600;
  color: #111111;
}

.feed-post-unit--touch .feed-card-back__stickers-count {
  font-size: 12px;
  color: #999999;
}

/* Bottom padding keeps the last row clear of the Flip back pill. */
.feed-post-unit--touch .feed-card-back__grid-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 12px 80px;
  scrollbar-width: none;
}
.feed-post-unit--touch .feed-card-back__grid-scroll::-webkit-scrollbar {
  display: none;
}

.feed-post-unit--touch .feed-card-back__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.feed-post-unit--touch .feed-card-back__sticker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.feed-post-unit--touch .feed-card-back__sticker-tile {
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  border-radius: 12px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.feed-post-unit--touch .feed-card-back__sticker-tile img {
  width: 78%;
  height: 78%;
  object-fit: contain;
  display: block;
}

.feed-post-unit--touch .feed-card-back__sticker-handle {
  border: 0;
  background: none;
  padding: 0;
  font-family: 'Poppins', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #6D28D9;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.feed-post-unit--touch .feed-card-back__grid-msg {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 13px;
  color: #999999;
  padding: 20px 0;
}

/* Floating Flip back pill: only exists on the back face. */
.feed-post-unit--touch .feed-card-back__flip-pill {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: #6D28D9;
  color: #ffffff;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 20px;
  box-shadow: 0 6px 18px rgba(60, 20, 140, 0.35);
  cursor: pointer;
  white-space: nowrap;
}

/* ---- Comment box in the sheet: your picture + a gray box that grows to
   5 lines (height set by feed-cards.js _syncComposer), then a row under it
   with the countdown and the send pill on the right. The left of that row
   is left open for future buttons. Overrides the old one-line input and
   round send button above only inside the sheet. ---- */
.feed-post-unit--touch .feed-card-back__input-row.feed-csheet-comp {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 12px 8px;
  background: #ffffff;
  border-top: 1px solid #eee;
}

.feed-post-unit--touch .feed-csheet-comp-top {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.feed-post-unit--touch .feed-csheet-me {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  margin-bottom: 4px;
  background: #ede9fe;
  color: #6D28D9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  font-weight: 700;
}

.feed-post-unit--touch .feed-csheet-me img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.feed-post-unit--touch .feed-csheet-field {
  flex: 1;
  min-width: 0;
  display: flex;
  background: #F4F4F6;
  border-radius: 18px;
  padding: 0 14px;
}

.feed-post-unit--touch .feed-csheet-comp .feed-card-back__input {
  display: block;
  flex: 1;
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: 42px;
  margin: 0;
  padding: 10px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
  color: #111111;
  line-height: 22px;
  resize: none;
  overflow-y: hidden;
}

.feed-post-unit--touch .feed-csheet-comp-under {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.feed-post-unit--touch .feed-csheet-count {
  font-size: 12px;
  font-weight: 600;
  color: #EF4444;
  font-variant-numeric: tabular-nums;
}

.feed-post-unit--touch .feed-csheet-comp .feed-card-back__send {
  width: 52px;
  height: 32px;
  border-radius: 16px;
  border: 0;
  padding: 0;
  background: #6D28D9;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.feed-post-unit--touch .feed-csheet-comp .feed-card-back__send.is-empty {
  background: #E4E1EA;
  color: #A9A4B6;
  cursor: default;
}

.feed-post-unit--touch .feed-csheet-comp .feed-card-back__send svg {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor;
}

/* Your comment, just posted: a quick purple flash. */
.feed-post-unit--touch .feed-card-back__comment-row--new {
  background-color: #EFE8FC;
}

/* ---- Back of the card on a Shop background (never build-your-own):
   feed-cards.js _applyShopBackground sets the image inline and adds
   .feed-card-back--on-bg. The stickers sit on the real background; the
   label and handles get contrast so they stay readable on any image. ---- */
.feed-post-unit--touch .feed-card-face--back.feed-card-back--on-bg {
  background-color: #1d1a26;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-color: transparent;
}

.feed-post-unit--touch .feed-card-back--on-bg .feed-card-back__stickers-title {
  color: #ffffff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

.feed-post-unit--touch .feed-card-back--on-bg .feed-card-back__sticker-handle {
  color: #ffffff;
  background: rgba(20, 10, 40, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 2px 8px;
  max-width: 100%;
  align-self: center;
}

.feed-post-unit--touch .feed-card-back--on-bg .feed-card-back__grid-msg {
  color: #ffffff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

/* The chip that opens the background's detail. Top right of the back. */
.feed-post-unit--touch .feed-card-back__bg-chip {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #111111;
  font-family: 'Poppins', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px 6px 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.feed-post-unit--touch .feed-card-back__bg-chip-thumb {
  width: 14px;
  height: 22px;
  border-radius: 3px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
  display: block;
}

/* ---- Phone Home: snap each post and each in-between row to the top,
   just under the 44px header. On phone Home, #main-content is what
   scrolls (measured: full screen height, header on top of it), so snap
   goes on #main-content, and only while #feed-area holds phone Home
   posts — leaving Home removes them, which turns snap off. Hard snap;
   "stop always" keeps a fast flick from flying past several posts. ---- */
@media (max-width: 768px) {
  #main-content:has(#feed-area.feed-main > .feed-post-unit--touch) {
    scroll-snap-type: y mandatory;
    scroll-padding-top: calc(44px + env(safe-area-inset-top, 0px));
  }

  /* Every direct child of the feed is a snap point — posts, suggestion
     rows, "all caught up" and the creators row after it. Anything without
     a snap point can't be stopped on under hard snap. */
  #feed-area.feed-main > * {
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }
}