/* The feed (handoff 15).  Full-screen snap-scrolling cards; own file so shared CSS stays untouched. */

main:has(> .feed-host) {
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.feed {
  --feed-top: 4.75rem;
  height: calc(100vh - var(--feed-top) - var(--shell-bottom, 0px));
  height: calc(100dvh - var(--feed-top) - var(--shell-bottom, 0px));
}

.feed-scroller {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-snap-type: y mandatory;
  scroll-behavior: auto;
  outline: none;
}

.feed-loading {
  padding: var(--space-12) var(--space-6);
  text-align: center;
}

.feed-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-items: stretch;
  box-sizing: border-box;
  height: 100%;
  padding: var(--space-3) max(var(--gutter), env(safe-area-inset-right, 0px)) var(--space-2) max(var(--gutter), env(safe-area-inset-left, 0px));
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.feed-card-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  box-sizing: border-box;
  width: 100%;
  max-width: 40rem;
  min-height: 0;
  height: 100%;
  justify-content: flex-start;
}

/* Long bites scroll inside the card; the actions stay in thumb reach at the bottom. */
.feed-card-inner > * {
  flex: none;
}

.feed-card-inner.feed-empty {
  justify-content: center;
  gap: var(--space-4);
}

/* The selector is deliberately more specific than `.feed-card-inner > * { flex: none; }`, which stays. */
.feed-card-inner > .feed-scroll {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--space-4);
  min-height: 0;
  padding-bottom: var(--space-4);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  outline-offset: -3px;
}

.feed-scroll::-webkit-scrollbar {
  display: none;
}

.feed-scroll > *,
.feed-scroll > .cx > * {
  flex: none;
}

.feed-scroll[data-more="true"] {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 3rem), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 3rem), transparent);
}

/* Era chip directly under the headline; map, Atlas link and "location unknown" after the text. */
.feed-scroll > .cx:not([hidden]) {
  display: contents;
}
.feed-scroll > .feed-hook { order: 1; }
.feed-scroll > .cx > .cx-top-slot { order: 2; }
.feed-scroll > .feed-body { order: 3; }
.feed-scroll > .cx > .cx-map,
.feed-scroll > .cx > .cx-atlas-slot,
.feed-scroll > .cx > .cx-places { order: 4; }

.feed-scroll .cx-map { max-width: 100%; }
.feed-scroll .cx-chip { min-height: 2rem; padding: 0.2rem 0.7rem; }

.feed-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.feed-banner,
.feed-chip {
  padding: 0.15rem 0.6rem;
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 999px;
}

.feed-banner {
  color: var(--color-caution);
  background: color-mix(in srgb, var(--color-caution) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-caution) 45%, transparent);
}

.feed-chip {
  color: var(--color-muted);
  border: 1px solid var(--color-line);
}

.feed-chip-review {
  color: var(--color-note);
  border-color: color-mix(in srgb, var(--color-note) 55%, transparent);
}

.feed-flag {
  display: inline-grid;
  place-items: center;
  color: var(--color-caution);
}

.feed-flag .feed-icon svg {
  width: 18px;
  height: 18px;
}

.feed-hook {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.625rem, 6.6vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.12;
  text-wrap: balance;
}

.feed-body {
  font-family: var(--font-reading);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--color-ink-soft);
  overflow-wrap: break-word;
}

@media (min-width: 44rem) {
  .feed-body {
    font-size: 1.1875rem;
  }
}

.feed-body p {
  margin: 0 0 0.85em;
}

.feed-body p:last-child {
  margin-bottom: 0;
}

.feed-book {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.feed-book strong {
  color: var(--color-ink);
  font-weight: 650;
}

.feed-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-line-soft);
}

.feed-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 3rem;
  min-height: 3rem;
  padding: 0;
  color: var(--color-ink-soft);
  font-size: var(--text-sm);
  font-weight: 650;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.feed-action .feed-icon svg {
  width: 24px;
  height: 24px;
}

/* Like, Dislike, Save: icon only; the label stays for screen readers. */
.feed-action:not([data-action="deeper"]) > span:last-child {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Go deeper: the one primary button, at the right. */
.feed-action[data-action="deeper"] {
  flex-direction: row-reverse;
  margin-left: auto;
  min-height: 2.75rem;
  padding: 0 var(--space-5);
  color: var(--color-on-action);
  background: var(--color-action);
  border-radius: var(--radius-sm);
}

@media (hover: hover) {
  .feed-action:not([data-action="deeper"]):hover {
    background: color-mix(in srgb, var(--color-ink) 6%, transparent);
  }
  .feed-action[data-action="deeper"]:hover {
    background: var(--color-action-hover);
  }
}

.feed-action:active {
  transform: scale(0.94);
}

.feed-action[data-action="deeper"]:active {
  transform: scale(0.98);
}

.feed-action[data-action="like"][aria-pressed="true"],
.feed-action[data-action="save"][aria-pressed="true"] {
  color: var(--color-accent);
  background: transparent;
}

.feed-action[data-action="dislike"][aria-pressed="true"] {
  color: var(--color-ink);
  background: color-mix(in srgb, var(--color-ink) 10%, transparent);
}

.feed-action[data-action="like"][aria-pressed="true"] svg,
.feed-action[data-action="save"][aria-pressed="true"] svg {
  fill: currentColor;
}

@keyframes feed-pop {
  40% {
    transform: scale(1.18);
  }
}

.feed-action[data-action="like"][aria-pressed="true"] .feed-icon {
  animation: feed-pop 280ms var(--ease-out);
}

.feed-reasons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.feed-reasons[hidden] {
  display: none;
}

.feed-reasons-label {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.feed-reason {
  min-height: 2.5rem;
  padding: 0 0.85rem;
  font-size: var(--text-sm);
  color: var(--color-ink-soft);
  background: transparent;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  cursor: pointer;
}

.feed-reason[aria-pressed="true"] {
  color: var(--color-on-action);
  background: var(--color-action);
  border-color: var(--color-action);
}

.feed-empty {
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  text-align: center;
}

.feed-empty h2 {
  margin: 0;
}

.feed-save-body {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6) var(--space-6);
}
@media (max-width: 44rem) {
  .feed-save-body { grid-template-columns: minmax(0, 1fr); padding-inline: var(--gutter); }
  .feed-save-new .button { flex: none; }
}

.feed-save-list {
  display: grid;
  gap: var(--space-2);
  max-height: 40dvh;
  overflow-y: auto;
}

.feed-save-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 3rem;
  padding: var(--space-2) var(--space-4);
  align-items: center;
  color: var(--color-ink);
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md, 0.75rem);
  cursor: pointer;
}

.feed-save-row[aria-pressed="true"] {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.feed-save-mark {
  color: var(--color-accent-strong);
  font-size: var(--text-xs);
  font-weight: 700;
}

.feed-save-new {
  display: flex;
  gap: var(--space-2);
}

.feed-save-name {
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-3);
  color: var(--color-ink);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md, 0.75rem);
  font: inherit;
}

.feed-host {
  min-height: 0;
}
