/*
 * IdealApp AURA AI — Community mobile art direction
 * Scope: Community Discover, Intelligence Hive and Agents only.
 * Desktop compositions remain unchanged.
 */

@media (max-width: 767px) {
  /* COMMUNITY SHELL — preserve a calm protected zone for the existing draggable AURA orb. */
  body:has(.community-ticker-shell) {
    --community-aura-safe-lane: 4rem;
  }

  main:has(.community-ticker-shell) > div.flex-1.overflow-y-auto > div {
    padding-bottom: 7rem !important;
  }

  body:has(.community-ticker-shell) .fixed.bottom-8.right-8.z-\[90\] {
    right: 0.75rem !important;
    bottom: calc(0.75rem + env(safe-area-inset-bottom)) !important;
    width: 2.75rem !important;
    height: 2.75rem !important;
  }

  body:has(.community-ticker-shell) .fixed.bottom-8.right-8.z-\[90\] > button {
    scale: 0.8;
    transform-origin: center;
  }

  /* DISCOVER — put the existing core video first, then preserve the live copy/actions. */
  section:has(video[src="/community/discover-hero.mp4"]) {
    border-radius: 24px;
  }

  section:has(video[src="/community/discover-hero.mp4"]) > div.relative.grid {
    display: flex;
    min-height: 0 !important;
    flex-direction: column;
  }

  section:has(video[src="/community/discover-hero.mp4"]) > div.relative.grid > div:last-child {
    order: -1;
    min-height: 290px !important;
    aspect-ratio: 16 / 11;
    margin-left: 0 !important;
    padding-left: 0 !important;
  }

  section:has(video[src="/community/discover-hero.mp4"]) video {
    object-position: center 44%;
  }

  section:has(video[src="/community/discover-hero.mp4"]) > div.relative.grid > div:last-child > div:last-child {
    background:
      linear-gradient(to bottom, rgba(7, 9, 8, 0.02) 54%, rgba(7, 9, 8, 0.9) 100%),
      linear-gradient(to right, rgba(7, 9, 8, 0.2), transparent 36%, transparent 64%, rgba(7, 9, 8, 0.12));
    margin-left: 0 !important;
  }

  section:has(video[src="/community/discover-hero.mp4"]) > div.relative.grid > div:first-child {
    padding: 1.35rem 1.25rem 1.5rem !important;
  }

  section:has(video[src="/community/discover-hero.mp4"]) h2 {
    margin-top: 0.9rem !important;
    font-size: clamp(1.65rem, 8.2vw, 2.25rem) !important;
    line-height: 1.04 !important;
    letter-spacing: -0.035em !important;
  }

  section:has(video[src="/community/discover-hero.mp4"]) h2 + p {
    margin-top: 1rem !important;
    font-size: 0.93rem !important;
    line-height: 1.65 !important;
  }

  section:has(video[src="/community/discover-hero.mp4"]) h2 + p + div {
    box-sizing: border-box;
    margin-top: 1.2rem !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    padding-right: var(--community-aura-safe-lane) !important;
  }

  section:has(video[src="/community/discover-hero.mp4"]) h2 + p + div button {
    width: 100%;
  }

  section:has(video[src="/community/discover-hero.mp4"]) > div.relative.grid > div:first-child > div:last-child {
    margin-top: 1.5rem !important;
    padding-top: 1.15rem !important;
  }

  section:has(video[src="/community/discover-hero.mp4"]) > div.relative.grid > div:first-child > div:last-child p:nth-child(2) {
    font-size: 1.05rem !important;
    line-height: 1.45 !important;
  }

  /* INTELLIGENCE HIVE — retain the hero, but stop the mobile crop from swallowing the screen. */
  #aura-intelligence-hive > div:first-child {
    min-height: 540px !important;
  }

  #aura-intelligence-hive > div:first-child > img {
    inset: 0 0 auto 0 !important;
    height: 57% !important;
    width: 100% !important;
    object-fit: contain !important;
    object-position: center top !important;
    opacity: 0.88 !important;
    transform: scale(0.92);
    transform-origin: top center;
  }

  #aura-intelligence-hive > div:first-child > div.relative {
    min-height: 540px !important;
    gap: 0.9rem !important;
    padding: 1rem !important;
  }

  #aura-intelligence-hive > div:first-child > div.relative > div:first-child {
    padding: 0.5rem 0.7rem !important;
  }

  #aura-intelligence-hive > div:first-child > div.relative > div:last-child {
    gap: 0.75rem !important;
  }

  #aura-intelligence-hive > div:first-child > div.relative > div:last-child > div:first-child {
    border-radius: 18px !important;
    padding: 1rem !important;
    background: rgba(0, 0, 0, 0.66) !important;
  }

  #aura-intelligence-hive > div:first-child > div.relative > div:last-child > div:first-child p {
    font-size: 0.78rem !important;
    line-height: 1.45rem !important;
  }

  #aura-intelligence-hive > div:first-child > div.relative > div:last-child > div:first-child button {
    min-height: 2.6rem !important;
    padding-inline: 1rem !important;
  }

  #aura-intelligence-hive > div:first-child > div.relative > div:last-child > div:last-child {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 0.35rem !important;
  }

  #aura-intelligence-hive > div:first-child > div.relative > div:last-child > div:last-child > div {
    border-radius: 14px !important;
    padding: 0.65rem 0.5rem !important;
    text-align: center;
  }

  #aura-intelligence-hive > div:first-child > div.relative > div:last-child > div:last-child p:first-child {
    font-size: 1rem !important;
  }

  #aura-intelligence-hive > div:first-child > div.relative > div:last-child > div:last-child p:last-child {
    font-size: 0.42rem !important;
    letter-spacing: 0.08em !important;
  }

  /*
   * AGENTS — the source film is a desktop composition whose meaningful scene
   * occupies only the far-left portion. Mobile therefore keeps the native film
   * but crops the film itself, not a larger wrapper, so the white desktop copy
   * lane can never consume half of the phone card.
   */
  section:has(video[src*="Agents_Vid_myhffb.mp4"]) {
    display: flex !important;
    min-height: 0 !important;
    width: 100% !important;
    flex-direction: column !important;
    overflow: hidden !important;
    isolation: isolate;
    border-radius: 24px !important;
    background: #ffffff !important;
  }

  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > img {
    display: none !important;
  }

  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div:nth-of-type(1) {
    position: relative !important;
    order: 2 !important;
    z-index: 30 !important;
    min-height: 0 !important;
    max-width: none !important;
    width: 100% !important;
    padding: 1.15rem 1.25rem 1.4rem !important;
    background: #ffffff !important;
  }

  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div:nth-of-type(1) > div:first-child {
    display: none !important;
  }

  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div:nth-of-type(1) > p:first-of-type {
    margin-top: 0 !important;
    color: rgba(141, 163, 13, 0.82) !important;
  }

  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div:nth-of-type(1) h2 {
    margin-top: 0.55rem !important;
    max-width: 19rem !important;
    font-size: 1.55rem !important;
    line-height: 1.05 !important;
  }

  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div:nth-of-type(1) h2 + p {
    margin-top: 0.75rem !important;
    max-width: 34rem !important;
    color: rgba(17, 19, 15, 0.62) !important;
    font-size: 0.93rem !important;
    line-height: 1.55 !important;
  }

  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div:nth-of-type(1) button {
    margin-top: 1rem !important;
    margin-right: var(--community-aura-safe-lane) !important;
    width: calc(100% - var(--community-aura-safe-lane)) !important;
    justify-content: center !important;
  }

  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div.absolute.inset-y-0.left-1\/2 {
    position: relative !important;
    inset: auto !important;
    left: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    order: 1 !important;
    z-index: 10 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: 16 / 10 !important;
    overflow: hidden !important;
    transform: none !important;
    background: #ffffff !important;
  }

  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div.absolute.inset-y-0.left-1\/2 > div {
    position: absolute !important;
    inset: 0 !important;
    overflow: hidden !important;
    background: #ffffff !important;
    -webkit-mask-image: none !important;
    mask-image: none !important;
  }

  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div.absolute.inset-y-0.left-1\/2 div[role="img"] {
    display: block !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
  }

  /* Crop the actual desktop film to its visual quarter. Both loop layers inherit
   * this geometry, so the crossfade remains seamless. */
  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div.absolute.inset-y-0.left-1\/2 video {
    inset: -8% auto auto -8% !important;
    width: 400% !important;
    max-width: none !important;
    height: 116% !important;
    object-fit: cover !important;
    object-position: left center !important;
  }

  /* Remove every desktop wash/gradient from the mobile media viewport. */
  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div.absolute.inset-y-0.left-1\/2 > div > div:not([role="img"]) {
    display: none !important;
  }

  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div.absolute.inset-y-0.left-1\/2::before,
  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div.absolute.inset-y-0.left-1\/2::after {
    content: none !important;
    display: none !important;
  }

  /* Hide the desktop left-side white wash. */
  section:has(video[src*="Agents_Vid_myhffb.mp4"]) > div:nth-of-type(3) {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  section:has(video[src*="Agents_Vid_myhffb.mp4"]) video,
  section:has(video[src="/community/discover-hero.mp4"]) video {
    animation: none !important;
  }
}
