/* Home — app/home.tsx (original styling). */

.screen-home {
  /* Content is clipped at the safe area (like the app's SafeAreaView edges=top). */
  padding-top: var(--safe-top);
}

.screen-home .scroll {
  padding-top: 8px;
}

.home-body {
  padding: 0 var(--s-lg);
}

/* Category chips: sticky under the header while the grid scrolls, bleeding to the
   screen edges. Edge fades (mask) appear only on a side with more chips to reveal;
   JS toggles .fade-start / .fade-end. Fixed height, so nothing shifts on switch. */
.home-chipbar {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 calc(-1 * var(--s-lg)) var(--s-sm);
  background: var(--bg);
  --fade-l: 0px;
  --fade-r: 0px;
}
.home-chipbar.fade-start {
  --fade-l: 28px;
}
.home-chipbar.fade-end {
  --fade-r: 28px;
}

.home-chips {
  gap: 6px;
  height: 54px;
  align-items: center;
  padding: 0 var(--s-lg);
  scroll-padding-inline: var(--s-lg);
  overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
}
/* The trailing padding of a flex scroller is dropped by some engines. */
.home-chips::after {
  content: '';
  flex: 0 0 calc(var(--s-lg) - 6px);
  height: 1px;
}

.home-chips .chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  touch-action: manipulation;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.35s var(--spring);
}
.home-chips .chip:active {
  transform: scale(0.94);
  transition-duration: 0.15s, 0.15s, 0.15s, 0.1s;
}
.home-chips .chip.active {
  border-color: var(--accent-soft);
  background: var(--accent-tint);
}
.home-chips .chip-emoji {
  font-size: 15px;
  line-height: 1;
  /* Colour emoji on every platform, never the text-style glyph. */
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
/* The label keeps its width when it turns bold, so the row never jumps. */
.home-chips .chip-label {
  display: inline-grid;
}
.home-chips .chip-label::after {
  content: attr(data-label);
  font-weight: 700;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}

/* The chip is 36px tall visually; the tap target is 46px. */
.home-chips .chip::after {
  content: '';
  position: absolute;
  inset: -5px 0;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-md);
}

.home-grid .tpl-card {
  width: 100%;
}

.screen-home .tpl-card.no-enter {
  animation: none;
}

/* Subtle "back to the landing page" chevron, left of the Get Pro pill. 32px visual,
   44px tap target (the ::after overhangs); no background. */
.home-back {
  position: relative;
  width: 32px;
  height: 32px;
  margin: 6px 0 6px -14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  font-size: 18px;
  color: var(--text-3);
  touch-action: manipulation;
}
.home-back::after {
  content: '';
  position: absolute;
  inset: -6px;
}
.app-header.has-back .side:not(.right) {
  align-items: center;
}
.app-header.has-back .pro-pill {
  margin-left: -2px;
}
/* Too narrow to fit chevron + pill beside the centered logo. */
@media (max-width: 359px) {
  .home-back {
    display: none;
  }
  .app-header.has-back .pro-pill {
    margin-left: -8px;
  }
}

/* "Trending Now" carousel at the top: tall cards in a sideways row that bleeds to the
   screen edges, snapping card by card, with the next card peeking at the right. */
.home-trend {
  margin: 0 calc(-1 * var(--s-lg)) 2px;
}
.home-trend-title {
  margin: 6px 0 12px;
  padding: 0 var(--s-lg);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text);
}
.home-trend-row {
  gap: 12px;
  /* Room below for the card shadow (overflow-y is clipped). */
  padding: 0 var(--s-lg) 14px;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--s-lg);
  overscroll-behavior-x: contain;
}
/* The trailing padding of a flex scroller is dropped by some engines. */
.home-trend-row::after {
  content: '';
  flex: 0 0 calc(var(--s-lg) - 12px);
  height: 1px;
}
.home-trend-row .trend-card {
  flex: 0 0 210px;
  width: 210px;
  border-radius: 28px;
  padding: 12px;
  scroll-snap-align: start;
}
.trend-card .label-pill {
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
  background: rgba(20, 16, 14, 0.5);
}
.trend-card .label-pill ion-icon {
  font-size: 16px;
  margin-right: 6px;
  flex-shrink: 0;
}
/* The row's title already says "Trending" (and For You lists only trending
   templates, home.js sets data-filter): only real usage counts show here. */
.home-grid[data-filter='foryou'] .tpl-stat[data-kind='trending'],
.home-trend .tpl-stat[data-kind='trending'] {
  display: none;
}
.home-trend .tpl-stat {
  top: 12px;
  left: 12px;
}
