/*
 * Newsycle Mobile Feed R1
 * Mobile-first presentation overlay for the public reader.
 *
 * Goal: make the reader feel like a calm social news feed rather than a
 * responsive dashboard. No data, ranking, collector, rights, auth or article
 * behaviour is changed here. Desktop remains deliberately untouched.
 */

@media (max-width: 767px) {
  html {
    scroll-padding-top: 106px;
  }

  body {
    background: var(--surface);
    background-image: none;
  }

  /* Remove preview chrome from the reading path. The Building shortcut remains
     in the mobile header, so the project updates are still reachable. */
  .build-strip {
    display: none !important;
  }

  .app-grid,
  .app-grid.wide {
    display: block;
    max-width: none;
    padding: 0;
  }

  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    height: auto;
    padding: max(env(safe-area-inset-top), 0px) 14px 0;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    box-shadow: none;
    backdrop-filter: blur(20px) saturate(1.15);
  }

  .mobile-header .brand {
    min-height: 55px;
    gap: 7px;
    font-size: 24px;
    letter-spacing: -1.35px;
  }

  .mobile-header .yarn-mark {
    width: 24px;
    height: 28px;
  }

  .mobile-header .row {
    gap: 1px;
  }

  .mobile-header .icon-button {
    width: 41px;
    min-width: 41px;
    height: 41px;
    min-height: 41px;
    color: var(--muted);
  }

  .main-column,
  .wide .main-column {
    width: 100%;
    min-height: calc(100dvh - 56px);
    padding: 0 16px calc(82px + env(safe-area-inset-bottom));
    border: 0;
    background: var(--surface);
  }

  /* The signed-in reader feed is the homepage. Do not make people scroll past
     a dashboard-style introduction or settings card before they see news. */
  .main-column:has(.feed-tabs) > .page-heading,
  .main-column:has(.feed-tabs) > .build-update-stack {
    display: none !important;
  }

  /* Keep preferences reachable without making them another dashboard panel.
     The visual qualification and accessibility path both retain the real
     button/dialog; only the explanatory card chrome is collapsed. */
  .main-column:has(.feed-tabs) > .yr-pref-bar {
    display: flex !important;
    justify-content: flex-end;
    min-height: 40px;
    margin: 0;
    padding: 5px 0 3px;
    border: 0;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none !important;
  }

  .main-column:has(.feed-tabs) > .yr-pref-bar > div {
    display: none;
  }

  .main-column:has(.feed-tabs) > .yr-pref-bar .button {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    min-height: 32px;
    padding: 5px 9px;
    border-color: var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 9px;
    font-weight: 650;
  }

  /* X-like feed selector: one simple, sticky decision row. */
  .main-column:has(.feed-tabs) > .feed-tabs {
    position: sticky;
    top: calc(56px + env(safe-area-inset-top));
    z-index: 35;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 0;
    margin: 0 -16px;
    padding: 0 16px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(20px) saturate(1.15);
  }

  .feed-tabs > button {
    min-height: 47px;
    padding: 0 7px;
    text-align: center;
    font-size: 12px;
    font-weight: 610;
    color: var(--muted);
  }

  .feed-tabs > button[aria-selected="true"] {
    color: var(--ink);
    font-weight: 760;
  }

  .feed-tabs > button[aria-selected="true"]::after {
    left: 28%;
    right: 28%;
    height: 2px;
    border-radius: 999px;
    background: var(--berry);
  }

  .feed-tabs .connection {
    display: none;
  }

  /* One low-profile horizontal topic rail. */
  .topic-chips {
    margin: 0 -16px;
    padding: 9px 16px 10px;
    gap: 7px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
  }

  .topic-chips .chip {
    min-height: 32px;
    padding: 6px 11px;
    border-color: var(--line);
    border-radius: 999px;
    background: transparent;
    font-size: 10px;
    scroll-snap-align: start;
  }

  .topic-chips .chip.selected {
    border-color: color-mix(in srgb, var(--berry) 24%, var(--line));
    background: var(--berry-wash);
    color: var(--berry);
  }

  .queue-wrapper {
    height: auto;
    min-height: 0;
    padding: 8px 0 2px;
  }

  .new-reports {
    min-height: 32px;
    box-shadow: none;
  }

  /* News Pulse stays as Newsycle intelligence, but becomes one native feed
     object instead of a dashboard inside the feed. */
  .main-column:has(.feed-tabs) > .yr-pulse-lane {
    margin: 9px 0 3px;
    border: 1px solid color-mix(in srgb, var(--berry) 16%, var(--line));
    border-radius: 14px;
    background:
      linear-gradient(145deg, color-mix(in srgb, var(--berry-wash) 66%, var(--surface)), var(--surface));
    box-shadow: none;
  }

  .yr-pulse-lane::before {
    width: 2px;
  }

  .yr-pulse-lane-head {
    display: block;
    padding: 12px 14px 6px;
    border-bottom: 0;
  }

  .yr-pulse-eyebrow {
    margin: 0 0 2px;
    font-size: 8px;
    letter-spacing: 1.25px;
  }

  .yr-pulse-lane-head h2 {
    margin: 0;
    font-size: 15px;
    letter-spacing: -.35px;
    line-height: 1.25;
  }

  .yr-pulse-intro,
  .yr-pulse-lane-legend,
  .yr-pulse-lane-side {
    display: none !important;
  }

  .yr-pulse-lane-grid {
    display: block;
  }

  .yr-pulse-feature {
    min-height: 0;
    padding: 8px 14px 14px;
    border: 0;
  }

  .yr-pulse-feature::after,
  .yr-pulse-feature > p,
  .yr-pulse-feature > small,
  .yr-pulse-lane-score {
    display: none;
  }

  .yr-pulse-feature h3 {
    max-width: none;
    margin: 8px 0 0;
    font-size: 19px;
    font-weight: 780;
    letter-spacing: -.55px;
    line-height: 1.18;
  }

  .yr-pulse-lane-badge {
    min-height: 20px;
    padding: 2px 7px;
    font-size: 7px;
    letter-spacing: .65px;
  }

  /* The feed itself becomes the dominant visual system. */
  #report-list {
    margin: 0 -16px;
  }

  .report-card,
  :root[data-theme="dark"] .report-card {
    margin: 0 !important;
    padding: 18px 16px 16px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--line) !important;
    border-radius: 0 !important;
    background: var(--surface) !important;
    box-shadow: none !important;
    transform: none !important;
  }

  .report-card:first-child,
  :root[data-theme="dark"] .report-card:first-child {
    padding-top: 18px !important;
  }

  .report-card.original-card,
  :root[data-theme="dark"] .report-card.original-card {
    background: var(--surface) !important;
    box-shadow: inset 2px 0 0 color-mix(in srgb, var(--berry) 40%, transparent) !important;
  }

  .report-card:hover,
  :root[data-theme="dark"] .report-card:hover {
    background: var(--surface) !important;
    box-shadow: none !important;
    transform: none !important;
  }

  .report-card .report-byline {
    gap: 8px;
    margin-bottom: 11px;
  }

  .report-card .identity {
    min-width: 0;
    gap: 9px;
  }

  .report-card .identity .avatar {
    width: 36px;
    height: 36px;
    font-size: 11px;
  }

  .report-card .identity .avatar.source {
    border-radius: 9px;
    font-size: 16px;
  }

  .report-card .identity strong {
    font-size: 12px;
    line-height: 1.25;
  }

  .report-card .identity small {
    margin-top: 2px;
    font-size: 9px;
    line-height: 1.35;
  }

  .report-card .report-time {
    font-size: 9px;
  }

  .report-card .report-time .icon-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
  }

  .original-label {
    width: max-content;
    margin: 0 0 8px;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 8px !important;
  }

  .report-heading h2,
  .original-card .report-heading h2,
  .compact .report-heading h2 {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 780;
    letter-spacing: -.7px;
    line-height: 1.18;
    text-shadow: none !important;
  }

  .report-summary,
  .original-card .report-summary,
  .compact .report-summary {
    display: -webkit-box;
    overflow: hidden;
    margin: 0 0 12px;
    color: var(--subtle);
    font-size: 13px;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  /* Large media supplies the feed rhythm. It reaches the phone edge rather
     than becoming another rounded card inside a card. */
  .report-image-link,
  :root[data-theme="dark"] .report-image-link {
    margin: 13px -16px 10px;
    border: 0 !important;
    border-top: 1px solid var(--line) !important;
    border-bottom: 1px solid var(--line) !important;
    border-radius: 0 !important;
    background: var(--surface-alt);
    box-shadow: none !important;
  }

  .report-image-link::after {
    display: none;
  }

  .report-image {
    width: 100%;
    aspect-ratio: 16 / 9 !important;
    object-fit: cover;
    filter: none !important;
  }

  .image-note {
    display: none;
  }

  .report-text-first {
    height: 1px;
    margin: 4px 0 10px;
    background: var(--line);
    opacity: 1;
  }

  /* Coverage remains useful, but is no longer a nested panel. */
  .coverage-link,
  :root[data-theme="dark"] .coverage-link {
    margin: 1px 0 0 !important;
    padding: 10px 0 7px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
  }

  .coverage-link strong {
    font-size: 10px;
  }

  .coverage-link small {
    font-size: 9px;
  }

  /* Feed reactions collapse to the social summary. Rich reaction choices stay
     available after opening the article/discussion instead of filling every
     feed card with a row of competing icons. */
  .report-card > .community-bar {
    justify-content: flex-start;
    gap: 10px;
    padding: 7px 0 2px;
    border: 0;
    background: transparent;
  }

  .report-card > .community-bar > .reaction-quick-set {
    display: none !important;
  }

  .report-card > .community-bar .community-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent !important;
  }

  .report-card > .community-bar .community-count,
  .report-card > .community-bar .community-action {
    min-height: 36px;
    padding: 4px 0;
    color: var(--muted);
    font-size: 10px;
  }

  .report-card > .community-bar .reaction-icon {
    width: 17px;
    height: 17px;
  }

  /* Three obvious secondary actions. No pill forest. */
  .report-actions,
  :root[data-theme="dark"] .report-actions {
    gap: 12px;
    margin-top: 1px;
    padding-top: 2px;
    border-top: 0 !important;
  }

  .report-actions .text-button,
  .report-actions .text-link {
    min-height: 38px;
    padding: 5px 1px;
    border-radius: 0;
    background: transparent !important;
    font-size: 10px;
  }

  .report-actions .icon {
    width: 16px;
    height: 16px;
  }

  /* Pulse card decoration is now metadata, not a second card shell. */
  .report-card.yr-pulse-card,
  .report-card.yr-pulse-card-breaking,
  .report-card.yr-pulse-card-candidate,
  .report-card.yr-pulse-card-watch,
  :root[data-theme="dark"] .report-card.yr-pulse-card-breaking {
    border-bottom: 1px solid var(--line) !important;
    box-shadow: none !important;
  }

  .yr-pulse-card-marker,
  .yr-pulse-card-marker-breaking,
  .yr-pulse-card-marker-candidate {
    margin: 0 0 9px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent !important;
    color: var(--berry);
  }

  .yr-pulse-marker-score {
    display: none;
  }

  .yr-pulse-marker-label {
    font-size: 8px;
    letter-spacing: .9px;
  }

  .yr-pulse-marker-dot {
    width: 5px;
    height: 5px;
  }

  /* Pulse reasoning remains available through the existing "Why this?"
     action. Do not add a second explanatory row to every feed card. */
  .report-card .yr-pulse-why,
  :root[data-theme="dark"] .report-card .yr-pulse-why {
    display: none !important;
  }

  /* Demo-only controls do not belong in a reader feed. */
  .main-column:has(.feed-tabs) > .review-tools {
    display: none !important;
  }

  .caught-up {
    padding: 28px 16px 20px;
  }

  .caught-up > .icon {
    margin-bottom: 8px;
  }

  .caught-up p {
    margin: 6px auto;
    line-height: 1.55;
  }

  /* Simple, native-feeling bottom navigation. The Building update remains in
     the header; removing the duplicate tab creates room for the Account item
     injected by the reader extension. */
  .bottom-nav {
    min-height: calc(62px + env(safe-area-inset-bottom));
    padding: 3px 7px env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: none;
    backdrop-filter: blur(22px) saturate(1.15);
  }

  .bottom-nav > a[href="#/update/two-sources"] {
    display: none !important;
  }

  .bottom-nav a {
    min-height: 56px;
    padding: 7px 5px 5px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 590;
  }

  .bottom-nav a::before,
  .bottom-nav a[aria-current="page"]::before {
    display: none !important;
  }

  .bottom-nav a .icon {
    width: 21px;
    height: 21px;
  }

  .bottom-nav a[aria-current="page"] {
    color: var(--berry);
    font-weight: 720;
  }

  /* Dark mode uses the exact same hierarchy. Only tones change. */
  :root[data-theme="dark"] body,
  :root[data-theme="dark"] .main-column,
  :root[data-theme="dark"] .wide .main-column {
    background: #0f0d12;
  }

  :root[data-theme="dark"] .mobile-header,
  :root[data-theme="dark"] .feed-tabs,
  :root[data-theme="dark"] .bottom-nav {
    border-color: rgba(255,255,255,.07);
    background: rgba(15,13,18,.93);
    box-shadow: none;
  }

  :root[data-theme="dark"] .topic-chips {
    border-color: rgba(255,255,255,.06);
    background: #0f0d12;
  }

  :root[data-theme="dark"] .main-column:has(.feed-tabs) > .yr-pulse-lane {
    border-color: rgba(255,79,154,.12);
    background:
      linear-gradient(145deg, rgba(255,79,154,.055), rgba(255,255,255,.016));
    box-shadow: none;
  }

  :root[data-theme="dark"] .report-card,
  :root[data-theme="dark"] .report-card.original-card {
    background: #0f0d12 !important;
  }

  :root[data-theme="dark"] .report-image-link {
    background: #0a080c;
  }

  :root[data-theme="dark"] .yr-pulse-evidence {
    border-color: rgba(255,255,255,.06);
    background: rgba(255,255,255,.025);
  }
}

@media (max-width: 360px) {
  .main-column,
  .wide .main-column {
    padding-inline: 14px;
  }

  .main-column:has(.feed-tabs) > .feed-tabs,
  .topic-chips,
  #report-list {
    margin-inline: -14px;
  }

  .main-column:has(.feed-tabs) > .feed-tabs,
  .topic-chips {
    padding-inline: 14px;
  }

  .report-card,
  :root[data-theme="dark"] .report-card {
    padding-inline: 14px !important;
  }

  .report-image-link,
  :root[data-theme="dark"] .report-image-link {
    margin-inline: -14px;
  }

  .report-heading h2,
  .original-card .report-heading h2,
  .compact .report-heading h2 {
    font-size: 21px;
  }
}

@media (prefers-reduced-motion: reduce) and (max-width: 767px) {
  .mobile-header,
  .feed-tabs,
  .bottom-nav,
  .report-card,
  .report-image {
    transition: none !important;
  }
}
