/* Mobile-first layer for Depot717 / 易次元
 * Breakpoints (this file):
 * - default / max-width 768px: phone IA
 * - min-width 769px: restore desktop chrome; hide mobile-only shells
 * Do not use body { overflow-x: hidden } as the only overflow fix.
 */

:root {
  --yc-m-nav-h: 56px;
  --yc-m-gap: 14px;
  --yc-m-radius: 14px;
}

/* ---- Desktop: hide mobile shells ---- */
@media (min-width: 769px) {
  .yc-m-home,
  .yc-m-bottom-nav,
  .yc-m-header,
  .yc-m-pc-hint {
    display: none !important;
  }
}

/* ---- Phone ---- */
@media (max-width: 768px) {
  html,
  body.yc-page {
    max-width: 100%;
  }

  body.yc-page {
    padding-bottom: calc(var(--yc-m-nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
  }

  /* Prevent sr-only / clipped text from expanding scrollWidth */
  .yc-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    max-width: 1px !important;
    max-height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
    left: 0 !important;
    top: 0 !important;
    transform: translateX(-100vw) !important;
  }

  .yc-home,
  .yc-m-home,
  .yc-search-wrap,
  .yc-search {
    max-width: 100%;
    overflow-x: clip;
  }

  body.yc-page {
    overflow-x: clip;
  }

  /* Hide desktop-heavy home surfaces without removing markup */
  body:not(.yc-subpage) .yc-hero,
  body:not(.yc-subpage) .yc-coverflow,
  body:not(.yc-subpage) .yc-flow-arrow,
  body:not(.yc-subpage) .yc-flow-dots,
  body:not(.yc-subpage) .yc-home-breath,
  body:not(.yc-subpage) .yc-portal-grid,
  body:not(.yc-subpage) #home-portals,
  body:not(.yc-subpage) #home-games,
  body:not(.yc-subpage) #home-movies,
  body:not(.yc-subpage) .yc-entertainment,
  body:not(.yc-subpage) #ai-era-quick,
  body:not(.yc-subpage) #hot-track-quick,
  body:not(.yc-subpage) .yc-ai-quick,
  body:not(.yc-subpage) .yc-hot-quick,
  body:not(.yc-subpage) .yc-orbit-bg,
  body:not(.yc-subpage) .orbit-bg,
  body:not(.yc-subpage) .orbit-ring,
  body:not(.yc-subpage) .star-dot,
  body:not(.yc-subpage) .yc-scroll-progress,
  .yc-orbit-bg,
  .orbit-ring,
  .star-dot {
    display: none !important;
  }

  .yc-m-hscroll {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  /* Desktop header → compact mobile header */
  .yc-header-wrap .yc-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    min-height: 52px;
  }
  .yc-header .yc-nav,
  .yc-header .yc-nav-right > a,
  .yc-header .yc-header-search,
  .yc-header .yc-round-btn,
  .yc-brand small {
    display: none !important;
  }
  .yc-header .yc-brand {
    grid-column: 1;
    justify-self: start;
  }
  .yc-header .yc-brand strong {
    font-size: 1.05rem;
  }
  .yc-header .yc-icon-btn {
    display: inline-flex !important;
    grid-column: 3;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  /* Prefer mobile search on home */
  body:not(.yc-subpage) .yc-search-wrap,
  body:not(.yc-subpage) .yc-search {
    margin: 8px 12px 4px;
    max-width: none;
    width: auto;
  }

  .yc-m-home {
    display: block;
    padding: 4px 12px 24px;
    min-width: 0;
  }

  .yc-m-block {
    margin: 18px 0 8px;
    min-width: 0;
  }

  .yc-m-block-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
  }

  .yc-m-block-head h2 {
    margin: 0;
    font-size: 1.15rem;
    letter-spacing: 0.02em;
  }

  .yc-m-block-head a {
    font-size: 0.85rem;
    opacity: 0.75;
    text-decoration: none;
  }

  .yc-m-hscroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .yc-m-hscroll::-webkit-scrollbar {
    height: 0;
  }

  .yc-m-rail-card {
    flex: 0 0 42vw;
    max-width: 168px;
    min-width: 132px;
    scroll-snap-align: start;
    text-decoration: none;
    color: inherit;
  }

  .yc-m-rail-cover,
  .yc-m-poster-media {
    position: relative;
    aspect-ratio: 2 / 3;
    border-radius: var(--yc-m-radius);
    overflow: hidden;
    background: #1c1712;
  }

  .yc-m-rail-cover img,
  .yc-m-poster-media img,
  .yc-m-feed-thumb img,
  .yc-m-ai-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: high-quality;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
  }

  .yc-m-rail-card strong,
  .yc-m-poster strong,
  .yc-m-feed-copy strong,
  .yc-m-ai-card strong {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 8px;
    font-size: 0.92rem;
    line-height: 1.35;
  }

  .yc-m-rail-cta {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.78rem;
    opacity: 0.8;
  }

  .yc-m-poster-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 10px;
  }

  .yc-m-poster {
    min-width: 0;
    text-decoration: none;
    color: inherit;
  }

  .yc-m-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.62);
    color: #fff8ea;
    font-size: 0.7rem;
    font-style: normal;
  }

  .yc-m-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .yc-m-feed-row {
    display: grid;
    grid-template-columns: 112px 1fr;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
  }

  .yc-m-feed-thumb {
    aspect-ratio: 16 / 10;
    border-radius: 12px;
    overflow: hidden;
    background: #1c1712;
  }

  .yc-m-feed-copy {
    min-width: 0;
  }

  .yc-m-feed-copy p {
    margin: 4px 0;
    font-size: 0.82rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: 0.78;
  }

  .yc-m-feed-copy span {
    font-size: 0.72rem;
    opacity: 0.55;
  }

  .yc-m-ai-grid {
    display: grid;
    gap: 14px;
  }

  .yc-m-ai-card {
    display: block;
    text-decoration: none;
    color: inherit;
    min-width: 0;
  }

  .yc-m-ai-cover {
    aspect-ratio: 16 / 9;
    border-radius: var(--yc-m-radius);
    overflow: hidden;
    background: #141820;
  }

  .yc-m-ai-card p {
    margin: 4px 0 0;
    font-size: 0.82rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: 0.75;
  }

  .yc-m-empty {
    margin: 0;
    opacity: 0.6;
    font-size: 0.9rem;
  }

  /* Bottom nav */
  .yc-m-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    min-height: calc(var(--yc-m-nav-h) + env(safe-area-inset-bottom, 0px));
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    background: rgba(18, 14, 10, 0.94);
    border-top: 1px solid rgba(255, 232, 196, 0.12);
    backdrop-filter: blur(10px);
  }

  .yc-m-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 44px;
    min-height: 44px;
    padding: 6px 2px;
    text-decoration: none;
    color: rgba(255, 244, 220, 0.62);
    font-size: 0.68rem;
  }

  .yc-m-nav-item.is-active {
    color: #f0d7a0;
  }

  .yc-m-nav-ico {
    font-size: 1rem;
    line-height: 1;
  }

  /* Movie category mobile */
  .category-page-movie .category-sidebar {
    display: none;
  }

  .category-page-movie .category-commerce-shell,
  .category-page-movie .category-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .category-page-movie .movie-poster-grid.category-commerce-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px 10px;
  }

  .category-page-movie .movie-poster-frame {
    aspect-ratio: 2 / 3;
  }

  .category-page-movie .movie-poster-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .category-page-movie .movie-card-body h2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
    font-size: 0.92rem;
  }

  .category-page-movie .category-filter-row,
  .category-page-movie .movie-filter-bar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .yc-m-load-more {
    display: block;
    width: 100%;
    margin: 16px 0 28px;
    min-height: 44px;
    border-radius: 999px;
    border: 1px solid rgba(255, 232, 196, 0.22);
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    font-size: 0.95rem;
  }

  .movie-poster-card.is-m-deferred {
    display: none;
  }

  /* Hot / AI reading */
  .category-page-hot .category-hot-grid,
  .category-page-ai-era .category-grid {
    grid-template-columns: 1fr !important;
  }

  .category-page-hot .category-resource-card,
  .category-page-ai-era .category-resource-card,
  .item-detail-page .detail-body,
  .article-page .article-body {
    font-size: 1.02rem;
    line-height: 1.7;
  }

  .category-page-hot .category-resource-card h2,
  .category-page-ai-era .category-resource-card h2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .yc-m-back-top {
    position: fixed;
    right: 14px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    z-index: 80;
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 232, 196, 0.28);
    background: rgba(18, 16, 14, 0.88);
    color: #ffe8c4;
    font-size: 0.8rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  }

  .yc-m-back-top[hidden] {
    display: none !important;
  }

  /* Movie detail player order helpers */
  .movie-detail-page .cms-movie-detail {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .movie-detail-page .yc-m-player-shell {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
  }

  .movie-detail-page .yc-m-player-shell video {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  /* PC-only categories hint */
  .yc-m-pc-hint {
    display: block;
    margin: 16px 12px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 232, 196, 0.08);
    border: 1px solid rgba(255, 232, 196, 0.16);
    line-height: 1.55;
  }

  /* Mascot: never occupy mobile chrome; markup may be absent */
  .mascot-widget,
  #mascot-widget {
    display: none !important;
  }

  /* Prevent common overflow offenders without body-only clip */
  .yc-home,
  .category-shell,
  .cms-container,
  .yc-m-home,
  .yc-section,
  .category-grid {
    min-width: 0;
    max-width: 100%;
  }

  img,
  video {
    max-width: 100%;
    height: auto;
  }
}


/* Keep main search bar usable; hide duplicate tag cloud under picks on phone */
@media (max-width: 768px) {
  body:not(.yc-subpage) .yc-search-section {
    width: 100%;
    padding: 0 12px;
    margin: 6px 0 10px;
    box-sizing: border-box;
  }
  body:not(.yc-subpage) .yc-search {
    width: 100%;
    height: 52px;
    margin: 0;
  }
  body:not(.yc-subpage) .yc-search input {
    padding: 0 96px 0 58px;
    font-size: 15px;
  }
  body:not(.yc-subpage) .yc-search-icon {
    left: 18px;
    width: 18px;
    height: 18px;
    border-width: 2px;
  }
  body:not(.yc-subpage) .yc-search-submit {
    min-width: 64px;
    padding: 0 14px;
    font-size: 14px;
    height: calc(100% - 12px);
    right: 6px;
  }
  body:not(.yc-subpage) .yc-search-hints {
    width: 100%;
    justify-content: flex-start;
    margin-top: 10px;
    gap: 6px;
  }
  body:not(.yc-subpage) .yc-tags-only {
    display: none !important;
  }
  body:not(.yc-subpage) #today-picks {
    display: block !important;
    margin-top: 8px;
    padding: 0 12px 8px;
  }
}
